brakecheck 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -14
- data/bin/brakecheck +9 -3
- data/brakecheck.gemspec +2 -12
- data/lib/brakecheck.rb +18 -37
- data/lib/brakecheck/rspec.rb +17 -0
- data/lib/brakecheck/version.rb +1 -1
- metadata +6 -48
- data/lib/bin_test.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e682c69de61ad736e0f3f3ffbc44dd429054cfd1
|
4
|
+
data.tar.gz: 281099bff9ad2c4b89b5acfe16a9239d98270ca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6b159898c555ba7324d825203a4a511d9e0ba9edd6e2d2a8a4849bf0a93883b99b4ea37fe55f37e77114dae59f8b1bdb335efd3090f6e36f2e583f7e489153a
|
7
|
+
data.tar.gz: 4cb5adf1d1e3893a60c81708a288340f6dc31add67c8743833609320edd7bdc27f27f69301ada907edf3ae2917f55de49e081e0f969c8932a13dcae3a1da26bc
|
data/README.md
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
# Brakecheck
|
2
2
|
|
3
|
-
Test breakage when important gems are stale.
|
4
|
-
|
5
|
-
## Why?!? What's wrong with Bundler?
|
6
|
-
|
7
|
-
We use brakeman regularly and it's important to keep that up to date. This breaks the build if brakeman is not current. Bundler still requires that somebody run bundle update.
|
3
|
+
Test breakage when important gems are stale, to always have the latest versions of rubocop/brakeman/bundler-audit etc.
|
8
4
|
|
9
5
|
## Installation
|
10
6
|
|
11
|
-
Add this line to your application's Gemfile:
|
12
7
|
|
13
8
|
```ruby
|
14
|
-
|
9
|
+
# Gemfile
|
10
|
+
gem 'brakecheck', group: :test, require: false
|
15
11
|
```
|
16
12
|
|
17
13
|
And then execute:
|
18
14
|
|
19
|
-
|
15
|
+
```
|
16
|
+
bundle
|
17
|
+
```
|
20
18
|
|
21
19
|
Or install it yourself as:
|
22
20
|
|
23
|
-
|
21
|
+
```
|
22
|
+
gem install brakecheck
|
23
|
+
```
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
### CLI
|
28
|
+
|
29
|
+
```
|
30
|
+
brakecheck rubocop
|
31
|
+
```
|
30
32
|
|
31
|
-
|
33
|
+
### RSpec
|
32
34
|
|
33
35
|
```ruby
|
34
|
-
require 'brakecheck'
|
36
|
+
require 'brakecheck/rspec'
|
35
37
|
|
36
38
|
describe "Brakeman" do
|
37
39
|
before do
|
data/bin/brakecheck
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'brakecheck'
|
3
|
+
abort "Need gem name as only argument" unless ARGV.size == 1
|
4
|
+
gem_name = ARGV[0]
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
success, message = Brakecheck::Core.compare(gem_name)
|
7
|
+
if success
|
8
|
+
puts message
|
9
|
+
else
|
10
|
+
abort message
|
11
|
+
end
|
data/brakecheck.gemspec
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'brakecheck/version'
|
1
|
+
require './lib/brakecheck/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = "brakecheck"
|
@@ -14,19 +11,12 @@ Gem::Specification.new do |spec|
|
|
14
11
|
spec.homepage = "https://github.com/apanzerj/brakecheck"
|
15
12
|
spec.license = "MIT"
|
16
13
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
14
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
spec.bindir = "bin"
|
21
15
|
spec.executables = ['brakecheck']
|
22
|
-
spec.require_paths = ["lib"]
|
23
16
|
|
24
17
|
spec.add_development_dependency "bundler", "~> 1.12"
|
25
18
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.
|
19
|
+
spec.add_development_dependency "rspec"
|
27
20
|
spec.add_development_dependency "webmock"
|
28
21
|
spec.add_development_dependency "pry"
|
29
|
-
spec.add_runtime_dependency "minitest"
|
30
|
-
spec.add_runtime_dependency "faraday"
|
31
|
-
spec.add_runtime_dependency "faraday_middleware"
|
32
22
|
end
|
data/lib/brakecheck.rb
CHANGED
@@ -1,51 +1,32 @@
|
|
1
1
|
require "brakecheck/version"
|
2
|
-
require "
|
3
|
-
require "
|
2
|
+
require "open-uri"
|
3
|
+
require "bundler"
|
4
4
|
|
5
5
|
module Brakecheck
|
6
6
|
class Core
|
7
|
-
|
7
|
+
RUBYGEMS_HOST = "https://rubygems.org"
|
8
|
+
LOCK = Bundler.default_lockfile
|
8
9
|
|
9
10
|
def self.latest(gem_name)
|
10
|
-
|
11
|
+
open("#{RUBYGEMS_HOST}/api/v1/versions/#{gem_name}/latest.json").read[/"version":"(.+?)"/, 1]
|
12
|
+
rescue StandardError
|
13
|
+
nil
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
faraday.use FaradayMiddleware::ParseJson
|
18
|
-
end
|
16
|
+
def self.local(gem_name)
|
17
|
+
lock = Bundler::LockfileParser.new(Bundler.read_file(LOCK))
|
18
|
+
return unless spec = lock.specs.detect { |s| s.name == gem_name }
|
19
|
+
spec.version.to_s
|
19
20
|
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Rspec
|
23
|
-
require 'rspec/expectations'
|
24
|
-
|
25
|
-
RSpec::Matchers.define :be_the_latest_version do
|
26
|
-
match do |gem_name|
|
27
|
-
spec_from_file = loaded_specs(gem_name)
|
28
|
-
Brakecheck::Core.latest(gem_name) == spec_from_file
|
29
|
-
end
|
30
21
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
"expected #{gem_name} to be #{Brakecheck::Core.latest(gem_name)} but was actually #{loaded_specs(gem_name)}."
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def loaded_specs(gem_name)
|
40
|
-
gem_here = specs.detect do |specs|
|
41
|
-
specs.name == gem_name
|
42
|
-
end
|
43
|
-
|
44
|
-
gem_here.nil? ? :not_in_bundle : gem_here.version.to_s
|
45
|
-
end
|
22
|
+
def self.compare(gem_name)
|
23
|
+
return [false, "#{gem_name} not found in #{LOCK.basename}"] unless local = local(gem_name)
|
24
|
+
return [false, "#{gem_name} not found on #{RUBYGEMS_HOST}"] unless latest = latest(gem_name)
|
46
25
|
|
47
|
-
|
48
|
-
|
26
|
+
if latest == local
|
27
|
+
[true, "Latest #{gem_name} #{latest} installed"]
|
28
|
+
else
|
29
|
+
[false, "Local version #{local} of #{gem_name} is not the latest version #{latest}"]
|
49
30
|
end
|
50
31
|
end
|
51
32
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'brakecheck'
|
2
|
+
require 'rspec/expectations'
|
3
|
+
|
4
|
+
module Brakecheck
|
5
|
+
module RSpec
|
6
|
+
::RSpec::Matchers.define :be_the_latest_version do
|
7
|
+
match do |gem_name|
|
8
|
+
success, @message = Brakecheck::Core.compare(gem_name)
|
9
|
+
success
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message do |_gem_name|
|
13
|
+
@message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/brakecheck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brakecheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Panzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -40,20 +40,6 @@ dependencies:
|
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: webmock
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: webmock
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,41 +67,13 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: faraday
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: faraday_middleware
|
70
|
+
name: pry
|
113
71
|
requirement: !ruby/object:Gem::Requirement
|
114
72
|
requirements:
|
115
73
|
- - ">="
|
116
74
|
- !ruby/object:Gem::Version
|
117
75
|
version: '0'
|
118
|
-
type: :
|
76
|
+
type: :development
|
119
77
|
prerelease: false
|
120
78
|
version_requirements: !ruby/object:Gem::Requirement
|
121
79
|
requirements:
|
@@ -142,8 +100,8 @@ files:
|
|
142
100
|
- bin/console
|
143
101
|
- bin/setup
|
144
102
|
- brakecheck.gemspec
|
145
|
-
- lib/bin_test.rb
|
146
103
|
- lib/brakecheck.rb
|
104
|
+
- lib/brakecheck/rspec.rb
|
147
105
|
- lib/brakecheck/version.rb
|
148
106
|
homepage: https://github.com/apanzerj/brakecheck
|
149
107
|
licenses:
|
data/lib/bin_test.rb
DELETED