octopussy 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/lib/octopussy.rb +5 -0
  2. data/lib/octopussy/client.rb +26 -3
  3. data/test/octopussy_test.rb +41 -2
  4. metadata +43 -83
  5. data/.document +0 -4
  6. data/.gitignore +0 -21
  7. data/LICENSE +0 -20
  8. data/README.markdown +0 -68
  9. data/Rakefile +0 -59
  10. data/VERSION +0 -1
  11. data/changelog.markdown +0 -30
  12. data/octopussy.gemspec +0 -105
  13. data/test/fixtures/blob.json +0 -10
  14. data/test/fixtures/branches.json +0 -6
  15. data/test/fixtures/close_issue.json +0 -1
  16. data/test/fixtures/collaborators.json +0 -1
  17. data/test/fixtures/comment.json +0 -1
  18. data/test/fixtures/contributors.json +0 -6
  19. data/test/fixtures/emails.json +0 -1
  20. data/test/fixtures/followers.json +0 -3
  21. data/test/fixtures/full_user.json +0 -27
  22. data/test/fixtures/issue.json +0 -14
  23. data/test/fixtures/issues.json +0 -50
  24. data/test/fixtures/keys.json +0 -1
  25. data/test/fixtures/labels.json +0 -1
  26. data/test/fixtures/languages.json +0 -1
  27. data/test/fixtures/list_branch_commits.json +0 -48
  28. data/test/fixtures/list_commits.json +0 -824
  29. data/test/fixtures/network.json +0 -26
  30. data/test/fixtures/network_data.json +0 -1
  31. data/test/fixtures/network_meta.json +0 -109
  32. data/test/fixtures/open_issue.json +0 -1
  33. data/test/fixtures/raw_git_data.json +0 -7
  34. data/test/fixtures/reopen_issue.json +0 -1
  35. data/test/fixtures/repo.json +0 -14
  36. data/test/fixtures/repo_search.json +0 -452
  37. data/test/fixtures/repos.json +0 -830
  38. data/test/fixtures/search.json +0 -44
  39. data/test/fixtures/show_commit.json +0 -37
  40. data/test/fixtures/tags.json +0 -8
  41. data/test/fixtures/trees.json +0 -140
  42. data/test/fixtures/user.json +0 -16
@@ -13,6 +13,8 @@ require 'octopussy/client'
13
13
 
14
14
  module Octopussy
15
15
  extend SingleForwardable
16
+
17
+ VERSION = "0.2.4".freeze
16
18
 
17
19
  class OctopussyError < StandardError
18
20
  attr_reader :data
@@ -54,4 +56,7 @@ module Octopussy
54
56
 
55
57
  # Commits
56
58
  def_delegators :client, :list_commits, :commit
59
+
60
+ # Timeline
61
+ def_delegators :client, :public_timeline
57
62
  end
@@ -9,8 +9,15 @@ module Octopussy
9
9
 
10
10
  # :login => 'pengwynn', :token => 'your_github_api_key'
11
11
  def initialize(auth={})
12
- @login = auth[:login]
13
- @token = auth[:token]
12
+ if auth[:password].nil?
13
+ @login = auth[:login]
14
+ @token = auth[:token]
15
+ self.class.basic_auth(nil, nil)
16
+ else
17
+ @login = auth[:login]
18
+ self.class.basic_auth(@login, auth[:password])
19
+ end
20
+
14
21
  end
15
22
 
16
23
  def search_users(q)
@@ -345,10 +352,26 @@ module Octopussy
345
352
  Hashie::Mash.new(response).commit
346
353
  end
347
354
 
355
+ def public_timeline(username = nil)
356
+ username ||= @login
357
+ if username.nil?
358
+ path = "http://github.com/timeline.json"
359
+ else
360
+ path = "http://github.com/#{username}.json"
361
+ end
362
+ response = self.class.get(path)
363
+ response.map{|item| Hashie::Mash.new(item)}
364
+ end
365
+
366
+ def timeline
367
+ response = self.class.get("http://github.com/#{@login}.private.json", :query => auth_params)
368
+ response.map{|item| Hashie::Mash.new(item)}
369
+ end
370
+
348
371
  private
349
372
 
350
373
  def auth_params
351
- @login.nil? ? {} : {:login => @login, :token => @token}
374
+ @token.nil? ? {} : {:login => @login, :token => @token}
352
375
  end
353
376
 
354
377
  def self.get(*args); handle_response super end
@@ -6,6 +6,14 @@ class OctopussyTest < Test::Unit::TestCase
6
6
  setup do
7
7
  @client = Octopussy::Client.new(:login => 'pengwynn', :token => 'OU812')
8
8
  end
9
+
10
+ should "authenticate via basic auth" do
11
+ stub_get("http://pengwynn:OU812@github.com/api/v2/json/user/show/pengwynn", "full_user.json")
12
+ client = Octopussy::Client.new(:login => 'pengwynn', :password => 'OU812')
13
+ user = client.user
14
+ user.plan.name.should == 'free'
15
+ user.plan.space.should == 307200
16
+ end
9
17
 
10
18
  should "should search users" do
11
19
  stub_get("/user/search/wynn", "search.json")
@@ -237,7 +245,19 @@ class OctopussyTest < Test::Unit::TestCase
237
245
  collaborators.last.should == 'adamstac'
238
246
  end
239
247
 
240
-
248
+ should "fetch a user's public timeline" do
249
+ stub_get("http://github.com/pengwynn.json", "timeline.json")
250
+ events = @client.public_timeline('pengwynn')
251
+ events.first['type'].should == 'FollowEvent'
252
+ events[1].repository.name.should == 'octopussy'
253
+ end
254
+
255
+ should "fetch a user's private timeline" do
256
+ stub_get("http://github.com/pengwynn.private.json?login=pengwynn&token=OU812", "timeline.json")
257
+ events = @client.timeline
258
+ events.first['type'].should == 'FollowEvent'
259
+ events[1].repository.name.should == 'octopussy'
260
+ end
241
261
  end
242
262
 
243
263
 
@@ -393,7 +413,7 @@ class OctopussyTest < Test::Unit::TestCase
393
413
  end
394
414
 
395
415
  should "return the contents of a blob with the blob's SHA" do
396
- stub_get("http://github.com/api/v2/yaml/blob/show/defunkt/facebox/4bf7a39e8c4ec54f8b4cd594a3616d69004aba69", "raw_git_data.json")
416
+ stub_get("http://github.com/api/v2/yaml/blob/show/defunkt/facebox/4bf7a39e8c4ec54f8b4cd594a3616d69004aba69", "raw_git_data.yaml")
397
417
  raw_text = Octopussy.raw({:username => "defunkt", :repo => "facebox"}, "4bf7a39e8c4ec54f8b4cd594a3616d69004aba69")
398
418
  assert raw_text.include?("cd13d9a61288dceb0a7aa73b55ed2fd019f4f1f7")
399
419
  end
@@ -417,6 +437,22 @@ class OctopussyTest < Test::Unit::TestCase
417
437
  show_commit = Octopussy.commit({:username => "defunkt", :repo => "facebox"}, sha)
418
438
  assert show_commit.message == "Fixed CSS expression, throwing errors in IE6."
419
439
  end
440
+
441
+ #timeline
442
+
443
+ should "fetch the public timeline" do
444
+ stub_get("http://github.com/timeline.json", "timeline.json")
445
+ events = Octopussy.public_timeline
446
+ events.first['type'].should == 'FollowEvent'
447
+ events[1].repository.name.should == 'octopussy'
448
+ end
449
+
450
+ should "fetch a user's public timeline" do
451
+ stub_get("http://github.com/pengwynn.json", "timeline.json")
452
+ events = Octopussy.public_timeline('pengwynn')
453
+ events.first['type'].should == 'FollowEvent'
454
+ events[1].repository.name.should == 'octopussy'
455
+ end
420
456
 
421
457
  end
422
458
 
@@ -724,7 +760,10 @@ class OctopussyTest < Test::Unit::TestCase
724
760
  event.event_type.should == 'download'
725
761
  event.repo.name.should == 'prototype'
726
762
  end
763
+
764
+
727
765
  end
766
+
728
767
 
729
768
 
730
769
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wynn Netherland
@@ -15,13 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-17 00:00:00 -05:00
18
+ date: 2010-08-07 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: hashie
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
23
  requirements:
26
24
  - - ~>
27
25
  - !ruby/object:Gem::Version
@@ -30,40 +28,40 @@ dependencies:
30
28
  - 2
31
29
  - 0
32
30
  version: 0.2.0
31
+ name: hashie
32
+ prerelease: false
33
+ requirement: *id001
33
34
  type: :runtime
34
- version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: httparty
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
37
  requirements:
40
38
  - - ~>
41
39
  - !ruby/object:Gem::Version
42
40
  segments:
43
41
  - 0
44
- - 4
45
42
  - 5
46
- version: 0.4.5
43
+ - 2
44
+ version: 0.5.2
45
+ name: httparty
46
+ prerelease: false
47
+ requirement: *id002
47
48
  type: :runtime
48
- version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: shoulda
51
- prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
51
  requirements:
54
- - - ">="
52
+ - - ~>
55
53
  - !ruby/object:Gem::Version
56
54
  segments:
57
55
  - 2
58
56
  - 10
59
- - 1
60
- version: 2.10.1
57
+ - 0
58
+ version: 2.10.0
59
+ name: shoulda
60
+ prerelease: false
61
+ requirement: *id003
61
62
  type: :development
62
- version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- name: jnunemaker-matchy
65
- prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
65
  requirements:
68
66
  - - "="
69
67
  - !ruby/object:Gem::Version
@@ -72,12 +70,12 @@ dependencies:
72
70
  - 4
73
71
  - 0
74
72
  version: 0.4.0
73
+ name: jnunemaker-matchy
74
+ prerelease: false
75
+ requirement: *id004
75
76
  type: :development
76
- version_requirements: *id004
77
77
  - !ruby/object:Gem::Dependency
78
- name: mocha
79
- prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
81
79
  requirements:
82
80
  - - ">="
83
81
  - !ruby/object:Gem::Version
@@ -86,12 +84,12 @@ dependencies:
86
84
  - 9
87
85
  - 4
88
86
  version: 0.9.4
87
+ name: mocha
88
+ prerelease: false
89
+ requirement: *id005
89
90
  type: :development
90
- version_requirements: *id005
91
91
  - !ruby/object:Gem::Dependency
92
- name: fakeweb
93
- prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
92
+ version_requirements: &id006 !ruby/object:Gem::Requirement
95
93
  requirements:
96
94
  - - ">="
97
95
  - !ruby/object:Gem::Version
@@ -100,70 +98,30 @@ dependencies:
100
98
  - 2
101
99
  - 5
102
100
  version: 1.2.5
101
+ name: fakeweb
102
+ prerelease: false
103
+ requirement: *id006
103
104
  type: :development
104
- version_requirements: *id006
105
105
  description: Simple wrapper for the GitHub API v2
106
106
  email: wynn.netherland@gmail.com
107
107
  executables: []
108
108
 
109
109
  extensions: []
110
110
 
111
- extra_rdoc_files:
112
- - LICENSE
113
- - README.markdown
111
+ extra_rdoc_files: []
112
+
114
113
  files:
115
- - .document
116
- - .gitignore
117
- - LICENSE
118
- - README.markdown
119
- - Rakefile
120
- - VERSION
121
- - changelog.markdown
122
- - lib/octopussy.rb
123
114
  - lib/octopussy/client.rb
124
115
  - lib/octopussy/event.rb
125
116
  - lib/octopussy/repo.rb
126
- - octopussy.gemspec
127
- - test/fixtures/blob.json
128
- - test/fixtures/branches.json
129
- - test/fixtures/close_issue.json
130
- - test/fixtures/collaborators.json
131
- - test/fixtures/comment.json
132
- - test/fixtures/contributors.json
133
- - test/fixtures/emails.json
134
- - test/fixtures/followers.json
135
- - test/fixtures/full_user.json
136
- - test/fixtures/issue.json
137
- - test/fixtures/issues.json
138
- - test/fixtures/keys.json
139
- - test/fixtures/labels.json
140
- - test/fixtures/languages.json
141
- - test/fixtures/list_branch_commits.json
142
- - test/fixtures/list_commits.json
143
- - test/fixtures/network.json
144
- - test/fixtures/network_data.json
145
- - test/fixtures/network_meta.json
146
- - test/fixtures/open_issue.json
147
- - test/fixtures/raw_git_data.json
148
- - test/fixtures/reopen_issue.json
149
- - test/fixtures/repo.json
150
- - test/fixtures/repo_search.json
151
- - test/fixtures/repos.json
152
- - test/fixtures/search.json
153
- - test/fixtures/show_commit.json
154
- - test/fixtures/tags.json
155
- - test/fixtures/trees.json
156
- - test/fixtures/user.json
157
- - test/helper.rb
158
- - test/octopussy_test.rb
159
- - test/repo_test.rb
117
+ - lib/octopussy.rb
160
118
  has_rdoc: true
161
- homepage: http://wynnnetherland.com/projects/octopussy
119
+ homepage: http://wynnnetherland.com/projects/octopussy/
162
120
  licenses: []
163
121
 
164
122
  post_install_message:
165
- rdoc_options:
166
- - --charset=UTF-8
123
+ rdoc_options: []
124
+
167
125
  require_paths:
168
126
  - lib
169
127
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -178,15 +136,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
136
  - - ">="
179
137
  - !ruby/object:Gem::Version
180
138
  segments:
181
- - 0
182
- version: "0"
139
+ - 1
140
+ - 3
141
+ - 6
142
+ version: 1.3.6
183
143
  requirements: []
184
144
 
185
145
  rubyforge_project:
186
146
  rubygems_version: 1.3.6
187
147
  signing_key:
188
148
  specification_version: 3
189
- summary: Simple wrapper for the GitHub API
149
+ summary: Wrapper for the Octopussy API
190
150
  test_files:
191
151
  - test/helper.rb
192
152
  - test/octopussy_test.rb
data/.document DELETED
@@ -1,4 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- features/**/*.feature
4
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Wynn Netherland
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,68 +0,0 @@
1
- # octopussy
2
-
3
- <img src='http://upload.wikimedia.org/wikipedia/en/b/bb/007Octopussyposter.jpg' style='float: right; margin: 0 0 10px 10px'/>
4
-
5
- Simple Ruby wrapper for the GitHub v2 API.
6
-
7
- ## Installation
8
-
9
- sudo gem install octopussy
10
-
11
- ## Some examples
12
-
13
- ### Show a user
14
-
15
- Octopussy.user('pengwynn')
16
- => <#Hashie::Mash blog="http://wynnnetherland.com" company="Orrka" created_at="2008/02/25 10:24:19 -0800" email="wynn.netherland@gmail.com" followers_count=21 following_count=55 id=865 location="Dallas, TX" login="pengwynn" name="Wynn Netherland" public_gist_count=4 public_repo_count=16>
17
-
18
- ### Show who a user follows
19
-
20
- Octopussy.following('pengwynn')
21
- => ["cglee", "bryansray", "rails", "zachinglis", "wycats", "obie", "mully", "squeejee", "jderrett", "Shopify", "ReinH", "technoweenie", "errfree", "defunkt", "joshsusser", "hashrocket", "newbamboo", "bigtiger", "github", "jamis", "jeresig", "thoughtbot", "therealadam", "jnunemaker", "seaofclouds", "choan", "llimllib", "kwhinnery", "marshall", "handcrafted", "adamstac", "jashkenas", "dan", "remy", "hayesdavis", "documentcloud", "imathis", "mdeiters", "njonsson", "asenchi", "mattsa", "marclove", "webiest", "brogers", "polomasta", "stephp", "mchelen", "piyush", "davidnorth", "rmetzler", "jferris", "madrobby", "zh", "erikvold", "desandro"]
22
-
23
- ## Working with repositories
24
-
25
- For convenience, methods that require a repo argument may be passed in any of the following forms
26
-
27
- * "pengwynn/linked"
28
- * {:username => 'pengwynn', :name => 'linkedin'}
29
- * {:username => 'pengwynn', :repo => 'linkedin'}
30
- * instance of Repo
31
-
32
- ### Show a repo
33
-
34
- Octopussy.repo("pengwynn/linkedin")
35
- => <#Hashie::Mash description="Ruby wrapper for the LinkedIn API" fork=false forks=1 homepage="http://bit.ly/ruby-linkedin" name="linkedin" open_issues=2 owner="pengwynn" private=false url="http://github.com/pengwynn/linkedin" watchers=36>
36
-
37
- ## Authenticated requests
38
-
39
- Some methods require authentication so you'll need to pass a login and an api_token. You can find your GitHub API token on your [account page](https://github.com/account)
40
-
41
- client = Octopussy::Client.new(:login => 'pengwynn', :token => 'OU812')
42
- client.follow!('adamstac')
43
-
44
- Read the full [docs](http://rdoc.info/projects/pengwynn/octopussy) or check out the [examples](http://github.com/pengwynn/octopussy/tree/master/examples)
45
-
46
- ## TODO
47
-
48
- * Feed parsing
49
- * More examples
50
-
51
- ## Note on Patches/Pull Requests
52
-
53
- * Fork the project.
54
- * Make your feature addition or bug fix.
55
- * Add tests for it. This is important so I don't break it in a
56
- future version unintentionally.
57
- * Commit, do not mess with rakefile, version, or history.
58
- (if you want to have your own version, that is fine but
59
- bump version in a commit by itself I can ignore when I pull)
60
- * Send me a pull request. Bonus points for topic branches.
61
-
62
- ## Credits
63
-
64
- Octopussy is inspired by [Octopi](http://github.com/fcoury/octopi) and aims to be a lightweight, less active-resourcey alternative.
65
-
66
- ## Copyright
67
-
68
- Copyright (c) 2009 [Wynn Netherland](http://wynnnetherland.com), [Adam Stacoviak](http://adamstacoviak.com/). See LICENSE for details.