README.md in ruby_dep-1.0.0 vs README.md in ruby_dep-1.1.0

- old
+ new

@@ -1,55 +1,83 @@ # RubyDep -Helps with various Ruby version management activities, such as: +[![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) -1. Reading supported Ruby version from a .travis.yml file -2. More stuff planned (reading TargetRubyVersion from .rubocop.yml file?) +## The problem -Reason: tests are the best indicator of compatibility. +Your gem doesn't support all possible Ruby versions. -So, it doesn't make mention the supported Ruby version(s) in: +And not all Ruby versions are secure to even have installed. -1. your gemspec -2. your README -3. your .travis.yml file +So, you need to tell users which Ruby versions you support in: -(That breaks the principle of single responsibility). +1. Your gemspec +2. Your README +3. Your .travis.yml file +4. Any issues you get about which version of Ruby is supported or not -Instead, it's better to: +But maintaning that information in 4 different places breaks the principle of +single responsibility. -- point to the Travis build in your README (or your gem home page on rubygems.org) -- extract the supported versions from your .travis.yml -- set the versions automatically in your Gemspec +## The solution -## Installation +This gems detects which versions of Ruby your project supports. -Add this line to your application's Gemfile: +It assumes you are using Travis and the versions listed in your `.travis.yml` are supported. +This helps you limit the Ruby versions you support - just by adding/removing entries in your Travis configuration file. + +Also, you it can warn users if they are using an outdated version of Ruby. + +(Or one with security vulnerabilities). + + +## Usage + +### E.g. in your gemspec file: + ```ruby -gem 'ruby_dep' + begin + require "ruby_dep/travis" + s.required_ruby_version = RubyDep::Travis.new.version_constraint + rescue LoadError + abort "Install 'ruby_dep' gem before building this gem" + end + + s.add_development_dependency 'ruby_dep', '~> 1.0' ``` -And then execute: +### In your `README.md`: - $ bundle +Replace your mentions of "supported Ruby versions" to point to the Travis build. -Or install it yourself as: +(Or, you can point to the rubygems.org site where the required Ruby version is listed). - $ gem install ruby_dep +If it works on Travis, it's assumed to be supported, right? -## Usage +If it fails, it isn't, right? -E.g. in your gemspec file: +### In your library: ```ruby -require 'ruby_dep' +require 'ruby_dep/warnings' +RubyDep::Warning.show_warnings +``` -# (...) +## Tips -spec.required_ruby_version = RubyDep::Travis.new.version_constraint -``` +To disable warnings, just set the following environment variable: + +`RUBY_DEP_GEM_SILENCE_WARNINGS=1` + + +## Roadmap + +Pull Requests are welcome. + +Plans include: reading supported Ruby from `.rubocop.yml` (`TargetRubyVersion` field). + ## Development Use `rake` to run tests.