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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f86fc95232d0cd5d6053045857fddb8e219701d
4
- data.tar.gz: 7adf75f80ca779ed4fa29118fcb4c1b4e4efd9ea
3
+ metadata.gz: e682c69de61ad736e0f3f3ffbc44dd429054cfd1
4
+ data.tar.gz: 281099bff9ad2c4b89b5acfe16a9239d98270ca2
5
5
  SHA512:
6
- metadata.gz: f66c71aff2839bed21fc02360495bf19c6cb0eee9d439c5a91fa15f53ca3216aac0ea6488677bfeb7580c59ad8ca1dd37c2294733b8401a96f70aaba7cbcce11
7
- data.tar.gz: f091d34aa833949d3f44491bf40dfff2c68cfa37aab9bb3e2e92e7652ed06c071f6367fb22daf4af8f96958a6a035bf02fd7240315da846396004a691d57593b
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
- gem 'brakecheck'
9
+ # Gemfile
10
+ gem 'brakecheck', group: :test, require: false
15
11
  ```
16
12
 
17
13
  And then execute:
18
14
 
19
- $ bundle
15
+ ```
16
+ bundle
17
+ ```
20
18
 
21
19
  Or install it yourself as:
22
20
 
23
- $ gem install brakecheck
21
+ ```
22
+ gem install brakecheck
23
+ ```
24
24
 
25
25
  ## Usage
26
26
 
27
- 1. Create a basic test
28
- 2. `include Brakecheck`
29
- 3. expect(gem_name).to be_the_latest_version
27
+ ### CLI
28
+
29
+ ```
30
+ brakecheck rubocop
31
+ ```
30
32
 
31
- Full example:
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
@@ -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
- require "bundler/setup"
4
- require 'rspec'
5
- RSpec::Core::Runner.run([File.join(__FILE__, "..", "..", "lib", "bin_test.rb")])
6
+ success, message = Brakecheck::Core.compare(gem_name)
7
+ if success
8
+ puts message
9
+ else
10
+ abort message
11
+ end
@@ -1,7 +1,4 @@
1
- # coding: utf-8
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.add_runtime_dependency "rspec", "~> 3.0"
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
@@ -1,51 +1,32 @@
1
1
  require "brakecheck/version"
2
- require "faraday"
3
- require "faraday_middleware"
2
+ require "open-uri"
3
+ require "bundler"
4
4
 
5
5
  module Brakecheck
6
6
  class Core
7
- attr_reader :client
7
+ RUBYGEMS_HOST = "https://rubygems.org"
8
+ LOCK = Bundler.default_lockfile
8
9
 
9
10
  def self.latest(gem_name)
10
- new.client.get("#{gem_name}/latest.json").body['version']
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 client
14
- @client = Faraday.new(:url => "https://rubygems.org/api/v1/versions") do |faraday|
15
- faraday.request :url_encoded
16
- faraday.adapter Faraday.default_adapter
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
- failure_message do |gem_name|
32
- if loaded_specs(gem_name) == :not_in_bundle
33
- "that gem is not in the bundle"
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
- def specs
48
- @specs ||= Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)).specs
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
@@ -1,3 +1,3 @@
1
1
  module Brakecheck
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
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.8
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-11 00:00:00.000000000 Z
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: pry
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: minitest
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: :runtime
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:
@@ -1,10 +0,0 @@
1
- require "brakecheck"
2
- RSpec.describe ENV['BRAKECHECK_GEM'] do
3
- before do
4
- WebMock.disable_net_connect!(allow: 'rubygems.org') if defined? WebMock
5
- end
6
-
7
- it 'is the lastest version' do
8
- expect(ENV['BRAKECHECK_GEM']).to be_the_latest_version
9
- end
10
- end