Module: Kaminari::Generators::GitHubApiHelper

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

Class Method Summary collapse

Class Method Details

.get_content_for(path) ⇒ Object



129
130
131
132
133
# File 'lib/generators/kaminari/views_generator.rb', line 129

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

.get_files_in_masterObject



116
117
118
119
120
121
122
123
124
125
126
# File 'lib/generators/kaminari/views_generator.rb', line 116

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