ruby_dep 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -5
- data/README.md +14 -6
- data/lib/ruby_dep/logger.rb +16 -0
- data/lib/ruby_dep/quiet.rb +3 -0
- data/lib/ruby_dep/ruby_version.rb +58 -0
- data/lib/ruby_dep/travis/ruby_version.rb +2 -0
- data/lib/ruby_dep/version.rb +1 -1
- data/lib/ruby_dep/warning.rb +65 -64
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14a8f932140718a77fa7320dcad7cb08a773070
|
4
|
+
data.tar.gz: 969284805a9cc3499b7265f86a48e02afd0eff4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a246baa7f0bdeaa701606c488c2d1f88fc32aad50eef6510e2a7142603c12969021973f42f0d858d1d034a33ea190caab3e2470f02fcda3c22eb47b0e61fae
|
7
|
+
data.tar.gz: 3f541d1ce2b598453287f1b2005eeb34da2cbb25962bfdc39d7afea29e5bc467672ad35543d201f38e4116d3974b641052259921e84bb60b0952fdecf6826ac3
|
data/.travis.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
bundler_args: --without development
|
4
|
+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
|
4
5
|
rvm:
|
5
|
-
- 2.0.0
|
6
|
-
- 2.1.9
|
7
|
-
- 2.2.4
|
8
6
|
- 2.2.5
|
9
7
|
- 2.3.1
|
10
|
-
- jruby-9.
|
11
|
-
|
8
|
+
- jruby-9.1.2.0
|
9
|
+
|
10
|
+
before_install: gem install bundler -v 1.12.5
|
12
11
|
cache: bundler
|
data/README.md
CHANGED
@@ -4,16 +4,24 @@
|
|
4
4
|
|
5
5
|
## Description
|
6
6
|
|
7
|
-
RubyDep
|
7
|
+
RubyDep does 2 things right now:
|
8
8
|
|
9
|
-
|
9
|
+
1. Helps end users avoid incompatible, buggy and insecure Ruby versions.
|
10
|
+
2. Helps gem owners manage their gem's `required_ruby_version` gemspec field based on `.travis.yml`.
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
## Quick info
|
13
|
+
|
14
|
+
- if you want to know how to disable the warnings, see here: https://github.com/e2/ruby_dep/wiki/Disabling-warnings
|
15
|
+
- for a list of Ruby versions that can be used to install ruby_dep, see here: https://travis-ci.org/e2/ruby_dep
|
16
|
+
- if your version of Ruby is not supported, open a new issue and explain your situation/problem
|
17
|
+
- when in doubt, open a new issue or [read the FAQ on the Wiki](https://github.com/e2/ruby_dep/wiki/FAQ).
|
18
|
+
- gems using RubyDep are designed to not be installable on a given Ruby version, unless it's specifically declared supported by those gems - but it's ok to ask for supporting your Ruby if you're stuck on an older version (for whatever reason)
|
19
|
+
- discussions about Ruby versions can get complex and frustrating - please be patient and constructive, and open-minded about solutions - especially if you're having problems
|
13
20
|
|
14
|
-
NOTE: RubyDep uses it's own approach on itself. This means it can only be installed on Ruby versions tested here: [check out the Travis build status](https://travis-ci.org/e2/ruby_dep). If you need support for an different/older version of Ruby, open an issue with "backport" in the title and provide a compelling case for supporting the version of Ruby you need.
|
15
|
-
When in doubt, open a new issue or [read the FAQ on the Wiki](https://github.com/e2/ruby_dep/wiki/FAQ).
|
16
21
|
|
22
|
+
## Supported Ruby versions:
|
23
|
+
|
24
|
+
NOTE: RubyDep uses it's own approach on itself. This means it can only be installed on Ruby versions tested here: [check out the Travis build status](https://travis-ci.org/e2/ruby_dep). If you need support for an different/older version of Ruby, open an issue with "backport" in the title and provide a compelling case for supporting the version of Ruby you need.
|
17
25
|
|
18
26
|
## Problem 1: "Which version of Ruby does your project support?"
|
19
27
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
module RubyDep
|
3
|
+
class RubyVersion
|
4
|
+
attr_reader :status # NOTE: monkey-patched by acceptance tests
|
5
|
+
attr_reader :version
|
6
|
+
attr_reader :engine
|
7
|
+
|
8
|
+
def initialize(ruby_version, engine)
|
9
|
+
@engine = engine
|
10
|
+
@version = Gem::Version.new(ruby_version)
|
11
|
+
@status = detect_status
|
12
|
+
end
|
13
|
+
|
14
|
+
def recognized?
|
15
|
+
info.any?
|
16
|
+
end
|
17
|
+
|
18
|
+
def recommended(status)
|
19
|
+
current = Gem::Version.new(@version)
|
20
|
+
info.select do |key, value|
|
21
|
+
value == status && Gem::Version.new(key) > current
|
22
|
+
end.keys.reverse
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
VERSION_INFO = {
|
28
|
+
'ruby' => {
|
29
|
+
'2.3.1' => :unknown,
|
30
|
+
'2.3.0' => :buggy,
|
31
|
+
'2.2.5' => :unknown,
|
32
|
+
'2.2.4' => :buggy,
|
33
|
+
'2.2.0' => :insecure,
|
34
|
+
'2.1.9' => :buggy,
|
35
|
+
'2.0.0' => :insecure
|
36
|
+
},
|
37
|
+
|
38
|
+
'jruby' => {
|
39
|
+
'2.3.0' => :unknown, # jruby-9.1.2.0, jruby-9.1.0.0
|
40
|
+
'2.2.3' => :buggy, # jruby-9.0.5.0
|
41
|
+
'2.2.0' => :insecure
|
42
|
+
}
|
43
|
+
}.freeze
|
44
|
+
|
45
|
+
def info
|
46
|
+
@info ||= VERSION_INFO[@engine] || {}
|
47
|
+
end
|
48
|
+
|
49
|
+
def detect_status
|
50
|
+
return :untracked unless recognized?
|
51
|
+
|
52
|
+
info.each do |ruby, status|
|
53
|
+
return status if @version >= Gem::Version.new(ruby)
|
54
|
+
end
|
55
|
+
:insecure
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -48,6 +48,8 @@ module RubyDep
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def jruby_version(version)
|
51
|
+
return '2.3.0' if version == '9.1.2.0'
|
52
|
+
return '2.3.0' if version == '9.1.0.0'
|
51
53
|
return '2.2.3' if version == '9.0.5.0'
|
52
54
|
return '2.2.2' if version == '9.0.4.0'
|
53
55
|
raise Error::Unrecognized::JRubyVersion, version
|
data/lib/ruby_dep/version.rb
CHANGED
data/lib/ruby_dep/warning.rb
CHANGED
@@ -1,96 +1,97 @@
|
|
1
|
+
require 'ruby_dep/logger'
|
2
|
+
require 'ruby_dep/ruby_version'
|
3
|
+
|
1
4
|
module RubyDep
|
5
|
+
PROJECT_URL = 'http://github.com/e2/ruby_dep'.freeze
|
6
|
+
|
2
7
|
class Warning
|
8
|
+
DISABLING_ENVIRONMENT_VAR = 'RUBY_DEP_GEM_SILENCE_WARNINGS'.freeze
|
3
9
|
PREFIX = 'RubyDep: WARNING: '.freeze
|
4
|
-
MSG_BUGGY = 'Your Ruby is outdated/buggy.'.freeze
|
5
|
-
MSG_INSECURE = 'Your Ruby has security vulnerabilities!'.freeze
|
6
10
|
|
7
|
-
|
8
|
-
'
|
11
|
+
WARNING = {
|
12
|
+
insecure: 'Your Ruby has security vulnerabilities!'.freeze,
|
13
|
+
buggy: 'Your Ruby is outdated/buggy.'.freeze,
|
14
|
+
untracked: 'Your Ruby may not be supported.'.freeze
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
NOTICE_RECOMMENDATION = 'Your Ruby is: %s (%s).'\
|
18
|
+
' Recommendation: upgrade to %s.'.freeze
|
19
|
+
|
20
|
+
NOTICE_BUGGY_ALTERNATIVE = '(Or, at least to %s)'.freeze
|
9
21
|
|
10
|
-
|
11
|
-
|
22
|
+
NOTICE_HOW_TO_DISABLE = '(To disable warnings, see:'\
|
23
|
+
"#{PROJECT_URL}/wiki/Disabling-warnings )".freeze
|
24
|
+
|
25
|
+
NOTICE_OPEN_ISSUE = 'If you need this version supported,'\
|
26
|
+
" please open an issue at #{PROJECT_URL}".freeze
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
@version = RubyVersion.new(RUBY_VERSION, RUBY_ENGINE)
|
30
|
+
@logger = Logger.new(STDERR, PREFIX)
|
31
|
+
end
|
12
32
|
|
13
33
|
def show_warnings
|
14
34
|
return if silenced?
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
when :buggy
|
19
|
-
warn_ruby(MSG_BUGGY, status)
|
20
|
-
when :unknown
|
21
|
-
else
|
22
|
-
raise "Unknown problem type: #{problem.inspect}"
|
23
|
-
end
|
35
|
+
return warn_ruby(WARNING[status]) if WARNING.key?(status)
|
36
|
+
return if status == :unknown
|
37
|
+
raise "Unknown problem type: #{problem.inspect}"
|
24
38
|
end
|
25
39
|
|
26
|
-
|
27
|
-
|
28
|
-
VERSION_INFO = {
|
29
|
-
'ruby' => {
|
30
|
-
'2.3.1' => :unknown,
|
31
|
-
'2.3.0' => :buggy,
|
32
|
-
'2.2.5' => :unknown,
|
33
|
-
'2.2.4' => :buggy,
|
34
|
-
'2.2.0' => :insecure,
|
35
|
-
'2.1.9' => :buggy,
|
36
|
-
'2.0.0' => :insecure
|
37
|
-
},
|
38
|
-
|
39
|
-
'jruby' => {
|
40
|
-
'2.2.3' => :unknown, # jruby-9.0.5.0
|
41
|
-
'2.2.0' => :insecure
|
42
|
-
}
|
43
|
-
}.freeze
|
44
|
-
|
45
|
-
def check_ruby
|
46
|
-
version = Gem::Version.new(RUBY_VERSION)
|
47
|
-
current_ruby_info.each do |ruby, status|
|
48
|
-
return status if version >= Gem::Version.new(ruby)
|
49
|
-
end
|
50
|
-
:insecure
|
40
|
+
def silence!
|
41
|
+
ENV[DISABLING_ENVIRONMENT_VAR] = '1'
|
51
42
|
end
|
52
43
|
|
44
|
+
private
|
45
|
+
|
53
46
|
def silenced?
|
54
|
-
value = ENV[
|
47
|
+
value = ENV[DISABLING_ENVIRONMENT_VAR]
|
55
48
|
(value || '0') !~ /^0|false|no|n$/
|
56
49
|
end
|
57
50
|
|
58
|
-
def
|
59
|
-
|
60
|
-
STDERR.puts PREFIX + recommendation(status)
|
51
|
+
def status
|
52
|
+
@version.status
|
61
53
|
end
|
62
54
|
|
63
|
-
def
|
64
|
-
msg
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
msg += " Recommendation: install #{recommended(:unknown).join(' or ')}."
|
69
|
-
return msg unless status == :insecure
|
55
|
+
def warn_ruby(msg)
|
56
|
+
@logger.warning(msg)
|
57
|
+
@logger.notice(recommendation)
|
58
|
+
@logger.notice(NOTICE_HOW_TO_DISABLE)
|
59
|
+
end
|
70
60
|
|
71
|
-
|
61
|
+
def recommendation
|
62
|
+
return unrecognized_msg unless @version.recognized?
|
63
|
+
return recommendation_msg unless status == :insecure
|
64
|
+
[recommendation_msg, safer_alternatives_msg].join(' ')
|
72
65
|
end
|
73
66
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
def unrecognized_msg
|
68
|
+
format(
|
69
|
+
"Your Ruby is: %s '%s' (unrecognized). %s",
|
70
|
+
@version.version,
|
71
|
+
@version.engine,
|
72
|
+
NOTICE_OPEN_ISSUE
|
73
|
+
)
|
79
74
|
end
|
80
75
|
|
81
|
-
def
|
82
|
-
|
76
|
+
def recommended_versions
|
77
|
+
@version.recommended(:unknown)
|
83
78
|
end
|
84
79
|
|
85
|
-
def
|
86
|
-
|
80
|
+
def buggy_alternatives
|
81
|
+
@version.recommended(:buggy)
|
87
82
|
end
|
88
83
|
|
89
|
-
def
|
84
|
+
def recommendation_msg
|
90
85
|
format(
|
91
|
-
|
92
|
-
|
86
|
+
NOTICE_RECOMMENDATION,
|
87
|
+
@version.version,
|
88
|
+
status,
|
89
|
+
recommended_versions.join(' or ')
|
93
90
|
)
|
94
91
|
end
|
92
|
+
|
93
|
+
def safer_alternatives_msg
|
94
|
+
format(NOTICE_BUGGY_ALTERNATIVE, buggy_alternatives.join(' or '))
|
95
|
+
end
|
95
96
|
end
|
96
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_dep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cezary Baginski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,6 +39,9 @@ files:
|
|
39
39
|
- LICENSE.txt
|
40
40
|
- README.md
|
41
41
|
- lib/ruby_dep.rb
|
42
|
+
- lib/ruby_dep/logger.rb
|
43
|
+
- lib/ruby_dep/quiet.rb
|
44
|
+
- lib/ruby_dep/ruby_version.rb
|
42
45
|
- lib/ruby_dep/travis.rb
|
43
46
|
- lib/ruby_dep/travis/ruby_version.rb
|
44
47
|
- lib/ruby_dep/version.rb
|
@@ -55,10 +58,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
58
|
requirements:
|
56
59
|
- - "~>"
|
57
60
|
- !ruby/object:Gem::Version
|
58
|
-
version: '2.
|
61
|
+
version: '2.2'
|
59
62
|
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
64
|
+
version: 2.2.5
|
62
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
66
|
requirements:
|
64
67
|
- - ">="
|
@@ -66,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
69
|
version: '0'
|
67
70
|
requirements: []
|
68
71
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.6.6
|
70
73
|
signing_key:
|
71
74
|
specification_version: 4
|
72
75
|
summary: Extracts supported Ruby versions from Travis file
|