any_good 0.0.3 → 0.0.4
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.
- checksums.yaml +5 -5
- data/lib/any_good.rb +29 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7fb208f16bb2d4c212c9cea27ec91ba93bd8024b617be1e3b2767c692e57ffc
|
4
|
+
data.tar.gz: e1d259e50a27ce665049ef9bb3c757be63fe132b8daf812d9442f220cdfaeeb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161a798f1b91ff1d60e2be248e52cbd23cd482d97f49063b24a6ad23109f9f86467eddaa5fca262aa5aa3058d975987bba8fa8572d6f004dad60ff72d014d646
|
7
|
+
data.tar.gz: 12393bd4beb5dd863a44cca7009fa17eadc4c3cfbee0b69c894928a9bd490aaac4e3f743da8c929cc3d019c5ce5f65fab77d846c43d7e2904bf05d98545f31a5
|
data/lib/any_good.rb
CHANGED
@@ -21,26 +21,11 @@ class AnyGood
|
|
21
21
|
GITHUB_URI_PATTERN = %r{^https?://(www\.)?github\.com/}
|
22
22
|
|
23
23
|
def fetch
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
gem_rev_deps: Gems.reverse_dependencies(name)
|
28
|
-
}
|
24
|
+
gem_info = fetch_gem
|
25
|
+
repo_id = detect_repo_id(*gem_info[:gem_info].values_at('source_code_uri', 'homepage_uri'))
|
26
|
+
github_info = fetch_github(repo_id)
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
if repo_id
|
33
|
-
data.merge!(
|
34
|
-
repo: @github_client.repository(repo_id).to_h,
|
35
|
-
open_issues: @github_client.issues(repo_id, state: 'open', per_page: 50).map(&:to_h),
|
36
|
-
closed_issues: @github_client.issues(repo_id, state: 'closed', per_page: 50).map(&:to_h),
|
37
|
-
last_commit: @github_client.commits(repo_id, per_page: 1).first.to_h
|
38
|
-
# open_prs: @github_client.issues(repo_id, state: 'open').map(&:to_h)
|
39
|
-
# closed_prs: @github_client.issues(repo_id, state: 'closed').map(&:to_h)
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
@data = OpenStruct.new(data)
|
28
|
+
@data = OpenStruct.new(gem_info.merge(github_info))
|
44
29
|
|
45
30
|
self
|
46
31
|
end
|
@@ -65,7 +50,7 @@ class AnyGood
|
|
65
50
|
T = TimeMath
|
66
51
|
now = Time.now
|
67
52
|
|
68
|
-
metric('Downloads', thresholds: [5_000, 10_000]) { data.
|
53
|
+
metric('Downloads', thresholds: [5_000, 10_000]) { data.gem_info['downloads'] }
|
69
54
|
metric('Latest version', thresholds: [T.year.decrease(now), T.month.decrease(now, 2)]) {
|
70
55
|
Time.parse(data.gem_versions.first['created_at'])
|
71
56
|
}
|
@@ -95,6 +80,30 @@ class AnyGood
|
|
95
80
|
|
96
81
|
private
|
97
82
|
|
83
|
+
def fetch_gem
|
84
|
+
{
|
85
|
+
gem_info: Gems.info(name),
|
86
|
+
gem_versions: Gems.versions(name),
|
87
|
+
gem_rev_deps: Gems.reverse_dependencies(name)
|
88
|
+
}
|
89
|
+
rescue JSON::ParserError => e
|
90
|
+
# Gems have no cleaner way to indicate gem does not exist :shrug:
|
91
|
+
raise unless e.message.include?('This rubygem could not be found.')
|
92
|
+
abort("Gem #{name} does not exist.")
|
93
|
+
end
|
94
|
+
|
95
|
+
def fetch_github(repo_id)
|
96
|
+
return {} unless repo_id
|
97
|
+
{
|
98
|
+
repo: @github_client.repository(repo_id).to_h,
|
99
|
+
open_issues: @github_client.issues(repo_id, state: 'open', per_page: 50).map(&:to_h),
|
100
|
+
closed_issues: @github_client.issues(repo_id, state: 'closed', per_page: 50).map(&:to_h),
|
101
|
+
last_commit: @github_client.commits(repo_id, per_page: 1).first.to_h
|
102
|
+
# open_prs: @github_client.issues(repo_id, state: 'open').map(&:to_h)
|
103
|
+
# closed_prs: @github_client.issues(repo_id, state: 'closed').map(&:to_h)
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
98
107
|
def detect_repo_id(*urls)
|
99
108
|
repo_url = urls.grep(GITHUB_URI_PATTERN).first or return nil
|
100
109
|
Octokit::Repository.from_url(repo_url).slug
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: any_good
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Shepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.7.4
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Is that gem any good?
|