ruby_dep 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ff4303cb0495bdf891173620d7f617c38f9bb8c
4
- data.tar.gz: 495b8ea913a703b6d4cf1a016e7b6cbeed4ef8dd
3
+ metadata.gz: 6162cd8effed647293da60172ca50c44277bc7f1
4
+ data.tar.gz: 1ca1c7888ea45b1531eae6608f38823bb7d26215
5
5
  SHA512:
6
- metadata.gz: e14fafce98b25dd34fafb1c429c764aa96717be3975ca64b9f42c64d40f858ffd7184c16313983828cd8c80815217585b34e41b557b71202ba1ab19105a205eb
7
- data.tar.gz: 8e4fec2237d44ce2a4f6a608f57dc40f061ecde2048a6062ab2482dac96ab7f5438cb6c5aafc64e96c80b6d365d5a121e05f138e999a758b7b681f1f44f8e6ba
6
+ metadata.gz: ef2e1a10793b65e5a6b785da3af395354f68240617d0f3e8ad739f723bf86efc0703f475991ae20f116eb4ad1c86270103a380e0d4ef3b49e99cd05ad20ed960
7
+ data.tar.gz: c3c487439cbb6b9dc21aad2573d850a4e2795cb1c774fdac1f0a31716ed6810fa1c2b8941c829c3d36882c6e3ee18a090fe5eb0f617b8cf21ae7d8b74aeae1c4
data/README.md CHANGED
@@ -1,54 +1,82 @@
1
1
  # RubyDep
2
2
 
3
- Helps with various Ruby version management activities, such as:
3
+ [![Gem Version](https://img.shields.io/gem/v/ruby_dep.svg?style=flat)](https://rubygems.org/gems/ruby_dep) [![Build Status](https://travis-ci.org/e2/ruby_dep.svg)](https://travis-ci.org/e2/ruby_dep)
4
4
 
5
- 1. Reading supported Ruby version from a .travis.yml file
6
- 2. More stuff planned (reading TargetRubyVersion from .rubocop.yml file?)
5
+ ## The problem
7
6
 
8
- Reason: tests are the best indicator of compatibility.
7
+ Your gem doesn't support all possible Ruby versions.
9
8
 
10
- So, it doesn't make mention the supported Ruby version(s) in:
9
+ And not all Ruby versions are secure to even have installed.
11
10
 
12
- 1. your gemspec
13
- 2. your README
14
- 3. your .travis.yml file
11
+ So, you need to tell users which Ruby versions you support in:
15
12
 
16
- (That breaks the principle of single responsibility).
13
+ 1. Your gemspec
14
+ 2. Your README
15
+ 3. Your .travis.yml file
16
+ 4. Any issues you get about which version of Ruby is supported or not
17
17
 
18
- Instead, it's better to:
18
+ But maintaning that information in 4 different places breaks the principle of
19
+ single responsibility.
19
20
 
20
- - point to the Travis build in your README (or your gem home page on rubygems.org)
21
- - extract the supported versions from your .travis.yml
22
- - set the versions automatically in your Gemspec
23
21
 
22
+ ## The solution
24
23
 
25
- ## Installation
24
+ This gems detects which versions of Ruby your project supports.
26
25
 
27
- Add this line to your application's Gemfile:
26
+ It assumes you are using Travis and the versions listed in your `.travis.yml` are supported.
27
+
28
+ This helps you limit the Ruby versions you support - just by adding/removing entries in your Travis configuration file.
29
+
30
+ Also, you it can warn users if they are using an outdated version of Ruby.
31
+
32
+ (Or one with security vulnerabilities).
33
+
34
+
35
+ ## Usage
36
+
37
+ ### E.g. in your gemspec file:
28
38
 
29
39
  ```ruby
30
- gem 'ruby_dep'
40
+ begin
41
+ require "ruby_dep/travis"
42
+ s.required_ruby_version = RubyDep::Travis.new.version_constraint
43
+ rescue LoadError
44
+ abort "Install 'ruby_dep' gem before building this gem"
45
+ end
46
+
47
+ s.add_development_dependency 'ruby_dep', '~> 1.0'
31
48
  ```
32
49
 
33
- And then execute:
50
+ ### In your `README.md`:
34
51
 
35
- $ bundle
52
+ Replace your mentions of "supported Ruby versions" to point to the Travis build.
36
53
 
37
- Or install it yourself as:
54
+ (Or, you can point to the rubygems.org site where the required Ruby version is listed).
38
55
 
39
- $ gem install ruby_dep
56
+ If it works on Travis, it's assumed to be supported, right?
40
57
 
41
- ## Usage
58
+ If it fails, it isn't, right?
42
59
 
43
- E.g. in your gemspec file:
60
+ ### In your library:
44
61
 
45
62
  ```ruby
46
- require 'ruby_dep'
63
+ require 'ruby_dep/warnings'
64
+ RubyDep::Warning.show_warnings
65
+ ```
47
66
 
48
- # (...)
67
+ ## Tips
68
+
69
+ To disable warnings, just set the following environment variable:
70
+
71
+ `RUBY_DEP_GEM_SILENCE_WARNINGS=1`
72
+
73
+
74
+ ## Roadmap
75
+
76
+ Pull Requests are welcome.
77
+
78
+ Plans include: reading supported Ruby from `.rubocop.yml` (`TargetRubyVersion` field).
49
79
 
50
- spec.required_ruby_version = RubyDep::Travis.new.version_constraint
51
- ```
52
80
 
53
81
  ## Development
54
82
 
@@ -1,3 +1,3 @@
1
1
  module RubyDep
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -0,0 +1,50 @@
1
+ module RubyDep
2
+ class Warning
3
+ MSG_BUGGY = 'RubyDep: WARNING: your Ruby is outdated/buggy.'\
4
+ ' Please upgrade.'.freeze
5
+
6
+ MSG_INSECURE = 'RubyDep: WARNING: your Ruby has security vulnerabilities!'\
7
+ ' Please upgrade!'.freeze
8
+
9
+ MSG_HOW_TO_DISABLE = ' (To disable warnings, set'\
10
+ ' RUBY_DEP_GEM_SILENCE_WARNINGS=1)'.freeze
11
+
12
+ def show_warnings
13
+ return if silenced?
14
+ case check_ruby
15
+ when :insecure
16
+ STDERR.puts MSG_INSECURE + MSG_HOW_TO_DISABLE
17
+ when :buggy
18
+ STDERR.puts MSG_BUGGY + MSG_HOW_TO_DISABLE
19
+ when :unknown
20
+ else
21
+ raise "Unknown problem type: #{problem.inspect}"
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ VERSION_INFO = {
28
+ '2.3.1' => :unknown,
29
+ '2.3.0' => :buggy,
30
+ '2.2.5' => :unknown,
31
+ '2.2.4' => :buggy,
32
+ '2.2.0' => :insecure,
33
+ '2.1.9' => :buggy,
34
+ '2.0.0' => :insecure
35
+ }.freeze
36
+
37
+ def check_ruby
38
+ version = Gem::Version.new(RUBY_VERSION)
39
+ VERSION_INFO.each do |ruby, status|
40
+ return status if version >= Gem::Version.new(ruby)
41
+ end
42
+ :insecure
43
+ end
44
+
45
+ def silenced?
46
+ value = ENV['RUBY_DEP_GEM_SILENCE_WARNINGS']
47
+ (value || '0') !~ /^0|false|no|n$/
48
+ end
49
+ end
50
+ end
data/ruby_dep.gemspec CHANGED
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- spec.add_development_dependency 'bundler', '~> 1.12.a'
31
+ spec.add_development_dependency 'bundler', '~> 1.11'
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_dep
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cezary Baginski
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.12.a
19
+ version: '1.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.12.a
26
+ version: '1.11'
27
27
  description: Creates a version constraint of supported Rubies,suitable for a gemspec
28
28
  file
29
29
  email:
@@ -46,6 +46,7 @@ files:
46
46
  - lib/ruby_dep.rb
47
47
  - lib/ruby_dep/travis.rb
48
48
  - lib/ruby_dep/version.rb
49
+ - lib/ruby_dep/warning.rb
49
50
  - ruby_dep.gemspec
50
51
  homepage: https://github.com/e2/ruby_dep
51
52
  licenses: