hubruby 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-08-30
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,14 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ TODO
6
+ lib/github/base.rb
7
+ lib/github/finders.rb
8
+ lib/github/models/repository.rb
9
+ lib/github/models/user.rb
10
+ lib/hubruby.rb
11
+ script/console
12
+ script/destroy
13
+ script/generate
14
+
data/README.rdoc ADDED
@@ -0,0 +1,44 @@
1
+ = hubruby
2
+
3
+ * http://github.com/diogenes/hubruby
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == SYNOPSIS:
10
+
11
+ FIX (code sample of usage)
12
+
13
+ == REQUIREMENTS:
14
+
15
+ * FIX (list of requirements)
16
+
17
+ == INSTALL:
18
+
19
+ * FIX (sudo gem install, anything else)
20
+
21
+ == LICENSE:
22
+
23
+ (The MIT License)
24
+
25
+ Copyright (c) 2010 Diógenes Falcão
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining
28
+ a copy of this software and associated documentation files (the
29
+ 'Software'), to deal in the Software without restriction, including
30
+ without limitation the rights to use, copy, modify, merge, publish,
31
+ distribute, sublicense, and/or sell copies of the Software, and to
32
+ permit persons to whom the Software is furnished to do so, subject to
33
+ the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be
36
+ included in all copies or substantial portions of the Software.
37
+
38
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
39
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
41
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
42
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
43
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
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.developer 'Diógenes Falcão', 'diogenes {d-o-t} araujo {at} gmail.com'
15
+ self.rubyforge_name = self.name
16
+ self.extra_deps = [['httparty','= 0.6.1']]
17
+ self.version = '0.0.2'
18
+ end
19
+
20
+ require 'newgem/tasks'
21
+ Dir['tasks/**/*.rake'].each { |t| load t }
22
+
23
+ # remove_task :default
24
+ task :default => [:spec]
data/TODO ADDED
@@ -0,0 +1,8 @@
1
+ TODO
2
+
3
+ Support to following URLs:
4
+ * /user/search/ <-- Search users by query
5
+ * /repos/show/#{username}/#{repo}/languages
6
+ * /repos/show/#{username}/#{repo}/contributors
7
+ * /repos/show/#{username}/#{repo}/collaborators
8
+ * /repos/search/#{escaped query}
@@ -0,0 +1,5 @@
1
+ require 'github/finders'
2
+
3
+ module GitHub
4
+ extend Finders
5
+ end
@@ -0,0 +1,49 @@
1
+ module GitHub
2
+ module Finders
3
+ def user(username)
4
+ j = json("/user/show/#{username}", :user)
5
+ User.from_json(j)
6
+ end
7
+
8
+ def following(username)
9
+ j = json("/user/show/#{username}/following", :users)
10
+ User.users_from_json(j)
11
+ end
12
+
13
+ def followers(username)
14
+ j = json("/user/show/#{username}/followers", :users)
15
+ User.users_from_json(j)
16
+ end
17
+
18
+ def repositories(username)
19
+ j = json("/repos/show/#{username}", :repositories)
20
+ Repository.repositories_from_json(j)
21
+ end
22
+
23
+ def watched(username)
24
+ j = json("/repos/watched/#{username}", :repositories)
25
+ Repository.repositories_from_json(j)
26
+ end
27
+
28
+ def repository(username, repository_name)
29
+ j = json("/repos/show/#{username}/#{repository_name}", :repository)
30
+ Repository.from_json(j)
31
+ end
32
+
33
+ def branches(username, repository_name)
34
+ json("/repos/show/#{username}/#{repository_name}/branches", :branches)
35
+ end
36
+
37
+ def network(username, repository_name)
38
+ j = json("/repos/show/#{username}/#{repository_name}/network", :network)
39
+ Repository.repositories_from_json(j)
40
+ end
41
+
42
+ private
43
+
44
+ def json(path, resource)
45
+ response = HTTParty.get('https://github.com/api/v2/json' << path).parsed_response
46
+ response[resource.to_s]
47
+ end
48
+ end # Finders
49
+ end # GitHub
@@ -0,0 +1,23 @@
1
+ require 'ostruct'
2
+
3
+ module GitHub
4
+ class Repository < OpenStruct
5
+ def self.from_json(json)
6
+ new(json)
7
+ end
8
+
9
+ def self.repositories_from_json(json)
10
+ json.inject([]) do |repositories, repository_json|
11
+ repositories << from_json(repository_json)
12
+ end
13
+ end
14
+
15
+ def branches
16
+ @branches ||= GitHub.branches(self.owner, self.name)
17
+ end
18
+
19
+ def network
20
+ @network ||= GitHub.network(self.owner, self.name)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ require 'ostruct'
2
+
3
+ module GitHub
4
+ class User < OpenStruct
5
+ def self.from_json(json)
6
+ new(json)
7
+ end
8
+
9
+ def self.users_from_json(json)
10
+ json.inject([]) do |users, username|
11
+ users << from_json(:username => username)
12
+ end
13
+ end
14
+
15
+ def following
16
+ @following ||= GitHub.following(self.username)
17
+ end
18
+
19
+ def followers
20
+ @followers ||= GitHub.followers(self.username)
21
+ end
22
+
23
+ def repositories
24
+ @repositories ||= GitHub.repositories(self.username)
25
+ end
26
+
27
+ def watched
28
+ @watched ||= GitHub.watched(self.username)
29
+ end
30
+ end
31
+ end
data/lib/hubruby.rb ADDED
@@ -0,0 +1,21 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubygems'
5
+ require 'httparty'
6
+
7
+ module Hubruby
8
+ VERSION = '0.0.1'
9
+
10
+ def self.require_all
11
+ Dir[File.join(File.dirname(__FILE__), %W(github ** *.rb))].each do |f|
12
+ require f
13
+ end
14
+ end
15
+
16
+ def self.init
17
+ require_all
18
+ end
19
+ end
20
+
21
+ Hubruby.init
data/script/console ADDED
@@ -0,0 +1,10 @@
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"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
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)
data/script/generate ADDED
@@ -0,0 +1,14 @@
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)
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hubruby
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - "Di\xC3\xB3genes Falc\xC3\xA3o"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-30 00:00:00 -03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httparty
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 6
30
+ - 1
31
+ version: 0.6.1
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rubyforge
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 0
44
+ - 4
45
+ version: 2.0.4
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: hoe
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 2
57
+ - 6
58
+ - 1
59
+ version: 2.6.1
60
+ type: :development
61
+ version_requirements: *id003
62
+ description: A simple Ruby library for accessing the current GitHub API (v2)
63
+ email:
64
+ - diogenes {d-o-t} araujo {at} gmail.com
65
+ executables: []
66
+
67
+ extensions: []
68
+
69
+ extra_rdoc_files:
70
+ - History.txt
71
+ - Manifest.txt
72
+ files:
73
+ - History.txt
74
+ - Manifest.txt
75
+ - README.rdoc
76
+ - Rakefile
77
+ - TODO
78
+ - lib/github/base.rb
79
+ - lib/github/finders.rb
80
+ - lib/github/models/repository.rb
81
+ - lib/github/models/user.rb
82
+ - lib/hubruby.rb
83
+ - script/console
84
+ - script/destroy
85
+ - script/generate
86
+ has_rdoc: true
87
+ homepage: http://github.com/diogenes/hubruby
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --main
93
+ - README.rdoc
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project: hubruby
113
+ rubygems_version: 1.3.6
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: A simple Ruby library for accessing the current GitHub API (v2)
117
+ test_files: []
118
+