bundle_outdated_formatter 0.3.0 → 0.7.0

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
- SHA1:
3
- metadata.gz: 01ca034f54fe1038725483780bd66d5ffaa54dd4
4
- data.tar.gz: 4d73ac36a9fbc80284074eef08d8e277b69a031d
2
+ SHA256:
3
+ metadata.gz: ef05c4b5bc20ce84e48b7ea4da096f84764e5e607e2b6a221e95f50c5b325dda
4
+ data.tar.gz: 01bbf8581dbafafd61e03b9978e3c329dba8be41c520aec87a89a640c6651c9f
5
5
  SHA512:
6
- metadata.gz: bd843a7fe2d0ea2d97d4a1517576db6dc6b9cc4272ca5573e1330d9de37dd1d13203b17572bf978e3aa018f82f6dcfbe5bb31ece0129198307cdc6a5b096a035
7
- data.tar.gz: 5c8ffeeb1c97cb179bee7ffe33d2de0355b3c3c827eef1bd1715fb10b8df779f9ee10cb448bc8b1314511e6054c72b57d0e9c1bd9243ec85c2d19b08833e9288
6
+ metadata.gz: 5d2d8ec02f4cc426757e59ed83772b8d106a3a48bd36a95f093afe368ab706a9508f59d21c108615d6f4a3140e5c3a51b3da0b3d6ccb4d8fd09d0897fead0716
7
+ data.tar.gz: 5a04539a93fed6a743369168cd8c151c24aaad3adfaa7ff0d8fc0dd4f4b69f655163b0ff91bed833989954442586c6cf714c31cdf76b22f92dc3d0cf7b21dae7
@@ -0,0 +1,21 @@
1
+ name: build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ${{ matrix.os }}
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ os: [ubuntu-latest, macos-latest, windows-latest]
12
+ ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7, ruby-head]
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ - name: Install dependencies
19
+ run: bundle install --jobs 4 --retry 3
20
+ - name: Run test
21
+ run: bundle exec rake
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --require spec_helper
@@ -1,9 +1,20 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+ require: rubocop-rspec
2
3
 
3
4
  AllCops:
4
5
  DisplayCopNames: true
6
+ NewCops: enable
5
7
 
6
- Layout/IndentHeredoc:
8
+ Bundler/DuplicatedGem:
9
+ Enabled: false
10
+
11
+ Layout/HashAlignment:
12
+ EnforcedHashRocketStyle: table
13
+
14
+ Layout/HeredocIndentation:
15
+ Enabled: false
16
+
17
+ Layout/LineLength:
7
18
  Enabled: false
8
19
 
9
20
  Layout/TrailingWhitespace:
@@ -18,5 +29,18 @@ Metrics/BlockLength:
18
29
  - 'spec/**/*.rb'
19
30
  - '*.gemspec'
20
31
 
21
- Metrics/LineLength:
32
+ Naming/HeredocDelimiterNaming:
33
+ Enabled: false
34
+
35
+ Style/FrozenStringLiteralComment:
36
+ Enabled: false
37
+
38
+ Style/IfUnlessModifier:
39
+ Exclude:
40
+ - 'Gemfile'
41
+
42
+ RSpec/FilePath:
43
+ Enabled: false
44
+
45
+ RSpec/NestedGroups:
22
46
  Enabled: false
@@ -1,7 +1,14 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-07-08 13:45:56 +0900 using RuboCop version 0.49.1.
3
+ # on 2020-06-28 04:47:04 UTC using RuboCop version 0.86.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'bundle_outdated_formatter.gemspec'
@@ -1,12 +1,20 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
3
  - 2.0.0
5
4
  - 2.1.10
6
- - 2.2.7
7
- - 2.3.4
8
- - 2.4.1
5
+ - 2.2.10
6
+ - 2.3.8
7
+ - 2.4.10
8
+ - 2.5.8
9
+ - 2.6.6
10
+ - 2.7.1
9
11
  - ruby-head
10
12
  before_install:
11
- - stty cols 160
12
- - gem install bundler -v 1.15.1
13
+ - |
14
+ if [[ `ruby -v` =~ 2\.[0-2]\.[0-9]+ ]]; then
15
+ gem install rubygems-update -v '<3' && update_rubygems
16
+ gem install bundler -v '<2'
17
+ else
18
+ gem update --system
19
+ gem update bundler
20
+ fi
@@ -1,5 +1,58 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.0 (2020-06-29)
4
+
5
+ ### Features
6
+
7
+ * Support Bundler >= 2.1.0.pre.1 (#4)
8
+
9
+ ### Miscellaneous
10
+
11
+ * Relax dependency version requirements
12
+ * Add workflows for GitHub Actions
13
+
14
+ ## 0.6.0 (2019-11-24)
15
+
16
+ ### Features
17
+
18
+ * Add `--column` option for `output` command (#3)
19
+
20
+ ### Bug Fixes
21
+
22
+ * Fix error of Terminal format with empty outdated gems
23
+ * Fix tests against Terminal (Unicode table) format
24
+
25
+ ### Miscellaneous
26
+
27
+ * Suppress output in tests
28
+
29
+ ## 0.5.1 (2019-04-16)
30
+
31
+ ### Bug Fixes
32
+
33
+ * Fix some dependency errors (#2)
34
+
35
+ ## 0.5.0 (2018-05-26)
36
+
37
+ ### Features
38
+
39
+ * Support Terminal (Unicode table) format
40
+ * Change default style of Terminal format from ASCII table to Unicode table
41
+ * Add `--style` option for `output` command
42
+ * Change single quotes in XML declaration to double quotes
43
+ * Avoid self-closing tags
44
+
45
+ ### Bug Fixes
46
+
47
+ * Fix `Illegal character` exception (#1)
48
+
49
+ ## 0.4.0 (2017-12-29)
50
+
51
+ ### Features
52
+
53
+ * Support Terminal (ASCII table) format
54
+ * Change default format from Markdown to Terminal
55
+
3
56
  ## 0.3.0 (2017-07-08)
4
57
 
5
58
  ### Features
data/Gemfile CHANGED
@@ -2,3 +2,45 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bundle_outdated_formatter.gemspec
4
4
  gemspec
5
+
6
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.4.0')
7
+ gem 'simplecov', '< 0.18.0'
8
+ end
9
+
10
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.3.0') && Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.4.0')
11
+ if RUBY_PLATFORM !~ /mingw/
12
+ gem 'rubocop', '< 0.82.0'
13
+ gem 'rubocop-rspec', '< 1.39.0'
14
+ end
15
+ end
16
+
17
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.3.0')
18
+ gem 'psych', '< 3.0.0'
19
+ end
20
+
21
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.2.0') && Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.3.0')
22
+ if RUBY_PLATFORM !~ /mingw/
23
+ gem 'rubocop', '< 0.69.0'
24
+ gem 'rubocop-rspec', '< 1.33.0'
25
+ end
26
+ end
27
+
28
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.2.0')
29
+ gem 'parallel', '< 1.17.0'
30
+
31
+ if RUBY_PLATFORM !~ /mingw/
32
+ gem 'rubocop-rspec', '< 1.5.2'
33
+ end
34
+ end
35
+
36
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.1.0') && Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.2.0')
37
+ if RUBY_PLATFORM !~ /mingw/
38
+ gem 'rubocop', '< 0.58.0'
39
+ end
40
+ end
41
+
42
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.1.0')
43
+ if RUBY_PLATFORM !~ /mingw/
44
+ gem 'rubocop', '< 0.51.0'
45
+ end
46
+ end
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 emsk
3
+ Copyright (c) 2017-2020 emsk
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # BundleOutdatedFormatter
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/bundle_outdated_formatter.svg)](https://badge.fury.io/rb/bundle_outdated_formatter)
4
+ [![Build Status](https://github.com/emsk/bundle_outdated_formatter/workflows/build/badge.svg)](https://github.com/emsk/bundle_outdated_formatter/actions?query=workflow%3Abuild)
4
5
  [![Build Status](https://travis-ci.org/emsk/bundle_outdated_formatter.svg?branch=master)](https://travis-ci.org/emsk/bundle_outdated_formatter)
5
- [![Coverage Status](https://coveralls.io/repos/github/emsk/bundle_outdated_formatter/badge.svg?branch=master)](https://coveralls.io/github/emsk/bundle_outdated_formatter)
6
+ [![Build status](https://ci.appveyor.com/api/projects/status/w2qfj0a4iicqhmhq?svg=true)](https://ci.appveyor.com/project/emsk/bundle-outdated-formatter)
7
+ [![Codecov](https://codecov.io/gh/emsk/bundle_outdated_formatter/branch/master/graph/badge.svg)](https://codecov.io/gh/emsk/bundle_outdated_formatter)
6
8
  [![Code Climate](https://codeclimate.com/github/emsk/bundle_outdated_formatter/badges/gpa.svg)](https://codeclimate.com/github/emsk/bundle_outdated_formatter)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/emsk/bundle_outdated_formatter.svg)](https://gemnasium.com/github.com/emsk/bundle_outdated_formatter)
8
9
  [![Inline docs](http://inch-ci.org/github/emsk/bundle_outdated_formatter.svg?branch=master)](http://inch-ci.org/github/emsk/bundle_outdated_formatter)
9
10
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
10
11
 
@@ -40,8 +41,10 @@ $ bundle outdated | bof
40
41
 
41
42
  | Option | Alias | Description | Default |
42
43
  | :----- | :---- | :---------- | :------ |
43
- | `--format` | `-f` | Format. `markdown`, `json`, `yaml`, `csv`, `xml`, or `html`. | `markdown` |
44
+ | `--format` | `-f` | Format. `terminal`, `markdown`, `json`, `yaml`, `csv`, `tsv`, `xml`, or `html`. | `terminal` |
44
45
  | `--pretty` | `-p` | `true` if pretty output.<br>This option is available in `json`, `xml`, or `html` formats. | `false` |
46
+ | `--style` | `-s` | Terminal table style. `unicode` or `ascii`.<br>This option is available in `terminal` format. | `unicode` |
47
+ | `--column` | `-c` | Output columns. The columns are sorted in specified order. | `gem newest installed requested groups` |
45
48
 
46
49
  ## Examples
47
50
 
@@ -54,9 +57,35 @@ Fetching dependency metadata from https://rubygems.org/..
54
57
  Resolving dependencies...
55
58
 
56
59
  Outdated gems included in the bundle:
57
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
58
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
59
- * headless (newest 2.3.1, installed 2.2.3)
60
+ * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
61
+ * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in group "default"
62
+ * headless (newest 2.3.1, installed 2.2.3)
63
+ ```
64
+
65
+ ### Convert to Terminal
66
+
67
+ Unicode style:
68
+
69
+ ```
70
+ ┌──────────┬────────┬───────────┬───────────┬───────────────────┐
71
+ │ gem │ newest │ installed │ requested │ groups │
72
+ ├──────────┼────────┼───────────┼───────────┼───────────────────┤
73
+ │ faker │ 1.6.6 │ 1.6.5 │ ~> 1.4 │ development, test │
74
+ │ hashie │ 3.4.6 │ 1.2.0 │ = 1.2.0 │ default │
75
+ │ headless │ 2.3.1 │ 2.2.3 │ │ │
76
+ └──────────┴────────┴───────────┴───────────┴───────────────────┘
77
+ ```
78
+
79
+ ASCII style:
80
+
81
+ ```
82
+ +----------+--------+-----------+-----------+-------------------+
83
+ | gem | newest | installed | requested | groups |
84
+ +----------+--------+-----------+-----------+-------------------+
85
+ | faker | 1.6.6 | 1.6.5 | ~> 1.4 | development, test |
86
+ | hashie | 3.4.6 | 1.2.0 | = 1.2.0 | default |
87
+ | headless | 2.3.1 | 2.2.3 | | |
88
+ +----------+--------+-----------+-----------+-------------------+
60
89
  ```
61
90
 
62
91
  ### Convert to Markdown
@@ -149,19 +178,19 @@ Pretty output:
149
178
  Normal output:
150
179
 
151
180
  ```
152
- <?xml version='1.0' encoding='UTF-8'?><gems><outdated><gem>faker</gem><newest>1.6.6</newest><installed>1.6.5</installed><requested>~> 1.4</requested><groups>development, test</groups></outdated><outdated><gem>hashie</gem><newest>3.4.6</newest><installed>1.2.0</installed><requested>= 1.2.0</requested><groups>default</groups></outdated><outdated><gem>headless</gem><newest>2.3.1</newest><installed>2.2.3</installed><requested></requested><groups></groups></outdated></gems>
181
+ <?xml version="1.0" encoding="UTF-8"?><gems><outdated><gem>faker</gem><newest>1.6.6</newest><installed>1.6.5</installed><requested>~&gt; 1.4</requested><groups>development, test</groups></outdated><outdated><gem>hashie</gem><newest>3.4.6</newest><installed>1.2.0</installed><requested>= 1.2.0</requested><groups>default</groups></outdated><outdated><gem>headless</gem><newest>2.3.1</newest><installed>2.2.3</installed><requested></requested><groups></groups></outdated></gems>
153
182
  ```
154
183
 
155
184
  Pretty output:
156
185
 
157
186
  ```
158
- <?xml version='1.0' encoding='UTF-8'?>
187
+ <?xml version="1.0" encoding="UTF-8"?>
159
188
  <gems>
160
189
  <outdated>
161
190
  <gem>faker</gem>
162
191
  <newest>1.6.6</newest>
163
192
  <installed>1.6.5</installed>
164
- <requested>~> 1.4</requested>
193
+ <requested>~&gt; 1.4</requested>
165
194
  <groups>development, test</groups>
166
195
  </outdated>
167
196
  <outdated>
@@ -186,7 +215,7 @@ Pretty output:
186
215
  Normal output:
187
216
 
188
217
  ```
189
- <table><tr><th>gem</th><th>newest</th><th>installed</th><th>requested</th><th>groups</th></tr><tr><td>faker</td><td>1.6.6</td><td>1.6.5</td><td>~> 1.4</td><td>development, test</td></tr><tr><td>hashie</td><td>3.4.6</td><td>1.2.0</td><td>= 1.2.0</td><td>default</td></tr><tr><td>headless</td><td>2.3.1</td><td>2.2.3</td><td></td><td></td></tr></table>
218
+ <table><tr><th>gem</th><th>newest</th><th>installed</th><th>requested</th><th>groups</th></tr><tr><td>faker</td><td>1.6.6</td><td>1.6.5</td><td>~&gt; 1.4</td><td>development, test</td></tr><tr><td>hashie</td><td>3.4.6</td><td>1.2.0</td><td>= 1.2.0</td><td>default</td></tr><tr><td>headless</td><td>2.3.1</td><td>2.2.3</td><td></td><td></td></tr></table>
190
219
  ```
191
220
 
192
221
  Pretty output:
@@ -204,7 +233,7 @@ Pretty output:
204
233
  <td>faker</td>
205
234
  <td>1.6.6</td>
206
235
  <td>1.6.5</td>
207
- <td>~> 1.4</td>
236
+ <td>~&gt; 1.4</td>
208
237
  <td>development, test</td>
209
238
  </tr>
210
239
  <tr>
@@ -224,6 +253,10 @@ Pretty output:
224
253
  </table>
225
254
  ```
226
255
 
256
+ ## Related
257
+
258
+ * [bundle-outdated-formatter](https://github.com/emsk/bundle-outdated-formatter) - A Node.js implementation of the bundle_outdated_formatter
259
+
227
260
  ## Supported Ruby Versions
228
261
 
229
262
  * Ruby 2.0.0
@@ -231,6 +264,9 @@ Pretty output:
231
264
  * Ruby 2.2
232
265
  * Ruby 2.3
233
266
  * Ruby 2.4
267
+ * Ruby 2.5
268
+ * Ruby 2.6
269
+ * Ruby 2.7
234
270
 
235
271
  ## Contributing
236
272
 
@@ -0,0 +1,35 @@
1
+ version: 1.0.{build}-{branch}
2
+
3
+ environment:
4
+ RUBYOPT: -Eutf-8
5
+ matrix:
6
+ - RUBY_VERSION: 200
7
+ - RUBY_VERSION: 200-x64
8
+ - RUBY_VERSION: 21
9
+ - RUBY_VERSION: 21-x64
10
+ - RUBY_VERSION: 22
11
+ - RUBY_VERSION: 22-x64
12
+ - RUBY_VERSION: 23
13
+ - RUBY_VERSION: 23-x64
14
+ - RUBY_VERSION: 24
15
+ - RUBY_VERSION: 24-x64
16
+ - RUBY_VERSION: 25
17
+ - RUBY_VERSION: 25-x64
18
+ - RUBY_VERSION: 26
19
+ - RUBY_VERSION: 26-x64
20
+ - RUBY_VERSION: 27
21
+ - RUBY_VERSION: 27-x64
22
+
23
+ install:
24
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
25
+ - bundle install
26
+
27
+ build: off
28
+
29
+ before_test:
30
+ - ruby -v
31
+ - gem -v
32
+ - bundle -v
33
+
34
+ test_script:
35
+ - bundle exec rake
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'bundle_outdated_formatter/version'
6
4
 
@@ -22,12 +20,19 @@ Gem::Specification.new do |spec|
22
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
21
  spec.require_paths = ['lib']
24
22
 
25
- spec.add_runtime_dependency 'psych', '~> 2.2'
26
- spec.add_runtime_dependency 'thor', '~> 0.19'
27
- spec.add_development_dependency 'bundler', '~> 1.15'
28
- spec.add_development_dependency 'coveralls', '~> 0.8'
29
- spec.add_development_dependency 'rake', '~> 12.0'
30
- spec.add_development_dependency 'rspec', '~> 3.6'
31
- spec.add_development_dependency 'rubocop', '~> 0.49'
32
- spec.add_development_dependency 'simplecov', '~> 0.14'
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
25
+ spec.add_runtime_dependency 'psych', '>= 2.2'
26
+ spec.add_runtime_dependency 'rexml', '~> 3.2'
27
+ spec.add_runtime_dependency 'thor', '>= 0.20'
28
+ spec.add_runtime_dependency 'tty-table', '~> 0.10'
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'codecov'
31
+ spec.add_development_dependency 'rake'
32
+ spec.add_development_dependency 'rspec', '~> 3.9'
33
+ if RUBY_PLATFORM !~ /mingw/
34
+ spec.add_development_dependency 'rubocop', '~> 0.86'
35
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.40'
36
+ end
37
+ spec.add_development_dependency 'simplecov'
33
38
  end
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'bundle_outdated_formatter/error'
3
+ require 'bundle_outdated_formatter/formatter/terminal_formatter'
3
4
  require 'bundle_outdated_formatter/formatter/markdown_formatter'
4
5
  require 'bundle_outdated_formatter/formatter/json_formatter'
5
6
  require 'bundle_outdated_formatter/formatter/yaml_formatter'
@@ -12,6 +13,7 @@ module BundleOutdatedFormatter
12
13
  # Command-line interface of {BundleOutdatedFormatter}
13
14
  class CLI < Thor
14
15
  FORMATTERS = {
16
+ 'terminal' => TerminalFormatter,
15
17
  'markdown' => MarkdownFormatter,
16
18
  'json' => JSONFormatter,
17
19
  'yaml' => YAMLFormatter,
@@ -20,15 +22,25 @@ module BundleOutdatedFormatter
20
22
  'xml' => XMLFormatter,
21
23
  'html' => HTMLFormatter
22
24
  }.freeze
25
+ STYLES = %w[unicode ascii].freeze
26
+ COLUMNS = %w[gem newest installed requested groups].freeze
27
+
28
+ def self.exit_on_failure?
29
+ false
30
+ end
23
31
 
24
32
  default_command :output
25
33
 
26
34
  desc 'output', 'Format output of `bundle outdated`'
27
- option :format, type: :string, aliases: '-f', default: 'markdown', desc: 'Format. (markdown, json, yaml, csv, tsv, xml, html)'
35
+ option :format, type: :string, aliases: '-f', default: 'terminal', desc: 'Format. (terminal, markdown, json, yaml, csv, tsv, xml, html)'
28
36
  option :pretty, type: :boolean, aliases: '-p', desc: '`true` if pretty output.'
37
+ option :style, type: :string, aliases: '-s', default: 'unicode', desc: 'Terminal table style. (unicode, ascii)'
38
+ option :column, type: :array, aliases: '-c', default: %w[gem newest installed requested groups], desc: 'Output columns. (columns are sorted in specified order)'
29
39
 
30
40
  def output
31
41
  raise BundleOutdatedFormatter::UnknownFormatError, options[:format] unless allow_format?
42
+ raise BundleOutdatedFormatter::UnknownStyleError, options[:style] unless allow_style?
43
+ raise BundleOutdatedFormatter::UnknownColumnError, options[:column] unless allow_column?
32
44
  return if STDIN.tty?
33
45
 
34
46
  formatter = create_formatter
@@ -46,7 +58,17 @@ module BundleOutdatedFormatter
46
58
  private
47
59
 
48
60
  def allow_format?
49
- FORMATTERS.keys.include?(options[:format])
61
+ FORMATTERS.key?(options[:format])
62
+ end
63
+
64
+ def allow_style?
65
+ STYLES.include?(options[:style])
66
+ end
67
+
68
+ def allow_column?
69
+ options[:column].all? do |column|
70
+ COLUMNS.include?(column)
71
+ end
50
72
  end
51
73
 
52
74
  def create_formatter
@@ -1,4 +1,6 @@
1
1
  module BundleOutdatedFormatter
2
2
  class Error < StandardError; end
3
3
  class UnknownFormatError < Error; end
4
+ class UnknownStyleError < Error; end
5
+ class UnknownColumnError < Error; end
4
6
  end
@@ -3,16 +3,16 @@ require 'rexml/document'
3
3
  module BundleOutdatedFormatter
4
4
  # Formatter for all formats
5
5
  class Formatter
6
- GEM_REGEXP = /\A(\* )*(?<gem>.+) \(/
7
- NEWEST_REGEXP = /newest (?<newest>[\d\.]+)/
8
- INSTALLED_REGEXP = /installed (?<installed>[\d\.]+)/
9
- REQUESTED_REGEXP = /requested (?<requested>.+)\)/
10
- GROUPS_REGEXP = /in groups "(?<groups>.+)"/
11
-
12
- COLUMNS = %w[gem newest installed requested groups].freeze
6
+ GEM_REGEXP = /\A\* (?<gem>.+) \(/.freeze
7
+ NEWEST_REGEXP = /newest (?<newest>[\d.]+)/.freeze
8
+ INSTALLED_REGEXP = /installed (?<installed>[\d.]+)/.freeze
9
+ REQUESTED_REGEXP = /requested (?<requested>.+)\)/.freeze
10
+ GROUPS_REGEXP = /in groups? "(?<groups>.+)"/.freeze
13
11
 
14
12
  def initialize(options)
15
13
  @pretty = options[:pretty]
14
+ @style = options[:style]
15
+ @columns = options[:column]
16
16
  @outdated_gems = []
17
17
  end
18
18
 
@@ -32,27 +32,23 @@ module BundleOutdatedFormatter
32
32
  matched = match_gem(line)
33
33
  return unless match_gem?(matched)
34
34
 
35
- {
36
- 'gem' => gem_text(matched[:gem], :gem),
37
- 'newest' => gem_text(matched[:newest], :newest),
38
- 'installed' => gem_text(matched[:installed], :installed),
39
- 'requested' => gem_text(matched[:requested], :requested),
40
- 'groups' => gem_text(matched[:groups], :groups)
41
- }
35
+ gems = {}
36
+ @columns.each do |column|
37
+ gems[column] = gem_text(matched[column.to_sym], column.to_sym)
38
+ end
39
+ gems
42
40
  end
43
41
 
44
42
  def match_gem(line)
45
- {
46
- gem: GEM_REGEXP.match(line),
47
- newest: NEWEST_REGEXP.match(line),
48
- installed: INSTALLED_REGEXP.match(line),
49
- requested: REQUESTED_REGEXP.match(line),
50
- groups: GROUPS_REGEXP.match(line)
51
- }
43
+ gems = {}
44
+ @columns.each do |column|
45
+ gems[column.to_sym] = self.class.const_get("#{column.upcase}_REGEXP").match(line)
46
+ end
47
+ gems
52
48
  end
53
49
 
54
50
  def match_gem?(matched)
55
- COLUMNS.any? do |column|
51
+ @columns.any? do |column|
56
52
  !matched[column.to_sym].nil?
57
53
  end
58
54
  end
@@ -6,7 +6,7 @@ module BundleOutdatedFormatter
6
6
  class CSVFormatter < Formatter
7
7
  def convert
8
8
  text = CSV.generate(force_quotes: true) do |csv|
9
- csv << COLUMNS
9
+ csv << @columns
10
10
  @outdated_gems.each do |gem|
11
11
  csv << gem.values
12
12
  end
@@ -29,7 +29,7 @@ module BundleOutdatedFormatter
29
29
  def add_header_row
30
30
  elements = @root.add_element(REXML::Element.new('tr'))
31
31
 
32
- COLUMNS.each do |column|
32
+ @columns.each do |column|
33
33
  elements.add_element('th').add_text(column)
34
34
  end
35
35
  end
@@ -37,8 +37,9 @@ module BundleOutdatedFormatter
37
37
  def add_data_row(gem)
38
38
  elements = @root.add_element(REXML::Element.new('tr'))
39
39
 
40
- COLUMNS.each do |column|
41
- elements.add_element('td').add_text(gem[column])
40
+ @columns.each do |column|
41
+ escaped_text = REXML::Text.new(gem[column], false, nil, false)
42
+ elements.add_element('td').add_text(escaped_text)
42
43
  end
43
44
  end
44
45
  end
@@ -3,17 +3,21 @@ require 'bundle_outdated_formatter/formatter'
3
3
  module BundleOutdatedFormatter
4
4
  # Formatter for Markdown
5
5
  class MarkdownFormatter < Formatter
6
- HEADER = <<-EOS.freeze
7
- | gem | newest | installed | requested | groups |
8
- | --- | --- | --- | --- | --- |
9
- EOS
10
-
11
6
  def convert
12
7
  @outdated_gems.map! do |gem|
13
8
  "| #{gem.values.join(' | ')} |".gsub(/ /, ' ')
14
9
  end
15
10
 
16
- (HEADER + @outdated_gems.join("\n")).chomp
11
+ (header + @outdated_gems.join("\n")).chomp
12
+ end
13
+
14
+ private
15
+
16
+ def header
17
+ <<-EOS
18
+ | #{@columns.join(' | ')} |
19
+ | #{Array.new(@columns.size, '---').join(' | ')} |
20
+ EOS
17
21
  end
18
22
  end
19
23
  end
@@ -0,0 +1,23 @@
1
+ require 'tty-table'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for Terminal
6
+ class TerminalFormatter < Formatter
7
+ def convert
8
+ table.render(@style.to_sym, padding: [0, 1]).chomp
9
+ end
10
+
11
+ private
12
+
13
+ def table
14
+ return TTY::Table.new([@columns]) if @outdated_gems.empty?
15
+
16
+ TTY::Table.new(header: @columns) do |t|
17
+ @outdated_gems.each do |gem|
18
+ t << gem.values
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -6,7 +6,7 @@ module BundleOutdatedFormatter
6
6
  class TSVFormatter < Formatter
7
7
  def convert
8
8
  text = CSV.generate(force_quotes: true, col_sep: "\t") do |tsv|
9
- tsv << COLUMNS
9
+ tsv << @columns
10
10
  @outdated_gems.each do |gem|
11
11
  tsv << gem.values
12
12
  end
@@ -8,8 +8,8 @@ module BundleOutdatedFormatter
8
8
  super(options)
9
9
 
10
10
  @xml = REXML::Document.new(nil, raw: :all)
11
- @xml << REXML::XMLDecl.new('1.0', 'UTF-8')
12
11
  @root = REXML::Element.new('gems')
12
+ @root.add_text('')
13
13
  @xml.add_element(@root)
14
14
  end
15
15
 
@@ -19,6 +19,8 @@ module BundleOutdatedFormatter
19
19
  end
20
20
 
21
21
  io = StringIO.new
22
+ io.write('<?xml version="1.0" encoding="UTF-8"?>')
23
+ io.write("\n") if @pretty
22
24
  xml_formatter.write(@xml, io)
23
25
  io.string.chomp
24
26
  end
@@ -28,8 +30,9 @@ module BundleOutdatedFormatter
28
30
  def add_outdated(gem)
29
31
  elements = @root.add_element(REXML::Element.new('outdated'))
30
32
 
31
- COLUMNS.each do |column|
32
- elements.add_element(column).add_text(gem[column])
33
+ @columns.each do |column|
34
+ escaped_text = REXML::Text.new(gem[column], false, nil, false)
35
+ elements.add_element(column).add_text(escaped_text)
33
36
  end
34
37
  end
35
38
  end
@@ -1,3 +1,3 @@
1
1
  module BundleOutdatedFormatter
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,127 +1,169 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundle_outdated_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - emsk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-08 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rexml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0.20'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0.20'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-table
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: '0.19'
61
+ version: '0.10'
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '0.19'
68
+ version: '0.10'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '1.15'
75
+ version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '1.15'
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: coveralls
84
+ name: codecov
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - "~>"
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
- version: '0.8'
89
+ version: '0'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - "~>"
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
- version: '0.8'
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rake
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
- version: '12.0'
103
+ version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - "~>"
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
- version: '12.0'
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rspec
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '3.6'
117
+ version: '3.9'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '3.6'
124
+ version: '3.9'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: rubocop
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: '0.49'
131
+ version: '0.86'
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
136
  - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: '0.49'
138
+ version: '0.86'
111
139
  - !ruby/object:Gem::Dependency
112
- name: simplecov
140
+ name: rubocop-rspec
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: '0.14'
145
+ version: '1.40'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
150
  - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: '0.14'
152
+ version: '1.40'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
125
167
  description: BundleOutdatedFormatter is a command-line tool to format output of `bundle
126
168
  outdated`
127
169
  email:
@@ -131,6 +173,7 @@ executables:
131
173
  extensions: []
132
174
  extra_rdoc_files: []
133
175
  files:
176
+ - ".github/workflows/build.yml"
134
177
  - ".gitignore"
135
178
  - ".rspec"
136
179
  - ".rubocop.yml"
@@ -141,6 +184,7 @@ files:
141
184
  - LICENSE.txt
142
185
  - README.md
143
186
  - Rakefile
187
+ - appveyor.yml
144
188
  - bin/console
145
189
  - bin/setup
146
190
  - bundle_outdated_formatter.gemspec
@@ -153,6 +197,7 @@ files:
153
197
  - lib/bundle_outdated_formatter/formatter/html_formatter.rb
154
198
  - lib/bundle_outdated_formatter/formatter/json_formatter.rb
155
199
  - lib/bundle_outdated_formatter/formatter/markdown_formatter.rb
200
+ - lib/bundle_outdated_formatter/formatter/terminal_formatter.rb
156
201
  - lib/bundle_outdated_formatter/formatter/tsv_formatter.rb
157
202
  - lib/bundle_outdated_formatter/formatter/xml_formatter.rb
158
203
  - lib/bundle_outdated_formatter/formatter/yaml_formatter.rb
@@ -169,15 +214,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
214
  requirements:
170
215
  - - ">="
171
216
  - !ruby/object:Gem::Version
172
- version: '0'
217
+ version: 2.0.0
173
218
  required_rubygems_version: !ruby/object:Gem::Requirement
174
219
  requirements:
175
220
  - - ">="
176
221
  - !ruby/object:Gem::Version
177
222
  version: '0'
178
223
  requirements: []
179
- rubyforge_project:
180
- rubygems_version: 2.6.10
224
+ rubygems_version: 3.1.2
181
225
  signing_key:
182
226
  specification_version: 4
183
227
  summary: Formatter for `bundle outdated`