hubruby 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,19 +4,21 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- A simple Ruby library for accessing the current GitHub API (v2).
7
+ A simple Ruby library for accessing the current GitHub API (v3).
8
8
 
9
9
  == SYNOPSIS:
10
10
 
11
11
  user = GitHub.user('diogenes')
12
12
  user.repositories
13
+ user.organizations
13
14
  user.following
14
15
  user.followers
15
16
  user.watched
16
17
 
17
18
  repository = GitHub.repository('aslakhellesoy', 'cucumber')
19
+ repository.owner
18
20
  repository.branches
19
- repository.network
21
+ repository.forks
20
22
 
21
23
  == REQUIREMENTS:
22
24
 
@@ -30,7 +32,7 @@ A simple Ruby library for accessing the current GitHub API (v2).
30
32
 
31
33
  (The MIT License)
32
34
 
33
- Copyright (c) 2010 Diógenes Falcão
35
+ Copyright (c) 2011 Diógenes Falcão
34
36
 
35
37
  Permission is hereby granted, free of charge, to any person obtaining
36
38
  a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
- require 'github/finders'
1
+ require 'github/dsl'
2
2
 
3
3
  module GitHub
4
- extend Finders
4
+ extend DSL
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
- module Finders
2
+ module DSL
3
3
  def user(login)
4
4
  j = json("/users/#{login}")
5
5
  User.from_hash(j)
@@ -64,10 +64,15 @@ module GitHub
64
64
  h.map {|u| User.from_hash(u) }
65
65
  end
66
66
 
67
+ def gists(login)
68
+ h = json("/users/#{login}/gists")
69
+ h.map {|g| Gist.from_hash(g) }
70
+ end
71
+
67
72
  private
68
73
 
69
74
  def json(path)
70
75
  HTTParty.get('https://api.github.com' << path).parsed_response
71
76
  end
72
- end # Finders
73
- end # GitHub
77
+ end
78
+ end
@@ -0,0 +1,9 @@
1
+ require 'ostruct'
2
+
3
+ module GitHub
4
+ class BaseModel < OpenStruct
5
+ def self.from_hash(h)
6
+ new(h)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ require 'github/models/base_model'
2
+
3
+ module GitHub
4
+ class Commit < BaseModel
5
+ def initialize(repository = nil, attrs = nil)
6
+ super(attrs)
7
+ self.repository = repository
8
+ end
9
+
10
+ def self.from_hash(h, repository)
11
+ new(repository, h)
12
+ end
13
+
14
+ def self.commits_from_hashes(h, repository)
15
+ h.map { |commit_attrs| from_hash(commit_attrs, repository) }
16
+ end
17
+
18
+ def id
19
+ @table[:id]
20
+ end
21
+
22
+ def committer
23
+ User.from_hash(@table[:committer]) if @table[:committer]
24
+ end
25
+
26
+ def author
27
+ User.from_hash(@table[:author]) if @table[:author]
28
+ end
29
+
30
+ def parents
31
+ @parents ||= @table[:parents].map do |parent_attrs|
32
+ repository.commit(parent_attrs['id'])
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ require 'github/models/base_model'
2
+
3
+ module GitHub
4
+ class Gist < BaseModel
5
+ def owner
6
+ @owner ||= GitHub::User.new(@table[:user])
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ require 'github/models/base_model'
2
+
3
+ module GitHub
4
+ class Organization < BaseModel
5
+ end
6
+ end
@@ -7,7 +7,7 @@ module GitHub
7
7
  end
8
8
 
9
9
  def owner
10
- @owner ||= GitHub::User.new(@table[:owner])
10
+ @owner ||= GitHub::User.new(:login => @table[:owner])
11
11
  end
12
12
 
13
13
  def branches
@@ -5,7 +5,7 @@ require 'rubygems'
5
5
  require 'httparty'
6
6
 
7
7
  module Hubruby
8
- VERSION = '0.1.0'
8
+ VERSION = '0.1.1'
9
9
 
10
10
  def self.require_all
11
11
  Dir[File.join(File.dirname(__FILE__), %W(github ** *.rb))].each do |f|
@@ -40,4 +40,8 @@ describe GitHub do
40
40
  it "should be able to find a commit" do
41
41
  subject.should respond_to(:commit)
42
42
  end
43
+
44
+ it "should be able to find gists of an user" do
45
+ subject.should respond_to(:gists)
46
+ end
43
47
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe GitHub::Commit do
4
+ it "should be instantiable from a hash" do
5
+ subject.class.should respond_to(:from_hash)
6
+ end
7
+
8
+ it "should be instantiable as a collection from a list of hashes" do
9
+ subject.class.should respond_to(:commits_from_hashes)
10
+ end
11
+
12
+ it "should be able to show its commit id" do
13
+ subject.should respond_to(:id)
14
+ end
15
+
16
+ it "should be able to show its commiter" do
17
+ subject.should respond_to(:committer)
18
+ end
19
+
20
+ it "should be able to show its author" do
21
+ subject.should respond_to(:author)
22
+ end
23
+
24
+ it "should be able to show its parents" do
25
+ subject.should respond_to(:parents)
26
+ end
27
+ end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper.rb'
2
3
 
3
4
  describe GitHub::User do
@@ -1,10 +1 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
1
  require 'hubruby'
metadata CHANGED
@@ -1,136 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hubruby
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - "Di\xC3\xB3genes Falc\xC3\xA3o"
7
+ authors:
8
+ - Diógenes Falcão
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-31 00:00:00 -03:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: httparty
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &12517180 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - "="
28
- - !ruby/object:Gem::Version
29
- hash: 5
30
- segments:
31
- - 0
32
- - 6
33
- - 1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.6.1
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rubyforge
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 2
48
- - 0
49
- - 4
50
- version: 2.0.4
51
- type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: hoe
55
23
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 19
62
- segments:
63
- - 2
64
- - 6
65
- - 2
66
- version: 2.6.2
67
- type: :development
68
- version_requirements: *id003
69
- description: A simple Ruby library for accessing the current GitHub API (v2).
70
- email:
71
- - diogenes {d-o-t} araujo {at} gmail.com
24
+ version_requirements: *12517180
25
+ description:
26
+ email: diogenes.araujo@gmail.com
72
27
  executables: []
73
-
74
28
  extensions: []
75
-
76
- extra_rdoc_files:
77
- - History.txt
78
- - Manifest.txt
79
- files:
80
- - History.txt
81
- - Manifest.txt
29
+ extra_rdoc_files:
82
30
  - README.rdoc
83
- - Rakefile
84
- - TODO
85
- - hubruby.gemspec
31
+ files:
32
+ - lib/hubruby.rb
86
33
  - lib/github/base.rb
87
- - lib/github/finders.rb
88
- - lib/github/models/repository.rb
34
+ - lib/github/models/commit.rb
35
+ - lib/github/models/base_model.rb
36
+ - lib/github/models/organization.rb
89
37
  - lib/github/models/user.rb
90
- - lib/hubruby.rb
91
- - script/console
92
- - script/destroy
93
- - script/generate
38
+ - lib/github/models/repository.rb
39
+ - lib/github/models/gist.rb
40
+ - lib/github/dsl.rb
41
+ - spec/spec_helper.rb
42
+ - spec/spec.opts
94
43
  - spec/github/github_spec.rb
95
44
  - spec/github/models/repository_spec.rb
96
45
  - spec/github/models/user_spec.rb
97
- - spec/spec.opts
98
- - spec/spec_helper.rb
99
- - tasks/rspec.rake
100
- has_rdoc: true
101
- homepage: http://github.com/diogenes/hubruby
46
+ - spec/github/models/commit_spec.rb
47
+ - README.rdoc
48
+ homepage:
102
49
  licenses: []
103
-
104
50
  post_install_message:
105
- rdoc_options:
106
- - --main
107
- - README.rdoc
108
- require_paths:
51
+ rdoc_options: []
52
+ require_paths:
109
53
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
54
+ required_ruby_version: !ruby/object:Gem::Requirement
111
55
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
61
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
128
66
  requirements: []
129
-
130
- rubyforge_project: hubruby
131
- rubygems_version: 1.3.7
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.6
132
69
  signing_key:
133
70
  specification_version: 3
134
- summary: A simple Ruby library to access the current GitHub API (v3)
71
+ summary: A simple Ruby library for accessing the current GitHub API (v3)
135
72
  test_files: []
136
-
@@ -1,11 +0,0 @@
1
- === 0.0.3 2010-08-30
2
-
3
- * Initial releases
4
-
5
- === 0.0.4 2010-09-03
6
-
7
- * Refactorings and Specifications
8
-
9
- === 0.1.0 2011-07-31
10
-
11
- * Initial support to the GitHub API v3
@@ -1,20 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.rdoc
4
- Rakefile
5
- TODO
6
- hubruby.gemspec
7
- lib/github/base.rb
8
- lib/github/finders.rb
9
- lib/github/models/repository.rb
10
- lib/github/models/user.rb
11
- lib/hubruby.rb
12
- script/console
13
- script/destroy
14
- script/generate
15
- spec/github/github_spec.rb
16
- spec/github/models/repository_spec.rb
17
- spec/github/models/user_spec.rb
18
- spec/spec.opts
19
- spec/spec_helper.rb
20
- tasks/rspec.rake
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/hubruby'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'hubruby' do
14
- self.summary = 'A simple Ruby library to access the current GitHub API (v3)'
15
- self.developer 'Diógenes Falcão', 'diogenes {d-o-t} araujo {at} gmail.com'
16
- self.rubyforge_name = self.name
17
- self.extra_deps = [['httparty','= 0.6.1']]
18
- self.version = '0.1.0'
19
- end
20
-
21
- require 'newgem/tasks'
22
- Dir['tasks/**/*.rake'].each { |t| load t }
23
-
24
- # remove_task :default
25
- task :default => [:spec]
data/TODO DELETED
File without changes
@@ -1,39 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{hubruby}
5
- s.version = "0.1.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Di\303\263genes Falc\303\243o"]
9
- s.date = %q{2011-07-31}
10
- s.description = %q{A simple Ruby library for accessing the current GitHub API (v2).}
11
- s.email = ["diogenes {d-o-t} araujo {at} gmail.com"]
12
- s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
13
- s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "hubruby.gemspec", "lib/github/base.rb", "lib/github/finders.rb", "lib/github/models/repository.rb", "lib/github/models/user.rb", "lib/hubruby.rb", "script/console", "script/destroy", "script/generate", "spec/github/github_spec.rb", "spec/github/models/repository_spec.rb", "spec/github/models/user_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
14
- s.homepage = %q{http://github.com/diogenes/hubruby}
15
- s.rdoc_options = ["--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{hubruby}
18
- s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{A simple Ruby library for accessing the current GitHub API (v2).}
20
-
21
- if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 3
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<httparty>, ["= 0.6.1"])
27
- s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
28
- s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
29
- else
30
- s.add_dependency(%q<httparty>, ["= 0.6.1"])
31
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
32
- s.add_dependency(%q<hoe>, [">= 2.6.2"])
33
- end
34
- else
35
- s.add_dependency(%q<httparty>, ["= 0.6.1"])
36
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
37
- s.add_dependency(%q<hoe>, [">= 2.6.2"])
38
- end
39
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/hubruby.rb'}"
9
- puts "Loading hubruby gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,21 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run the specs under spec/models"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/**/*_spec.rb']
21
- end