strong_versions 0.2.1 → 0.3.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
  SHA256:
3
- metadata.gz: 1e9137c23cce3c8cf3ca835657b64fbfe74761fad58f14f9572020d5360dc4bf
4
- data.tar.gz: 66e4f5b06fc23363b9a83016fcf2140006d124fef6813228d4cd6c6d8d4b5a1e
3
+ metadata.gz: 1c22d65fb8950d91b5f8303c8f5eba7842a39d6ea9410b70071ccd7cf5944a0c
4
+ data.tar.gz: 840a9a7c0dd86371ca55a2b8884a7a7b86688342c1cadd038d501ffd864f6166
5
5
  SHA512:
6
- metadata.gz: 1b5cfc945a0cbe534a01010b78a263c380943591889839b07a271577a7815ebe9ec03eaed6ac5247cfdbcc3e94ce8f7d9986cb85a8ba7684e45cd0edf3a59cca
7
- data.tar.gz: fca7aa528b8aff694f213ec0e8aea6744185060556090a2dfe89d3fb5e2bd95639816832b91ead81203fabb01e1187eac237ea0060e38d86f693458e8d9e5475
6
+ metadata.gz: 460734cdc1a68bdc008f7bb496895da1f0735e9e4b29db2a1f816f41895717cae236ae27e14242ca92f25d0fe5346ff1cdb1532115a8997f63f86dfcee0e10ab
7
+ data.tar.gz: 634139436aec6caa3d9be60723a6fea378c702799046ffc6929d84e38a61d1927cf8c5f3820dc79c5f67c4e2628c0238da7caeb0fd71b57536b4cea897d5555a
data/README.md CHANGED
@@ -8,7 +8,7 @@ Is right here inside us
8
8
 
9
9
  # Overview
10
10
 
11
- _StrongVersions_ is a _Bundler_ plugin that enforces a strict policy on your `Gemfile` requirements:
11
+ _StrongVersions_ enforces a strict policy on your `Gemfile` requirements:
12
12
 
13
13
  * The pessimistic `~>` operator must be used for all gem requirement definitions.
14
14
  * If the gem version is greater than 1, the requirement format must be `major.minor`, e.g. `'~> 2.5`'
@@ -17,18 +17,18 @@ _StrongVersions_ is a _Bundler_ plugin that enforces a strict policy on your `Ge
17
17
  * All gems with a `path` or `git` source are ignored, e.g. `path: '/path/to/gem'`, `git: 'https://github.com/bobf/strong_versions'`
18
18
  * All gems specified in the [ignore list](#ignore) are ignored.
19
19
 
20
- Any gems that do not satisfy these rules will cause `bundle install` to fail and give output detailing which gems did not meet the standard and why.
20
+ Any gems that do not satisfy these rules will be included in included in the _StrongVersions_ output with details on why they did not meet the standard.
21
21
 
22
- The benefit of applying this standard is that it [should](https://semver.org/) always be relatively safe to run `bundle update` to upgrade to the latest compatible versions of all dependencies.
22
+ The benefit of applying this standard is that, if all gems follow [Semantic Versioning](https://semver.org/) always be relatively safe to run `bundle update` to upgrade to the latest compatible versions of all dependencies. Running `bundle update` often brings advantages both in terms of bug fixes and security updates.
23
23
 
24
24
  ![StrongVersions](doc/images/strong-versions-example.png)
25
25
 
26
26
  ## Installation
27
27
 
28
- Add the plugin to your `Gemfile`
28
+ Add the gem to your `Gemfile`
29
29
 
30
30
  ```ruby
31
- plugin 'strong_versions', '~> 0.2.1'
31
+ gem 'strong_versions', '~> 0.3.0'
32
32
  ```
33
33
 
34
34
  And rebuild your bundle:
@@ -37,15 +37,24 @@ And rebuild your bundle:
37
37
  $ bundle install
38
38
  ```
39
39
 
40
+ Or install yourself:
41
+ ```bash
42
+ $ gem install strong_versions -v '0.3.0'
43
+ ```
44
+
40
45
  ## Usage
41
46
 
42
- _StrongVersions_ will automatically hook into _Bundler_ and raise an exception every time you call `bundle install` if there are any errors.
47
+ _StrongVersions_ is invoked with a provided executable:
43
48
 
44
- If you prefer to see a warning rather than raise an exception, see [raise or warn](#raise_or_warn).
49
+ ```bash
50
+ $ bundle exec strong_versions
51
+ ```
52
+
53
+ The executable will output all non-passing gems and will return an exit code of `1` on failure, `0` on success (i.e. all gems passing).
45
54
 
46
55
  ### Exclusions
47
56
 
48
- <a name="ignore"></a>You can exclude any gems from this list by adding them to the `ignore` section of `.strong_versions.yml` in your project root, e.g.:
57
+ <a name="ignore"></a>You can tell _StrongVersions_ to ignore any of your gems (e.g. those that don't follow _semantic versioning_) by adding them to the `ignore` section of `.strong_versions.yml` in your project root, e.g.:
49
58
 
50
59
  ```yaml
51
60
  # .strong_versions.yml
@@ -53,19 +62,6 @@ ignore:
53
62
  - rails
54
63
  ```
55
64
 
56
- ### Raise or Warn
57
-
58
- <a name="raise_or_warn"></a>_StrongVersions_ can be configured to raise an exception (default) or output a warning when the standard is not met.
59
-
60
- Warning instead of raising is especially useful when you want to add new dependencies to your `Gemfile` as you can initially set them with loose requirements and then update the `Gemfile` with more precise values based on your new `Gemfile.lock`.
61
-
62
- Set `on_failure` in `.strong_versions.yml` to either `raise` or `warn`:
63
-
64
- ```yaml
65
- # .strong_versions.yml
66
- on_failure: warn
67
- ```
68
-
69
65
  ## Contributing
70
66
 
71
67
  Fork and create a pull request.
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'strong_versions'
4
+
5
+ config_path = Bundler.root.join('.strong_versions.yml')
6
+ config = StrongVersions::Config.new(config_path)
7
+ dependencies = Bundler.definition.dependencies
8
+
9
+ valid = StrongVersions::Dependencies.new(dependencies).validate!(
10
+ except: config.exceptions,
11
+ on_failure: 'warn'
12
+ )
13
+
14
+ exit 0 if valid
15
+ exit 1
Binary file
@@ -10,7 +10,7 @@ module StrongVersions
10
10
  end
11
11
 
12
12
  def validate!(options = {})
13
- return if validate(options)
13
+ return true if validate(options)
14
14
 
15
15
  on_failure = options.fetch(:on_failure, 'raise')
16
16
  case on_failure
@@ -19,6 +19,8 @@ module StrongVersions
19
19
  when 'warn'
20
20
  warn_failure
21
21
  end
22
+
23
+ false
22
24
  end
23
25
 
24
26
  def validate(options = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StrongVersions
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/plugins.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # XXX: StrongVersions was intended to be a Bundler plugin but, unfortunately,
4
+ # the plugin system is still in its infancy and has many issues which make it
5
+ # not fit for purpose. If those issues get resolved then I will re-add
6
+ # documentation for use as a plugin.
7
+
3
8
  require 'strong_versions'
4
9
 
5
10
  Bundler::Plugin.add_hook('before-install-all') do |dependencies|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  end
22
22
 
23
23
  spec.bindir = 'bin'
24
- spec.executables = []
24
+ spec.executables = %w[strong_versions]
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  # Rails 4 is locked to I18n ~> 0.7 so, unfortunately, until we are ready to
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_versions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -111,7 +111,8 @@ dependencies:
111
111
  description: Ensure your gems are appropriately versioned
112
112
  email:
113
113
  - robertanthonyfarrell@gmail.com
114
- executables: []
114
+ executables:
115
+ - strong_versions
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
@@ -129,6 +130,7 @@ files:
129
130
  - bin/rspec
130
131
  - bin/rubocop
131
132
  - bin/setup
133
+ - bin/strong_versions
132
134
  - config/locales/en.yml
133
135
  - doc/images/strong-versions-example.png
134
136
  - lib/strong_versions.rb