bundler_diffgems 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45338706478a5ec3c5b5d825351e3d59b437a6f5
4
- data.tar.gz: 879599fac5ecac8950b178d2631da58868203f52
3
+ metadata.gz: 93542c8c3bcf1356c0afee9d3e863bc6d66cb7c7
4
+ data.tar.gz: 9be0727d0e366e5c5cce1d185af3728697b2a67e
5
5
  SHA512:
6
- metadata.gz: 530657d505d641f3be597ad83c97d6889805e7e31476ac16153749de45589e3a6272bbe27aa01c656cabec22788886955ca510d92283785ba15c8129ce8e38f1
7
- data.tar.gz: a2c39bd64b1b4f5c9dc3c8169b58e447a86c2b2c7bac1cde90a433e49885f15971a6223ad14716812f57723ba297c29c44a386cb04e04420d94a0649fef89a13
6
+ metadata.gz: 9c44b986538ca36b9d5af7cbfb07bd1ff5d86d67d9036ede86370d7723dada3b8deb29fb990a968196bad9c1e70db7cfb1590446b5a66e09eb44119fc718b07c
7
+ data.tar.gz: 9f754a9ab5de525da7c0b765ad7effb0c3e9ab4dc8b498cc4b96a3dd16b42407bf1b53f5612549dd64168776098ef98a40f47140064821a0709378caf05f17b4
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/sinsoku/bundler_diffgems.svg?branch=master)](https://travis-ci.org/sinsoku/bundler_diffgems)
5
5
  [![codecov](https://codecov.io/gh/sinsoku/bundler_diffgems/branch/master/graph/badge.svg)](https://codecov.io/gh/sinsoku/bundler_diffgems)
6
6
 
7
- BundlerDiffgems show changes with GitHub comapre view urls.
7
+ A bundler subcommand that use Git, compare with the previous Gemfile.lock, and display updated gems and comapre links.
8
8
 
9
9
  ## Installation
10
10
 
@@ -24,13 +24,37 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
+ Run `bundle update` as usual:
28
+
27
29
  ```
28
30
  $ bundle update
29
31
  Fetching gem metadata from https://rubygems.org
30
- (...updating
32
+ ...
33
+ ```
34
+
35
+ Then `bundle diffgems`:
36
+
37
+ ```
31
38
  $ bundle diffgems
32
39
  rake: 11.3.0 => 12.0.0 - https://github.com/ruby/rake/compare/v11.3.0...v12.0.0
33
40
  rspec: 3.5.0 =>
41
+ ...
42
+ ```
43
+
44
+ You can see updated gems with compare links.
45
+
46
+ ## Options
47
+
48
+ Options are:
49
+
50
+ ```
51
+ Usage: bundle diffgems [options]
52
+ -c, --commit COMMIT Specify a commit
53
+ -f, --format FORMATTER Choose a formatter
54
+ default
55
+ md_table
56
+ --escape-json Escape output as a JSON string
57
+ -v, --version Display the version
34
58
  ```
35
59
 
36
60
  ## Development
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'gems_comparator'
3
+ require 'json'
3
4
  require 'optparse'
4
5
 
5
6
  module BundlerDiffgems
@@ -19,8 +20,12 @@ module BundlerDiffgems
19
20
 
20
21
  def invoke
21
22
  parse_options!
23
+ set_access_token!
24
+
22
25
  gems = GemsComparator.compare(before_lockfile, after_lockfile)
23
- puts formatter.new.render(gems)
26
+ output = formatter.new.render(gems)
27
+ output = JSON.dump(output) if @escape_json
28
+ puts output
24
29
  rescue => e
25
30
  puts e.inspect
26
31
  end
@@ -41,14 +46,40 @@ module BundlerDiffgems
41
46
  File.read(file_name)
42
47
  end
43
48
 
44
- def parse_options!
49
+ def parse_options! # rubocop:disable Metrics/MethodLength
45
50
  opt = OptionParser.new
46
- opt.on('-c', '--comit=COMMIT') { |val| @commit = val }
47
- opt.on('-f', '--format=FORMATTER') { |val| @format = val.to_sym }
51
+ opt.banner = 'Usage: bundle diffgems [options]'
52
+ opt.on('-c', '--commit COMMIT', 'Specify a commit') { |val| @commit = val }
53
+ formatter_desc = [
54
+ 'Choose a formatter',
55
+ ' default',
56
+ ' md_table'
57
+ ]
58
+ opt.on('-f', '--format FORMATTER', *formatter_desc) { |val| @format = val.to_sym }
59
+ opt.on('--escape-json', 'Escape output as a JSON string') do |val|
60
+ @escape_json = val
61
+ end
62
+ opt.on('-v', '--version', 'Display the version') do
63
+ puts BundlerDiffgems::VERSION
64
+ exit
65
+ end
48
66
  options = opt.parse(@args)
49
67
  @commit ||= options.shift
50
68
  end
51
69
 
70
+ def set_access_token!
71
+ return if GemsComparator.config.client.access_token
72
+ hub_config_path = "#{ENV['HOME']}/.config/hub"
73
+ return unless File.exist?(hub_config_path)
74
+
75
+ yaml = YAML.load_file(hub_config_path)
76
+ oauth_token = yaml.dig('github.com', 0, 'oauth_token')
77
+ return if oauth_token.nil?
78
+ GemsComparator.configure do |config|
79
+ config.client = Octokit::Client.new(access_token: oauth_token)
80
+ end
81
+ end
82
+
52
83
  def commit
53
84
  @commit || DEFAULT_OPTIONS[:commit]
54
85
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module BundlerDiffgems
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler_diffgems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinsoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gems_comparator