github-api-client 0.1.3.2 → 0.2.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rainbow"
4
+ gem "activerecord", ">= 3.0.3"
5
+ gem "activesupport", ">= 3.0.3"
6
+ gem "sqlite3-ruby"
7
+
8
+ group :development do
9
+ gem "github-api-client", :path => "./"
10
+ gem "rspec", ">= 2.3.0"
11
+ gem "mocha"
12
+ gem "yard", ">= 0.6.0"
13
+ gem "cucumber"
14
+ gem "bundler", ">= 1.0.0"
15
+ gem "jeweler", ">= 1.5.2"
16
+ gem "rcov"
17
+ end
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: ./
3
+ specs:
4
+ github-api-client (0.2.1)
5
+ activerecord (>= 3.0.3)
6
+ activerecord (>= 3.0.3)
7
+ activesupport (>= 3.0.3)
8
+ rainbow
9
+ rainbow (>= 1.1)
10
+ sqlite3-ruby
11
+ sqlite3-ruby (>= 1.3.2)
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ activemodel (3.0.3)
17
+ activesupport (= 3.0.3)
18
+ builder (~> 2.1.2)
19
+ i18n (~> 0.4)
20
+ activerecord (3.0.3)
21
+ activemodel (= 3.0.3)
22
+ activesupport (= 3.0.3)
23
+ arel (~> 2.0.2)
24
+ tzinfo (~> 0.3.23)
25
+ activesupport (3.0.3)
26
+ arel (2.0.6)
27
+ builder (2.1.2)
28
+ cucumber (0.10.0)
29
+ builder (>= 2.1.2)
30
+ diff-lcs (~> 1.1.2)
31
+ gherkin (~> 2.3.2)
32
+ json (~> 1.4.6)
33
+ term-ansicolor (~> 1.0.5)
34
+ diff-lcs (1.1.2)
35
+ gherkin (2.3.2)
36
+ json (~> 1.4.6)
37
+ term-ansicolor (~> 1.0.5)
38
+ git (1.2.5)
39
+ i18n (0.5.0)
40
+ jeweler (1.5.2)
41
+ bundler (~> 1.0.0)
42
+ git (>= 1.2.5)
43
+ rake
44
+ json (1.4.6)
45
+ mocha (0.9.10)
46
+ rake
47
+ rainbow (1.1)
48
+ rake (0.8.7)
49
+ rcov (0.9.9)
50
+ rspec (2.3.0)
51
+ rspec-core (~> 2.3.0)
52
+ rspec-expectations (~> 2.3.0)
53
+ rspec-mocks (~> 2.3.0)
54
+ rspec-core (2.3.1)
55
+ rspec-expectations (2.3.0)
56
+ diff-lcs (~> 1.1.2)
57
+ rspec-mocks (2.3.0)
58
+ sqlite3-ruby (1.3.2)
59
+ term-ansicolor (1.0.5)
60
+ tzinfo (0.3.23)
61
+ yard (0.6.4)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ activerecord (>= 3.0.3)
68
+ activesupport (>= 3.0.3)
69
+ bundler (>= 1.0.0)
70
+ cucumber
71
+ github-api-client!
72
+ jeweler (>= 1.5.2)
73
+ mocha
74
+ rainbow
75
+ rcov
76
+ rspec (>= 2.3.0)
77
+ sqlite3-ruby
78
+ yard (>= 0.6.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jakub Okoński
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.
@@ -0,0 +1,19 @@
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
+
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "github-api-client"
18
+ gem.homepage = "http://github.com/farnoy/github-api-client"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Library for easy GitHub API browsing}
21
+ gem.description = %Q{Caches retrieved information to your user profile and reuses it when you query again.}
22
+ gem.email = "kuba@okonski.org"
23
+ gem.authors = ["Jakub Okoński"]
24
+ gem.add_runtime_dependency('rainbow', '>=1.1')
25
+ gem.add_runtime_dependency('activerecord', '>=3.0.3')
26
+ gem.add_runtime_dependency('sqlite3-ruby', '>=1.3.2')
27
+
28
+ gem.add_development_dependency 'yard', '>= 0.6.0'
29
+ gem.add_development_dependency 'rspec', '>= 2.3.0'
30
+ gem.add_development_dependency 'cucumber'
31
+ gem.add_development_dependency 'bundler', '>= 1.0.0'
32
+ gem.add_development_dependency 'jeweler', '>= 1.5.2'
33
+ end
34
+ Jeweler::RubygemsDotOrgTasks.new
35
+
36
+ require 'rspec/core'
37
+ require 'rspec/core/rake_task'
38
+ RSpec::Core::RakeTask.new(:spec) do |spec|
39
+ spec.pattern = FileList['spec/**/*_spec.rb']
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
43
+ spec.pattern = 'spec/**/*_spec.rb'
44
+ spec.rcov = true
45
+ end
46
+
47
+ require 'cucumber/rake/task'
48
+ Cucumber::Rake::Task.new(:features)
49
+
50
+ task :default => :spec
51
+
52
+ require 'yard'
53
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1.2
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift('./lib/')
3
+
4
+ require 'github-api-client'
5
+
6
+ GitHub::Config::Options[:verbose] = true if ARGV.include? '--verbose'
7
+
8
+ unless ARGV.include? 'test'
9
+ # Dev temporary code here
10
+ #GitHub::Repo.get('parndt/hub').parent.fetch(:self, :watchers).watchers
11
+ GitHub::User.get('schacon').fetch(:self, :followers, :followings)
12
+ else # launches all-features code
13
+ # Performance tests
14
+ GitHub::Repo.get('mojombo/jekyll').fetch(:self, :watchers)
15
+ GitHub::Repo.get('schacon/kidgloves').fetch(:watchers).watchers.each
16
+ GitHub::Repo.get('parndt/hub').parent.fetch(:self, :watchers).watchers
17
+ GitHub::User.get('kneath').fetch(:followers, :followings)
18
+ GitHub::User.get('defunkt').fetch(:followers, :followings)
19
+ GitHub::User.get('schacon').fetch(:followers, :followings)
20
+ end
@@ -0,0 +1,13 @@
1
+ Feature: Fetching Objects
2
+ In order to fetch objects from GitHub
3
+ I just need to fire up few commands
4
+
5
+ Scenario: Fetching user information
6
+ Given I fetch user "schacon"
7
+ Then My local database should contain that record
8
+ And That record's "name" should be "Scott Chacon"
9
+
10
+ Scenario: Fetching repo information
11
+ Given I fetch repo "mojombo/jekyll"
12
+ Then My local database should contain that record
13
+ And That record's "login" of the "owner" should be "mojombo"
@@ -0,0 +1,29 @@
1
+ Before do
2
+ %w(Repo User).each do |attr|
3
+ GitHub.const_get(attr).delete_all
4
+ end
5
+ end
6
+
7
+ Given /^I fetch user "(.*)"$/ do |login|
8
+ @record = GitHub::User.get(login)
9
+ end
10
+
11
+ Given /^I fetch repo "(.*)"$/ do |permalink|
12
+ @record = GitHub::Repo.get(permalink)
13
+ end
14
+
15
+ Then /^My local database should contain that record$/ do
16
+ @record.class.find(@record.id).should == @record
17
+ end
18
+
19
+ Then /^That record's "([^"]*)" should be "([^"]*)"$/ do |sig, prop|
20
+ @record.send(sig.to_sym).should == prop
21
+ end
22
+
23
+ Then /^That record's "([^"]*)" of the "([^"]*)" should be "([^"]*)"$/ do |sig, type, prop|
24
+ @record.send(type.to_sym).send(sig.to_sym).should == prop
25
+ end
26
+
27
+ Given /^I set verbose option to "(.*)"$/ do |bool|
28
+ GitHub::Config::Options[:verbose] = bool
29
+ end
@@ -0,0 +1,31 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
11
+ require 'github-api-client'
12
+
13
+ require 'rspec/expectations'
14
+ require 'stringio'
15
+ require "mocha"
16
+
17
+ # Mocha integration into Cucumber
18
+ # source: https://gist.github.com/80554
19
+ World(Mocha::API)
20
+
21
+ Before do
22
+ mocha_setup
23
+ end
24
+
25
+ After do
26
+ begin
27
+ mocha_verify
28
+ ensure
29
+ mocha_teardown
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "github-api-client"
3
+ s.version = '0.1.3.2'
4
+ s.summary = 'Library for easy GitHub API browsing'
5
+ s.description = s.summary
6
+ s.author = 'Jakub Okoński'
7
+ s.email = 'kuba@okonski.org'
8
+ s.homepage = 'http://github.com/farnoy/github-api-client'
9
+
10
+ s.files = Dir['lib/github_api.rb', 'lib/github_api/*', 'db/*/**', 'lib/core_ext/*']
11
+ s.require_path = 'lib'
12
+ s.has_rdoc = false
13
+
14
+ s.add_dependency('rainbow', '>=1.1')
15
+ s.add_dependency('activerecord', '>=3.0.3')
16
+ s.add_dependency('sqlite3-ruby', '>=1.3.2')
17
+ end
@@ -0,0 +1,127 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{github-api-client}
8
+ s.version = "0.2.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jakub Okoński"]
12
+ s.date = %q{2010-12-22}
13
+ s.description = %q{Caches retrieved information to your user profile and reuses it when you query again.}
14
+ s.email = %q{kuba@okonski.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".rspec",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "api-browser.rb",
28
+ "db/migrate/001_create_users.rb",
29
+ "db/migrate/002_create_user_followings.rb",
30
+ "db/migrate/003_create_repos.rb",
31
+ "db/migrate/004_create_repo_watchings.rb",
32
+ "features/github-api-client.feature",
33
+ "features/step_definitions/github-api-client_steps.rb",
34
+ "features/support/env.rb",
35
+ "gemspec.old.orig",
36
+ "github-api-client.gemspec",
37
+ "lib/core_ext/habtm.rb",
38
+ "lib/github-api-client.rb",
39
+ "lib/github-api-client/base.rb",
40
+ "lib/github-api-client/browser.rb",
41
+ "lib/github-api-client/config.rb",
42
+ "lib/github-api-client/repo.rb",
43
+ "lib/github-api-client/user.rb",
44
+ "spec/github-api-client_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+ s.homepage = %q{http://github.com/farnoy/github-api-client}
48
+ s.licenses = ["MIT"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.7}
51
+ s.summary = %q{Library for easy GitHub API browsing}
52
+ s.test_files = [
53
+ "spec/github-api-client_spec.rb",
54
+ "spec/spec_helper.rb"
55
+ ]
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<rainbow>, [">= 0"])
63
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0.3"])
64
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.3"])
65
+ s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 0"])
66
+ s.add_development_dependency(%q<github-api-client>, [">= 0"])
67
+ s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
68
+ s.add_development_dependency(%q<mocha>, [">= 0"])
69
+ s.add_development_dependency(%q<yard>, [">= 0.6.0"])
70
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
71
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
72
+ s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
73
+ s.add_development_dependency(%q<rcov>, [">= 0"])
74
+ s.add_runtime_dependency(%q<rainbow>, [">= 1.1"])
75
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0.3"])
76
+ s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 1.3.2"])
77
+ s.add_development_dependency(%q<yard>, [">= 0.6.0"])
78
+ s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
79
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
80
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
81
+ s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
82
+ else
83
+ s.add_dependency(%q<rainbow>, [">= 0"])
84
+ s.add_dependency(%q<activerecord>, [">= 3.0.3"])
85
+ s.add_dependency(%q<activesupport>, [">= 3.0.3"])
86
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
87
+ s.add_dependency(%q<github-api-client>, [">= 0"])
88
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
89
+ s.add_dependency(%q<mocha>, [">= 0"])
90
+ s.add_dependency(%q<yard>, [">= 0.6.0"])
91
+ s.add_dependency(%q<cucumber>, [">= 0"])
92
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
93
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
94
+ s.add_dependency(%q<rcov>, [">= 0"])
95
+ s.add_dependency(%q<rainbow>, [">= 1.1"])
96
+ s.add_dependency(%q<activerecord>, [">= 3.0.3"])
97
+ s.add_dependency(%q<sqlite3-ruby>, [">= 1.3.2"])
98
+ s.add_dependency(%q<yard>, [">= 0.6.0"])
99
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
100
+ s.add_dependency(%q<cucumber>, [">= 0"])
101
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
102
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
103
+ end
104
+ else
105
+ s.add_dependency(%q<rainbow>, [">= 0"])
106
+ s.add_dependency(%q<activerecord>, [">= 3.0.3"])
107
+ s.add_dependency(%q<activesupport>, [">= 3.0.3"])
108
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
109
+ s.add_dependency(%q<github-api-client>, [">= 0"])
110
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
111
+ s.add_dependency(%q<mocha>, [">= 0"])
112
+ s.add_dependency(%q<yard>, [">= 0.6.0"])
113
+ s.add_dependency(%q<cucumber>, [">= 0"])
114
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
115
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
116
+ s.add_dependency(%q<rcov>, [">= 0"])
117
+ s.add_dependency(%q<rainbow>, [">= 1.1"])
118
+ s.add_dependency(%q<activerecord>, [">= 3.0.3"])
119
+ s.add_dependency(%q<sqlite3-ruby>, [">= 1.3.2"])
120
+ s.add_dependency(%q<yard>, [">= 0.6.0"])
121
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
122
+ s.add_dependency(%q<cucumber>, [">= 0"])
123
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
124
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
125
+ end
126
+ end
127
+
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'rubygems'
4
+ require 'bundler/setup'
4
5
  gem 'github-api-client'
5
- $:.unshift File.dirname(__FILE__) if Dir.pwd != Gem.loaded_specs['github-api-client'].full_gem_path # devel trick
6
+
7
+ $:.unshift Gem.loaded_specs['github-api-client'].full_gem_path # devel trick
8
+
6
9
  require 'net/http'
7
10
  require 'uri'
8
11
  require 'yaml'
@@ -10,15 +13,14 @@ require 'singleton'
10
13
  require 'active_record'
11
14
  require 'core_ext/habtm'
12
15
  require 'rainbow'
13
- require 'progressbar'
14
- require 'github_api/config'
16
+ require 'github-api-client/config'
15
17
 
16
18
  GitHub::Config.setup
17
19
 
18
- require 'github_api/base'
19
- require 'github_api/user'
20
- require 'github_api/repo'
21
- require 'github_api/browser'
20
+ require 'github-api-client/base'
21
+ require 'github-api-client/user'
22
+ require 'github-api-client/repo'
23
+ require 'github-api-client/browser'
22
24
 
23
25
  unless $user = GitHub::User.where(GitHub::Config::Secrets).first
24
26
  $user = GitHub::User.create(GitHub::Config::Secrets)
@@ -4,6 +4,13 @@ module GitHub
4
4
  # Constant with defined all the paths used in the application
5
5
  Path = {:dir => ENV['HOME'] + "/.github", :dbfile => ENV['HOME'] + "/.github/github.db", :migrations => Gem.loaded_specs['github-api-client'].full_gem_path + "/db/migrate", :secrets => ENV['HOME'] + "/.github" + "/secrets.yml"}
6
6
 
7
+ if Dir.pwd != Gem.loaded_specs['github-api-client'].full_gem_path
8
+ Version = File.read(Gem.loaded_specs['github-api-client'].full_gem_path + "/VERSION")
9
+ else
10
+ Version = File.read(Dir.pwd + "/VERSION")
11
+ end
12
+ VERSION = Version
13
+
7
14
  # Secrets array, uses env vars if defined
8
15
  Secrets = {"login" => ENV['GITHUB_USER'], "token" => ENV['GITHUB_TOKEN']} if ENV['GITHUB_USER'] && ENV['GITHUB_TOKEN']
9
16
  begin
@@ -30,7 +37,7 @@ You have two ways of defining your user to have authenticated access to your API
30
37
  def self.setup
31
38
  Dir.mkdir GitHub::Config::Path[:dir] rescue nil
32
39
  ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => GitHub::Config::Path[:dbfile]
33
- ActiveRecord::Migrator.migrate(GitHub::Config::Path[:migrations], nil)
40
+ ActiveRecord::Migrator.migrate(GitHub::Config::Path[:migrations], nil) if not File.exists? GitHub::Config::Path[:dbfile]
34
41
  end
35
42
  end
36
43
  end
@@ -35,15 +35,16 @@ module GitHub
35
35
  def get_watchers
36
36
  watchers = YAML::load(GitHub::Browser.get("/repos/show/#{self.permalink}/watchers"))['watchers']
37
37
  puts "Fetching watchers for #{"repo".color(:blue).bright} #{self.permalink.color(:green).bright}"
38
- progress = ProgressBar.new("progress", watchers.count)
38
+ i, count = 0, watchers.count.to_s.color(:green).bright
39
39
  self.transaction do
40
40
  watchers.each do |watcher|
41
+ i += 1
41
42
  attr = {:login => watcher}
42
43
  self.watchers.find_or_create(GitHub::User.find_or_create_by_login(attr))
43
- progress.inc
44
+ print "\r#{i.to_s.color(:blue).bright}/#{count}"
44
45
  end
45
46
  end
46
- progress.finish
47
+ puts nil
47
48
  self
48
49
  end
49
50
 
@@ -74,30 +74,32 @@ module GitHub
74
74
  def get_followers
75
75
  users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users']
76
76
  puts "Fetching followers for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
77
- progress = ProgressBar.new("progress", users.count)
77
+ i, count = 0, users.count.to_s.color(:green).bright
78
78
  self.transaction do
79
79
  users.each do |user|
80
+ i += 1
80
81
  u = GitHub::User.find_or_create_by_login(user)
81
82
  self.followers.find_or_create u
82
- progress.inc
83
+ print "\r#{i.to_s.color(:yellow).bright}/#{count}"
83
84
  end
84
85
  end
85
- progress.finish
86
+ puts nil
86
87
  self
87
88
  end
88
89
 
89
90
  def get_followings
90
91
  users = YAML::load(GitHub::Browser.get "/user/show/#{login}/following")['users']
91
92
  puts "Fetching followings for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
92
- progress = ProgressBar.new("progress", users.count)
93
+ i, count = 0, users.count.to_s.color(:green).bright
93
94
  self.transaction do
94
95
  users.each do |user|
96
+ i += 1
95
97
  u = GitHub::User.find_or_create_by_login(user)
96
98
  self.followings.find_or_create u
97
- progress.inc
99
+ print "\r#{i.to_s.color(:yellow).bright}/#{count}"
98
100
  end
99
101
  end
100
- progress.finish
102
+ puts nil
101
103
  self
102
104
  end
103
105
 
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
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
16
+ GitHub::Config.setup
17
+ end
18
+
19
+ context "options" do
20
+
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
+
29
+ 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
+
39
+ 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
64
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'github-api-client'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rspec
12
+ config.mock_with :mocha
13
+ end
metadata CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 2
7
8
  - 1
8
- - 3
9
9
  - 2
10
- version: 0.1.3.2
10
+ version: 0.2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jakub Oko\xC5\x84ski"
@@ -15,26 +15,24 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-04 00:00:00 +01:00
18
+ date: 2010-12-22 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rainbow
23
- prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
28
  segments:
30
- - 1
31
- - 1
32
- version: "1.1"
29
+ - 0
30
+ version: "0"
33
31
  type: :runtime
32
+ prerelease: false
34
33
  version_requirements: *id001
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: activerecord
37
- prerelease: false
38
36
  requirement: &id002 !ruby/object:Gem::Requirement
39
37
  none: false
40
38
  requirements:
@@ -46,11 +44,180 @@ dependencies:
46
44
  - 3
47
45
  version: 3.0.3
48
46
  type: :runtime
47
+ prerelease: false
49
48
  version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: activesupport
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 3
58
+ - 0
59
+ - 3
60
+ version: 3.0.3
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: *id003
50
64
  - !ruby/object:Gem::Dependency
51
65
  name: sqlite3-ruby
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :runtime
52
75
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: github-api-client
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: rspec
92
+ requirement: &id006 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 2
99
+ - 3
100
+ - 0
101
+ version: 2.3.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: mocha
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ type: :development
116
+ prerelease: false
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: yard
120
+ requirement: &id008 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 0
127
+ - 6
128
+ - 0
129
+ version: 0.6.0
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: *id008
133
+ - !ruby/object:Gem::Dependency
134
+ name: cucumber
135
+ requirement: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *id009
146
+ - !ruby/object:Gem::Dependency
147
+ name: bundler
148
+ requirement: &id010 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ segments:
154
+ - 1
155
+ - 0
156
+ - 0
157
+ version: 1.0.0
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: *id010
161
+ - !ruby/object:Gem::Dependency
162
+ name: jeweler
163
+ requirement: &id011 !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ segments:
169
+ - 1
170
+ - 5
171
+ - 2
172
+ version: 1.5.2
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: *id011
176
+ - !ruby/object:Gem::Dependency
177
+ name: rcov
178
+ requirement: &id012 !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: *id012
189
+ - !ruby/object:Gem::Dependency
190
+ name: rainbow
191
+ requirement: &id013 !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ segments:
197
+ - 1
198
+ - 1
199
+ version: "1.1"
200
+ type: :runtime
201
+ prerelease: false
202
+ version_requirements: *id013
203
+ - !ruby/object:Gem::Dependency
204
+ name: activerecord
205
+ requirement: &id014 !ruby/object:Gem::Requirement
206
+ none: false
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ segments:
211
+ - 3
212
+ - 0
213
+ - 3
214
+ version: 3.0.3
215
+ type: :runtime
216
+ prerelease: false
217
+ version_requirements: *id014
218
+ - !ruby/object:Gem::Dependency
219
+ name: sqlite3-ruby
220
+ requirement: &id015 !ruby/object:Gem::Requirement
54
221
  none: false
55
222
  requirements:
56
223
  - - ">="
@@ -61,31 +228,121 @@ dependencies:
61
228
  - 2
62
229
  version: 1.3.2
63
230
  type: :runtime
64
- version_requirements: *id003
65
- description: Library for easy GitHub API browsing
231
+ prerelease: false
232
+ version_requirements: *id015
233
+ - !ruby/object:Gem::Dependency
234
+ name: yard
235
+ requirement: &id016 !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ segments:
241
+ - 0
242
+ - 6
243
+ - 0
244
+ version: 0.6.0
245
+ type: :development
246
+ prerelease: false
247
+ version_requirements: *id016
248
+ - !ruby/object:Gem::Dependency
249
+ name: rspec
250
+ requirement: &id017 !ruby/object:Gem::Requirement
251
+ none: false
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ segments:
256
+ - 2
257
+ - 3
258
+ - 0
259
+ version: 2.3.0
260
+ type: :development
261
+ prerelease: false
262
+ version_requirements: *id017
263
+ - !ruby/object:Gem::Dependency
264
+ name: cucumber
265
+ requirement: &id018 !ruby/object:Gem::Requirement
266
+ none: false
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ segments:
271
+ - 0
272
+ version: "0"
273
+ type: :development
274
+ prerelease: false
275
+ version_requirements: *id018
276
+ - !ruby/object:Gem::Dependency
277
+ name: bundler
278
+ requirement: &id019 !ruby/object:Gem::Requirement
279
+ none: false
280
+ requirements:
281
+ - - ">="
282
+ - !ruby/object:Gem::Version
283
+ segments:
284
+ - 1
285
+ - 0
286
+ - 0
287
+ version: 1.0.0
288
+ type: :development
289
+ prerelease: false
290
+ version_requirements: *id019
291
+ - !ruby/object:Gem::Dependency
292
+ name: jeweler
293
+ requirement: &id020 !ruby/object:Gem::Requirement
294
+ none: false
295
+ requirements:
296
+ - - ">="
297
+ - !ruby/object:Gem::Version
298
+ segments:
299
+ - 1
300
+ - 5
301
+ - 2
302
+ version: 1.5.2
303
+ type: :development
304
+ prerelease: false
305
+ version_requirements: *id020
306
+ description: Caches retrieved information to your user profile and reuses it when you query again.
66
307
  email: kuba@okonski.org
67
308
  executables: []
68
309
 
69
310
  extensions: []
70
311
 
71
- extra_rdoc_files: []
72
-
312
+ extra_rdoc_files:
313
+ - LICENSE.txt
314
+ - README.rdoc
73
315
  files:
74
- - lib/github_api.rb
75
- - lib/github_api/base.rb
76
- - lib/github_api/repo.rb
77
- - lib/github_api/browser.rb
78
- - lib/github_api/config.rb
79
- - lib/github_api/user.rb
80
- - db/migrate/004_create_repo_watchings.rb
81
- - db/migrate/003_create_repos.rb
82
- - db/migrate/002_create_user_followings.rb
316
+ - .rspec
317
+ - Gemfile
318
+ - Gemfile.lock
319
+ - LICENSE.txt
320
+ - README.rdoc
321
+ - Rakefile
322
+ - VERSION
323
+ - api-browser.rb
83
324
  - db/migrate/001_create_users.rb
325
+ - db/migrate/002_create_user_followings.rb
326
+ - db/migrate/003_create_repos.rb
327
+ - db/migrate/004_create_repo_watchings.rb
328
+ - features/github-api-client.feature
329
+ - features/step_definitions/github-api-client_steps.rb
330
+ - features/support/env.rb
331
+ - gemspec.old.orig
332
+ - github-api-client.gemspec
84
333
  - lib/core_ext/habtm.rb
85
- has_rdoc: false
334
+ - lib/github-api-client.rb
335
+ - lib/github-api-client/base.rb
336
+ - lib/github-api-client/browser.rb
337
+ - lib/github-api-client/config.rb
338
+ - lib/github-api-client/repo.rb
339
+ - lib/github-api-client/user.rb
340
+ - spec/github-api-client_spec.rb
341
+ - spec/spec_helper.rb
342
+ has_rdoc: true
86
343
  homepage: http://github.com/farnoy/github-api-client
87
- licenses: []
88
-
344
+ licenses:
345
+ - MIT
89
346
  post_install_message:
90
347
  rdoc_options: []
91
348
 
@@ -96,6 +353,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
353
  requirements:
97
354
  - - ">="
98
355
  - !ruby/object:Gem::Version
356
+ hash: -4447354938044863617
99
357
  segments:
100
358
  - 0
101
359
  version: "0"
@@ -114,5 +372,6 @@ rubygems_version: 1.3.7
114
372
  signing_key:
115
373
  specification_version: 3
116
374
  summary: Library for easy GitHub API browsing
117
- test_files: []
118
-
375
+ test_files:
376
+ - spec/github-api-client_spec.rb
377
+ - spec/spec_helper.rb