ruby_dep 1.1.0 → 1.2.0

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: 6162cd8effed647293da60172ca50c44277bc7f1
4
- data.tar.gz: 1ca1c7888ea45b1531eae6608f38823bb7d26215
3
+ metadata.gz: 139539b2a5db649646809eb696ded2cdc83f22de
4
+ data.tar.gz: 2b0ba1b76e1c066696672d43faff2d77bf841e7c
5
5
  SHA512:
6
- metadata.gz: ef2e1a10793b65e5a6b785da3af395354f68240617d0f3e8ad739f723bf86efc0703f475991ae20f116eb4ad1c86270103a380e0d4ef3b49e99cd05ad20ed960
7
- data.tar.gz: c3c487439cbb6b9dc21aad2573d850a4e2795cb1c774fdac1f0a31716ed6810fa1c2b8941c829c3d36882c6e3ee18a090fe5eb0f617b8cf21ae7d8b74aeae1c4
6
+ metadata.gz: c7e5f69acb5b96a247fcd7dcab013a54a2141b31241e3e6cbbc047d519189ae7bab7d50a0d1ebdd1c5fa32ccb90753d8ffbdaeae48aefe172ba4fd3504b61dd9
7
+ data.tar.gz: fc40843fe82fd96af98ea6762134a8c8d31f89b6ab0732bc8f60cb4b2a328fb14ec3176c23221f528e1e4fa1e00280cf46ca60d2e95f591dae24daa25e5834d5
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ spec/examples.txt
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ bundler_args: --without development
3
4
  rvm:
4
5
  - 2.2.4
5
- before_install: gem install bundler -v 1.12.0.rc.4
6
+ - jruby-9.0.5.0
7
+ before_install: gem install bundler -v 1.12.1
data/README.md CHANGED
@@ -4,24 +4,31 @@
4
4
 
5
5
  ## The problem
6
6
 
7
- Your gem doesn't support all possible Ruby versions.
7
+ Your gem shouldn't (and likely doesn't) support all possible Ruby versions.
8
8
 
9
- And not all Ruby versions are secure to even have installed.
9
+ (And not all Ruby versions are secure to even be installed).
10
10
 
11
- So, you need to tell users which Ruby versions you support in:
11
+ You need a way to protect users who don't know about this. So, you need to tell users which Ruby versions you support in:
12
12
 
13
13
  1. Your gemspec
14
14
  2. Your README
15
15
  3. Your .travis.yml file
16
16
  4. Any issues you get about which version of Ruby is supported or not
17
17
 
18
- But maintaning that information in 4 different places breaks the principle of
18
+ But, maintaning that information in 4 different places breaks the principle of
19
19
  single responsibility.
20
20
 
21
+ And users often don't really "read" a README if they can avoid it.
22
+
21
23
 
22
24
  ## The solution
23
25
 
24
- This gems detects which versions of Ruby your project supports.
26
+ This gem helps you and your project users avoid Ruby version problems by:
27
+
28
+ - warning users if their Ruby is seriously outdated or contains serious vulnerabilities
29
+ - helps you manage which Ruby versions you actually support (and prevents installing other versions)
30
+
31
+ How? This gems detects which Ruby version users are using and which ones your project supports.
25
32
 
26
33
  It assumes you are using Travis and the versions listed in your `.travis.yml` are supported.
27
34
 
@@ -44,18 +51,17 @@ Also, you it can warn users if they are using an outdated version of Ruby.
44
51
  abort "Install 'ruby_dep' gem before building this gem"
45
52
  end
46
53
 
47
- s.add_development_dependency 'ruby_dep', '~> 1.0'
54
+ s.add_development_dependency 'ruby_dep', '~> 1.1'
48
55
  ```
49
56
 
50
57
  ### In your `README.md`:
51
58
 
52
59
  Replace your mentions of "supported Ruby versions" to point to the Travis build.
53
60
 
54
- (Or, you can point to the rubygems.org site where the required Ruby version is listed).
61
+ If users see their Ruby version "green" on Travis, it suggests it's supported, right?
55
62
 
56
- If it works on Travis, it's assumed to be supported, right?
63
+ (Or, you can point to the rubygems.org site where the required Ruby version is listed).
57
64
 
58
- If it fails, it isn't, right?
59
65
 
60
66
  ### In your library:
61
67
 
@@ -70,6 +76,17 @@ To disable warnings, just set the following environment variable:
70
76
 
71
77
  `RUBY_DEP_GEM_SILENCE_WARNINGS=1`
72
78
 
79
+ You can follow these rules of thumb:
80
+
81
+ 1. Avoid changing major version numbers, even if you're dropping a major version of Ruby (e.g. 1.9.2)
82
+ 2. If you want to support a current version, add it to your `.travis.yml` (e.g. Ruby 2.3.1)
83
+ 3. To support an earlier version of Ruby, add it to your `.travis.yml` and release a new gem version.
84
+ 4. If you want to support a range of Rubies, include the whole range without gaps in minor version numbers (e.g. 2.0.0, 2.1.0, 2.2.0, 2.3.0)
85
+ 5. If you just want to test a Ruby version (but not actually support it), put it into the "allow failures" part of your Travis build matrix.
86
+ 6. If you want to drop support for a Ruby, remove it from the `.travis.yml` and just bump your gem's minor number.
87
+
88
+ When in doubt, open an issue and just ask.
89
+
73
90
 
74
91
  ## Roadmap
75
92
 
@@ -1,5 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
+ require 'ruby_dep/travis/ruby_version'
4
+
3
5
  module RubyDep
4
6
  class Travis
5
7
  def version_constraint(filename = '.travis.yml')
@@ -10,13 +12,15 @@ module RubyDep
10
12
  lowest = lowest_supported(selected)
11
13
 
12
14
  ["~> #{lowest[0..1].join('.')}", ">= #{lowest.join('.')}"]
15
+ rescue RubyVersion::Error => ex
16
+ abort("RubyDep Error: #{ex.message}")
13
17
  end
14
18
 
15
19
  private
16
20
 
17
21
  def versions_for_latest_major(versions)
18
22
  by_major = versions.map do |x|
19
- Gem::Version.new(x).segments[0..2]
23
+ RubyVersion.new(x).segments[0..2]
20
24
  end.group_by(&:first)
21
25
 
22
26
  last_supported_major = by_major.keys.sort.last
@@ -0,0 +1,57 @@
1
+ module RubyDep
2
+ class Travis
3
+ class RubyVersion
4
+ REGEXP = /^
5
+ (?:
6
+ (?<engine>ruby|jruby)
7
+ -)?
8
+ (?<version>\d+\.\d+\.\d+(?:\.\d+)?)
9
+ (?:-p\d+)?
10
+ (?:-clang)?
11
+ $/x
12
+
13
+ class Error < RuntimeError
14
+ class Unrecognized < Error
15
+ def initialize(invalid_version_string)
16
+ @invalid_version_string = invalid_version_string
17
+ end
18
+
19
+ def message
20
+ "Unrecognized Ruby version: #{@invalid_version_string.inspect}"
21
+ end
22
+
23
+ class JRubyVersion < Unrecognized
24
+ def message
25
+ "Unrecognized JRuby version: #{@invalid_version_string.inspect}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ def initialize(travis_version_string)
32
+ ruby_version_string = version_for(travis_version_string)
33
+ @version = Gem::Version.new(ruby_version_string)
34
+ end
35
+
36
+ def segments
37
+ @version.segments
38
+ end
39
+
40
+ private
41
+
42
+ def version_for(travis_version_string)
43
+ match = REGEXP.match(travis_version_string)
44
+ raise Error::Unrecognized, travis_version_string unless match
45
+ return match[:version] unless match[:engine]
46
+ return jruby_version(match[:version]) if match[:engine] == 'jruby'
47
+ match[:version] # if match[:engine] == 'ruby'
48
+ end
49
+
50
+ def jruby_version(version)
51
+ return '2.2.3' if version == '9.0.5.0'
52
+ return '2.2.2' if version == '9.0.4.0'
53
+ raise Error::Unrecognized::JRubyVersion, version
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyDep
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -25,18 +25,26 @@ module RubyDep
25
25
  private
26
26
 
27
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
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.2.3' => :unknown, # jruby-9.0.5.0
40
+ '2.2.0' => :insecure
41
+ }
35
42
  }.freeze
36
43
 
37
44
  def check_ruby
38
45
  version = Gem::Version.new(RUBY_VERSION)
39
- VERSION_INFO.each do |ruby, status|
46
+ info = VERSION_INFO[RUBY_ENGINE] || {}
47
+ info.each do |ruby, status|
40
48
  return status if version >= Gem::Version.new(ruby)
41
49
  end
42
50
  :insecure
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.1.0
4
+ version: 1.2.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-04-26 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '1.12'
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.11'
26
+ version: '1.12'
27
27
  description: Creates a version constraint of supported Rubies,suitable for a gemspec
28
28
  file
29
29
  email:
@@ -36,18 +36,13 @@ files:
36
36
  - ".rspec"
37
37
  - ".rubocop.yml"
38
38
  - ".travis.yml"
39
- - Gemfile
40
- - Guardfile
41
39
  - LICENSE.txt
42
40
  - README.md
43
- - Rakefile
44
- - bin/console
45
- - bin/setup
46
41
  - lib/ruby_dep.rb
47
42
  - lib/ruby_dep/travis.rb
43
+ - lib/ruby_dep/travis/ruby_version.rb
48
44
  - lib/ruby_dep/version.rb
49
45
  - lib/ruby_dep/warning.rb
50
- - ruby_dep.gemspec
51
46
  homepage: https://github.com/e2/ruby_dep
52
47
  licenses:
53
48
  - MIT
@@ -63,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
58
  version: '2.2'
64
59
  - - ">="
65
60
  - !ruby/object:Gem::Version
66
- version: 2.2.4
61
+ version: 2.2.3
67
62
  required_rubygems_version: !ruby/object:Gem::Requirement
68
63
  requirements:
69
64
  - - ">="
@@ -71,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
66
  version: '0'
72
67
  requirements: []
73
68
  rubyforge_project:
74
- rubygems_version: 2.6.3
69
+ rubygems_version: 2.5.1
75
70
  signing_key:
76
71
  specification_version: 4
77
72
  summary: Extracts supported Ruby versions from Travis file
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in ruby_dep.gemspec
4
- gemspec
5
-
6
- gem 'rake'
7
-
8
- group :development do
9
- gem 'rubocop', '~> 0.39.0'
10
- gem 'guard-rubocop', '~> 1.2'
11
- gem 'guard-rspec', '~> 4.6'
12
- end
13
-
14
- group :test do
15
- gem 'rspec', '~> 3.4'
16
- end
data/Guardfile DELETED
@@ -1,77 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- ## Uncomment and set this to only include directories you want to watch
5
- # directories %w(app lib config test spec features) \
6
- # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
-
8
- ## Note: if you are using the `directories` clause above and you are not
9
- ## watching the project directory ('.'), then you will want to move
10
- ## the Guardfile to a watched dir and symlink it back, e.g.
11
- #
12
- # $ mkdir config
13
- # $ mv Guardfile config/
14
- # $ ln -s config/Guardfile .
15
- #
16
- # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
-
18
- # Note: The cmd option is now required due to the increasing number of ways
19
- # rspec may be run, below are examples of the most common uses.
20
- # * bundler: 'bundle exec rspec'
21
- # * bundler binstubs: 'bin/rspec'
22
- # * spring: 'bin/rspec' (This will use spring if running and you have
23
- # installed the spring binstubs per the docs)
24
- # * zeus: 'zeus rspec' (requires the server to be started separately)
25
- # * 'just' rspec: 'rspec'
26
-
27
- group :specs, halt_on_fail: true do
28
- guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
29
- require 'guard/rspec/dsl'
30
- dsl = Guard::RSpec::Dsl.new(self)
31
-
32
- # Feel free to open issues for suggestions and improvements
33
-
34
- # RSpec files
35
- rspec = dsl.rspec
36
- watch(rspec.spec_helper) { rspec.spec_dir }
37
- watch(rspec.spec_support) { rspec.spec_dir }
38
- watch(rspec.spec_files)
39
-
40
- # Ruby files
41
- ruby = dsl.ruby
42
- dsl.watch_spec_files_for(ruby.lib_files)
43
-
44
- # Rails files
45
- rails = dsl.rails(view_extensions: %w(erb haml slim))
46
- dsl.watch_spec_files_for(rails.app_files)
47
- dsl.watch_spec_files_for(rails.views)
48
-
49
- watch(rails.controllers) do |m|
50
- [
51
- rspec.spec.call("routing/#{m[1]}_routing"),
52
- rspec.spec.call("controllers/#{m[1]}_controller"),
53
- rspec.spec.call("acceptance/#{m[1]}")
54
- ]
55
- end
56
-
57
- # Rails config changes
58
- watch(rails.spec_helper) { rspec.spec_dir }
59
- watch(rails.routes) { "#{rspec.spec_dir}/routing" }
60
- watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
61
-
62
- # Capybara features specs
63
- watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
64
- watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
65
-
66
- # Turnip features and steps
67
- watch(%r{^spec/acceptance/(.+)\.feature$})
68
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
69
- Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
70
- end
71
- end
72
-
73
- guard :rubocop do
74
- watch(/.+\.rb$/)
75
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
76
- end
77
- end
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec) do |task|
5
- task.verbose = false
6
- end
7
-
8
- task default: :spec
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'ruby_dep'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,32 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ruby_dep/version'
5
-
6
- # Yes, inception: we're using this ourselves
7
- require 'ruby_dep/travis'
8
-
9
- Gem::Specification.new do |spec|
10
- spec.name = 'ruby_dep'
11
- spec.version = RubyDep::VERSION
12
- spec.authors = ['Cezary Baginski']
13
- spec.email = ['cezary@chronomantic.net']
14
-
15
- spec.summary = 'Extracts supported Ruby versions from Travis file'
16
- spec.description = 'Creates a version constraint of supported Rubies,' \
17
- 'suitable for a gemspec file'
18
- spec.homepage = 'https://github.com/e2/ruby_dep'
19
- spec.license = 'MIT'
20
-
21
- spec.required_ruby_version = RubyDep::Travis.new.version_constraint
22
-
23
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
- f.match(%r{^(test|spec|features)/})
25
- end
26
-
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
30
-
31
- spec.add_development_dependency 'bundler', '~> 1.11'
32
- end