octopi 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ doc/
3
3
  pkg/
4
4
  contrib/nothingspecial.rb
5
5
  **/*.swp
6
+ *.rbc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- octopi (0.4.2)
4
+ octopi (0.4.4)
5
5
  api_cache
6
6
  httparty (>= 0.4.5)
7
7
  mechanize (>= 0.9.3)
@@ -54,8 +54,9 @@ Use the following format:
54
54
  #
55
55
 
56
56
  # GitHub user login and token
57
- login: github-username
58
- token: github-token
57
+ github:
58
+ user: github-username
59
+ token: github-token
59
60
 
60
61
  # Trace level
61
62
  # Possible values:
@@ -66,7 +67,7 @@ Use the following format:
66
67
 
67
68
  And change the way you connect to:
68
69
 
69
- authenticated_with :config => "github.yml" do
70
+ authenticated :config => "github.yml") do
70
71
  (...)
71
72
  end
72
73
 
@@ -137,7 +138,7 @@ Single commit information:
137
138
 
138
139
  In alphabetical order:
139
140
 
140
- * Ryan Bigg - http://ryanbigg.net
141
+ * Ryan Bigg - http://ryanbigg.com
141
142
  * Brandon Calloway - http://github.com/bcalloway
142
143
  * runpaint - http://github.com/runpaint
143
144
 
@@ -27,8 +27,12 @@ module Octopi
27
27
 
28
28
  def authenticated(options={}, &block)
29
29
  begin
30
- config = config = File.open(options[:config]) { |yf| YAML::load(yf) } if options[:config]
31
- config = read_gitconfig
30
+ if options[:config]
31
+ config = YAML.load_file(options[:config])
32
+ else
33
+ config = read_gitconfig
34
+ end
35
+
32
36
  options[:login] = config["github"]["user"]
33
37
  options[:token] = config["github"]["token"]
34
38
 
@@ -135,4 +139,4 @@ module Octopi
135
139
  puts text
136
140
  end
137
141
  end
138
- end
142
+ end
@@ -0,0 +1,15 @@
1
+ module Octopi
2
+ class Tree < Base
3
+ attr_accessor :name, :size, :sha, :mode, :mime_type, :type, :user, :repository
4
+
5
+ def self.find(options)
6
+ ensure_hash(options)
7
+ user, repo = gather_details(options)
8
+ route = "/tree/show/#{user}/#{repo}/#{options[:sha]}"
9
+ trees = Api.api.get(route)["tree"].map do |tree|
10
+ Tree.new(tree.merge(:user => user, :repository => repo))
11
+ end
12
+ TreeSet.new(trees)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), "tree")
2
+ class Octopi::TreeSet < Array
3
+ include Octopi
4
+ attr_accessor :user, :repository
5
+
6
+ def initialize(array)
7
+ self.user = array.first.user
8
+ self.repository = array.first.repository
9
+ super(array)
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Octopi
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -7,6 +7,13 @@ class AuthenticatedTest < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  context "Authenticating" do
10
+ should "be able to login with github.yml" do
11
+ authenticated :config => File.join(File.dirname(__FILE__), "github.yml") do
12
+ assert_equal "8f700e0d7747826f3e56ee13651414bd", Api.api.token
13
+ assert_not_nil User.find("fcoury")
14
+ end
15
+ end
16
+
10
17
  should "be possible with username and password" do
11
18
  authenticated_with(:login => "fcoury", :password => "yruocf") do
12
19
  assert_equal "8f700e0d7747826f3e56ee13651414bd", Api.api.token
@@ -0,0 +1,3 @@
1
+ github:
2
+ user: fcoury
3
+ token: 8f700e0d7747826f3e56ee13651414bd
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
+
3
+ class TreeTest < Test::Unit::TestCase
4
+ include Octopi
5
+
6
+ def setup
7
+ fake_everything
8
+ end
9
+
10
+ should "be able to find a tree set" do
11
+ shared_options = { :user => "fcoury", :repo => "octopi"}
12
+ branch = Branch.all(shared_options).detect { |b| b.name == "master" }
13
+ assert Tree.find(shared_options.merge!(:sha => branch.sha)).is_a?(TreeSet)
14
+ end
15
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: octopi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.4
5
+ version: 0.4.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Felipe Coury
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-13 00:00:00 +10:00
14
+ date: 2011-07-07 00:00:00 +10:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -168,6 +168,8 @@ files:
168
168
  - lib/octopi/resource.rb
169
169
  - lib/octopi/self.rb
170
170
  - lib/octopi/tag.rb
171
+ - lib/octopi/tree.rb
172
+ - lib/octopi/tree_set.rb
171
173
  - lib/octopi/user.rb
172
174
  - lib/octopi/version.rb
173
175
  - octopi.gemspec
@@ -183,6 +185,7 @@ files:
183
185
  - test/commit_test.rb
184
186
  - test/file_object_test.rb
185
187
  - test/gist_test.rb
188
+ - test/github.yml
186
189
  - test/issue_comment.rb
187
190
  - test/issue_set_test.rb
188
191
  - test/issue_test.rb
@@ -313,6 +316,7 @@ files:
313
316
  - test/stubs/users/wycats
314
317
  - test/tag_test.rb
315
318
  - test/test_helper.rb
319
+ - test/tree_test.rb
316
320
  - test/user_test.rb
317
321
  - test_auth.rb
318
322
  has_rdoc: true
@@ -352,6 +356,7 @@ test_files:
352
356
  - test/commit_test.rb
353
357
  - test/file_object_test.rb
354
358
  - test/gist_test.rb
359
+ - test/github.yml
355
360
  - test/issue_comment.rb
356
361
  - test/issue_set_test.rb
357
362
  - test/issue_test.rb
@@ -482,4 +487,5 @@ test_files:
482
487
  - test/stubs/users/wycats
483
488
  - test/tag_test.rb
484
489
  - test/test_helper.rb
490
+ - test/tree_test.rb
485
491
  - test/user_test.rb