bundler-diff 0.4.0 → 0.5.0
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 +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +0 -1
- data/README.md +1 -0
- data/lib/bundler_diff.rb +35 -5
- data/lib/bundler_diff/cli.rb +20 -25
- data/lib/bundler_diff/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa495cccf95f5c21f03fa11fac02dd9f682205d9892fc53a6c4b72a3fcca066d
|
4
|
+
data.tar.gz: ddd43a9b67597a11167d9eee5d32b19c6e96cd4d9f2c096d250d3fa5ba292082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b003ca66c18d8c78d28145349b8e20817912a52703da2f2698f731c4b05d8ed5fc75de3c668e43b5c98f720d26338df1b81b2829519ce2f10bacfc0b5a81cf
|
7
|
+
data.tar.gz: 130a7bf297aa2d21b847f2058d53e9d89776cd469674f15cdbefc1e2bd868e2c866412f679fee3a9dc7effb596a520f3298b59f209be128cff959f2385cba00e
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/bundler_diff.rb
CHANGED
@@ -7,10 +7,40 @@ require 'bundler_diff/formatter/md_table'
|
|
7
7
|
require 'bundler_diff/version'
|
8
8
|
|
9
9
|
module BundlerDiff
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
class << self
|
11
|
+
def formatters
|
12
|
+
@formatters ||= {
|
13
|
+
default: Formatter::Default,
|
14
|
+
md_table: Formatter::MdTable
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_options(args) # rubocop:disable Metrics/MethodLength
|
19
|
+
options = {}
|
20
|
+
|
21
|
+
opt = OptionParser.new
|
22
|
+
opt.banner = 'Usage: bundle diff [options]'
|
23
|
+
opt.on('-c', '--commit COMMIT', 'Specify a commit') { |val| options[:commit] = val }
|
24
|
+
formatter_desc = [
|
25
|
+
'Choose a formatter',
|
26
|
+
' default',
|
27
|
+
' md_table'
|
28
|
+
]
|
29
|
+
opt.on('-f', '--format FORMATTER', *formatter_desc) do |val|
|
30
|
+
options[:format] = val.to_sym
|
31
|
+
end
|
32
|
+
opt.on('--escape-json', 'Escape output as a JSON string') do |val|
|
33
|
+
options[:escape_json] = val
|
34
|
+
end
|
35
|
+
opt.on('--access-token ACCESS_TOKEN', 'Set access token for GitHub API') do |val|
|
36
|
+
options[:access_token] = val
|
37
|
+
end
|
38
|
+
|
39
|
+
opt.on('-v', '--version', 'Display the version') { options[:version] = true }
|
40
|
+
|
41
|
+
remaining_args = opt.parse(args)
|
42
|
+
options[:commit] ||= remaining_args.shift
|
43
|
+
options
|
44
|
+
end
|
15
45
|
end
|
16
46
|
end
|
data/lib/bundler_diff/cli.rb
CHANGED
@@ -25,7 +25,7 @@ module BundlerDiff
|
|
25
25
|
|
26
26
|
gems = GemsComparator.compare(before_lockfile, after_lockfile)
|
27
27
|
output = formatter.new.render(gems)
|
28
|
-
output = JSON.dump(output) if @escape_json
|
28
|
+
output = JSON.dump(output) if @options[:escape_json]
|
29
29
|
puts output
|
30
30
|
rescue StandardError => e
|
31
31
|
puts e.inspect
|
@@ -47,46 +47,41 @@ module BundlerDiff
|
|
47
47
|
File.read(file_name)
|
48
48
|
end
|
49
49
|
|
50
|
-
def parse_options!
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
formatter_desc = [
|
55
|
-
'Choose a formatter',
|
56
|
-
' default',
|
57
|
-
' md_table'
|
58
|
-
]
|
59
|
-
opt.on('-f', '--format FORMATTER', *formatter_desc) { |val| @format = val.to_sym }
|
60
|
-
opt.on('--escape-json', 'Escape output as a JSON string') do |val|
|
61
|
-
@escape_json = val
|
62
|
-
end
|
63
|
-
opt.on('-v', '--version', 'Display the version') do
|
50
|
+
def parse_options!
|
51
|
+
@options = BundlerDiff.parse_options(@args)
|
52
|
+
|
53
|
+
if @options.key?(:version)
|
64
54
|
puts BundlerDiff::VERSION
|
65
55
|
exit
|
66
56
|
end
|
67
|
-
options
|
68
|
-
@
|
57
|
+
@options[:commit] ||= DEFAULT_OPTIONS[:commit]
|
58
|
+
@options[:format] ||= DEFAULT_OPTIONS[:format]
|
59
|
+
@options[:access_token] ||=
|
60
|
+
ENV['BUNDLER_DIFF_GITHUB_TOKEN'] || ENV['GITHUB_TOKEN'] || hub_token
|
69
61
|
end
|
70
62
|
|
71
63
|
def set_access_token!
|
72
|
-
return if
|
64
|
+
return if @options[:access_token].nil?
|
65
|
+
|
66
|
+
GemsComparator.configure do |config|
|
67
|
+
config.client = Octokit::Client.new(access_token: @options[:access_token])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def hub_token
|
73
72
|
hub_config_path = "#{ENV['HOME']}/.config/hub"
|
74
73
|
return unless File.exist?(hub_config_path)
|
75
74
|
|
76
75
|
yaml = YAML.load_file(hub_config_path)
|
77
|
-
|
78
|
-
return if oauth_token.nil?
|
79
|
-
GemsComparator.configure do |config|
|
80
|
-
config.client = Octokit::Client.new(access_token: oauth_token)
|
81
|
-
end
|
76
|
+
yaml.dig('github.com', 0, 'oauth_token')
|
82
77
|
end
|
83
78
|
|
84
79
|
def commit
|
85
|
-
@
|
80
|
+
@options[:commit]
|
86
81
|
end
|
87
82
|
|
88
83
|
def formatter
|
89
|
-
format = @
|
84
|
+
format = @options[:format]
|
90
85
|
BundlerDiff.formatters[format] || Formatter::Default
|
91
86
|
end
|
92
87
|
end
|
data/lib/bundler_diff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sinsoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gems_comparator
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.7.
|
146
|
+
rubygems_version: 2.7.7
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: A gem support your "bundle update"
|