breezer 0.9.0 → 0.9.1

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: 6424e8a10398402701c4f9dc0aab3352aa59496df25c43b856d1e123d37da4ed
4
- data.tar.gz: 385ff3e95c6c0317ed1bd5176cef91c7aa75b5ef9e11ca189e0cfb8fa8845cc2
3
+ metadata.gz: e74d162c603c5b847156a19d964cfd416c25c438857b52fd41db29541f9a9247
4
+ data.tar.gz: 8811230f6e8501a695ae771ce2ed3f8fb7ca26206c0a78d5abc552c30a7d8f75
5
5
  SHA512:
6
- metadata.gz: 8b3d91c6e58a1d451aed9bfc520df9dd047fb5274e5d9ef3c5dd05affe1973714a52260124f2cde4f52a70ce7e3b1591862fd0c016b719460d37a439c37cbda4
7
- data.tar.gz: 72b8d93356851b5751d3306a93e6bc63f74221aedfa12ed1a9288883a01d950433dbfbb7c636d3631dc4c28e90f5bab1bed726f247a47e414d3ef9ca4bf57b2b
6
+ metadata.gz: bb5ad11225a914577596a3998df6efa5a2ef668c354c04d1b46fd22c71b78c6c7db79b727f116418de84c56466c7230ed71ce90fb5918ca4e1a03b29892079d3
7
+ data.tar.gz: e00cb84064da02d14599b880d79b5ff192d4592f10c3e2aaa6901db5baa4c0a8c2e3036e78905bad3fdf70f8fc2a09626dc610914af6f830387f6edf88f97c21
@@ -2,7 +2,7 @@ Metrics/CyclomaticComplexity:
2
2
  Max: 8
3
3
 
4
4
  Metrics/MethodLength:
5
- Max: 30
5
+ Max: 35
6
6
 
7
7
  Layout/LineLength:
8
8
  Max: 100
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- breezer (0.9.0)
4
+ breezer (0.9.1)
5
5
  bundler (> 1.0)
6
6
 
7
7
  GEM
@@ -15,18 +15,25 @@ module Breezer
15
15
  options = parse_options({ debug: false }, args)
16
16
  lockfile_file = options[:lockfile_file] || "#{gemfile_file}.lock"
17
17
 
18
+ # Will raise if files are not valid
19
+ check_files_presence!(gemfile_file, lockfile_file)
20
+
21
+ Breezer.freeze!(gemfile_file, lockfile_file, options)
22
+ end
23
+
24
+ # Check that the Gemfile and the Lockfile exists
25
+ def check_files_presence!(gemfile_file, lockfile_file)
26
+
18
27
  unless File.file?(gemfile_file)
19
28
  puts "Unable to find a Gemfile (searched in #{gemfile_file})"
20
29
  raise NoGemfileException, "Unable to find a Gemfile (searched in #{gemfile_file})"
21
30
  end
22
31
 
23
- unless File.file?(lockfile_file)
24
- puts "Unable to find a Lockfile (Gemfile.lock). If you don't have a Gemfile.lock yet, "\
25
- "you can run 'bundle install' first. (searched in #{lockfile_file})"
26
- raise NoLockfileException, "Unable to find a Lockfile (Gemfile.lock) (searched in #{lockfile_file})"
27
- end
32
+ return if File.file?(lockfile_file)
28
33
 
29
- Breezer.freeze!(gemfile_file, lockfile_file, options)
34
+ puts "Unable to find a Lockfile (Gemfile.lock). If you don't have a Gemfile.lock yet, "\
35
+ "you can run 'bundle install' first. (searched in #{lockfile_file})"
36
+ raise NoLockfileException, "Unable to find a Lockfile (Gemfile.lock) (searched in #{lockfile_file})"
30
37
  end
31
38
 
32
39
  def get_gemfile_file(args)
@@ -74,6 +81,7 @@ module Breezer
74
81
  exit(0)
75
82
  end
76
83
  end.parse!(argv)
84
+ options
77
85
  end
78
86
  end
79
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Breezer
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest/around/spec'
5
+ require 'breezer'
6
+
7
+ describe Breezer::Command do # rubocop:todo Metrics/BlockLength
8
+ around do |test|
9
+ files = Dir["#{File.dirname(__FILE__)}/samples/*"]
10
+ Dir.mktmpdir do |dir|
11
+ @dir = dir
12
+ FileUtils.cp files, dir
13
+ Bundler::SharedHelpers.chdir(dir) do
14
+ test.call
15
+ end
16
+ end
17
+ end
18
+
19
+ it 'can get_gemfile_file' do
20
+ _(Breezer::Command.get_gemfile_file([])).must_equal('./Gemfile')
21
+ _(Breezer::Command.get_gemfile_file(['..'])).must_equal('../Gemfile')
22
+ _(Breezer::Command.get_gemfile_file(['Gemfile'])).must_equal('Gemfile')
23
+ _(Breezer::Command.get_gemfile_file(['./Gemfile.checked'])).must_equal('./Gemfile.checked')
24
+ _(Breezer::Command.get_gemfile_file(['../../idontexist'])).must_equal('../../idontexist')
25
+ end
26
+
27
+ it 'can parse_options' do
28
+ _(Breezer::Command.parse_options({}, [])).must_equal({})
29
+ _(Breezer::Command.parse_options({}, %w[-l major])).must_equal(level: 'major')
30
+ _(Breezer::Command.parse_options({}, %w[-L Gemfile.look])).must_equal(lockfile_file: 'Gemfile.look')
31
+ _(Breezer::Command.parse_options({}, %w[-d])).must_equal(dry: true)
32
+ _(Breezer::Command.parse_options({}, %w[-o Gemfool])).must_equal(output: 'Gemfool')
33
+ _(Breezer::Command.parse_options({}, %w[-c])).must_equal(check: true)
34
+ end
35
+
36
+ it 'run without options' do
37
+ _specs = Breezer::Command.run!(%w[])
38
+ _(File.read('Gemfile')).must_equal File.read('Gemfile.final.patch')
39
+ end
40
+
41
+ it 'run with minor level options' do
42
+ _specs = Breezer::Command.run!(%w[Gemfile -l minor])
43
+ _(File.read('Gemfile')).must_equal File.read('Gemfile.final.minor')
44
+ end
45
+
46
+ it 'run with dry run' do
47
+ specs = Breezer::Command.run!(%w[Gemfile -d])
48
+ _(specs).must_equal File.read('Gemfile.final.patch')
49
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
50
+ end
51
+
52
+ it 'run with custom output' do
53
+ specs = Breezer::Command.run!(%w[Gemfile -o Gemfile.custom])
54
+
55
+ _(specs).must_equal File.read('Gemfile.final.patch')
56
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
57
+ _(File.read('Gemfile.custom')).must_equal File.read('Gemfile.final.patch')
58
+ end
59
+
60
+ it 'run with checks on invalid gemfile' do
61
+ specs = Breezer::Command.run!(%w[Gemfile -c])
62
+ _(specs).must_equal false
63
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
64
+ end
65
+
66
+ it 'run with checks on valid gemfile' do
67
+ specs = Breezer::Command.run!(%w[Gemfile.checked --lockfile=Gemfile.lock -c])
68
+ _(specs).must_equal true
69
+ end
70
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breezer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Aubin
@@ -123,6 +123,7 @@ files:
123
123
  - test/samples/Gemfile.final.patch
124
124
  - test/samples/Gemfile.lock
125
125
  - test/test_breezer.rb
126
+ - test/test_command.rb
126
127
  - test/test_freezer.rb
127
128
  - test/test_parser.rb
128
129
  homepage: http://rubygems.org/gems/breezer