Class: Git::Flock::Flocker

Inherits:
Object
  • Object
show all
Defined in:
lib/git/flock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Flocker

Returns a new instance of Flocker.



15
16
17
18
# File 'lib/git/flock.rb', line 15

def initialize(options)
  @orgname = options[:orgname] || fail_args
  @token = options[:token] || fail_args
end

Instance Attribute Details

#orgnameObject (readonly)

Returns the value of attribute orgname.



20
21
22
# File 'lib/git/flock.rb', line 20

def orgname
  @orgname
end

#tokenObject (readonly)

Returns the value of attribute token.



20
21
22
# File 'lib/git/flock.rb', line 20

def token
  @token
end

Instance Method Details

#fail_argsObject



33
34
35
36
# File 'lib/git/flock.rb', line 33

def fail_args
  puts 'usage: git-flock org-name api-key'
  exit
end

#flockemObject



22
23
24
25
26
27
# File 'lib/git/flock.rb', line 22

def flockem
  JSON.load(repos).each { |repo| `git clone #{repo['ssh_url']}` }
rescue Exception => e
  puts e.message
  fail_args
end

#reposObject



29
30
31
# File 'lib/git/flock.rb', line 29

def repos
  `curl -u #{token}:x-oauth-basic -s https://api.github.com/orgs/#{orgname}/repos`
end