github_metadata 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  class GithubMetadata
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -47,7 +47,7 @@ class GithubMetadata
47
47
  # to fetch the repo document and importantly will swallow GithubMetadata::RepoNotFound
48
48
  # errors, returning nil instead so you can easily do something like this:
49
49
  #
50
- # if metdata = GithubMetadata.fetch('rails', 'rails')
50
+ # if metadata = GithubMetadata.fetch('rails', 'rails')
51
51
  # ...
52
52
  # end
53
53
  def self.fetch(user, repo)
@@ -134,12 +134,17 @@ class GithubMetadata
134
134
  # as instances of GithubMetadata::Commit
135
135
  def recent_commits
136
136
  @recent_commits ||= commits_feed.entries.map {|e| GithubMetadata::Commit.new(e) }
137
+
138
+ # TODO: Write tests for this error handling. See commits_feed method - this will result in NoMethodError 'entries' on nil
139
+ rescue NoMethodError => err
140
+ nil
137
141
  end
138
142
 
139
143
  # Returns the average date of recent commits (by default all (max 20), can be modified
140
144
  # by giving the optional argument)
141
145
  def average_recent_committed_at(num=100)
142
146
  commit_times = recent_commits[0...num].map {|c| c.committed_at.to_f }
147
+ return nil if commit_times.empty?
143
148
  average_time = commit_times.inject(0) {|s, i| s + i} / commit_times.length
144
149
  Time.at(average_time).utc
145
150
  end
@@ -154,11 +159,13 @@ class GithubMetadata
154
159
 
155
160
  def commits_feed
156
161
  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
162
+
163
+ http_response = open(commits_feed_url)
164
+ if http_response.status[0].to_i == 200
165
+ # sub \n is required since github decided to make their atom feed invalid by adding a blank line before the xml instruct
166
+ @commits_feed = Feedzirra::Feed.parse(http_response.read.sub("\n", ''))
160
167
  else
161
- @commits_feed = response
168
+ nil
162
169
  end
163
170
  end
164
171
 
metadata CHANGED
@@ -1,83 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: github_metadata
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
4
5
  prerelease:
5
- version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Christoph Olszowka
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-23 00:00:00 +02:00
12
+ date: 2011-10-12 00:00:00.000000000 +02:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: nokogiri
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70134702788000 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: feedzirra
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70134702788000
26
+ - !ruby/object:Gem::Dependency
27
+ name: feedzirra
28
+ requirement: &70134702787580 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
36
34
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: i18n
40
35
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70134702787580
37
+ - !ruby/object:Gem::Dependency
38
+ name: i18n
39
+ requirement: &70134702787120 !ruby/object:Gem::Requirement
42
40
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
47
45
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
46
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *70134702787120
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &70134702786600 !ruby/object:Gem::Requirement
53
51
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
57
55
  version: 2.0.0
58
56
  type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: simplecov
62
57
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *70134702786600
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ requirement: &70134702786080 !ruby/object:Gem::Requirement
64
62
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
68
66
  version: 0.4.1
69
67
  type: :development
70
- version_requirements: *id005
71
- description: Extracts additional information like amount of committers, issues and wiki pages from Github repos
72
- email:
68
+ prerelease: false
69
+ version_requirements: *70134702786080
70
+ description: Extracts additional information like amount of committers, issues and
71
+ wiki pages from Github repos
72
+ email:
73
73
  - christoph at olszowka de
74
74
  executables: []
75
-
76
75
  extensions: []
77
-
78
76
  extra_rdoc_files: []
79
-
80
- files:
77
+ files:
81
78
  - .gitignore
82
79
  - .rspec
83
80
  - Gemfile
@@ -90,33 +87,31 @@ files:
90
87
  - spec/github_metadata_spec.rb
91
88
  - spec/spec_helper.rb
92
89
  has_rdoc: true
93
- homepage: ""
90
+ homepage: ''
94
91
  licenses: []
95
-
96
92
  post_install_message:
97
93
  rdoc_options: []
98
-
99
- require_paths:
94
+ require_paths:
100
95
  - lib
101
- required_ruby_version: !ruby/object:Gem::Requirement
96
+ required_ruby_version: !ruby/object:Gem::Requirement
102
97
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: "0"
107
- required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
103
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
113
108
  requirements: []
114
-
115
109
  rubyforge_project: github_metadata
116
- rubygems_version: 1.6.1
110
+ rubygems_version: 1.6.2
117
111
  signing_key:
118
112
  specification_version: 3
119
- summary: Extracts additional information from Github repos that isn't available via API
120
- test_files:
113
+ summary: Extracts additional information from Github repos that isn't available via
114
+ API
115
+ test_files:
121
116
  - spec/github_metadata_spec.rb
122
117
  - spec/spec_helper.rb