bundler-advise 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eeda25d3d3de4dfbbc3068bbc557e30e3e4ee53a
4
- data.tar.gz: 7530da925c37770508dc2287302d7c9c972e8068
3
+ metadata.gz: 38cee1f39e9fa2eb6f276c900c68f5db15322f10
4
+ data.tar.gz: 21550b726a1c7983a28bf63f356416b07e1fde90
5
5
  SHA512:
6
- metadata.gz: 6eeefba5041fcea4c9081f7050b34d94fb2110092f25d8cacacf31b65878930fe56d3925aea2275e118ac7c029c07b9a444aa4d0b65db45ee19215dc8c19a93f
7
- data.tar.gz: af14055e3ed6337af33731cd431fe20425a445b066d827d6da643d0a5460639f3242e9cf5f7ec7a1414d94ff7ea6f10fc8f3c516ef9d6ef487d375b12e485dbf
6
+ metadata.gz: 2461d7d8e80437d77e1ff0f20eb5aec62e8d544d758dc322e6052bd32ce357b168f8cd0b46cc854556da7237a4ee228f0b5570446dcd226454951f0eac295e0d
7
+ data.tar.gz: 389bf42f21a3fdc56d590a113da98e2430f621be825767dd657913da591313fcd2b9e749a471f0b359c8a7f13fb4ef11f04931a3cd70b8c11d270f0bc1e6e0e1
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/chrismo/bundler-advise'
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0")
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'git'
23
23
  spec.add_dependency 'bundler', '~> 1.10'
24
24
 
25
+ spec.add_development_dependency 'bundler-fixture', '~> 1.0'
25
26
  spec.add_development_dependency 'pry'
26
27
  spec.add_development_dependency 'rake', '~> 10.0'
27
28
  spec.add_development_dependency 'rspec'
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Advise
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-advise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-06 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler-fixture
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,12 +117,6 @@ files:
103
117
  - lib/bundler/advise/advisory.rb
104
118
  - lib/bundler/advise/gem_adviser.rb
105
119
  - lib/bundler/advise/version.rb
106
- - spec/bundler/advisories_spec.rb
107
- - spec/bundler/advisory_spec.rb
108
- - spec/bundler/gem_adviser_spec.rb
109
- - spec/fixture/advisories_fixture.rb
110
- - spec/fixture/bundler_fixture.rb
111
- - spec/spec_helper.rb
112
120
  homepage: https://github.com/chrismo/bundler-advise
113
121
  licenses:
114
122
  - MIT
@@ -1,60 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- describe Advisories do
4
- context 'defaults' do
5
- it 'should default to home dir' do
6
- Advisories.new.dir.should == File.expand_path('~/.ruby-advisory-db')
7
- end
8
-
9
- it 'should default to rubysec ruby-advisory-db' do
10
- Advisories.new.repo.should == 'git@github.com:rubysec/ruby-advisory-db.git'
11
- end
12
- end
13
-
14
- context 'git clone/updates' do
15
- before do
16
- @a = Advisories.new(
17
- dir: File.join(Dir.tmpdir, '.ruby-advisory-db'),
18
- repo: 'git@github.com:chrismo/bundler-advise.git'
19
- )
20
- end
21
-
22
- after do
23
- FileUtils.rmtree @a.dir
24
- end
25
-
26
- it 'should clone if no copy exists' do
27
- File.exist?(@a.dir).should_not be true
28
- @a.update
29
- File.exist?(@a.dir).should be true
30
- File.exist?(File.join(@a.dir, '.git')).should be true
31
- end
32
-
33
- it 'should pull if working dir exists' do
34
- File.exist?(@a.dir).should_not be true
35
- @a.update
36
- File.exist?(File.join(@a.dir, '.git')).should be true
37
- @a.update
38
- end
39
-
40
- it 'should error handle messed up dir' do
41
- FileUtils.makedirs @a.dir
42
- lambda { @a.update }.should raise_error(/problem with working dir.*#{Regexp.escape(@a.dir)}/)
43
- end
44
-
45
- it 'should clean update a messed up dir' do
46
- FileUtils.makedirs @a.dir
47
- @a.clean_update!
48
- File.exist?(File.join(@a.dir, '.git')).should be true
49
- end
50
- end
51
-
52
- it 'should retrieve advisories for a gem' do
53
- @a = Advisories.new(dir: fixture_dir)
54
- ads = @a.gem_advisories_for('bar')
55
- ads.length.should == 1
56
- ad = ads.first
57
- ad.gem.should == 'bar'
58
- ad.patched_versions.should == [Gem::Requirement.create('>= 1.0.2')]
59
- end
60
- end
@@ -1,61 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- describe Advisory do
4
- context 'persistence' do
5
- it 'should parse the yummy yml' do
6
- ad = Advisory.from_yml(File.join(fixture_dir, 'gems', 'bar', 'bar-1_0_1.yml'))
7
- ad.id.should == 'bar-1_0_1'
8
- ad.gem.should == 'bar'
9
- ad.url.should == 'http://bar-gem-is-awesome.com'
10
- ad.title.should == 'bar 1.0.1 might explode your spleen'
11
- ad.date.should == DateTime.parse('2015-11-18')
12
- ad.description.should == 'This version could, like, explode your spleen if taken internally'
13
- ad.unaffected_versions.should == [Gem::Requirement.create('1.0.0')]
14
- ad.patched_versions.should == [Gem::Requirement.create('>= 1.0.2')]
15
- end
16
-
17
- it 'should output back to yaml as hash' do
18
- yml_fn = File.join(fixture_dir, 'gems', 'bar', 'bar-1_0_1.yml')
19
- actual_yml = File.read(yml_fn)
20
- ad = Advisory.from_yml(yml_fn)
21
- ad.to_yaml.should == actual_yml
22
- end
23
- end
24
-
25
- it 'should determine if patched' do
26
- ad = Advisory.new(patched_versions: '>= 1.4.3')
27
- ad.is_not_patched?('1.4.2').should be true
28
- ad.is_not_patched?('1.4.3').should be false
29
- ad.is_not_patched?('1.4.4').should be false
30
-
31
- ad.is_affected?('1.4.2').should be true
32
- ad.is_affected?('1.4.3').should be false
33
- ad.is_affected?('1.4.4').should be false
34
- end
35
-
36
- it 'should determine if unaffected' do
37
- ad = Advisory.new(unaffected_versions: '>= 1.4.3')
38
- ad.is_not_unaffected?('1.4.2').should be true
39
- ad.is_not_unaffected?('1.4.3').should be false
40
- ad.is_not_unaffected?('1.4.4').should be false
41
-
42
- ad.is_affected?('1.4.2').should be true
43
- ad.is_affected?('1.4.3').should be false
44
- ad.is_affected?('1.4.4').should be false
45
- end
46
-
47
- it 'should have sane defaults if patched and unaffected not specified' do
48
- ad = Advisory.new
49
- ad.is_not_unaffected?('1.4.2').should be true
50
- ad.is_not_patched?('1.4.2').should be true
51
- ad.is_affected?('1.4.2').should be true
52
- end
53
-
54
- it 'should work well if both specified' do
55
- ad = Advisory.new(unaffected_versions: '< 1.3.0', patched_versions: '>= 1.4.3')
56
- ad.is_affected?('1.2.0').should be false
57
- ad.is_affected?('1.3.9').should be true
58
- ad.is_affected?('1.4.2').should be true
59
- ad.is_affected?('1.4.3').should be false
60
- end
61
- end
@@ -1,64 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- describe GemAdviser do
4
- before do
5
- @bf = BundlerFixture.new
6
- @bf.create_lockfile(gem_specs: [
7
- @bf.create_spec('foo', '1.2.3', {'quux' => '~> 1.4'}),
8
- @bf.create_spec('bar', '5.6'),
9
- @bf.create_spec('quux', '1.4.3')
10
- ])
11
-
12
- @af = AdvisoriesFixture.new
13
- end
14
-
15
- def dump
16
- puts File.read(File.join(@bf.dir, 'Gemfile.lock'))
17
- end
18
-
19
- after do
20
- FileUtils.rmtree @af.clean_up
21
- FileUtils.rmtree @bf.clean_up
22
- end
23
-
24
- it 'should find one matching advisories' do
25
- @af.save_advisory(Advisory.new(gem: 'quux', patched_versions: '>= 1.4.5'))
26
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
27
- ga.scan_lockfile.map(&:gem).should == ['quux']
28
- end
29
-
30
- it 'should not find one non-matching advisories' do
31
- @af.save_advisory(Advisory.new(gem: 'quux', patched_versions: '>= 1.4.2'))
32
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
33
- ga.scan_lockfile.map(&:gem).should be_empty
34
- end
35
-
36
- it 'should find one matching from many advisories' do
37
- @af.save_advisory(Advisory.new(gem: 'quux', patched_versions: '>= 1.4.5'))
38
- @af.save_advisory(Advisory.new(gem: 'quux', patched_versions: '>= 1.4.2'))
39
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
40
- ga.scan_lockfile.map(&:gem).should == ['quux']
41
- end
42
-
43
- it 'should find many matching from many advisories' do
44
- @af.save_advisory(Advisory.new(gem: 'quux', date: '2014-01-12', patched_versions: '>= 1.4.5'))
45
- @af.save_advisory(Advisory.new(gem: 'quux', date: '2014-01-13', patched_versions: '>= 1.4.4'))
46
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
47
- ga.scan_lockfile.map(&:date).should == ['2014-01-12', '2014-01-13']
48
- end
49
-
50
- it 'should find many gems matching from many advisories' do
51
- @af.save_advisory(Advisory.new(gem: 'quux', patched_versions: '>= 1.4.5'))
52
- @af.save_advisory(Advisory.new(gem: 'bar', patched_versions: '>= 6.0'))
53
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
54
- ga.scan_lockfile.map(&:gem).should == ['bar', 'quux']
55
- end
56
-
57
- it 'should skip matching but unaffected' do
58
- @af.save_advisory(Advisory.new(gem: 'quux',
59
- unaffected_versions: '~> 1.4.0',
60
- patched_versions: '>= 1.6.0'))
61
- ga = GemAdviser.new(dir: @bf.dir, advisories: Advisories.new(dir: @af.dir))
62
- ga.scan_lockfile.map(&:gem).should be_empty
63
- end
64
- end
@@ -1,20 +0,0 @@
1
- class AdvisoriesFixture
2
- attr_reader :dir
3
-
4
- def initialize
5
- @dir = File.join(Dir.tmpdir, 'advisory_db')
6
- FileUtils.makedirs @dir
7
- end
8
-
9
- def clean_up
10
- FileUtils.rmtree @dir
11
- end
12
-
13
- def save_advisory(ad)
14
- gem_path = File.join(@dir, 'gems', ad.gem)
15
- FileUtils.makedirs gem_path
16
- last_fn = Dir[File.join(gem_path, '*yml')].last || '000.yml'
17
- next_fn = "#{File.basename(last_fn, '.yml').next}.yml"
18
- File.open(File.join(gem_path, next_fn), 'wb') { |f| f.print ad.to_yaml }
19
- end
20
- end
@@ -1,44 +0,0 @@
1
- class BundlerFixture
2
- attr_reader :dir
3
-
4
- def initialize
5
- @dir = File.join(Dir.tmpdir, 'fake_project_root')
6
- FileUtils.makedirs @dir
7
- end
8
-
9
- def clean_up
10
- FileUtils.rmtree @dir
11
- end
12
-
13
- def create_lockfile(gem_specs:)
14
- dir = @dir
15
- index = Bundler::Index.new
16
- deps = []
17
- gem_specs.each do |g|
18
- index << g
19
- deps << Bundler::DepProxy.new(Bundler::Dependency.new(g.name, g.version), g.platform)
20
- end
21
- spec_set = Bundler::Resolver.resolve(deps, index)
22
-
23
- sources = Bundler::SourceList.new
24
- sources.add_rubygems_remote('https://rubygems.org')
25
- spec_set.each { |s| s.source = sources.rubygems_sources.first }
26
-
27
- gemfile_fn = File.join(dir, 'Gemfile.lock')
28
- defn = Bundler::Definition.new(gemfile_fn, deps.map(&:dep), sources, true)
29
- defn.instance_variable_set('@index', index)
30
- defn.instance_variable_set('@resolve', spec_set)
31
- defn.lock(gemfile_fn)
32
- end
33
-
34
- def create_spec(name, version, dependencies={})
35
- Gem::Specification.new do |s|
36
- s.name = name
37
- s.version = Gem::Version.new(version)
38
- s.platform = 'ruby'
39
- dependencies.each do |name, requirement|
40
- s.add_dependency name, requirement
41
- end
42
- end
43
- end
44
- end
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'bundler/advise'
3
-
4
- include Bundler::Advise
5
-
6
- RSpec.configure do |c|
7
- c.expect_with(:rspec) { |co| co.syntax = :should }
8
- end
9
-
10
- require_relative 'fixture/advisories_fixture'
11
- require_relative 'fixture/bundler_fixture'
12
-
13
- def fixture_dir
14
- File.expand_path('../fixture', __FILE__)
15
- end