libyear-bundler 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: 6605cda8b92cd002e2b1a536a716ba50d8c0df4b550db28f6b0be4760d7734f7
4
- data.tar.gz: eec844bd3aaf31c95fc29827ca6a33166da392ab799a03b3b3b5269cc5507fe7
3
+ metadata.gz: e9b6ae5fa040a91add039ed6d36fd2a6f3084a42efe9adfa1207fdad342ae6b9
4
+ data.tar.gz: dc93d875dcf16eb18c20bb09bbc8ed38efb1866b49d3b6fe3b721be3d78f009a
5
5
  SHA512:
6
- metadata.gz: 555318739eb3506de90e6d21f103fbb8ce2c0bd4225595830465c0aae476a906d55ffcf534e375925146c695348bbca975fe75ef962752bb4d41f474b6308b2d
7
- data.tar.gz: a1fe20a4d14b170ccc8b10949868cf859382135651ec799bd1c0bfff4c588a5b92e63d7bf347cc0987feb4aa8199966e986b56d797d30828e9b01b3fb64cde72
6
+ metadata.gz: ef8e98ac272c82f87634523708d44d0e805d571909c4e68b57be3e760780b13b345b6d1fbe09222dc41aedebcfd47105e6cea4baae13555b693a9ba0ec90a3fb
7
+ data.tar.gz: b06125191e905323a3d43098306899be8e48f7dff79df11b62f8a1d9865311ce6d8048c50706316543b8eb3fcb3b925d55d6ba9e7170019cd0a4894d4fb9af45
@@ -7,6 +7,7 @@ require 'yaml'
7
7
  require 'libyear_bundler/calculators/libyear'
8
8
  require 'libyear_bundler/calculators/version_number_delta'
9
9
  require 'libyear_bundler/calculators/version_sequence_delta'
10
+ require 'libyear_bundler/yaml_loader'
10
11
 
11
12
  module LibyearBundler
12
13
  module Models
@@ -78,13 +79,19 @@ module LibyearBundler
78
79
  def all_versions
79
80
  @_all_versions ||= begin
80
81
  uri = ::URI.parse(RUBY_VERSION_DATA_URL)
81
- response = ::Net::HTTP.get_response(uri)
82
- # The Date object is passed through here due to a bug in
83
- # YAML#safe_load
84
- # https://github.com/ruby/psych/issues/262
85
- ::YAML
86
- .safe_load(response.body, [Date])
87
- .map { |release| release['version'] }
82
+ opt = { open_timeout: 3, read_timeout: 5, use_ssl: true }
83
+ response = ::Net::HTTP.start(uri.hostname, uri.port, opt) do |con|
84
+ con.request_get(uri.path)
85
+ end
86
+ if response.is_a?(::Net::HTTPSuccess)
87
+ YAMLLoader.safe_load(response.body).map { |release| release['version'] }
88
+ else
89
+ warn format('Unable to get Ruby version list: response code: %s', response.code)
90
+ []
91
+ end
92
+ rescue ::Timeout::Error
93
+ warn 'Unable to get Ruby version list: network timeout'
94
+ []
88
95
  end
89
96
  end
90
97
  end
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'libyear_bundler/yaml_loader'
2
3
 
3
4
  module LibyearBundler
4
5
  # A cache of release dates by name and version, for both gems and rubies.
@@ -18,10 +19,18 @@ module LibyearBundler
18
19
  end
19
20
  end
20
21
 
22
+ def empty?
23
+ @data.empty?
24
+ end
25
+
26
+ def size
27
+ @data.size
28
+ end
29
+
21
30
  class << self
22
31
  def load(path)
23
32
  if File.exist?(path)
24
- new(YAML.safe_load(File.read(path), [Date]))
33
+ new(YAMLLoader.safe_load(File.read(path)))
25
34
  else
26
35
  new({})
27
36
  end
@@ -1,3 +1,3 @@
1
1
  module LibyearBundler
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.6.1".freeze
3
3
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module LibyearBundler
6
+ # Supports different versions of the `YAML` constant. For example,
7
+ #
8
+ # > psych 3.0.3 YAML#safe_load expected the permitted/whitelisted classes in
9
+ # > the second parameter.
10
+ # >
11
+ # > psych 3.1.0 YAML#safe_load introduced keyword argument permitted_classes
12
+ # > in addition to permitted/whitelisted classes in the second parameter.
13
+ # >
14
+ # > psych 4.0.0 dropped the second positional parameter of YAML#safe_load, and
15
+ # > expects the permitted/whitelisted classes only in keyword parameter
16
+ # > permitted_classes.
17
+ # > https://github.com/jaredbeck/libyear-bundler/issues/22
18
+ #
19
+ # I expect this will only get more complicated over the years, as we try to
20
+ # support old rubies for as long as possible.
21
+ #
22
+ # Other known issues:
23
+ #
24
+ # - https://github.com/ruby/psych/issues/262
25
+ module YAMLLoader
26
+ class << self
27
+ def safe_load(yaml, permitted_classes: [::Date])
28
+ if YAML.method(:safe_load).parameters.include?([:key, :permitted_classes])
29
+ YAML.safe_load(yaml, permitted_classes: permitted_classes)
30
+ else
31
+ YAML.safe_load(yaml, permitted_classes)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -33,9 +33,6 @@ Gem::Specification.new do |spec|
33
33
  # above.
34
34
  spec.add_dependency "bundler", ">= 1.14", "< 3"
35
35
 
36
- spec.add_development_dependency "rspec", "~> 3.9"
37
-
38
- # rubocop 0.57 drops support for ruby 2.1, so 0.56 is the highest we can
39
- # use. We're going to support ruby 2.1 as long as possible. See above.
40
- spec.add_development_dependency "rubocop", "~> 0.56.0"
36
+ # Development dependencies are specified in `/gemfiles`. See CONTRIBUTING.md
37
+ # for details.
41
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libyear-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Beck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-13 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,34 +30,6 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '3.9'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3.9'
47
- - !ruby/object:Gem::Dependency
48
- name: rubocop
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 0.56.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: 0.56.0
61
33
  description:
62
34
  email:
63
35
  - jared@jaredbeck.com
@@ -80,6 +52,7 @@ files:
80
52
  - lib/libyear_bundler/release_date_cache.rb
81
53
  - lib/libyear_bundler/report.rb
82
54
  - lib/libyear_bundler/version.rb
55
+ - lib/libyear_bundler/yaml_loader.rb
83
56
  - libyear-bundler.gemspec
84
57
  homepage: https://libyear.com
85
58
  licenses:
@@ -100,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
73
  - !ruby/object:Gem::Version
101
74
  version: '0'
102
75
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.6.3
76
+ rubygems_version: 3.2.20
105
77
  signing_key:
106
78
  specification_version: 4
107
79
  summary: A simple measure of dependency freshness