Class: GithubControl::Repositories
- Inherits:
-
Object
- Object
- GithubControl::Repositories
- Includes:
- Enumerable
- Defined in:
- lib/github-control/repositories.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #clear ⇒ Object
- #create(name, access) ⇒ Object
- #delete(name) ⇒ Object
- #destroy ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #get(name) ⇒ Object
-
#initialize(user) ⇒ Repositories
constructor
A new instance of Repositories.
- #size ⇒ Object
Constructor Details
#initialize(user) ⇒ Repositories
Returns a new instance of Repositories.
5 6 7 |
# File 'lib/github-control/repositories.rb', line 5 def initialize(user) @user = user end |
Instance Method Details
#[](name) ⇒ Object
20 21 22 |
# File 'lib/github-control/repositories.rb', line 20 def [](name) get(name) end |
#clear ⇒ Object
43 44 45 |
# File 'lib/github-control/repositories.rb', line 43 def clear @set = nil end |
#create(name, access) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/github-control/repositories.rb', line 9 def create(name, access) @user.cli.post("/repos/create", :name => name, :public => access == :public ? 1 : 0 ) repo = Repository.new(@user, name, access) set << repo repo end |
#delete(name) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/github-control/repositories.rb', line 28 def delete(name) response = @user.cli.post("/repos/delete/#{name}") @user.cli.post("/repos/delete/#{name}", :delete_token => response["delete_token"]) any? && set.delete(name) end |
#destroy ⇒ Object
35 36 37 |
# File 'lib/github-control/repositories.rb', line 35 def destroy each { |r| delete(r.name) } end |
#each(&block) ⇒ Object
39 40 41 |
# File 'lib/github-control/repositories.rb', line 39 def each(&block) set.each(&block) end |
#empty? ⇒ Boolean
47 48 49 |
# File 'lib/github-control/repositories.rb', line 47 def empty? ! any? end |
#get(name) ⇒ Object
24 25 26 |
# File 'lib/github-control/repositories.rb', line 24 def get(name) set.detect { |r| r.name == name } end |
#size ⇒ Object
51 52 53 |
# File 'lib/github-control/repositories.rb', line 51 def size set.size end |