Class: Baya::Adapters::Github
- Inherits:
-
Object
- Object
- Baya::Adapters::Github
- Defined in:
- lib/baya/adapters/github.rb
Constant Summary collapse
- API_ROOT =
"https://api.github.com/"
Instance Method Summary collapse
- #archive(root) ⇒ Object
-
#initialize(config) ⇒ Github
constructor
A new instance of Github.
- #repos ⇒ Object
Constructor Details
#initialize(config) ⇒ Github
Returns a new instance of Github.
11 12 13 14 |
# File 'lib/baya/adapters/github.rb', line 11 def initialize(config) @config = config check_config end |
Instance Method Details
#archive(root) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/baya/adapters/github.rb', line 16 def archive(root) repos.each do |url| name = url.split('/').last.gsub(/\.git$/, "") git = Git.new('origin' => url, 'destination' => name) git.archive(root + '/' + @config['destination']) end end |
#repos ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/baya/adapters/github.rb', line 24 def repos api_url = API_ROOT + target http = Curl.get(api_url) json = http.body_str data = Yajl::Parser.parse(json) data.map do |repo| repo['clone_url'] end end |