Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/converter/network.rb')
-rw-r--r--tasks/converter/network.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/tasks/converter/network.rb b/tasks/converter/network.rb
index 848778a..cc60276 100644
--- a/tasks/converter/network.rb
+++ b/tasks/converter/network.rb
@@ -3,8 +3,12 @@ class Converter
module Network
protected
- def get_paths_by_type(dir, file_re, tree = get_tree(get_tree_sha(dir)))
- tree['tree'].select { |f| f['type'] == 'blob' && f['path'] =~ file_re }.map { |f| f['path'] }
+ def get_paths_by_type(dir, file_re, recursive = true)
+ get_file_paths(dir, recursive).select { |path| path =~ file_re }
+ end
+
+ def get_file_paths(dir, recursive = true)
+ get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
end
def read_files(path, files)
@@ -44,7 +48,8 @@ class Converter
def get_file(url)
- cache_path = "./#@cache_path#{URI(url).path}"
+ uri = URI(url)
+ cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
FileUtils.mkdir_p File.dirname(cache_path)
if File.exists?(cache_path)
log_http_get_file url, true
@@ -81,8 +86,8 @@ class Converter
@trees ||= get_tree(@branch_sha)
end
- def get_tree(sha)
- get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}")
+ def get_tree(sha, recursive = true)
+ get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
end
def get_json(url)