thanks 0.3.2 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 655a4400ca031755cb9d10f6e6132fc3c149f2fa
4
- data.tar.gz: 34572cb970bbc356fc3f5409f8daf3426a869b0d
3
+ metadata.gz: 2309a06ca3fa70810f93ce1a080ba00331c3e321
4
+ data.tar.gz: 3aced666c930246034c900dba2679f945e9a6dd4
5
5
  SHA512:
6
- metadata.gz: 17e90e7dba51cd7c676c614c611652c75f881d045f9200a2c4bcee77cfecd4110a1bc16880e41eb530d99a60f9cd0b51077fcb9c70190fc1c4f91dcff3071128
7
- data.tar.gz: 0a8d4950fcd0f6df36d8ed5650d405c2f92deaddc56f7f91814328389e98da143485884413dde5e7b71354f78de30d526a78c33cfd0cc75436aac188a00df7f6
6
+ metadata.gz: 24bb10637e3b15cc1308eb2ba526d6b000abfc54e8790aae92e1c3b365147d361cf90029f4c43fc938626465761ec2b187a33613207a00ee63b918f22e45bc9e
7
+ data.tar.gz: 1077a77ab2c59194e4c1b6595e4ae19a45bdb1b822ab7688cf6490a6c52ec4f9a38413bd236b71f9cc3f4499c23333f9a0b5520a2622eb04d325f399bfcd01da
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Thanks
2
2
 
3
- ![download counter link at rubygems](https://img.shields.io/gem/dt/thanks.svg)
3
+ [![download counter link at rubygems](https://img.shields.io/gem/dt/thanks.svg)](https://rubygems.org/gems/thanks)
4
+ [![Build Status at Travis CI](https://travis-ci.org/dpritchett/thanks-ruby.svg?branch=master)](https://travis-ci.org/dpritchett/thanks-ruby)
4
5
 
5
6
  Find out how to support the authors of the gems you depend on. Inspired by @feross's [thanks package for Node](https://github.com/feross/thanks).
6
7
 
@@ -8,7 +9,7 @@ Find out how to support the authors of the gems you depend on. Inspired by @fero
8
9
 
9
10
  TODO:
10
11
 
11
- - Add your donation linkt to the registry
12
+ - Add your donation link to the registry
12
13
  - Cleaner gem listing code?
13
14
 
14
15
  Help wanted! This is free of course :)
@@ -1,8 +1,48 @@
1
+ require 'yaml'
2
+ require 'net/http'
3
+
1
4
  module Thanks
2
- REGISTRY = {
3
- 'bundler' => 'https://rubytogether.org',
4
- 'gemstash' => 'https://rubytogether.org',
5
- 'rubocop' => 'https://opencollective.com/rubocop',
6
- 'split' => 'https://opencollective.com/split'
7
- }.freeze
5
+ # Loaders for the local registry and the online version
6
+ class Registry
7
+ def fetch
8
+ @remote_memoized ||= remote
9
+ rescue SocketError => err
10
+ STDERR.puts("Unable to contact GitHub: #{err}")
11
+ local
12
+ end
13
+
14
+ def local
15
+ @_local ||= YAML.load_file(File.join(__dir__, 'registry.yml'))
16
+ end
17
+
18
+ def remote
19
+ if response.code != '200'
20
+ STDERR.puts "Bad HTTP request: #{response.body}"
21
+ false
22
+ else
23
+ YAML.safe_load(response.body.to_s)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def request
30
+ Net::HTTP::Get.new(remote_uri)
31
+ end
32
+
33
+ def response
34
+ Net::HTTP.start(
35
+ remote_uri.hostname,
36
+ remote_uri.port,
37
+ use_ssl: true,
38
+ timeout: 2
39
+ ) do |http|
40
+ http.request(request)
41
+ end
42
+ end
43
+
44
+ def remote_uri
45
+ URI('https://raw.githubusercontent.com/dpritchett/thanks-ruby/master/lib/thanks/registry.yml')
46
+ end
47
+ end
8
48
  end
@@ -0,0 +1,5 @@
1
+ ---
2
+ bundler: https://rubytogether.org
3
+ gemstash: https://rubytogether.org
4
+ rubocop: https://opencollective.com/rubocop
5
+ split: https://opencollective.com/split
@@ -1,3 +1,3 @@
1
1
  module Thanks
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
data/lib/thanks.rb CHANGED
@@ -19,7 +19,9 @@ module Thanks
19
19
  end
20
20
 
21
21
  def self.matches
22
- @_matches ||= REGISTRY.select do |name, _url|
22
+ registry = Registry.new.fetch
23
+
24
+ @_matches ||= registry.select do |name, _url|
23
25
  system_gems.include?(name) ||
24
26
  bundled_gems.include?(name)
25
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thanks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Pritchett
@@ -88,6 +88,7 @@ files:
88
88
  - img/screencast.gif
89
89
  - lib/thanks.rb
90
90
  - lib/thanks/registry.rb
91
+ - lib/thanks/registry.yml
91
92
  - lib/thanks/version.rb
92
93
  - thanks.gemspec
93
94
  homepage: https://github.com/dpritchett/thanks-ruby