File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,22 @@ def self.find(name, version = nil)
74
74
end
75
75
end
76
76
77
+ def self . find_by_slug ( slug , version = nil )
78
+ doc = all . find { |klass | klass . slug == slug }
79
+
80
+ unless doc
81
+ raise DocNotFound . new ( %(could not find doc with "#{ slug } ") , slug )
82
+ end
83
+
84
+ if version . present?
85
+ version = doc . versions . find { |klass | klass . version == version || klass . version_slug == version }
86
+ raise DocNotFound . new ( %(could not find version "#{ version } " for doc "#{ doc . name } ") , doc . name ) unless version
87
+ doc = version
88
+ end
89
+
90
+ doc
91
+ end
92
+
77
93
def self . generate_page ( name , version , page_id )
78
94
find ( name , version ) . store_page ( store , page_id )
79
95
end
Original file line number Diff line number Diff line change @@ -158,8 +158,14 @@ class DocsCLI < Thor
158
158
option :packaged , type : :boolean
159
159
def upload ( *names )
160
160
require 'net/sftp'
161
- names = Dir [ File . join ( Docs . store_path , '*.tar.gz' ) ] . map { |f | File . basename ( f , '.tar.gz' ) } if options [ :packaged ]
162
- docs = find_docs ( names )
161
+
162
+ if options [ :packaged ]
163
+ slugs = Dir [ File . join ( Docs . store_path , '*.tar.gz' ) ] . map { |f | File . basename ( f , '.tar.gz' ) }
164
+ docs = find_docs_by_slugs ( slugs )
165
+ else
166
+ docs = find_docs ( names )
167
+ end
168
+
163
169
assert_docs ( docs )
164
170
165
171
# Sync files with S3 (used by the web app)
@@ -251,6 +257,13 @@ class DocsCLI < Thor
251
257
end
252
258
end
253
259
260
+ def find_docs_by_slugs ( slugs )
261
+ slugs . flat_map do |slug |
262
+ slug , version = slug . split ( /~/ )
263
+ Docs . find_by_slug ( slug , version )
264
+ end
265
+ end
266
+
254
267
def assert_docs ( docs )
255
268
if docs . empty?
256
269
puts 'ERROR: called with no arguments.'
You can’t perform that action at this time.
0 commit comments