octopi 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -6,6 +6,10 @@ To install it as a Gem, just run:
6
6
 
7
7
  $ sudo gem install octopi
8
8
 
9
+ To include it in your modules or in irb use:
10
+
11
+ include Octopi
12
+
9
13
  Get notifications via Twitter, following @octopi_gem:
10
14
  http://twitter.com/octopi_gem
11
15
 
data/Rakefile CHANGED
@@ -15,6 +15,8 @@ begin
15
15
  gem.add_dependency('httparty', '>= 0.4.5')
16
16
  gem.add_dependency('mechanize', '>= 0.9.3')
17
17
  gem.add_dependency('api_cache', '>= 0')
18
+ gem.add_development_dependency 'shoulda'
19
+ gem.add_development_dependency 'fakeweb'
18
20
  gem.files.exclude 'test/**/*'
19
21
  gem.files.exclude 'test*'
20
22
  gem.files.exclude 'doc/**/*'
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :build:
4
2
  :major: 0
5
3
  :minor: 4
4
+ :patch: 1
5
+ :build:
data/lib/octopi/api.rb CHANGED
@@ -103,7 +103,6 @@ module Octopi
103
103
 
104
104
 
105
105
  def find_all(path, result_key, query, klass=nil, cache=true)
106
- { :query => query, :id => query, :cache => cache }
107
106
  result = get(path, { :query => query, :id => query, :cache => cache }, klass)
108
107
  result[result_key]
109
108
  end
@@ -190,7 +189,7 @@ module Octopi
190
189
  # puts resp.code.inspect
191
190
  raise NotFound, klass || self.class if resp.code.to_i == 404
192
191
  raise APIError,
193
- "GitHub returned status #{resp.code}" unless resp.code.to_i == 200
192
+ "GitHub returned status #{resp.code}" unless resp.code.to_i == 200 || resp.code.to_i == 201
194
193
  # FIXME: This fails for showing raw Git data because that call returns
195
194
  # text/html as the content type. This issue has been reported.
196
195
 
data/lib/octopi/issue.rb CHANGED
@@ -33,12 +33,14 @@ module Octopi
33
33
  def self.find_all(options={})
34
34
  ensure_hash(options)
35
35
  user, repo = gather_details(options)
36
- state = (options[:state] || "open").downcase
37
- validate_args(user => :user, repo.name => :repo, state => :state)
38
-
39
- issues = super user, repo.name, state
40
- issues.each { |i| i.repository = repo }
41
- issues
36
+ states = [options[:state]] if options[:state]
37
+ states ||= ["open", "closed"]
38
+ issues = []
39
+ states.each do |state|
40
+ validate_args(user => :user, repo.name => :repo, state => :state)
41
+ issues << super(user, repo.name, state)
42
+ end
43
+ issues.flatten.each { |i| i.repository = repo }
42
44
  end
43
45
 
44
46
  # TODO: Make find use hashes like find_all
@@ -99,6 +101,11 @@ module Octopi
99
101
  IssueComment.new(data['comment'])
100
102
  end
101
103
 
104
+ def comments
105
+ data = Api.api.get(command_path("comments"))
106
+ data["comments"].map { |c| IssueComment.new(c) }
107
+ end
108
+
102
109
  private
103
110
  def prefix(command)
104
111
  "/issues/#{command}/#{repository.owner}/#{repository.name}"
@@ -1,7 +1,6 @@
1
1
  module Octopi
2
2
  class IssueComment < Base
3
3
  include Resource
4
- attr_accessor :comment, :status
5
-
4
+ attr_accessor :body, :user
6
5
  end
7
6
  end
@@ -97,7 +97,7 @@ module Octopi
97
97
  end
98
98
 
99
99
  def issues(state = "open")
100
- IssueSet.new(Octopi::Issue.find_all(:user => owner, :repository => self))
100
+ IssueSet.new(Octopi::Issue.find_all(:user => owner, :repository => self, :state => state))
101
101
  end
102
102
 
103
103
  def all_issues
@@ -109,7 +109,7 @@ module Octopi
109
109
  end
110
110
 
111
111
  def collaborators
112
- property('collaborators', [self.owner, self.name].join('/')).values.map { |v| User.find(v.join) }
112
+ property('collaborators', [self.owner, self.name].join('/')).values.flatten.map { |v| User.find(v) }
113
113
  end
114
114
 
115
115
  def languages
@@ -119,6 +119,10 @@ module Octopi
119
119
  def self.create(options={})
120
120
  raise AuthenticationRequired, "To create a repository you must be authenticated." if Api.api.read_only?
121
121
  self.validate_args(options[:name] => :repo)
122
+ if options[:user]
123
+ self.validate_args(options[:user] => :user)
124
+ options[:name] = "#{options[:user]}/#{options[:name]}"
125
+ end
122
126
  new(Api.api.post(path_for(:create), options.merge( :cache => false ))["repository"])
123
127
  end
124
128
 
data/octopi.gemspec CHANGED
@@ -1,88 +1,85 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{octopi}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Felipe Coury"]
12
- s.date = %q{2010-12-05}
12
+ s.date = %q{2011-04-28}
13
13
  s.email = %q{felipe.coury@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
16
- "README.markdown"
16
+ "README.markdown"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- ".yardoc",
21
- "CHANGELOG.md",
22
- "LICENSE",
23
- "README.markdown",
24
- "Rakefile",
25
- "VERSION.yml",
26
- "contrib/backup.rb",
27
- "lib/ext/string_ext.rb",
28
- "lib/octopi.rb",
29
- "lib/octopi/api.rb",
30
- "lib/octopi/base.rb",
31
- "lib/octopi/blob.rb",
32
- "lib/octopi/branch.rb",
33
- "lib/octopi/branch_set.rb",
34
- "lib/octopi/comment.rb",
35
- "lib/octopi/commit.rb",
36
- "lib/octopi/error.rb",
37
- "lib/octopi/file_object.rb",
38
- "lib/octopi/gist.rb",
39
- "lib/octopi/issue.rb",
40
- "lib/octopi/issue_comment.rb",
41
- "lib/octopi/issue_set.rb",
42
- "lib/octopi/key.rb",
43
- "lib/octopi/key_set.rb",
44
- "lib/octopi/plan.rb",
45
- "lib/octopi/repository.rb",
46
- "lib/octopi/repository_set.rb",
47
- "lib/octopi/resource.rb",
48
- "lib/octopi/self.rb",
49
- "lib/octopi/tag.rb",
50
- "lib/octopi/user.rb",
51
- "octopi.gemspec"
19
+ ".yardoc",
20
+ "CHANGELOG.md",
21
+ "LICENSE",
22
+ "README.markdown",
23
+ "Rakefile",
24
+ "VERSION.yml",
25
+ "contrib/backup.rb",
26
+ "lib/ext/string_ext.rb",
27
+ "lib/octopi.rb",
28
+ "lib/octopi/api.rb",
29
+ "lib/octopi/base.rb",
30
+ "lib/octopi/blob.rb",
31
+ "lib/octopi/branch.rb",
32
+ "lib/octopi/branch_set.rb",
33
+ "lib/octopi/comment.rb",
34
+ "lib/octopi/commit.rb",
35
+ "lib/octopi/error.rb",
36
+ "lib/octopi/file_object.rb",
37
+ "lib/octopi/gist.rb",
38
+ "lib/octopi/issue.rb",
39
+ "lib/octopi/issue_comment.rb",
40
+ "lib/octopi/issue_set.rb",
41
+ "lib/octopi/key.rb",
42
+ "lib/octopi/key_set.rb",
43
+ "lib/octopi/plan.rb",
44
+ "lib/octopi/repository.rb",
45
+ "lib/octopi/repository_set.rb",
46
+ "lib/octopi/resource.rb",
47
+ "lib/octopi/self.rb",
48
+ "lib/octopi/tag.rb",
49
+ "lib/octopi/user.rb",
50
+ "octopi.gemspec"
52
51
  ]
53
52
  s.homepage = %q{http://github.com/fcoury/octopi}
54
- s.rdoc_options = ["--charset=UTF-8"]
55
53
  s.require_paths = ["lib"]
56
54
  s.rubyforge_project = %q{octopi}
57
- s.rubygems_version = %q{1.3.7}
55
+ s.rubygems_version = %q{1.5.2}
58
56
  s.summary = %q{A Ruby interface to GitHub API v2}
59
57
  s.test_files = [
58
+ "examples/authenticated.rb",
59
+ "examples/issues.rb",
60
+ "examples/overall.rb",
60
61
  "test/api_test.rb",
61
- "test/authenticated_test.rb",
62
- "test/base_test.rb",
63
- "test/blob_test.rb",
64
- "test/branch_test.rb",
65
- "test/commit_test.rb",
66
- "test/file_object_test.rb",
67
- "test/gist_test.rb",
68
- "test/issue_comment.rb",
69
- "test/issue_set_test.rb",
70
- "test/issue_test.rb",
71
- "test/key_set_test.rb",
72
- "test/key_test.rb",
73
- "test/repository_set_test.rb",
74
- "test/repository_test.rb",
75
- "test/stubs/commits/fcoury/octopi/octopi.rb",
76
- "test/tag_test.rb",
77
- "test/test_helper.rb",
78
- "test/user_test.rb",
79
- "examples/authenticated.rb",
80
- "examples/issues.rb",
81
- "examples/overall.rb"
62
+ "test/authenticated_test.rb",
63
+ "test/base_test.rb",
64
+ "test/blob_test.rb",
65
+ "test/branch_test.rb",
66
+ "test/commit_test.rb",
67
+ "test/file_object_test.rb",
68
+ "test/gist_test.rb",
69
+ "test/issue_comment.rb",
70
+ "test/issue_set_test.rb",
71
+ "test/issue_test.rb",
72
+ "test/key_set_test.rb",
73
+ "test/key_test.rb",
74
+ "test/repository_set_test.rb",
75
+ "test/repository_test.rb",
76
+ "test/stubs/commits/fcoury/octopi/octopi.rb",
77
+ "test/tag_test.rb",
78
+ "test/test_helper.rb",
79
+ "test/user_test.rb"
82
80
  ]
83
81
 
84
82
  if s.respond_to? :specification_version then
85
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
86
83
  s.specification_version = 3
87
84
 
88
85
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -90,17 +87,23 @@ Gem::Specification.new do |s|
90
87
  s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
91
88
  s.add_runtime_dependency(%q<mechanize>, [">= 0.9.3"])
92
89
  s.add_runtime_dependency(%q<api_cache>, [">= 0"])
90
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
91
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
93
92
  else
94
93
  s.add_dependency(%q<nokogiri>, [">= 1.3.1"])
95
94
  s.add_dependency(%q<httparty>, [">= 0.4.5"])
96
95
  s.add_dependency(%q<mechanize>, [">= 0.9.3"])
97
96
  s.add_dependency(%q<api_cache>, [">= 0"])
97
+ s.add_dependency(%q<shoulda>, [">= 0"])
98
+ s.add_dependency(%q<fakeweb>, [">= 0"])
98
99
  end
99
100
  else
100
101
  s.add_dependency(%q<nokogiri>, [">= 1.3.1"])
101
102
  s.add_dependency(%q<httparty>, [">= 0.4.5"])
102
103
  s.add_dependency(%q<mechanize>, [">= 0.9.3"])
103
104
  s.add_dependency(%q<api_cache>, [">= 0"])
105
+ s.add_dependency(%q<shoulda>, [">= 0"])
106
+ s.add_dependency(%q<fakeweb>, [">= 0"])
104
107
  end
105
108
  end
106
109
 
data/test/commit_test.rb CHANGED
@@ -24,6 +24,13 @@ class CommitTest < Test::Unit::TestCase
24
24
  assert_equal 30, commits.size
25
25
  end
26
26
 
27
+ should "second page of commits" do
28
+ commits = Commit.find_all(:user => "fcoury", :repository => "octopi", :page => 2)
29
+ assert_not_nil commits
30
+ assert_equal 30, commits.size
31
+ assert_not_nil commits.first.repository
32
+ end
33
+
27
34
  should "be able to specify a branch" do
28
35
  commits = Commit.find_all(:user => "fcoury", :repository => "octopi", :branch => "lazy")
29
36
  assert_not_nil commits
data/test/issue_test.rb CHANGED
@@ -17,20 +17,26 @@ class IssueTest < Test::Unit::TestCase
17
17
  should "using objects" do
18
18
  issues = Issue.find_all(:user => @user, :repo => @repo)
19
19
  assert_not_nil issues
20
- assert_equal 21, issues.size
20
+ assert_equal 30, issues.size
21
21
  end
22
-
22
+
23
23
  should "using strings" do
24
24
  issues = Issue.find_all(:user => "fcoury", :repo => "octopi")
25
25
  assert_not_nil issues
26
- assert_equal 21, issues.size
26
+ assert_equal 30, issues.size
27
27
  end
28
-
29
- should "specifying a state" do
28
+
29
+ should "all closed issues" do
30
30
  issues = Issue.find_all(:user => @user, :repo => @repo, :state => "closed")
31
31
  assert_not_nil issues
32
32
  assert_equal 9, issues.size
33
33
  end
34
+
35
+ should "all open issues" do
36
+ issues = Issue.find_all(:user => @user, :repo => @repo, :state => "open")
37
+ assert_not_nil issues
38
+ assert_equal 21, issues.size
39
+ end
34
40
  end
35
41
 
36
42
  context "finding a single issue" do
@@ -115,6 +121,13 @@ class IssueTest < Test::Unit::TestCase
115
121
  comment = @issue.comment("Yes, it is broken.")
116
122
  assert comment.is_a?(IssueComment)
117
123
  end
124
+
125
+ should "be able to get all comments" do
126
+ first_comment = @issue.comments.first
127
+ assert first_comment.is_a?(IssueComment)
128
+ assert_equal "This is fixed in recent release.", first_comment.body
129
+ assert_equal "radar", first_comment.user
130
+ end
118
131
  end
119
132
  end
120
133
  end
@@ -84,10 +84,10 @@ class RepositoryTest < Test::Unit::TestCase
84
84
  assert_equal 21, issues.size
85
85
  end
86
86
 
87
- should "be able to find all issues" do
87
+ should "be able to find all issues, regardless of state" do
88
88
  issues = @repository.all_issues
89
89
  assert_not_nil issues
90
- assert_equal 42, issues.size
90
+ assert_equal 30, issues.size
91
91
  end
92
92
 
93
93
  should "be able to find an issue" do
@@ -97,8 +97,9 @@ class RepositoryTest < Test::Unit::TestCase
97
97
  should "be able to find all collaborators" do
98
98
  @collaborators = @repository.collaborators
99
99
  assert_not_nil @collaborators
100
- assert_equal 1, @collaborators.size
100
+ assert_equal 2, @collaborators.size
101
101
  assert @collaborators.first.is_a?(User)
102
+ assert @collaborators.last.is_a?(User)
102
103
  end
103
104
 
104
105
  should "be able to find all languages" do
@@ -113,6 +114,12 @@ class RepositoryTest < Test::Unit::TestCase
113
114
  end
114
115
  end
115
116
 
117
+ should "be able to create a repository under another user (or organization)" do
118
+ auth do
119
+ Repository.create(:name => "octopus", :user => "other-user")
120
+ end
121
+ end
122
+
116
123
  should "be able to delete a repository" do
117
124
  auth do
118
125
  @repository.delete!
data/test/test_helper.rb CHANGED
@@ -63,7 +63,10 @@ def fake_everything
63
63
  "issues/list/fcoury/octopi/open" => issues("open"),
64
64
  "issues/list/fcoury/octopi/closed" => issues("closed"),
65
65
 
66
- "issues/search/fcoury/octopi/open/test" => issues("search"),
66
+ "issues/search/fcoury/octopi/open/test" => issues("search"),
67
+
68
+ #comments for an issue
69
+ "issues/comments/fcoury/octopi/28" => File.join("comments", "fcoury", "octopi", "comments"),
67
70
 
68
71
  # Closed issue
69
72
  "issues/show/fcoury/octopi/27" => issues("27"),
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
4
+ prerelease:
5
+ version: 0.4.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Felipe Coury
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-12-05 00:00:00 +11:00
13
+ date: 2011-04-28 00:00:00 +10:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 25
30
- segments:
31
- - 1
32
- - 3
33
- - 1
34
24
  version: 1.3.1
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ">="
44
34
  - !ruby/object:Gem::Version
45
- hash: 5
46
- segments:
47
- - 0
48
- - 4
49
- - 5
50
35
  version: 0.4.5
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ">="
60
45
  - !ruby/object:Gem::Version
61
- hash: 61
62
- segments:
63
- - 0
64
- - 9
65
- - 3
66
46
  version: 0.9.3
67
47
  type: :runtime
68
48
  version_requirements: *id003
@@ -74,12 +54,31 @@ dependencies:
74
54
  requirements:
75
55
  - - ">="
76
56
  - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
57
  version: "0"
81
58
  type: :runtime
82
59
  version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: shoulda
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: fakeweb
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id006
83
82
  description:
84
83
  email: felipe.coury@gmail.com
85
84
  executables: []
@@ -90,7 +89,6 @@ extra_rdoc_files:
90
89
  - LICENSE
91
90
  - README.markdown
92
91
  files:
93
- - .gitignore
94
92
  - .yardoc
95
93
  - CHANGELOG.md
96
94
  - LICENSE
@@ -123,6 +121,9 @@ files:
123
121
  - lib/octopi/tag.rb
124
122
  - lib/octopi/user.rb
125
123
  - octopi.gemspec
124
+ - examples/authenticated.rb
125
+ - examples/issues.rb
126
+ - examples/overall.rb
126
127
  - test/api_test.rb
127
128
  - test/authenticated_test.rb
128
129
  - test/base_test.rb
@@ -142,16 +143,13 @@ files:
142
143
  - test/tag_test.rb
143
144
  - test/test_helper.rb
144
145
  - test/user_test.rb
145
- - examples/authenticated.rb
146
- - examples/issues.rb
147
- - examples/overall.rb
148
146
  has_rdoc: true
149
147
  homepage: http://github.com/fcoury/octopi
150
148
  licenses: []
151
149
 
152
150
  post_install_message:
153
- rdoc_options:
154
- - --charset=UTF-8
151
+ rdoc_options: []
152
+
155
153
  require_paths:
156
154
  - lib
157
155
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -159,27 +157,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
157
  requirements:
160
158
  - - ">="
161
159
  - !ruby/object:Gem::Version
162
- hash: 3
163
- segments:
164
- - 0
165
160
  version: "0"
166
161
  required_rubygems_version: !ruby/object:Gem::Requirement
167
162
  none: false
168
163
  requirements:
169
164
  - - ">="
170
165
  - !ruby/object:Gem::Version
171
- hash: 3
172
- segments:
173
- - 0
174
166
  version: "0"
175
167
  requirements: []
176
168
 
177
169
  rubyforge_project: octopi
178
- rubygems_version: 1.3.7
170
+ rubygems_version: 1.5.2
179
171
  signing_key:
180
172
  specification_version: 3
181
173
  summary: A Ruby interface to GitHub API v2
182
174
  test_files:
175
+ - examples/authenticated.rb
176
+ - examples/issues.rb
177
+ - examples/overall.rb
183
178
  - test/api_test.rb
184
179
  - test/authenticated_test.rb
185
180
  - test/base_test.rb
@@ -199,6 +194,3 @@ test_files:
199
194
  - test/tag_test.rb
200
195
  - test/test_helper.rb
201
196
  - test/user_test.rb
202
- - examples/authenticated.rb
203
- - examples/issues.rb
204
- - examples/overall.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- examples/github.yml
2
- doc/
3
- pkg/
4
- contrib/nothingspecial.rb