gah 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ gah
2
+ ===
3
+
4
+ The **G**ithub **A**PI **H**elper
5
+
6
+ **gah** allows you to access some features that Github didn't made available in the APIs
7
+
8
+ installation
9
+ ------------
10
+
11
+ $: [sudo] gem install gah
12
+
13
+ synopsis
14
+ --------
15
+
16
+ Initialize a new Repo
17
+
18
+ gah = Gah::Repo.new("fyskij/octodigest")
19
+
20
+
21
+ Number of commits in a repo:
22
+
23
+ gah.commits
24
+
25
+ => 67
26
+
27
+ Contributors:
28
+
29
+ gah.contributors
30
+
31
+ =>
32
+ {
33
+ "name": "Gildo Fiorito" .... etc
34
+
35
+
36
+ Number of contributors:
37
+
38
+ gah.contributors.length
39
+
40
+ => 3
41
+
42
+ List of tags:
43
+
44
+ gah.tags
45
+
46
+ => {v1.2.0} => "cfad76700b3d38eb3be97e2d5ef75cc0a398f818"
47
+ etc
48
+
49
+ license
50
+ -------
51
+
52
+ This program is distributed under GPL
53
+
54
+ issues
55
+ ------
56
+
57
+ [Issues](http://github.com/fyskij/gah/issues)
58
+
59
+ author
60
+ ------
61
+ [Ermenegildo "Gildo" Fiorito](http://isagit.com)
@@ -0,0 +1,14 @@
1
+ require 'json'
2
+
3
+ dir = File.dirname(File.expand_path(__FILE__))
4
+ $LOAD_PATH.unshift(File.join('gah'))
5
+ $LOAD_PATH.unshift(dir)
6
+
7
+ require 'gah/helpers'
8
+ require 'gah/repository'
9
+
10
+ module Gah
11
+
12
+ VERSION = "0.0.1"
13
+
14
+ end
@@ -0,0 +1,20 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module Helpers
5
+
6
+ def gapi(api)
7
+ uri = URI.parse("http://github.com/api/v2/json#{api}")
8
+ http = Net::HTTP.new(uri.host, uri.port)
9
+ request = Net::HTTP::Get.new(uri.request_uri)
10
+
11
+ response = http.request(request)
12
+ body = JSON.parse(response.body)
13
+
14
+ if body.has_key? "error"
15
+ raise "#{uri}"
16
+ end
17
+
18
+ return body
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ module Gah
2
+ class Repo
3
+
4
+ include Helpers
5
+
6
+ BASE = "/repos/show/"
7
+
8
+ def initialize(repo)
9
+ @repo = repo
10
+ end
11
+
12
+ def contributors
13
+ gapi (BASE + @repo + "/contributors")
14
+ end
15
+
16
+ def contributions
17
+ count = 0
18
+ contributors["contributors"].each do |c|
19
+ count += c["contributions"]
20
+ end
21
+
22
+ return count
23
+ end
24
+
25
+ def tags
26
+ tags = gapi (BASE + @repo + "/tags")
27
+ end
28
+
29
+ def refs
30
+ end
31
+
32
+ end
33
+ end
File without changes
@@ -0,0 +1,33 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'gah'
4
+
5
+ ##
6
+ # test/spec/mini 5
7
+ # http://gist.github.com/307649
8
+ # chris@ozmm.org
9
+ #
10
+ def context(*args, &block)
11
+ return super unless (name = args.first) && block
12
+ require 'test/unit'
13
+ klass = Class.new Test::Unit::TestCase do
14
+ def self.test(name, &block)
15
+ define_method("test_#{name.to_s.gsub(/\W/,'_')}", &block) if block
16
+ end
17
+ def self.xtest(*args) end
18
+ def self.context(*args, &block) instance_eval(&block) end
19
+ def self.setup(&block)
20
+ define_method(:setup) { self.class.setups.each { |s| instance_eval(&s) } }
21
+ setups << block
22
+ end
23
+ def self.setups; @setups ||= [] end
24
+ def self.teardown(&block) define_method(:teardown, &block) end
25
+ end
26
+ (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
27
+ klass.class_eval &block
28
+ end
29
+
30
+ def fixture(name)
31
+ @fixtures ||= {}
32
+ @fixtures[name] ||= JSON.parse(File.read("test/fixtures/#{name}.json"))
33
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gah
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Ermenegildo Fiorito
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-11 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: gah allows you to access some features that Github didn't made available in the APIs
22
+ email: fyskij@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - README.md
31
+ - lib/gah.rb
32
+ - lib/gah/helpers.rb
33
+ - lib/gah/repository.rb
34
+ - test/helper.rb
35
+ - test/commits.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/fyskij/gah
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.7
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: The Github API Helper
68
+ test_files: []
69
+