Module: BootstrapPager::Generators::GitHubApiHelper

Defined in:
lib/generators/bootstrap_pager/views_generator.rb

Class Method Summary collapse

Class Method Details

.get_content_for(path) ⇒ Object


110
111
112
113
114
# File 'lib/generators/bootstrap_pager/views_generator.rb', line 110

def get_content_for(path)
  open('https://api.github.com/repos/amatsuda/bootstrap_pager_themes/contents/' + path) do |json|
    Base64.decode64(ActiveSupport::JSON.decode(json)['content'])
  end
end

.get_files_in_masterObject


97
98
99
100
101
102
103
104
105
106
107
# File 'lib/generators/bootstrap_pager/views_generator.rb', line 97

def get_files_in_master
  master_tree_sha = open('https://api.github.com/repos/amatsuda/bootstrap_pager_themes/git/refs/heads/master') do |json|
    ActiveSupport::JSON.decode(json)['object']['sha']
  end
  open('https://api.github.com/repos/amatsuda/bootstrap_pager_themes/git/trees/' + master_tree_sha + '?recursive=1') do |json|
    blobs = ActiveSupport::JSON.decode(json)['tree'].find_all {|i| i['type'] == 'blob' }
    blobs.map do |blob|
      [blob['path'], blob['sha']]
    end
  end
end