breezer 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8f8f19ad6f1beb64e5de2db0bbb603e5111e58898f6fba612aac9b36cdee9e11
4
+ data.tar.gz: 6fcf0b5f2de83d2257e8084e39be2cd0457c1714c03bd8f8a925c9deea9c484c
5
+ SHA512:
6
+ metadata.gz: 0e60d519e028b0833ed30d71b1bcffd4aeb7515f8189c278a7b3070b74b7dc8fe7249eb6ba566e3d7a81956346a108199804dc112acc4bf91246cb8ad70acd38
7
+ data.tar.gz: 00a05a1b47bf03df92c20a557a6cf38d676699e9bde45c7e42aaac2f4926c820f673366cc2023115ec936b0effcdc103b26e5a081157f01e84933b1b76f2baaa
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ breezer (0.3.0)
5
+ bundler (> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ bump (0.8.0)
11
+ minitest (5.14.0)
12
+ minitest-around (0.5.0)
13
+ minitest (~> 5.0)
14
+ rake (13.0.1)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ breezer!
21
+ bump
22
+ minitest
23
+ minitest-around
24
+ rake (>= 10.0.0)
25
+
26
+ BUNDLED WITH
27
+ 2.1.4
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # breezer
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/breezer.svg)](http://badge.fury.io/rb/breezer) [![Build Status](https://travis-ci.org/lambda2/breezer.svg?branch=master)](https://travis-ci.org/lambda2/breezer) [![Code Climate](https://codeclimate.com/github/lambda2/breezer/badges/gpa.svg)](https://codeclimate.com/github/lambda2/breezer) [![Test Coverage](https://codeclimate.com/github/lambda2/breezer/badges/coverage.svg)](https://codeclimate.com/github/lambda2/breezer)
4
+
5
+
6
+ A cli to automatically set all your Gemfile dependancies to your current version.
7
+
8
+ ## TL;DR
9
+
10
+ ![video](./images/demo.gif)
11
+
12
+ ## In short
13
+
14
+ * Updates your Gemfile with your actual used version (from the Gemfile.lock)
15
+ * Set if you want to constraint the exact version (ex: = 4.3.2), the patch level (ex: ~> 1.2.3) or the minor level (ex: 1.2).
16
+ * Run a check on your Gemfile to ensure all your deps are properly constrained.
17
+ * No deps except bundler.
18
+
19
+ ## Cli
20
+
21
+ ```bash
22
+ Usage: breezer DIR [options]
23
+ -l, --level LEVEL Set the minimum level of gem updates (default: patch). Set to 'exact' to lock gems versions (not recommended).
24
+ -L, --lockfile NAME Use different lockfile (default: Gemfile.lock)
25
+ -d, --dry-run Print the updated Gemfile instead of writing it
26
+ -o, --output FILE The output file (default: Gemfile)
27
+ -c, --check Check that all gems have version constraints
28
+ -h, --help Show this help message
29
+ ```
30
+
31
+ ## Library
32
+
33
+ ```ruby
34
+ require 'breezer'
35
+
36
+ Breezer.freeze!('Gemfile', 'Gemfile.lock', {level: :minor})
37
+ ```
38
+
39
+ ## Requirements
40
+
41
+ * `bundler`
42
+
43
+ ## Install
44
+
45
+ * `gem install breezer`
46
+
47
+ ## License
48
+
49
+ [MIT License](http://www.opensource.org/licenses/mit-license.php)
50
+
51
+ ## Authors
52
+
53
+ * [André Aubin](https://github.com/lambda2)
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+ ## Test
64
+
65
+ ```Bash
66
+ bundle exec rake test
67
+ ```
68
+
69
+ ## Release
70
+
71
+ ```Bash
72
+ bundle exec rake bump:{patch|minor|major}
73
+ bundle exec rake release
74
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rake/testtask'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+ require 'bump/tasks'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ t.test_files = FileList["test/test_*.rb"]
9
+ end
10
+
11
+ desc "Run tests"
12
+ task :default => :test
data/bin/breezer ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler'
5
+ require 'breezer'
6
+ require 'optparse'
7
+
8
+ gemfile_dir = ARGV.first || '.'
9
+
10
+ gemfile_file = File.directory?(gemfile_dir) ? File.join(gemfile_dir, 'Gemfile') : gemfile_dir
11
+ lockfile_file = "#{gemfile_file}.lock"
12
+
13
+ options = {
14
+ debug: false
15
+ }
16
+
17
+ OptionParser.new do |parser|
18
+ parser.banner = 'Usage: breezer DIR [options]'
19
+
20
+ parser.on('-l', '--level LEVEL', "Set the minimum level of gem updates (default: patch). Set to 'exact' to lock gems versions (not recommended).") do |v|
21
+ unless %w[major minor patch exact].include?(v)
22
+ raise "Error: level must be one of: 'major', 'minor', 'patch' or 'exact', #{v} given."
23
+ end
24
+
25
+ options[:level] = v
26
+ end
27
+
28
+ parser.on('-L', '--lockfile NAME', 'Use different lockfile (default: Gemfile.lock)') do |v|
29
+ lockfile_file = v
30
+ end
31
+
32
+ parser.on('-d', '--dry-run', 'Print the updated Gemfile instead of writing it') do
33
+ options[:dry] = true
34
+ end
35
+
36
+ parser.on('-o', '--output FILE', 'The output file (default: Gemfile)') do |v|
37
+ options[:output] = v
38
+ end
39
+
40
+ parser.on('-c', '--check', 'Check that all gems have version constraints') do |_v|
41
+ options[:check] = true
42
+ end
43
+
44
+ parser.on('-h', '--help', 'Show this help message') do
45
+ puts parser
46
+ exit(0)
47
+ end
48
+ end.parse!
49
+
50
+ unless File.file?(gemfile_file)
51
+ puts "Unable to find a Gemfile (searched in #{gemfile_file})"
52
+ exit(1)
53
+ end
54
+
55
+ unless File.file?(lockfile_file)
56
+ puts "Unable to find a Lockfile (Gemfile.lock). If you don't have a Gemfile.lock yet, you can run 'bundle install' first. (searched in #{lockfile_file})"
57
+ exit(1)
58
+ end
59
+
60
+ r = Breezer.freeze!(gemfile_file, lockfile_file, options)
61
+ exit(r == false ? 2 : 0)
data/breezer.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'breezer'
5
+ s.version = '0.3.0'
6
+
7
+ s.authors = ['André Aubin']
8
+ s.date = '2020-02-05'
9
+ s.description = 'Automatically set versions in your Gemfile'
10
+ s.email = 'hello@andral.xyz'
11
+ glob = ->(patterns) { s.files & Dir[*patterns] }
12
+
13
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
14
+
15
+ s.executables = glob['bin/*'].map { |path| File.basename(path) }
16
+ s.default_executable = s.executables.first if Gem::VERSION < '1.7.'
17
+
18
+ s.homepage = 'http://rubygems.org/gems/breezer'
19
+ s.require_paths = ['lib']
20
+ s.summary = 'Breezer!'
21
+ s.license = 'MIT'
22
+
23
+ s.required_ruby_version = '>= 2.4.0'
24
+ s.required_rubygems_version = '>= 2.7.0'
25
+
26
+ s.add_development_dependency 'bump'
27
+ s.add_development_dependency 'minitest'
28
+ s.add_development_dependency 'minitest-around'
29
+ s.add_development_dependency 'rake', '>= 10.0.0'
30
+
31
+ s.add_runtime_dependency('bundler', '> 1.0')
32
+ end
data/images/demo.gif ADDED
Binary file
data/lib/breezer.rb ADDED
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # This is our main class.
5
+ # Call Breezer.freeze! to update the Gemfile
6
+ #
7
+ class Breezer
8
+ def self.freeze!(gemfile_path, lockfile_path, **options)
9
+ absolute_lockfile_path = File.join(lockfile_path)
10
+ absolute_gemfile_path = File.join(gemfile_path)
11
+ ENV['BUNDLE_GEMFILE'] = absolute_gemfile_path
12
+
13
+ deps = Parser.deps(absolute_lockfile_path, options)
14
+
15
+ gemfile = Bundler.read_file(absolute_gemfile_path)
16
+ if options[:check]
17
+ check_gemfile!(gemfile, deps, options)
18
+ else
19
+ update_gemfile!(gemfile, deps, options, options[:output] || absolute_gemfile_path)
20
+ end
21
+ end
22
+
23
+ def self.check_gemfile!(gemfile, deps, options)
24
+ checks = Freezer.check_gemfile!(gemfile, deps, options)
25
+ print_check_results(checks)
26
+ checks.values.map { |e| e[:valid] }.all?
27
+ end
28
+
29
+ def self.update_gemfile!(gemfile, deps, options, output)
30
+ updated_gemfile = Freezer.update_gemfile!(gemfile, deps, options)
31
+ write_or_print_output(updated_gemfile, output, options)
32
+ end
33
+
34
+ def self.write_or_print_output(updated_gemfile, output_path, **options)
35
+ if options[:dry]
36
+ puts updated_gemfile
37
+ else
38
+ File.open(output_path, 'w') do |file|
39
+ file.write(updated_gemfile)
40
+ end
41
+ end
42
+ updated_gemfile
43
+ end
44
+
45
+ def self.print_check_results(checks)
46
+ invalid = checks.reject { |_k, v| v[:valid] }
47
+ if invalid.empty?
48
+ (puts 'Gemfile dependencies are properly constrained' && return)
49
+ end
50
+ puts "#{invalid.values.count} dependencies are not properly set"
51
+ invalid.each do |no, line|
52
+ suggested = line[:proposed_version] ? " (Suggested: '~> #{line[:proposed_version]}')" : ''
53
+ puts format('Line %-3d: gem %-20s%s', no, "'#{line[:name]}'", suggested)
54
+ end
55
+ end
56
+ end
57
+
58
+ require 'breezer/parser'
59
+ require 'breezer/freezer'
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ class Breezer::Freezer
6
+ GEM_REGEX = /gem[\s]+(?<fullname>['"](?<name>[\w\-_]+)['"])(?<fullversion>,?[\s]?['"](?<version>[~><=]+[\s]?[\d\.]+)['"])?(?<fullsecversion>,?[\s]?['"](?<secversion>[~><=]+[\s]?[\d\.]+)['"])?/.freeze
7
+
8
+ def self.update_gemfile!(gemfile, deps, **options)
9
+ new_gemfile = []
10
+ gemfile.split("\n").each { |line| new_gemfile << parse(line, deps, options) }
11
+ [*new_gemfile, ''].join("\n")
12
+ end
13
+
14
+ def self.check_gemfile!(gemfile, deps, **options)
15
+ gemfile.split("\n").each_with_index.map do |line, no|
16
+ [no + 1, check(line, deps, options)]
17
+ end.to_h
18
+ end
19
+
20
+ # Parse a gemfile line, and return the line updated with dependencies
21
+ def self.parse(line, deps, **options)
22
+ return line unless valid_line?(line)
23
+
24
+ matches = line.match(GEM_REGEX)
25
+
26
+ # return the line if we didn't matched a name
27
+ return line unless matches[:name]
28
+
29
+ proposed_version = deps[matches[:name]]
30
+ version_string = version_for_name(proposed_version, options)
31
+
32
+ # return the line if we didn't find a version
33
+ return line unless proposed_version && version_string
34
+
35
+ # if we already have a version and we don't want to override
36
+ return line if matches[:version] && options[:preserve]
37
+
38
+ transform_line_for_version(line, matches, version_string)
39
+ end
40
+
41
+ # Return false if there is no deps declaration in the given line
42
+ def self.valid_line?(line)
43
+ # Drop lines if no gem declared
44
+ return false if (line =~ /gem[\s]+/).nil?
45
+
46
+ # Drop line if it's a comment
47
+ return false unless (line =~ /^[\s]?#/).nil?
48
+
49
+ # Drop line if it contains a skip comment
50
+ return false unless (line =~ /breezer-disable/).nil?
51
+
52
+ true
53
+ end
54
+
55
+ # Parse a gemfile line, and return true or false wether the line is valid
56
+ def self.check(line, deps, **options)
57
+ return { valid: true } unless valid_line?(line)
58
+
59
+ matches = line.match(GEM_REGEX)
60
+
61
+ # return the line if we didn't matched a name
62
+ return { valid: true } unless matches[:name]
63
+
64
+ proposed_version = deps[matches[:name]]
65
+ version_for_name(proposed_version, options)
66
+
67
+ # Do we have a version ?
68
+ {
69
+ name: matches[:name],
70
+ proposed_version: proposed_version,
71
+ valid: !matches[:version].nil?
72
+ }
73
+ end
74
+
75
+ # Will rewrite the old deps line with the good version
76
+ def self.transform_line_for_version(line, matches, version_string)
77
+ # We remove the other version
78
+ line = line.gsub(matches[:fullsecversion], '') if matches[:fullsecversion]
79
+
80
+ # If we had a version
81
+ if matches[:version]
82
+ line.gsub(matches[:version], version_string)
83
+ else
84
+ line.gsub(matches[:fullname], "#{matches[:fullname]}, '#{version_string}'")
85
+ end
86
+ end
87
+
88
+ # Will return the Gemfile.lock version of a deps
89
+ def self.version_for_name(proposed_version, options)
90
+ get_version_string(proposed_version, options)
91
+ end
92
+
93
+ # Will convert the version according to the given level (default 'patch')
94
+ def self.get_version_string(version, options)
95
+ options = { level: 'patch' }.merge(options)
96
+
97
+ gv = Gem::Version.create(version)
98
+ return unless gv
99
+
100
+ segments = [*gv.canonical_segments, 0, 0, 0].first(3)
101
+ case options[:level].to_s
102
+ when 'major'
103
+ "~> #{segments.first}"
104
+ when 'minor'
105
+ "~> #{segments.first(2).join('.')}"
106
+ when 'patch'
107
+ "~> #{segments.first(3).join('.')}"
108
+ when 'exact'
109
+ "= #{version}"
110
+ else
111
+ raise("Unsupported option: #{options[:level]}")
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ class Breezer::Parser
6
+ def self.deps(lockfile_path = 'Gemfile.lock', **_options)
7
+ lockfile = Bundler::LockfileParser.new(Bundler.read_file(lockfile_path))
8
+ specs = lockfile.specs
9
+ specs.map { |h| [h.name, h.version.version] }.to_h
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) {|repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '2.6.5'
5
+
6
+ gem 'colorize'
7
+
8
+ gem 'ruby-progressbar'
9
+
10
+ gem 'bootsnap', '>= 1.4.2', require: false
11
+
12
+ group :development, :test do
13
+ gem 'bullet'
14
+ gem 'byebug', platforms: %i[mri mingw x64_mingw]
15
+ gem 'rubocop', '~> 0.79.0'
16
+ end
17
+
18
+ group :development do
19
+ gem 'listen', '>= 3.0.5', '< 3.2'
20
+ gem 'web-console', '>= 3.3.0'
21
+ gem 'spring'
22
+ gem 'spring-watcher-listen', '~> 2.0.0'
23
+ end
24
+
25
+ group :test do
26
+ gem 'simplecov', require: false
27
+ end
28
+
29
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) {|repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '2.6.5'
5
+
6
+ gem 'colorize', '~> 0.8.1'
7
+
8
+ gem 'ruby-progressbar', '~> 1.10.1'
9
+
10
+ gem 'bootsnap', '~> 1.4.5', require: false
11
+
12
+ group :development, :test do
13
+ gem 'bullet', '~> 6.1.0'
14
+ gem 'byebug', '~> 11.1.1', platforms: %i[mri mingw x64_mingw]
15
+ gem 'rubocop', '~> 0.79.0'
16
+ end
17
+
18
+ group :development do
19
+ gem 'listen', '~> 3.1.5'
20
+ gem 'web-console', '~> 4.0.1'
21
+ gem 'spring', '~> 2.1.0'
22
+ gem 'spring-watcher-listen', '~> 2.0.1'
23
+ end
24
+
25
+ group :test do
26
+ gem 'simplecov', '~> 0.18.1', require: false
27
+ end
28
+
29
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # breezer-disable
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) {|repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '2.6.5'
5
+
6
+ gem 'colorize', '~> 0.8'
7
+
8
+ gem 'ruby-progressbar', '~> 1.10'
9
+
10
+ gem 'bootsnap', '~> 1.4', require: false
11
+
12
+ group :development, :test do
13
+ gem 'bullet', '~> 6.1'
14
+ gem 'byebug', '~> 11.1', platforms: %i[mri mingw x64_mingw]
15
+ gem 'rubocop', '~> 0.79'
16
+ end
17
+
18
+ group :development do
19
+ gem 'listen', '~> 3.1'
20
+ gem 'web-console', '~> 4.0'
21
+ gem 'spring', '~> 2.1'
22
+ gem 'spring-watcher-listen', '~> 2.0'
23
+ end
24
+
25
+ group :test do
26
+ gem 'simplecov', '~> 0.18', require: false
27
+ end
28
+
29
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) {|repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '2.6.5'
5
+
6
+ gem 'colorize', '~> 0.8.1'
7
+
8
+ gem 'ruby-progressbar', '~> 1.10.1'
9
+
10
+ gem 'bootsnap', '~> 1.4.5', require: false
11
+
12
+ group :development, :test do
13
+ gem 'bullet', '~> 6.1.0'
14
+ gem 'byebug', '~> 11.1.1', platforms: %i[mri mingw x64_mingw]
15
+ gem 'rubocop', '~> 0.79.0'
16
+ end
17
+
18
+ group :development do
19
+ gem 'listen', '~> 3.1.5'
20
+ gem 'web-console', '~> 4.0.1'
21
+ gem 'spring', '~> 2.1.0'
22
+ gem 'spring-watcher-listen', '~> 2.0.1'
23
+ end
24
+
25
+ group :test do
26
+ gem 'simplecov', '~> 0.18.1', require: false
27
+ end
28
+
29
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@@ -0,0 +1,129 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionpack (6.0.2.1)
5
+ actionview (= 6.0.2.1)
6
+ activesupport (= 6.0.2.1)
7
+ rack (~> 2.0, >= 2.0.8)
8
+ rack-test (>= 0.6.3)
9
+ rails-dom-testing (~> 2.0)
10
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
11
+ actionview (6.0.2.1)
12
+ activesupport (= 6.0.2.1)
13
+ builder (~> 3.1)
14
+ erubi (~> 1.4)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
17
+ activemodel (6.0.2.1)
18
+ activesupport (= 6.0.2.1)
19
+ activesupport (6.0.2.1)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (>= 0.7, < 2)
22
+ minitest (~> 5.1)
23
+ tzinfo (~> 1.1)
24
+ zeitwerk (~> 2.2)
25
+ ast (2.4.0)
26
+ bindex (0.8.1)
27
+ bootsnap (1.4.5)
28
+ msgpack (~> 1.0)
29
+ builder (3.2.4)
30
+ bullet (6.1.0)
31
+ activesupport (>= 3.0.0)
32
+ uniform_notifier (~> 1.11)
33
+ byebug (11.1.1)
34
+ colorize (0.8.1)
35
+ concurrent-ruby (1.1.5)
36
+ crass (1.0.6)
37
+ docile (1.3.2)
38
+ erubi (1.9.0)
39
+ ffi (1.12.2)
40
+ i18n (1.8.2)
41
+ concurrent-ruby (~> 1.0)
42
+ jaro_winkler (1.5.4)
43
+ listen (3.1.5)
44
+ rb-fsevent (~> 0.9, >= 0.9.4)
45
+ rb-inotify (~> 0.9, >= 0.9.7)
46
+ ruby_dep (~> 1.2)
47
+ loofah (2.4.0)
48
+ crass (~> 1.0.2)
49
+ nokogiri (>= 1.5.9)
50
+ method_source (0.9.2)
51
+ mini_portile2 (2.4.0)
52
+ minitest (5.14.0)
53
+ msgpack (1.3.3)
54
+ nokogiri (1.10.7)
55
+ mini_portile2 (~> 2.4.0)
56
+ parallel (1.19.1)
57
+ parser (2.7.0.2)
58
+ ast (~> 2.4.0)
59
+ rack (2.1.2)
60
+ rack-test (1.1.0)
61
+ rack (>= 1.0, < 3)
62
+ rails-dom-testing (2.0.3)
63
+ activesupport (>= 4.2.0)
64
+ nokogiri (>= 1.6)
65
+ rails-html-sanitizer (1.3.0)
66
+ loofah (~> 2.3)
67
+ railties (6.0.2.1)
68
+ actionpack (= 6.0.2.1)
69
+ activesupport (= 6.0.2.1)
70
+ method_source
71
+ rake (>= 0.8.7)
72
+ thor (>= 0.20.3, < 2.0)
73
+ rainbow (3.0.0)
74
+ rake (13.0.1)
75
+ rb-fsevent (0.10.3)
76
+ rb-inotify (0.10.1)
77
+ ffi (~> 1.0)
78
+ rubocop (0.79.0)
79
+ jaro_winkler (~> 1.5.1)
80
+ parallel (~> 1.10)
81
+ parser (>= 2.7.0.1)
82
+ rainbow (>= 2.2.2, < 4.0)
83
+ ruby-progressbar (~> 1.7)
84
+ unicode-display_width (>= 1.4.0, < 1.7)
85
+ ruby-progressbar (1.10.1)
86
+ ruby_dep (1.5.0)
87
+ simplecov (0.18.1)
88
+ docile (~> 1.1)
89
+ simplecov-html (~> 0.11.0)
90
+ simplecov-html (0.11.0)
91
+ spring (2.1.0)
92
+ spring-watcher-listen (2.0.1)
93
+ listen (>= 2.7, < 4.0)
94
+ spring (>= 1.2, < 3.0)
95
+ thor (1.0.1)
96
+ thread_safe (0.3.6)
97
+ tzinfo (1.2.6)
98
+ thread_safe (~> 0.1)
99
+ unicode-display_width (1.6.1)
100
+ uniform_notifier (1.13.0)
101
+ web-console (4.0.1)
102
+ actionview (>= 6.0.0)
103
+ activemodel (>= 6.0.0)
104
+ bindex (>= 0.4.0)
105
+ railties (>= 6.0.0)
106
+ zeitwerk (2.2.2)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ bootsnap (>= 1.4.2)
113
+ bullet
114
+ byebug
115
+ colorize
116
+ listen (>= 3.0.5, < 3.2)
117
+ rubocop (~> 0.79.0)
118
+ ruby-progressbar
119
+ simplecov
120
+ spring
121
+ spring-watcher-listen (~> 2.0.0)
122
+ tzinfo-data
123
+ web-console (>= 3.3.0)
124
+
125
+ RUBY VERSION
126
+ ruby 2.6.5p114
127
+
128
+ BUNDLED WITH
129
+ 2.0.2
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest/around/spec'
5
+ require 'breezer'
6
+
7
+ describe Breezer do
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 'run without options' do
20
+ _specs = Breezer.freeze!('Gemfile', 'Gemfile.lock', {})
21
+ _(File.read('Gemfile')).must_equal File.read('Gemfile.final.patch')
22
+ end
23
+
24
+ it 'run with minor level options' do
25
+ _specs = Breezer.freeze!('Gemfile', 'Gemfile.lock', level: :minor)
26
+ _(File.read('Gemfile')).must_equal File.read('Gemfile.final.minor')
27
+ end
28
+
29
+ it 'run with dry run' do
30
+ specs = Breezer.freeze!('Gemfile', 'Gemfile.lock', dry: true)
31
+ _(specs).must_equal File.read('Gemfile.final.patch')
32
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
33
+ end
34
+
35
+ it 'run with custom output' do
36
+ specs = Breezer.freeze!('Gemfile', 'Gemfile.lock', output: 'Gemfile.custom')
37
+ _(specs).must_equal File.read('Gemfile.final.patch')
38
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
39
+ _(File.read('Gemfile.custom')).must_equal File.read('Gemfile.final.patch')
40
+ end
41
+
42
+ it 'run with checks on invalid gemfile' do
43
+ specs = Breezer.freeze!('Gemfile', 'Gemfile.lock', check: true)
44
+ _(specs).must_equal false
45
+ _(File.read('Gemfile')).wont_be_same_as File.read('Gemfile.final.patch')
46
+ end
47
+
48
+ it 'run with checks on valid gemfile' do
49
+ specs = Breezer.freeze!('Gemfile.checked', 'Gemfile.lock', check: true)
50
+ _(specs).must_equal true
51
+ end
52
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'breezer'
5
+
6
+ class TestBreezer < Minitest::Test
7
+ DEPS = {
8
+ 'actionpack' => '6.0.2.1',
9
+ 'actionview' => '6.0.2.1',
10
+ 'activemodel' => '6.0.2.1',
11
+ 'activesupport' => '6.0.2.1',
12
+ 'ast' => '2.4.0',
13
+ 'bindex' => '0.8.1',
14
+ 'bootsnap' => '1.4.5',
15
+ 'builder' => '3.2.4',
16
+ 'bullet' => '6.1.0',
17
+ 'byebug' => '11.1.1',
18
+ 'colorize' => '0.8.1',
19
+ 'concurrent-ruby' => '1.1.5',
20
+ 'crass' => '1.0.6',
21
+ 'docile' => '1.3.2',
22
+ 'erubi' => '1.9.0',
23
+ 'ffi' => '1.12.2',
24
+ 'i18n' => '1.8.2',
25
+ 'jaro_winkler' => '1.5.4',
26
+ 'listen' => '3.1.5',
27
+ 'loofah' => '2.4.0',
28
+ 'method_source' => '0.9.2',
29
+ 'mini_portile2' => '2.4.0',
30
+ 'minitest' => '5.14.0',
31
+ 'msgpack' => '1.3.3',
32
+ 'nokogiri' => '1.10.7',
33
+ 'parallel' => '1.19.1',
34
+ 'parser' => '2.7.0.2',
35
+ 'rack' => '2.1.2',
36
+ 'rack-test' => '1.1.0',
37
+ 'rails-dom-testing' => '2.0.3',
38
+ 'rails-html-sanitizer' => '1.3.0',
39
+ 'railties' => '6.0.2.1',
40
+ 'rainbow' => '3.0.0',
41
+ 'rake' => '13.0.1',
42
+ 'rb-fsevent' => '0.10.3',
43
+ 'rb-inotify' => '0.10.1',
44
+ 'rubocop' => '0.79.0',
45
+ 'ruby-progressbar' => '1.10.1',
46
+ 'ruby_dep' => '1.5.0',
47
+ 'simplecov' => '0.18.1',
48
+ 'simplecov-html' => '0.11.0',
49
+ 'spring' => '2.1.0',
50
+ 'spring-watcher-listen' => '2.0.1',
51
+ 'thor' => '1.0.1',
52
+ 'thread_safe' => '0.3.6',
53
+ 'tzinfo' => '1.2.6',
54
+ 'unicode-display_width' => '1.6.1',
55
+ 'uniform_notifier' => '1.13.0',
56
+ 'web-console' => '4.0.1',
57
+ 'zeitwerk' => '2.2.2'
58
+ }.freeze
59
+
60
+ def test_good_matchs
61
+ [
62
+ [
63
+ "gem 'colorize'",
64
+ "gem 'colorize', '~> 0.8.1'"
65
+ ],
66
+ [
67
+ "gem 'ruby-progressbar'",
68
+ "gem 'ruby-progressbar', '~> 1.10.1'"
69
+ ],
70
+ [
71
+ "gem 'bootsnap', '>= 1.4.2', require: false",
72
+ "gem 'bootsnap', '~> 1.4.5', require: false"
73
+ ],
74
+ [
75
+ " gem 'bullet'",
76
+ " gem 'bullet', '~> 6.1.0'"
77
+ ],
78
+ [
79
+ " gem 'byebug', platforms: %i[mri mingw x64_mingw]",
80
+ " gem 'byebug', '~> 11.1.1', platforms: %i[mri mingw x64_mingw]"
81
+ ],
82
+ [
83
+ " gem 'rubocop', '~> 0.79.0'",
84
+ " gem 'rubocop', '~> 0.79.0'"
85
+ ],
86
+ [
87
+ " gem 'listen', '>= 3.0.5', '< 3.2'",
88
+ " gem 'listen', '~> 3.1.5'"
89
+ ],
90
+ [
91
+ " gem 'web-console', '>= 3.3.0'",
92
+ " gem 'web-console', '~> 4.0.1'"
93
+ ],
94
+ [
95
+ " gem 'spring'",
96
+ " gem 'spring', '~> 2.1.0'"
97
+ ],
98
+ [
99
+ " gem 'spring-watcher-listen', '~> 2.0.0'",
100
+ " gem 'spring-watcher-listen', '~> 2.0.1'"
101
+ ]
102
+ ].each do |line|
103
+ old_line, new_line = line
104
+ assert_equal new_line, Breezer::Freezer.parse(old_line, DEPS)
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'breezer'
5
+
6
+ class TestParser < Minitest::Test
7
+ def test_simple_load
8
+ Bundler::SharedHelpers.chdir("#{File.dirname(__FILE__)}/samples") do
9
+ specs = Breezer::Parser.deps('Gemfile.lock')
10
+ assert_equal specs['colorize'], '0.8.1'
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: breezer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - André Aubin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bump
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-around
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 10.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 10.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ description: Automatically set versions in your Gemfile
84
+ email: hello@andral.xyz
85
+ executables:
86
+ - breezer
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - README.md
94
+ - Rakefile
95
+ - bin/breezer
96
+ - breezer.gemspec
97
+ - images/demo.gif
98
+ - lib/breezer.rb
99
+ - lib/breezer/freezer.rb
100
+ - lib/breezer/parser.rb
101
+ - test/samples/Gemfile
102
+ - test/samples/Gemfile.checked
103
+ - test/samples/Gemfile.final.minor
104
+ - test/samples/Gemfile.final.patch
105
+ - test/samples/Gemfile.lock
106
+ - test/test_breezer.rb
107
+ - test/test_freezer.rb
108
+ - test/test_parser.rb
109
+ homepage: http://rubygems.org/gems/breezer
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 2.4.0
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 2.7.0
127
+ requirements: []
128
+ rubygems_version: 3.0.6
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Breezer!
132
+ test_files: []