github_metadata 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ script: "bundle exec rspec ."
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ notifications:
7
+ email:
8
+ on_success: always
9
+ on_failure: always
@@ -1,4 +1,5 @@
1
1
  = Github Metadata
2
+ {<img src="http://travis-ci.org/colszowka/github_metadata.png" />}[http://travis-ci.org/colszowka/github_metadata]
2
3
 
3
4
  The Github repository API does not include all the information available on the
4
5
  web view of a repo. It also has some trouble reporting correctly the availability of
@@ -6,18 +7,15 @@ a wiki and issues.
6
7
 
7
8
  The github_metadata gem is here to solve this. Currently it gives you, for any github repo:
8
9
 
9
- * The availability and (if present) the count of wiki pages
10
- * The availability and (if present) the count of issues
11
- * The count of pull requests
12
- * The list of contributors, with username and real name if available, and thereby also
13
- the count of contributors
14
- * The default branch
15
- * The most recent commits
16
- * The average date for recent commits (to analyze project activity - hat tip to Ryan Bates for the
17
- idea!)
18
-
19
- By the way: It goes very easy on the github servers in doing so, currently only performing 1 request
20
- to fetch all of the information per instance.
10
+ * The availability and (if present) the count of wiki pages
11
+ * The availability and (if present) the count of issues
12
+ * The count of pull requests
13
+ * The list of contributors, with username and real name if available, and thereby also
14
+ the count of contributors
15
+ * The default branch
16
+ * The most recent commits
17
+ * The average date for recent commits (to analyze project activity - hat tip to Ryan Bates for the
18
+ idea!)
21
19
 
22
20
  == Usage
23
21
 
@@ -43,7 +41,7 @@ Check out the full documentation to see all available methods.
43
41
 
44
42
  == Compatible rubies
45
43
 
46
- Tested on MRI 1.8.7, 1.9.1, 1.9.2, and REE
44
+ Tested on MRI 1.8.7, 1.9.2, 1.9.3
47
45
 
48
46
  == Note on Patches/Pull Requests
49
47
 
@@ -66,6 +66,10 @@ class GithubMetadata
66
66
  File.join(github_url, 'contributors')
67
67
  end
68
68
 
69
+ def branches_url
70
+ File.join(github_url, 'branches')
71
+ end
72
+
69
73
  def commits_feed_url
70
74
  File.join(github_url, "commits/#{default_branch}.atom")
71
75
  end
@@ -101,7 +105,7 @@ class GithubMetadata
101
105
 
102
106
  # Returns the amount of wiki pages or nil when no wiki is present
103
107
  def wiki_pages
104
- wiki_link = document.at_css('a[highlight="repo_wiki"]')
108
+ wiki_link = document.at_css('a[highlight="repo_wiki"] .counter')
105
109
  return nil unless wiki_link
106
110
  wiki_link.text[/\d+/].to_i
107
111
  end
@@ -113,21 +117,23 @@ class GithubMetadata
113
117
 
114
118
  # Returns issue count or nil if issues are disabled
115
119
  def issues
116
- issue_link = document.at_css('a[highlight="issues"]')
120
+ issue_link = document.at_css('a[highlight="issues"] .counter')
117
121
  return nil unless issue_link
118
122
  issue_link.text[/\d+/].to_i
119
123
  end
120
124
 
121
125
  # Returns amount of pull requests
122
126
  def pull_requests
123
- pull_request_link = document.at_css('a[highlight="repo_pulls"]')
127
+ pull_request_link = document.at_css('a[highlight="repo_pulls"] .counter')
124
128
  return nil unless pull_request_link
125
129
  pull_request_link.text[/\d+/].to_i
126
130
  end
127
131
 
128
132
  # Returns the default branch of the repo
129
133
  def default_branch
130
- document.at_css('.tabs .contextswitch code').text
134
+ @default_branch ||= Nokogiri::HTML(open(branches_url)).at_css('tr.base td.name h3').text.strip.chomp
135
+ rescue OpenURI::HTTPError => err
136
+ raise GithubMetadata::RepoNotFound, err.to_s
131
137
  end
132
138
 
133
139
  # Returns (at most) the last 20 commits (fetched from atom feed of the default_branch)
@@ -1,3 +1,3 @@
1
1
  class GithubMetadata
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -12,14 +12,14 @@ describe GithubMetadata do
12
12
  its(:repo) { should == 'cucumber' }
13
13
 
14
14
  specify { should have_wiki }
15
- its(:wiki_pages) { should == @raw.match(/Wiki \((\d+)\)/)[1].to_i }
15
+ its(:wiki_pages) { should == @raw.match(/Wiki[^\d]+(\d+)/)[1].to_i}
16
16
 
17
17
  # specify { should_not have_issues }
18
18
  # its(:issues) { should be_nil }
19
19
  it { should have_issues }
20
- its(:issues) { should == @raw.match(/Issues \((\d+)\)/)[1].to_i }
20
+ its(:issues) { should == @raw.match(/Issues[^\d]+(\d+)/)[1].to_i }
21
21
 
22
- its(:pull_requests) { should == @raw.match(/Pull Requests \((\d+)\)/)[1].to_i }
22
+ its(:pull_requests) { should == @raw.match(/Pull Requests[^\d]+(\d+)/)[1].to_i }
23
23
 
24
24
  its("contributors.length") { should == @raw.match(/(\d+) contributors/)[1].to_i}
25
25
  its(:contributor_usernames) { should include('aslakhellesoy') }
@@ -50,9 +50,9 @@ describe GithubMetadata do
50
50
  its(:wiki_pages) { should be_nil }
51
51
 
52
52
  it { should have_issues }
53
- its(:issues) { should == @raw.match(/Issues \((\d+)\)/)[1].to_i }
53
+ its(:issues) { should == @raw.match(/Issues[^\d]+(\d+)/)[1].to_i }
54
54
 
55
- its(:pull_requests) { should == @raw.match(/Pull Requests \((\d+)\)/)[1].to_i }
55
+ its(:pull_requests) { should == @raw.match(/Pull Requests[^\d]+(\d+)/)[1].to_i }
56
56
 
57
57
  its("contributors.length") { should == @raw.match(/(\d+) contributors/)[1].to_i}
58
58
  its(:contributors) { should be_all {|c| c.instance_of?(GithubMetadata::Contributor)} }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-12 00:00:00.000000000 +02:00
12
+ date: 2011-10-13 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
17
- requirement: &70134702788000 !ruby/object:Gem::Requirement
17
+ requirement: &70316236097140 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70134702788000
25
+ version_requirements: *70316236097140
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: feedzirra
28
- requirement: &70134702787580 !ruby/object:Gem::Requirement
28
+ requirement: &70316236095860 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70134702787580
36
+ version_requirements: *70316236095860
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &70134702787120 !ruby/object:Gem::Requirement
39
+ requirement: &70316236094600 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70134702787120
47
+ version_requirements: *70316236094600
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &70134702786600 !ruby/object:Gem::Requirement
50
+ requirement: &70316236078080 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70134702786600
58
+ version_requirements: *70316236078080
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: simplecov
61
- requirement: &70134702786080 !ruby/object:Gem::Requirement
61
+ requirement: &70316236075480 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 0.4.1
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70134702786080
69
+ version_requirements: *70316236075480
70
70
  description: Extracts additional information like amount of committers, issues and
71
71
  wiki pages from Github repos
72
72
  email:
@@ -77,6 +77,7 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - .gitignore
79
79
  - .rspec
80
+ - .travis.yml
80
81
  - Gemfile
81
82
  - LICENSE
82
83
  - README.rdoc