github-api-client 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,16 +1,17 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rainbow"
4
- gem "activerecord", ">= 3.0.3"
5
- gem "activesupport", ">= 3.0.3"
6
- gem "sqlite3-ruby"
3
+ gem "rainbow", ">= 1.1.3"
4
+ gem "rake", "0.8.7"
5
+ gem "activerecord", ">= 3.1.0"
6
+ gem "activesupport", ">= 3.1.0"
7
+ gem "sqlite3", ">= 1.3.5"
8
+ gem "OptionParser", ">= 0.5.1"
7
9
 
8
10
  group :development do
9
- gem "rspec", ">= 2.3.0"
10
- gem "mocha"
11
+ gem "rspec", ">= 2.7.0"
12
+ gem "mocha", ">= 0.10.0"
11
13
  gem "yard", ">= 0.6.0"
12
- gem "cucumber"
13
- #gem "bundler"
14
- gem "jeweler", "~> 1.5.2"
15
- gem "rcov"
14
+ gem "cucumber", ">= 1.1.4"
15
+ gem "jeweler", ">= 1.6.4"
16
+ gem "rcov", ">= 0.9.11"
16
17
  end
data/Gemfile.lock CHANGED
@@ -1,63 +1,69 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.0.3)
5
- activesupport (= 3.0.3)
6
- builder (~> 2.1.2)
7
- i18n (~> 0.4)
8
- activerecord (3.0.3)
9
- activemodel (= 3.0.3)
10
- activesupport (= 3.0.3)
11
- arel (~> 2.0.2)
12
- tzinfo (~> 0.3.23)
13
- activesupport (3.0.3)
14
- arel (2.0.6)
15
- builder (2.1.2)
16
- cucumber (0.10.0)
4
+ OptionParser (0.5.1)
5
+ activemodel (3.1.3)
6
+ activesupport (= 3.1.3)
7
+ builder (~> 3.0.0)
8
+ i18n (~> 0.6)
9
+ activerecord (3.1.3)
10
+ activemodel (= 3.1.3)
11
+ activesupport (= 3.1.3)
12
+ arel (~> 2.2.1)
13
+ tzinfo (~> 0.3.29)
14
+ activesupport (3.1.3)
15
+ multi_json (~> 1.0)
16
+ arel (2.2.1)
17
+ builder (3.0.0)
18
+ cucumber (1.1.4)
17
19
  builder (>= 2.1.2)
18
- diff-lcs (~> 1.1.2)
19
- gherkin (~> 2.3.2)
20
- json (~> 1.4.6)
21
- term-ansicolor (~> 1.0.5)
22
- diff-lcs (1.1.2)
23
- gherkin (2.3.3)
24
- json (~> 1.4.6)
20
+ diff-lcs (>= 1.1.2)
21
+ gherkin (~> 2.7.1)
22
+ json (>= 1.4.6)
23
+ term-ansicolor (>= 1.0.6)
24
+ diff-lcs (1.1.3)
25
+ gherkin (2.7.3)
26
+ json (>= 1.4.6)
25
27
  git (1.2.5)
26
- i18n (0.5.0)
27
- jeweler (1.5.2)
28
- bundler (~> 1.0.0)
28
+ i18n (0.6.0)
29
+ jeweler (1.6.4)
30
+ bundler (~> 1.0)
29
31
  git (>= 1.2.5)
30
32
  rake
31
- json (1.4.6)
32
- mocha (0.9.10)
33
- rake
34
- rainbow (1.1)
33
+ json (1.6.5)
34
+ metaclass (0.0.1)
35
+ mocha (0.10.2)
36
+ metaclass (~> 0.0.1)
37
+ multi_json (1.0.4)
38
+ rainbow (1.1.3)
35
39
  rake (0.8.7)
36
- rcov (0.9.9)
37
- rspec (2.4.0)
38
- rspec-core (~> 2.4.0)
39
- rspec-expectations (~> 2.4.0)
40
- rspec-mocks (~> 2.4.0)
41
- rspec-core (2.4.0)
42
- rspec-expectations (2.4.0)
40
+ rcov (0.9.11)
41
+ rspec (2.8.0)
42
+ rspec-core (~> 2.8.0)
43
+ rspec-expectations (~> 2.8.0)
44
+ rspec-mocks (~> 2.8.0)
45
+ rspec-core (2.8.0)
46
+ rspec-expectations (2.8.0)
43
47
  diff-lcs (~> 1.1.2)
44
- rspec-mocks (2.4.0)
45
- sqlite3-ruby (1.3.2)
46
- term-ansicolor (1.0.5)
47
- tzinfo (0.3.23)
48
- yard (0.6.4)
48
+ rspec-mocks (2.8.0)
49
+ sqlite3 (1.3.5)
50
+ term-ansicolor (1.0.7)
51
+ tzinfo (0.3.31)
52
+ yard (0.7.4)
49
53
 
50
54
  PLATFORMS
51
55
  ruby
52
56
 
53
57
  DEPENDENCIES
54
- activerecord (>= 3.0.3)
55
- activesupport (>= 3.0.3)
56
- cucumber
57
- jeweler (~> 1.5.2)
58
- mocha
59
- rainbow
60
- rcov
61
- rspec (>= 2.3.0)
62
- sqlite3-ruby
58
+ OptionParser (>= 0.5.1)
59
+ activerecord (>= 3.1.0)
60
+ activesupport (>= 3.1.0)
61
+ cucumber (>= 1.1.4)
62
+ jeweler (>= 1.6.4)
63
+ mocha (>= 0.10.0)
64
+ rainbow (>= 1.1.3)
65
+ rake (= 0.8.7)
66
+ rcov (>= 0.9.11)
67
+ rspec (>= 2.7.0)
68
+ sqlite3 (>= 1.3.5)
63
69
  yard (>= 0.6.0)
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Jakub Okoński
1
+ Copyright (c) 2012 Jakub Okoński
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # github-api-client
2
+
3
+ GitHub API Client that supports caching content client-side, allowing every later requests to be **instant**.
4
+
5
+ # Configuration
6
+ You have three ways of defining your user to have authenticated access to your API:
7
+
8
+ 1. Put a file in: ~/.github/secrets.yml or \Users\username\.github\secrets.yml
9
+ # secrets.yml
10
+ user:
11
+ login: your_login
12
+ token: your_token
13
+ 2. Put GITHUB_USER and GITHUB_TOKEN in your environment, so github-api-client can read it.
14
+ 3. Configure your global git profile as defined here http://help.github.com/git-email-settings
15
+
16
+ ## Contributing to github-api-client
17
+
18
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
19
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
20
+ * Fork the project
21
+ * Start a feature/bugfix branch
22
+ * Commit and push until you are happy with your contribution
23
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
24
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
25
+
26
+ ## Copyright
27
+
28
+ Copyright (c) 2012 Jakub Okoński. See LICENSE.txt for
29
+ further details.
30
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.2
@@ -1,7 +1,8 @@
1
- class ActiveRecord::Associations::HasAndBelongsToManyAssociation
1
+ puts "EXECUTING"
2
+ ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do
2
3
  # Short alias for if exists then create
3
4
  # @param [ActiveRecord::Base] object An object to check if exists and create
4
5
  def find_or_create(object)
5
- self << object unless exists?(object)
6
+ self.concat(object) unless include?(object)
6
7
  end
7
8
  end
@@ -42,6 +42,7 @@ module GitHub
42
42
  # @param [Hash] attributes GitHub API retrieved attributes to be parsed
43
43
  # @return [Hash] parsed attributes, fully compatibile with local db
44
44
  def self.parse_attributes(resource, attributes)
45
+ return {} unless attributes # Guard against empty results
45
46
  hash = case resource
46
47
  when :user_get then {:public_repo_count => :nil, :public_gist_count => :nil, :created => :nil, :permission => :nil, :followers_count => :nil, :following_count => :nil}
47
48
  when :user_search then {:name => :login, :username => :login, :fullname => :name, :followers => :nil, :repos => :nil, :created => :nil, :permission => :nil}
@@ -49,6 +50,7 @@ module GitHub
49
50
  when :org_get then {:public_gist_count => nil, :public_repo_count => nil, :following_count => :nil, :followers_count => :nil}
50
51
  when :org_repo_index then {:owner => nil, :open_issues => nil, :has_issues => nil, :watchers => nil, :forks => nil, :fork => :b_fork, :gravatar_id => nil, :organization => :organization_login, :master_branch => nil}
51
52
  when :org_repo_get then {:owner => nil, :open_issues => nil, :has_issues => nil, :watchers => nil, :forks => nil, :fork => :b_fork, :gravatar_id => nil, :organization => :organization_login}
53
+ else raise "Unknown resource #{resource.inspect} with attributes #{attributes.inspect}"
52
54
  end
53
55
  # Provides abstraction layer between YAML :keys and 'keys' returned by Hub
54
56
  symbolized_resources = [:repo_get, :org_repo_index, :org_repo_get]
@@ -10,25 +10,35 @@ module GitHub
10
10
  # @option version "v3"
11
11
  # @return [String] Base GitHub API url for v2
12
12
  def self.base_uri(version = 'v2')
13
- "http://github.com/api/#{version}/yaml"
13
+ gh_uri = GitHub::Config::Options[:server]||'github.com'
14
+ "http://#{gh_uri}/api/#{version}/yaml"
14
15
  end
15
16
 
16
17
  # Runs HTTP GET request at given uri
17
18
  # @param [String] uri URI to be joined with base_uri and requested
18
19
  # @return [String] request result
19
20
  def self.get(uri, version = 'v2')
20
- uri = uri.gsub(" ","+")
21
- puts "Requesting #{URI.parse(self.base_uri(version) + uri)}" if GitHub::Config::Options[:verbose]
22
- Net::HTTP.get URI.parse(self.base_uri + uri)
21
+ uri = URI.parse(self.base_uri(version) + uri.gsub(" ","+"))
22
+ puts "Requesting #{uri}" if GitHub::Config::Options[:verbose]
23
+ Net::HTTP.get uri
23
24
  end
24
25
 
25
26
  # Runs HTTP POST requests with options such as GitHub::User.auth_info
26
27
  # @param [String] uri URI to be joined with base_uri and requested
27
28
  # @return [String] request result
28
29
  def self.post(uri, options = {}, version = 'v2')
30
+ uri = URI.parse(self.base_uri(version) + uri.gsub(" ","+"))
31
+ puts "Requesting #{uri} with options: #{options}" if GitHub::Config::Options[:verbose]
32
+ Net::HTTP.post_form uri, options
33
+ end
34
+
35
+ # Runs HTTP PATCH request at a given uri
36
+ # @param [String] uri URI to be joined with base_uri and requested
37
+ # @return [String] request result
38
+ def self.patch(uri, options = {}, version = 'v2')
29
39
  uri = uri.gsub(" ","+")
30
40
  puts "Requesting #{URI.parse(self.base_uri(version) + uri)} with options: #{options}" if GitHub::Config::Options[:verbose]
31
- Net::HTTP.post_form URI.parse(self.base_uri + uri), options
41
+ Net::HTTP.patch URI.parse(self.base_uri + uri), options
32
42
  end
33
43
  end
34
44
  end
@@ -15,30 +15,37 @@ module GitHub
15
15
  VERSION = Version
16
16
 
17
17
  # Secrets array, uses env vars if defined
18
- Secrets = {
19
- "login" => ENV['GITHUB_USER'],
20
- "token" => ENV['GITHUB_TOKEN']
21
- } if ENV['GITHUB_USER'] && ENV['GITHUB_TOKEN']
22
-
23
- begin
24
- # If not env vars, then ~/.github/secrets.yml
25
- Secrets ||= YAML::load_file(GitHub::Config::Path[:secrets])['user']
26
- rescue Errno::ENOENT
27
- # Eye candy with rainbow
28
- puts <<-report
29
- You have two ways of defining your user to have authenticated access to your API:
18
+ Secrets = case
19
+ when ENV['GITHUB_USER'] && ENV['GITHUB_TOKEN']
20
+ {
21
+ "login" => ENV['GITHUB_USER'],
22
+ "token" => ENV['GITHUB_TOKEN']
23
+ }
24
+ when `git config --global github.user` && !`git config --global github.token`
25
+ {
26
+ "login" => `git config --global github.user`.strip,
27
+ "token" => `git config --global github.token`.strip
28
+ } if `git config --global github.user` && !`git config --global github.token`
29
+ else
30
+ begin
31
+ # If not env vars, then ~/.github/secrets.yml
32
+ YAML::load_file(GitHub::Config::Path[:secrets])['user']
33
+ rescue Errno::ENOENT
34
+ # Eye candy with rainbow
35
+ puts <<-report
36
+ You have three ways of defining your user to have authenticated access to your API:
30
37
  #{"1.".color(:cyan)} Put a file in: #{GitHub::Config::Path[:secrets].color(:blue).bright}
31
38
  Define in yaml:
32
39
  #{"user".color(:yellow).bright}:
33
40
  #{"login".color(:green).bright}: #{"your_login".color(:magenta)}
34
41
  #{"token".color(:blue).bright}: #{"your_token".color(:magenta)}
35
42
  #{"2.".color(:cyan)} Put #{"GITHUB_USER".color(:green).bright} and #{"GITHUB_TOKEN".color(:blue).bright} in your environment, so github-api-client can read it.
36
-
43
+ #{"3.".color(:cyan)} Configure your global git profile as defined here #{"http://help.github.com/git-email-settings/".color(:blue).bright}
44
+
37
45
  report
46
+ end
38
47
  end
39
48
 
40
- Secrets ||= nil
41
-
42
49
  Options = {
43
50
  :verbose => false
44
51
  }
@@ -58,7 +65,7 @@ You have two ways of defining your user to have authenticated access to your API
58
65
  end
59
66
 
60
67
  def self.reset
61
- system "rm #{Path[:dbfile]}"
68
+ File.delete Path[:dbfile]
62
69
  setup
63
70
  end
64
71
  end
@@ -30,13 +30,13 @@ module GitHub
30
30
  private
31
31
  def get_members
32
32
  members = YAML::load(GitHub::Browser.get "/organizations/#{login}/public_members")['users']
33
- puts "Fetching members for #{"organization".color(:magenta).bright} #{self.login.color(:green).bright}"
33
+ puts "Fetching members for #{"organization".color(:magenta).bright} #{self.login.dup.color(:green).bright}"
34
34
  i, count = 0, members.count.to_s.color(:green).bright
35
35
  self.transaction do
36
36
  members.each do |user|
37
37
  i += 1
38
38
  u = GitHub::User.find_or_create_by_login(user['login'])
39
- self.members.find_or_create u
39
+ self.association(:members).find_or_create u
40
40
  print "\r#{i.to_s.color(:yellow).bright}/#{count}"
41
41
  end
42
42
  end
@@ -46,7 +46,7 @@ module GitHub
46
46
 
47
47
  def get_repositories
48
48
  repos = YAML::load(GitHub::Browser.get "/organizations/#{login}/public_repositories")['repositories']
49
- puts "Fetching repositories for #{"organization".color(:magenta).bright} #{self.login.color(:green).bright}"
49
+ puts "Fetching repositories for #{"organization".color(:magenta).bright} #{self.login.dup.color(:green).bright}"
50
50
  i, count = 0, repos.count.to_s.color(:green).bright
51
51
  self.transaction do
52
52
  repos.each do |repo|
@@ -47,13 +47,13 @@ module GitHub
47
47
  private
48
48
  def get_watchers
49
49
  watchers = YAML::load(GitHub::Browser.get("/repos/show/#{self.permalink}/watchers"))['watchers']
50
- puts "Fetching watchers for #{"repo".color(:blue).bright} #{self.permalink.color(:green).bright}"
50
+ puts "Fetching watchers for #{"repo".color(:blue).bright} #{self.permalink.dup.color(:green).bright}"
51
51
  i, count = 0, watchers.count.to_s.color(:green).bright
52
52
  self.transaction do
53
53
  watchers.each do |watcher|
54
54
  i += 1
55
55
  attr = {:login => watcher}
56
- self.watchers.find_or_create(GitHub::User.find_or_create_by_login(attr))
56
+ self.association(:watchers).find_or_create(GitHub::User.find_or_create_by_login(attr))
57
57
  print "\r#{i.to_s.color(:blue).bright}/#{count}"
58
58
  end
59
59
  end
@@ -66,6 +66,7 @@ module GitHub
66
66
  when :followers then get_followers
67
67
  when :followings then get_followings
68
68
  when :organizations then get_organizations
69
+ when :repos then get_repos
69
70
  end
70
71
  end
71
72
  self
@@ -76,14 +77,14 @@ module GitHub
76
77
  # @return GitHub::User Chainable after mapping followers association
77
78
  private
78
79
  def get_followers
79
- users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users']
80
- puts "Fetching followers for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
80
+ users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users'] || []
81
+ puts "Fetching followers for #{"user".color(:yellow).bright} #{self.login.dup.color(:green).bright}"
81
82
  i, count = 0, users.count.to_s.color(:green).bright
82
83
  self.transaction do
83
84
  users.each do |user|
84
85
  i += 1
85
86
  u = GitHub::User.find_or_create_by_login(user)
86
- self.followers.find_or_create u
87
+ self.association(:followers).find_or_create u
87
88
  print "\r#{i.to_s.color(:yellow).bright}/#{count}"
88
89
  end
89
90
  end
@@ -92,14 +93,14 @@ module GitHub
92
93
  end
93
94
 
94
95
  def get_followings
95
- users = YAML::load(GitHub::Browser.get "/user/show/#{login}/following")['users']
96
- puts "Fetching followings for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
96
+ users = YAML::load(GitHub::Browser.get "/user/show/#{login}/following")['users'] || []
97
+ puts "Fetching followings for #{"user".color(:yellow).bright} #{self.login.dup.color(:green).bright}"
97
98
  i, count = 0, users.count.to_s.color(:green).bright
98
99
  self.transaction do
99
100
  users.each do |user|
100
101
  i += 1
101
102
  u = GitHub::User.find_or_create_by_login(user)
102
- self.followings.find_or_create u
103
+ self.association(:followings).find_or_create u
103
104
  print "\r#{i.to_s.color(:yellow).bright}/#{count}"
104
105
  end
105
106
  end
@@ -108,14 +109,14 @@ module GitHub
108
109
  end
109
110
 
110
111
  def get_organizations
111
- organizations = YAML::load(GitHub::Browser.get "/user/show/#{login}/organizations")['organizations']
112
- puts "Fetching organizations for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
112
+ organizations = YAML::load(GitHub::Browser.get "/user/show/#{login}/organizations")['organizations'] || []
113
+ puts "Fetching organizations for #{"user".color(:yellow).bright} #{self.login.dup.color(:green).bright}"
113
114
  i, count = 0, organizations.count.to_s.color(:green).bright
114
115
  self.transaction do
115
116
  organizations.each do |org|
116
117
  i += 1
117
118
  u = GitHub::Organization.find_or_create_by_login(org['login'])
118
- self.organizations.find_or_create u
119
+ self.association(:organizations).find_or_create u
119
120
  print "\r#{i.to_s.color(:yellow).bright}/#{count}"
120
121
  end
121
122
  end
@@ -123,6 +124,26 @@ module GitHub
123
124
  self
124
125
  end
125
126
 
127
+ # Executes when you got a real object
128
+ # @see GitHub::User#fetch
129
+ # @return GitHub::User Chainable after mapping followers association
130
+ def get_repos
131
+ repos = YAML::load(GitHub::Browser.get "/repos/show/#{login}")['repositories'] || []
132
+ puts "Fetching repositories for #{"user".color(:yellow).bright} #{self.login.dup.color(:green).bright}"
133
+ i, count = 0, repos.count.to_s.color(:green).bright
134
+ self.transaction do
135
+ repos.each do |repo|
136
+ i += 1
137
+ u = GitHub::User.find_or_create_by_login(repo[:owner])
138
+ r = GitHub::Repo.where(:owner_id => u.id, :name => repo[:name]).first
139
+ r ||= GitHub::Repo.create(:owner => u, :name => repo[:name])
140
+ print "\r#{i.to_s.color(:yellow).bright}/#{count}"
141
+ end
142
+ end
143
+ puts nil
144
+ self
145
+ end
146
+
126
147
  public
127
148
  # Returns an array with logins of GitHub::User followers
128
149
  # @param [String] login GitHub login of which followers will be mapped
@@ -1,64 +1,122 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "GitHub Api Client" do
4
-
5
- context "configuration" do
6
-
7
- it "should create database on first run" do
8
- File.stubs(:exists?).returns(false)
9
- ActiveRecord::Migrator.expects(:migrate).with(GitHub::Config::Path[:migrations], nil).once
10
- GitHub::Config.setup
11
- end
12
-
13
- it "should not migrate database every time" do
14
- File.stubs(:exists?).returns(true)
15
- ActiveRecord::Migrator.expects(:migrate).never
4
+
5
+ before(:all) do
6
+
7
+ @real_github_user = `git config --global github.user`.strip
8
+ @real_github_token = `git config --global github.token`.strip
9
+
10
+ `git config --global --unset github.user`
11
+ `git config --global --unset github.token`
12
+
16
13
  GitHub::Config.setup
17
- end
18
-
19
- context "options" do
20
14
 
21
- context "with enabled verbose" do
22
-
23
- it "should print messages" do
24
- GitHub::Config::Options.expects(:"[]").with(:verbose).returns(true)
25
- $stdout.expects(:puts).once
26
- GitHub::Browser.get("/users/show/farnoy")
27
- end
28
-
15
+ end
16
+
17
+ after(:all) do
18
+
19
+ if !@real_github_user.empty?
20
+ `git config --global github.user "#{@real_github_user}"`
21
+ else
22
+ `git config --global --unset github.user`
29
23
  end
30
-
31
- context "with disabled verbose" do
32
-
33
- it "should not print messages" do
34
- GitHub::Config::Options.expects(:"[]").with(:verbose).returns(false)
35
- $stdout.expects(:puts).never
36
- GitHub::Browser.get("/users/show/farnoy")
37
- end
38
-
24
+
25
+ if !@real_github_token.empty?
26
+ `git config --global github.token "#{@real_github_token}"`
27
+ else
28
+ `git config --global --unset github.token`
29
+ end
30
+
31
+ end
32
+
33
+ context "configuration" do
34
+
35
+ it "should create database on first run" do
36
+ File.stubs(:exists?).returns(false)
37
+ ActiveRecord::Migrator.expects(:migrate).with(GitHub::Config::Path[:migrations], nil).once
38
+ GitHub::Config.setup
39
+ end
40
+
41
+ it "should not migrate database every time" do
42
+ File.stubs(:exists?).returns(true)
43
+ ActiveRecord::Migrator.expects(:migrate).never
44
+ GitHub::Config.setup
39
45
  end
40
-
41
- end
42
- end
43
-
44
- context "basics" do
45
-
46
- it "should save objects to database" do
47
- u = GitHub::User.get("farnoy")
48
- u.should == GitHub::User.find(u.id)
49
- end
50
-
51
- end
52
-
53
- context "version" do
54
-
55
- it "should assign properly" do
56
- GitHub::Config::Version.should == File.read('VERSION')
57
- end
58
-
59
- it "should alias CAPITALIZED name for maniacs" do
60
- GitHub::Config::Version.should == GitHub::Config::VERSION
61
- end
62
-
63
- end
46
+
47
+ it "should find git config setting for github user if defined" do
48
+ `git config --global github.user "test"`
49
+ `git config --global github.user`.strip.should == 'test'
50
+ `git config --global --unset github.user`
51
+
52
+
53
+ end
54
+
55
+ it "should find git config setting for github token if defined" do
56
+ `git config --global github.token "token"`
57
+ `git config --global github.token`.strip.should == 'token'
58
+ `git config --global --unset github.token`
59
+ end
60
+
61
+ it "should fall through if no user is defined" do
62
+ `git config --global --unset github.user`
63
+ GitHub::Config.expects(:setup).once
64
+ File.expects(:delete).with(GitHub::Config::Path[:dbfile]).once
65
+ GitHub::Config.reset
66
+ end
67
+
68
+
69
+ context "options" do
70
+
71
+ context "with enabled verbose" do
72
+
73
+ it "should print messages" do
74
+ GitHub::Config::Options.expects(:"[]").with(:verbose).returns(true)
75
+ GitHub::Browser.expects(:base_uri).once.returns("")
76
+ uri = mock("URI")
77
+ URI.expects(:parse).returns uri
78
+ Net::HTTP.expects(:get).with uri
79
+ $stdout.expects(:puts).once
80
+ GitHub::Browser.get("/users/show/farnoy")
81
+ end
82
+
83
+ end
84
+
85
+ context "with disabled verbose" do
86
+
87
+ it "should not print messages" do
88
+ GitHub::Config::Options.expects(:"[]").with(:verbose).returns(false)
89
+ GitHub::Browser.expects(:base_uri).once.returns("")
90
+ uri = mock("URI")
91
+ URI.expects(:parse).returns uri
92
+ Net::HTTP.expects(:get).with uri
93
+ $stdout.expects(:puts).never
94
+ GitHub::Browser.get("/users/show/farnoy")
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+ end
101
+
102
+ context "basics" do
103
+
104
+ it "should save objects to database" do
105
+ u = GitHub::User.get("farnoy")
106
+ u.should == GitHub::User.find(u.id)
107
+ end
108
+
109
+ end
110
+
111
+ context "version" do
112
+
113
+ it "should assign properly" do
114
+ GitHub::Config::Version.should == File.read('VERSION')
115
+ end
116
+
117
+ it "should alias CAPITALIZED name for maniacs" do
118
+ GitHub::Config::Version.should == GitHub::Config::VERSION
119
+ end
120
+
121
+ end
64
122
  end
metadata CHANGED
@@ -1,137 +1,158 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: github-api-client
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
4
5
  prerelease:
5
- version: 0.3.0
6
6
  platform: ruby
7
- authors:
8
- - "Jakub Oko\xC5\x84ski"
7
+ authors:
8
+ - Jakub Okoński
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-07 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rainbow
16
+ requirement: &26761220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.3
22
+ type: :runtime
17
23
  prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: *26761220
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &26780540 !ruby/object:Gem::Requirement
19
28
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
24
33
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: activerecord
28
34
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: *26780540
36
+ - !ruby/object:Gem::Dependency
37
+ name: activerecord
38
+ requirement: &26780060 !ruby/object:Gem::Requirement
30
39
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 3.0.3
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 3.1.0
35
44
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
45
+ prerelease: false
46
+ version_requirements: *26780060
47
+ - !ruby/object:Gem::Dependency
38
48
  name: activesupport
49
+ requirement: &26779580 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ type: :runtime
39
56
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
57
+ version_requirements: *26779580
58
+ - !ruby/object:Gem::Dependency
59
+ name: sqlite3
60
+ requirement: &26779100 !ruby/object:Gem::Requirement
41
61
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 3.0.3
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.5
46
66
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: sqlite3-ruby
50
67
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
68
+ version_requirements: *26779100
69
+ - !ruby/object:Gem::Dependency
70
+ name: OptionParser
71
+ requirement: &26778620 !ruby/object:Gem::Requirement
52
72
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.5.1
57
77
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: rspec
61
78
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ version_requirements: *26778620
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &26778140 !ruby/object:Gem::Requirement
63
83
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 2.3.0
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 2.7.0
68
88
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: mocha
72
89
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
90
+ version_requirements: *26778140
91
+ - !ruby/object:Gem::Dependency
92
+ name: mocha
93
+ requirement: &26777660 !ruby/object:Gem::Requirement
74
94
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 0.10.0
79
99
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: yard
83
100
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
101
+ version_requirements: *26777660
102
+ - !ruby/object:Gem::Dependency
103
+ name: yard
104
+ requirement: &26777180 !ruby/object:Gem::Requirement
85
105
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
89
109
  version: 0.6.0
90
110
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: cucumber
94
111
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
112
+ version_requirements: *26777180
113
+ - !ruby/object:Gem::Dependency
114
+ name: cucumber
115
+ requirement: &26776700 !ruby/object:Gem::Requirement
96
116
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 1.1.4
101
121
  type: :development
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
- name: jeweler
105
122
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
123
+ version_requirements: *26776700
124
+ - !ruby/object:Gem::Dependency
125
+ name: jeweler
126
+ requirement: &26776220 !ruby/object:Gem::Requirement
107
127
  none: false
108
- requirements:
109
- - - ~>
110
- - !ruby/object:Gem::Version
111
- version: 1.5.2
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.6.4
112
132
  type: :development
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
- name: rcov
116
133
  prerelease: false
117
- requirement: &id010 !ruby/object:Gem::Requirement
134
+ version_requirements: *26776220
135
+ - !ruby/object:Gem::Dependency
136
+ name: rcov
137
+ requirement: &26775740 !ruby/object:Gem::Requirement
118
138
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: 0.9.11
123
143
  type: :development
124
- version_requirements: *id010
125
- description: Caches retrieved information to your user profile and reuses it when you query again.
144
+ prerelease: false
145
+ version_requirements: *26775740
146
+ description: Caches retrieved information to your user profile and reuses it when
147
+ you query again.
126
148
  email: kuba@okonski.org
127
- executables:
149
+ executables:
128
150
  - api-browser.rb
129
151
  extensions: []
130
-
131
- extra_rdoc_files:
152
+ extra_rdoc_files:
132
153
  - LICENSE.txt
133
- - README.rdoc
134
- files:
154
+ - README.md
155
+ files:
135
156
  - Gemfile
136
157
  - Gemfile.lock
137
158
  - VERSION
@@ -150,43 +171,42 @@ files:
150
171
  - lib/github-api-client/repo.rb
151
172
  - lib/github-api-client/user.rb
152
173
  - LICENSE.txt
153
- - README.rdoc
154
- - features/fetching.feature
155
- - features/step_definitions/fetching_steps.rb
174
+ - README.md
156
175
  - features/support/env.rb
157
- - spec/github-api-client_spec.rb
176
+ - features/step_definitions/fetching_steps.rb
177
+ - features/fetching.feature
158
178
  - spec/spec_helper.rb
179
+ - spec/github-api-client_spec.rb
159
180
  - bin/api-browser.rb
160
181
  homepage: http://github.com/okonski/github-api-client
161
- licenses:
182
+ licenses:
162
183
  - MIT
163
184
  post_install_message:
164
185
  rdoc_options: []
165
-
166
- require_paths:
186
+ require_paths:
167
187
  - lib
168
- required_ruby_version: !ruby/object:Gem::Requirement
188
+ required_ruby_version: !ruby/object:Gem::Requirement
169
189
  none: false
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: "0"
174
- required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
195
  none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- version: "0"
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
180
200
  requirements: []
181
-
182
201
  rubyforge_project:
183
- rubygems_version: 1.8.1
202
+ rubygems_version: 1.8.12
184
203
  signing_key:
185
204
  specification_version: 3
186
205
  summary: Library for easy GitHub API browsing
187
- test_files:
188
- - features/fetching.feature
189
- - features/step_definitions/fetching_steps.rb
206
+ test_files:
190
207
  - features/support/env.rb
191
- - spec/github-api-client_spec.rb
208
+ - features/step_definitions/fetching_steps.rb
209
+ - features/fetching.feature
192
210
  - spec/spec_helper.rb
211
+ - spec/github-api-client_spec.rb
212
+ has_rdoc:
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = github-api-client
2
-
3
- Description goes here.
4
-
5
- == Contributing to github-api-client
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Jakub Okoński. See LICENSE.txt for
18
- further details.
19
-