github_metadata 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/github_metadata.gemspec +0 -2
- data/lib/github_metadata.rb +9 -3
- data/lib/github_metadata/version.rb +1 -1
- data/spec/github_metadata_spec.rb +43 -17
- data/spec/spec_helper.rb +1 -10
- metadata +3 -25
data/github_metadata.gemspec
CHANGED
@@ -19,8 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency 'i18n'
|
20
20
|
s.add_development_dependency 'rspec', '>= 2.0.0'
|
21
21
|
s.add_development_dependency 'simplecov', ">= 0.4.1"
|
22
|
-
s.add_development_dependency 'vcr'
|
23
|
-
s.add_development_dependency 'webmock'
|
24
22
|
|
25
23
|
s.files = `git ls-files`.split("\n")
|
26
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/github_metadata.rb
CHANGED
@@ -139,9 +139,9 @@ class GithubMetadata
|
|
139
139
|
# Returns the average date of recent commits (by default all (max 20), can be modified
|
140
140
|
# by giving the optional argument)
|
141
141
|
def average_recent_committed_at(num=100)
|
142
|
-
commit_times = recent_commits[0
|
142
|
+
commit_times = recent_commits[0...num].map {|c| c.committed_at.to_f }
|
143
143
|
average_time = commit_times.inject(0) {|s, i| s + i} / commit_times.length
|
144
|
-
Time.at(average_time)
|
144
|
+
Time.at(average_time).utc
|
145
145
|
end
|
146
146
|
|
147
147
|
private
|
@@ -153,7 +153,13 @@ class GithubMetadata
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def commits_feed
|
156
|
-
@commits_feed
|
156
|
+
return @commits_feed if @commits_feed
|
157
|
+
response = Feedzirra::Feed.fetch_and_parse(commits_feed_url)
|
158
|
+
if response.kind_of?(Fixnum)
|
159
|
+
return nil
|
160
|
+
else
|
161
|
+
@commits_feed = response
|
162
|
+
end
|
157
163
|
end
|
158
164
|
|
159
165
|
def load_contributors
|
@@ -1,21 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
describe GithubMetadata do
|
4
|
-
context "initialized with
|
4
|
+
context "initialized with cucumber/cucumber" do
|
5
5
|
before(:all) do
|
6
|
-
@metadata = GithubMetadata.new('
|
6
|
+
@metadata = GithubMetadata.new('cucumber', 'cucumber')
|
7
7
|
@raw = open("https://github.com/#{@metadata.user}/#{@metadata.repo}/contributors").read
|
8
8
|
end
|
9
9
|
subject { @metadata }
|
10
10
|
|
11
|
-
its(:user) { should == '
|
11
|
+
its(:user) { should == 'cucumber' }
|
12
12
|
its(:repo) { should == 'cucumber' }
|
13
13
|
|
14
14
|
specify { should have_wiki }
|
15
15
|
its(:wiki_pages) { should == @raw.match(/Wiki \((\d+)\)/)[1].to_i }
|
16
16
|
|
17
|
-
specify { should_not have_issues }
|
18
|
-
its(:issues) { should be_nil }
|
17
|
+
# specify { should_not have_issues }
|
18
|
+
# its(:issues) { should be_nil }
|
19
|
+
it { should have_issues }
|
20
|
+
its(:issues) { should == @raw.match(/Issues \((\d+)\)/)[1].to_i }
|
19
21
|
|
20
22
|
its(:pull_requests) { should == @raw.match(/Pull Requests \((\d+)\)/)[1].to_i }
|
21
23
|
|
@@ -30,13 +32,14 @@ describe GithubMetadata do
|
|
30
32
|
|
31
33
|
its(:default_branch) { should == 'master' }
|
32
34
|
|
33
|
-
its(:commits_feed_url) { should == 'https://github.com/
|
35
|
+
its(:commits_feed_url) { should == 'https://github.com/cucumber/cucumber/commits/master.atom' }
|
34
36
|
end
|
35
37
|
|
36
38
|
context "initialized with colszowka/simplecov" do
|
37
39
|
before(:all) do
|
38
40
|
@metadata = GithubMetadata.new('colszowka', 'simplecov')
|
39
41
|
@raw = open("https://github.com/#{@metadata.user}/#{@metadata.repo}/contributors").read
|
42
|
+
@feed = Nokogiri::XML(open(@metadata.commits_feed_url))
|
40
43
|
end
|
41
44
|
subject { @metadata }
|
42
45
|
|
@@ -49,7 +52,7 @@ describe GithubMetadata do
|
|
49
52
|
it { should have_issues }
|
50
53
|
its(:issues) { should == @raw.match(/Issues \((\d+)\)/)[1].to_i }
|
51
54
|
|
52
|
-
its(:pull_requests) { should ==
|
55
|
+
its(:pull_requests) { should == @raw.match(/Pull Requests \((\d+)\)/)[1].to_i }
|
53
56
|
|
54
57
|
its("contributors.length") { should == @raw.match(/(\d+) contributors/)[1].to_i}
|
55
58
|
its(:contributors) { should be_all {|c| c.instance_of?(GithubMetadata::Contributor)} }
|
@@ -65,9 +68,7 @@ describe GithubMetadata do
|
|
65
68
|
|
66
69
|
context "recent_commits" do
|
67
70
|
before(:all) do
|
68
|
-
|
69
|
-
@metadata.recent_commits
|
70
|
-
end
|
71
|
+
@metadata.recent_commits
|
71
72
|
end
|
72
73
|
subject { @metadata.recent_commits }
|
73
74
|
|
@@ -77,18 +78,35 @@ describe GithubMetadata do
|
|
77
78
|
subject { @metadata.recent_commits.first }
|
78
79
|
|
79
80
|
it { should be_a(GithubMetadata::Commit)}
|
80
|
-
its(:title) { should == '
|
81
|
-
its(:author) { should == '
|
82
|
-
its(:url) { should == '
|
83
|
-
its("committed_at.utc") { should == Time.
|
81
|
+
its(:title) { should == @feed.css('entry').first.children.css('title').first.content }
|
82
|
+
its(:author) { should == @feed.css('entry').first.children.css('author name').first.content }
|
83
|
+
its(:url) { should == @feed.css('entry').first.children.css('link').first['href'] }
|
84
|
+
its("committed_at.utc") { should == Time.parse(@feed.css('entry').first.children.css('updated').first.content).utc }
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
88
|
it("should return last commit date for average_recent_committed_at(1)") do
|
88
|
-
subject.average_recent_committed_at(1).should == Time.
|
89
|
+
subject.average_recent_committed_at(1).should == Time.parse(@feed.css('entry').first.children.css('updated').first.content).utc
|
89
90
|
end
|
90
91
|
|
91
|
-
its("average_recent_committed_at.to_i")
|
92
|
+
its("average_recent_committed_at.to_i") do
|
93
|
+
expected_date = @feed.css('entry updated').map {|u| Time.parse(u.content).to_f}.inject(0){|a,b| a+b} / 20
|
94
|
+
should == expected_date.to_i
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "initialized with jquery/jquery" do
|
99
|
+
before(:all) do
|
100
|
+
@metadata = GithubMetadata.new('jquery', 'jquery')
|
101
|
+
@raw = open("https://github.com/#{@metadata.user}/#{@metadata.repo}/contributors").read
|
102
|
+
end
|
103
|
+
subject { @metadata }
|
104
|
+
|
105
|
+
specify { should_not have_wiki }
|
106
|
+
its(:wiki_pages) { should be_nil }
|
107
|
+
|
108
|
+
specify { should_not have_issues }
|
109
|
+
its(:issues) { should be_nil }
|
92
110
|
end
|
93
111
|
|
94
112
|
context "initialized with an invalid repo path" do
|
@@ -97,9 +115,17 @@ describe GithubMetadata do
|
|
97
115
|
end
|
98
116
|
subject { @metadata }
|
99
117
|
|
100
|
-
it "should raise GithubMetadata::RepoNotFound" do
|
118
|
+
it "should raise GithubMetadata::RepoNotFound when accessing .issues" do
|
101
119
|
lambda { subject.issues }.should raise_error(GithubMetadata::RepoNotFound)
|
102
120
|
end
|
121
|
+
|
122
|
+
it "should raise GithubMetadata::RepoNotFound when accessing .recent_commits" do
|
123
|
+
lambda { subject.recent_commits }.should raise_error(GithubMetadata::RepoNotFound)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should raise GithubMetadata::RepoNotFound when accessing .average_recent_committed_at" do
|
127
|
+
lambda { subject.average_recent_committed_at }.should raise_error(GithubMetadata::RepoNotFound)
|
128
|
+
end
|
103
129
|
end
|
104
130
|
|
105
131
|
describe "fetch with invalid repo path" do
|
data/spec/spec_helper.rb
CHANGED
@@ -6,13 +6,4 @@ require 'github_metadata'
|
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
# some (optional) config here
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'vcr'
|
12
|
-
|
13
|
-
VCR.config do |c|
|
14
|
-
c.allow_http_connections_when_no_cassette = true
|
15
|
-
c.default_cassette_options = { :record => :new_episodes }
|
16
|
-
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
17
|
-
c.stub_with :webmock # or :fakeweb
|
18
|
-
end
|
9
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: github_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Christoph Olszowka
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-23 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -68,28 +68,6 @@ dependencies:
|
|
68
68
|
version: 0.4.1
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: vcr
|
73
|
-
prerelease: false
|
74
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: "0"
|
80
|
-
type: :development
|
81
|
-
version_requirements: *id006
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: webmock
|
84
|
-
prerelease: false
|
85
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: "0"
|
91
|
-
type: :development
|
92
|
-
version_requirements: *id007
|
93
71
|
description: Extracts additional information like amount of committers, issues and wiki pages from Github repos
|
94
72
|
email:
|
95
73
|
- christoph at olszowka de
|
@@ -135,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
113
|
requirements: []
|
136
114
|
|
137
115
|
rubyforge_project: github_metadata
|
138
|
-
rubygems_version: 1.
|
116
|
+
rubygems_version: 1.6.1
|
139
117
|
signing_key:
|
140
118
|
specification_version: 3
|
141
119
|
summary: Extracts additional information from Github repos that isn't available via API
|