Skip to content

Commit 5d3c30a

Browse files
committed
converter: recursive tree fetch
1 parent 49322ce commit 5d3c30a

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ gemspec
66
gem 'compass', require: false
77

88
group :development do
9-
gem 'byebug', platform: :mri_21, require: false
9+
gem 'byebug', platforms: [:mri_21, :mri_22], require: false
1010
end

tasks/converter/js_conversion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def process_javascript_assets
2929

3030
def bootstrap_js_files
3131
@bootstrap_js_files ||= begin
32-
files = get_paths_by_type 'js', /\.js$/
32+
files = get_paths_by_type('js', /\.js$/).reject { |path| path =~ %r(^tests/) }
3333
files.sort_by { |f|
3434
case f
3535
# tooltip depends on popover and must be loaded earlier

tasks/converter/less_conversion.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ def process_stylesheet_assets
150150
end
151151

152152
def bootstrap_less_files
153-
@bootstrap_less_files ||= get_paths_by_type('less', /\.less$/) +
154-
get_paths_by_type('mixins', /\.less$/,
155-
get_tree(get_tree_sha('mixins', get_tree(get_tree_sha('less'))))).map { |p| "mixins/#{p}" }
153+
@bootstrap_less_files ||= get_paths_by_type('less', /\.less$/)
156154
end
157155

158156
# apply general less to scss conversion

tasks/converter/network.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ class Converter
33
module Network
44
protected
55

6-
def get_paths_by_type(dir, file_re, tree = get_tree(get_tree_sha(dir)))
7-
tree['tree'].select { |f| f['type'] == 'blob' && f['path'] =~ file_re }.map { |f| f['path'] }
6+
def get_paths_by_type(dir, file_re, recursive = true)
7+
get_file_paths(dir, recursive).select { |path| path =~ file_re }
8+
end
9+
10+
def get_file_paths(dir, recursive = true)
11+
get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
812
end
913

1014
def read_files(path, files)
@@ -44,7 +48,8 @@ def write_cached_files(path, files)
4448

4549

4650
def get_file(url)
47-
cache_path = "./#@cache_path#{URI(url).path}"
51+
uri = URI(url)
52+
cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
4853
FileUtils.mkdir_p File.dirname(cache_path)
4954
if File.exists?(cache_path)
5055
log_http_get_file url, true
@@ -81,8 +86,8 @@ def get_trees
8186
@trees ||= get_tree(@branch_sha)
8287
end
8388

84-
def get_tree(sha)
85-
get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}")
89+
def get_tree(sha, recursive = true)
90+
get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
8691
end
8792

8893
def get_json(url)

0 commit comments

Comments
 (0)