bof 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2b349f5b591143cce43bcca4f5a939769b0bb697d7cf7cf9214d8c35d87fb760
4
+ data.tar.gz: 84269b4ed2c31256538abb134386107bbffa56ca32316cf05aaf94d89b7d13e8
5
+ SHA512:
6
+ metadata.gz: 8ddc5314b37eaa2e80e12e7bf842faa165e8619991d39b0c2fdd2f37d5573dc4cab2cf93df8ca7b13ed709178793e3c0a9fd07cf25eb185c77e3ae0b1f0ad9f3
7
+ data.tar.gz: 636c29fba0d7070e30337cf19a1c404e8463d2c9ee70abf0802fbaa95216abaca12e1cdfa7c6ab3e74f31213890114164696c5db302a1383bf0a9388a9ce0a29
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,25 @@
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.6', '2.7', '3.0']
13
+ steps:
14
+ - uses: actions/checkout@v4
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
22
+ - name: Upload coverage to Codecov
23
+ uses: codecov/codecov-action@v3
24
+ with:
25
+ file: ./coverage/.resultset.json
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ require: rubocop-rspec
3
+
4
+ AllCops:
5
+ DisplayCopNames: true
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+
9
+ Bundler/DuplicatedGem:
10
+ Enabled: false
11
+
12
+ Layout/HashAlignment:
13
+ EnforcedHashRocketStyle: table
14
+
15
+ Layout/HeredocIndentation:
16
+ Enabled: false
17
+
18
+ Layout/LineLength:
19
+ Enabled: false
20
+
21
+ Layout/TrailingWhitespace:
22
+ Exclude:
23
+ - 'spec/**/*.rb'
24
+
25
+ Metrics/AbcSize:
26
+ Max: 20
27
+
28
+ Metrics/BlockLength:
29
+ Exclude:
30
+ - 'spec/**/*.rb'
31
+ - '*.gemspec'
32
+
33
+ Naming/HeredocDelimiterNaming:
34
+ Enabled: false
35
+
36
+ Style/FrozenStringLiteralComment:
37
+ Enabled: false
38
+
39
+ Style/IfUnlessModifier:
40
+ Exclude:
41
+ - 'Gemfile'
42
+
43
+ RSpec/FilePath:
44
+ Enabled: false
45
+
46
+ RSpec/NestedGroups:
47
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,41 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-04-27 14:43:08 UTC using RuboCop version 1.13.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
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'
15
+
16
+ # Offense count: 3
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
19
+ Layout/EmptyLineBetweenDefs:
20
+ Exclude:
21
+ - 'lib/bundle_outdated_formatter/error.rb'
22
+
23
+ # Offense count: 278
24
+ # Configuration parameters: AllowSubject.
25
+ RSpec/MultipleMemoizedHelpers:
26
+ Max: 31
27
+
28
+ # Offense count: 10
29
+ # Cop supports --auto-correct.
30
+ Style/GlobalStdStream:
31
+ Exclude:
32
+ - 'lib/bundle_outdated_formatter/cli.rb'
33
+ - 'lib/bundle_outdated_formatter/formatter.rb'
34
+ - 'spec/bundle_outdated_formatter/cli_spec.rb'
35
+
36
+ # Offense count: 4
37
+ # Cop supports --auto-correct.
38
+ # Configuration parameters: AllowModifier.
39
+ Style/SoleNestedConditional:
40
+ Exclude:
41
+ - 'Gemfile'
data/CHANGELOG.md ADDED
@@ -0,0 +1,84 @@
1
+ # Change Log
2
+
3
+ ## 1.0.0 (2023-12-27)
4
+
5
+ * Support table format stdin for Bundler 2.2 or higher ( https://github.com/ytkg/bundle_outdated_formatter/pull/6 )
6
+
7
+ ## 0.7.0 (2020-06-29)
8
+
9
+ ### Features
10
+
11
+ * Support Bundler >= 2.1.0.pre.1 (#4)
12
+
13
+ ### Miscellaneous
14
+
15
+ * Relax dependency version requirements
16
+ * Add workflows for GitHub Actions
17
+
18
+ ## 0.6.0 (2019-11-24)
19
+
20
+ ### Features
21
+
22
+ * Add `--column` option for `output` command (#3)
23
+
24
+ ### Bug Fixes
25
+
26
+ * Fix error of Terminal format with empty outdated gems
27
+ * Fix tests against Terminal (Unicode table) format
28
+
29
+ ### Miscellaneous
30
+
31
+ * Suppress output in tests
32
+
33
+ ## 0.5.1 (2019-04-16)
34
+
35
+ ### Bug Fixes
36
+
37
+ * Fix some dependency errors (#2)
38
+
39
+ ## 0.5.0 (2018-05-26)
40
+
41
+ ### Features
42
+
43
+ * Support Terminal (Unicode table) format
44
+ * Change default style of Terminal format from ASCII table to Unicode table
45
+ * Add `--style` option for `output` command
46
+ * Change single quotes in XML declaration to double quotes
47
+ * Avoid self-closing tags
48
+
49
+ ### Bug Fixes
50
+
51
+ * Fix `Illegal character` exception (#1)
52
+
53
+ ## 0.4.0 (2017-12-29)
54
+
55
+ ### Features
56
+
57
+ * Support Terminal (ASCII table) format
58
+ * Change default format from Markdown to Terminal
59
+
60
+ ## 0.3.0 (2017-07-08)
61
+
62
+ ### Features
63
+
64
+ * Support TSV format
65
+ * Add `--pretty` option for `output` command
66
+ * Raise `UnknownFormatError` if format is not allowed
67
+
68
+ ## 0.2.0 (2017-06-19)
69
+
70
+ ### Features
71
+
72
+ * Support JSON format
73
+ * Support YAML format
74
+ * Support CSV format
75
+ * Support XML format
76
+ * Support HTML format
77
+
78
+ ## 0.1.0 (2017-06-15)
79
+
80
+ ### Features
81
+
82
+ * Add `output` command (default)
83
+ * Support Markdown format (default)
84
+ * Add `version`, `--version`, and `-v` commands
data/Gemfile ADDED
@@ -0,0 +1,46 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bundle_outdated_formatter.gemspec
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
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017-2021 emsk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # BundleOutdatedFormatter
2
+
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/actions/workflows/build.yml/badge.svg)](https://github.com/emsk/bundle_outdated_formatter/actions/workflows/build.yml)
5
+ [![Codecov](https://codecov.io/gh/emsk/bundle_outdated_formatter/branch/main/graph/badge.svg)](https://codecov.io/gh/emsk/bundle_outdated_formatter)
6
+ [![Code Climate](https://codeclimate.com/github/emsk/bundle_outdated_formatter/badges/gpa.svg)](https://codeclimate.com/github/emsk/bundle_outdated_formatter)
7
+ [![Inline docs](http://inch-ci.org/github/emsk/bundle_outdated_formatter.svg?branch=main)](http://inch-ci.org/github/emsk/bundle_outdated_formatter)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
9
+
10
+ BundleOutdatedFormatter is a command-line tool to format output of `bundle outdated`.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'bof'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```sh
23
+ $ bundle
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```sh
29
+ $ gem install bof
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```sh
35
+ $ bundle outdated | bof
36
+ ```
37
+
38
+ ## Command Options
39
+
40
+ | Option | Alias | Description | Default |
41
+ | :----- | :---- | :---------- | :------ |
42
+ | `--format` | `-f` | Format. `terminal`, `markdown`, `json`, `yaml`, `csv`, `tsv`, `xml`, or `html`. | `terminal` |
43
+ | `--pretty` | `-p` | `true` if pretty output.<br>This option is available in `json`, `xml`, or `html` formats. | `false` |
44
+ | `--style` | `-s` | Terminal table style. `unicode` or `ascii`.<br>This option is available in `terminal` format. | `unicode` |
45
+ | `--column` | `-c` | Output columns. The columns are sorted in specified order. | `gem newest installed requested groups` |
46
+
47
+ ## Examples
48
+
49
+ Output of `bundle outdated`:
50
+
51
+ ```
52
+ Fetching gem metadata from https://rubygems.org/..........
53
+ Fetching version metadata from https://rubygems.org/...
54
+ Fetching dependency metadata from https://rubygems.org/..
55
+ Resolving dependencies...
56
+
57
+ Outdated gems included in the bundle:
58
+ * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
59
+ * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in group "default"
60
+ * headless (newest 2.3.1, installed 2.2.3)
61
+ ```
62
+
63
+ ### Convert to Terminal
64
+
65
+ Unicode style:
66
+
67
+ ```
68
+ ┌──────────┬────────┬───────────┬───────────┬───────────────────┐
69
+ │ gem │ newest │ installed │ requested │ groups │
70
+ ├──────────┼────────┼───────────┼───────────┼───────────────────┤
71
+ │ faker │ 1.6.6 │ 1.6.5 │ ~> 1.4 │ development, test │
72
+ │ hashie │ 3.4.6 │ 1.2.0 │ = 1.2.0 │ default │
73
+ │ headless │ 2.3.1 │ 2.2.3 │ │ │
74
+ └──────────┴────────┴───────────┴───────────┴───────────────────┘
75
+ ```
76
+
77
+ ASCII style:
78
+
79
+ ```
80
+ +----------+--------+-----------+-----------+-------------------+
81
+ | gem | newest | installed | requested | groups |
82
+ +----------+--------+-----------+-----------+-------------------+
83
+ | faker | 1.6.6 | 1.6.5 | ~> 1.4 | development, test |
84
+ | hashie | 3.4.6 | 1.2.0 | = 1.2.0 | default |
85
+ | headless | 2.3.1 | 2.2.3 | | |
86
+ +----------+--------+-----------+-----------+-------------------+
87
+ ```
88
+
89
+ ### Convert to Markdown
90
+
91
+ ```
92
+ | gem | newest | installed | requested | groups |
93
+ | --- | --- | --- | --- | --- |
94
+ | faker | 1.6.6 | 1.6.5 | ~> 1.4 | development, test |
95
+ | hashie | 3.4.6 | 1.2.0 | = 1.2.0 | default |
96
+ | headless | 2.3.1 | 2.2.3 | | |
97
+ ```
98
+
99
+ ### Convert to JSON
100
+
101
+ Normal output:
102
+
103
+ ```
104
+ [{"gem":"faker","newest":"1.6.6","installed":"1.6.5","requested":"~> 1.4","groups":"development, test"},{"gem":"hashie","newest":"3.4.6","installed":"1.2.0","requested":"= 1.2.0","groups":"default"},{"gem":"headless","newest":"2.3.1","installed":"2.2.3","requested":"","groups":""}]
105
+ ```
106
+
107
+ Pretty output:
108
+
109
+ ```
110
+ [
111
+ {
112
+ "gem": "faker",
113
+ "newest": "1.6.6",
114
+ "installed": "1.6.5",
115
+ "requested": "~> 1.4",
116
+ "groups": "development, test"
117
+ },
118
+ {
119
+ "gem": "hashie",
120
+ "newest": "3.4.6",
121
+ "installed": "1.2.0",
122
+ "requested": "= 1.2.0",
123
+ "groups": "default"
124
+ },
125
+ {
126
+ "gem": "headless",
127
+ "newest": "2.3.1",
128
+ "installed": "2.2.3",
129
+ "requested": "",
130
+ "groups": ""
131
+ }
132
+ ]
133
+ ```
134
+
135
+ ### Convert to YAML
136
+
137
+ ```
138
+ ---
139
+ - gem: faker
140
+ newest: 1.6.6
141
+ installed: 1.6.5
142
+ requested: "~> 1.4"
143
+ groups: development, test
144
+ - gem: hashie
145
+ newest: 3.4.6
146
+ installed: 1.2.0
147
+ requested: "= 1.2.0"
148
+ groups: default
149
+ - gem: headless
150
+ newest: 2.3.1
151
+ installed: 2.2.3
152
+ requested: ''
153
+ groups: ''
154
+ ```
155
+
156
+ ### Convert to CSV
157
+
158
+ ```
159
+ "gem","newest","installed","requested","groups"
160
+ "faker","1.6.6","1.6.5","~> 1.4","development, test"
161
+ "hashie","3.4.6","1.2.0","= 1.2.0","default"
162
+ "headless","2.3.1","2.2.3","",""
163
+ ```
164
+
165
+ ### Convert to TSV
166
+
167
+ ```
168
+ "gem" "newest" "installed" "requested" "groups"
169
+ "faker" "1.6.6" "1.6.5" "~> 1.4" "development, test"
170
+ "hashie" "3.4.6" "1.2.0" "= 1.2.0" "default"
171
+ "headless" "2.3.1" "2.2.3" "" ""
172
+ ```
173
+
174
+ ### Convert to XML
175
+
176
+ Normal output:
177
+
178
+ ```
179
+ <?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>
180
+ ```
181
+
182
+ Pretty output:
183
+
184
+ ```
185
+ <?xml version="1.0" encoding="UTF-8"?>
186
+ <gems>
187
+ <outdated>
188
+ <gem>faker</gem>
189
+ <newest>1.6.6</newest>
190
+ <installed>1.6.5</installed>
191
+ <requested>~&gt; 1.4</requested>
192
+ <groups>development, test</groups>
193
+ </outdated>
194
+ <outdated>
195
+ <gem>hashie</gem>
196
+ <newest>3.4.6</newest>
197
+ <installed>1.2.0</installed>
198
+ <requested>= 1.2.0</requested>
199
+ <groups>default</groups>
200
+ </outdated>
201
+ <outdated>
202
+ <gem>headless</gem>
203
+ <newest>2.3.1</newest>
204
+ <installed>2.2.3</installed>
205
+ <requested></requested>
206
+ <groups></groups>
207
+ </outdated>
208
+ </gems>
209
+ ```
210
+
211
+ ### Convert to HTML
212
+
213
+ Normal output:
214
+
215
+ ```
216
+ <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>
217
+ ```
218
+
219
+ Pretty output:
220
+
221
+ ```
222
+ <table>
223
+ <tr>
224
+ <th>gem</th>
225
+ <th>newest</th>
226
+ <th>installed</th>
227
+ <th>requested</th>
228
+ <th>groups</th>
229
+ </tr>
230
+ <tr>
231
+ <td>faker</td>
232
+ <td>1.6.6</td>
233
+ <td>1.6.5</td>
234
+ <td>~&gt; 1.4</td>
235
+ <td>development, test</td>
236
+ </tr>
237
+ <tr>
238
+ <td>hashie</td>
239
+ <td>3.4.6</td>
240
+ <td>1.2.0</td>
241
+ <td>= 1.2.0</td>
242
+ <td>default</td>
243
+ </tr>
244
+ <tr>
245
+ <td>headless</td>
246
+ <td>2.3.1</td>
247
+ <td>2.2.3</td>
248
+ <td></td>
249
+ <td></td>
250
+ </tr>
251
+ </table>
252
+ ```
253
+
254
+ ## Related
255
+
256
+ * [bundle-outdated-formatter](https://github.com/emsk/bundle-outdated-formatter) - A Node.js implementation of the bundle_outdated_formatter
257
+
258
+ ## Supported Ruby Versions
259
+
260
+ Ruby 2.0.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0
261
+
262
+ ## Contributing
263
+
264
+ Bug reports and pull requests are welcome.
265
+
266
+ ## License
267
+
268
+ [MIT](LICENSE.txt)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'bundle_outdated_formatter'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'bundle_outdated_formatter/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bof'
7
+ spec.version = BundleOutdatedFormatter::VERSION
8
+ spec.authors = ['emsk']
9
+ spec.email = ['emsk1987@gmail.com']
10
+
11
+ spec.summary = 'Formatter for `bundle outdated`'
12
+ spec.description = 'BundleOutdatedFormatter is a command-line tool to format output of `bundle outdated`'
13
+ spec.homepage = 'https://github.com/ytkg/bundle_outdated_formatter'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.required_ruby_version = '>= 2.6.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 'rake'
31
+ spec.add_development_dependency 'rspec'
32
+ if RUBY_PLATFORM !~ /mingw/
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'rubocop-rspec'
35
+ end
36
+ spec.add_development_dependency 'simplecov'
37
+ end
data/exe/bof ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundle_outdated_formatter'
4
+
5
+ BundleOutdatedFormatter::CLI.start
@@ -0,0 +1,78 @@
1
+ require 'thor'
2
+ require 'bundle_outdated_formatter/error'
3
+ require 'bundle_outdated_formatter/formatter/terminal_formatter'
4
+ require 'bundle_outdated_formatter/formatter/markdown_formatter'
5
+ require 'bundle_outdated_formatter/formatter/json_formatter'
6
+ require 'bundle_outdated_formatter/formatter/yaml_formatter'
7
+ require 'bundle_outdated_formatter/formatter/csv_formatter'
8
+ require 'bundle_outdated_formatter/formatter/tsv_formatter'
9
+ require 'bundle_outdated_formatter/formatter/xml_formatter'
10
+ require 'bundle_outdated_formatter/formatter/html_formatter'
11
+
12
+ module BundleOutdatedFormatter
13
+ # Command-line interface of {BundleOutdatedFormatter}
14
+ class CLI < Thor
15
+ FORMATTERS = {
16
+ 'terminal' => TerminalFormatter,
17
+ 'markdown' => MarkdownFormatter,
18
+ 'json' => JSONFormatter,
19
+ 'yaml' => YAMLFormatter,
20
+ 'csv' => CSVFormatter,
21
+ 'tsv' => TSVFormatter,
22
+ 'xml' => XMLFormatter,
23
+ 'html' => HTMLFormatter
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
31
+
32
+ default_command :output
33
+
34
+ desc 'output', 'Format output of `bundle outdated`'
35
+ option :format, type: :string, aliases: '-f', default: 'terminal', desc: 'Format. (terminal, markdown, json, yaml, csv, tsv, xml, html)'
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)'
39
+
40
+ def output
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?
44
+ return if STDIN.tty?
45
+
46
+ formatter = create_formatter
47
+ formatter.read_stdin
48
+ puts formatter.convert
49
+ end
50
+
51
+ desc 'version, -v, --version', 'Print the version'
52
+ map %w[-v --version] => :version
53
+
54
+ def version
55
+ puts "bundle_outdated_formatter #{BundleOutdatedFormatter::VERSION}"
56
+ end
57
+
58
+ private
59
+
60
+ def allow_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
72
+ end
73
+
74
+ def create_formatter
75
+ FORMATTERS[options[:format]].new(options)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,6 @@
1
+ module BundleOutdatedFormatter
2
+ class Error < StandardError; end
3
+ class UnknownFormatError < Error; end
4
+ class UnknownStyleError < Error; end
5
+ class UnknownColumnError < Error; end
6
+ end
@@ -0,0 +1,17 @@
1
+ require 'csv'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for CSV
6
+ class CSVFormatter < Formatter
7
+ def convert
8
+ text = CSV.generate(force_quotes: true) do |csv|
9
+ csv << @columns
10
+ @outdated_gems.each do |gem|
11
+ csv << gem.values
12
+ end
13
+ end
14
+ text.chomp
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ require 'rexml/document'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for HTML
6
+ class HTMLFormatter < Formatter
7
+ def initialize(options)
8
+ super(options)
9
+
10
+ @html = REXML::Document.new(nil, raw: :all)
11
+ @root = REXML::Element.new('table')
12
+ @html.add_element(@root)
13
+ end
14
+
15
+ def convert
16
+ add_header_row
17
+
18
+ @outdated_gems.each do |gem|
19
+ add_data_row(gem)
20
+ end
21
+
22
+ io = StringIO.new
23
+ xml_formatter.write(@html, io)
24
+ io.string.chomp
25
+ end
26
+
27
+ private
28
+
29
+ def add_header_row
30
+ elements = @root.add_element(REXML::Element.new('tr'))
31
+
32
+ @columns.each do |column|
33
+ elements.add_element('th').add_text(column)
34
+ end
35
+ end
36
+
37
+ def add_data_row(gem)
38
+ elements = @root.add_element(REXML::Element.new('tr'))
39
+
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)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ require 'json'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for JSON
6
+ class JSONFormatter < Formatter
7
+ def convert
8
+ text = @pretty ? JSON.pretty_generate(@outdated_gems) : @outdated_gems.to_json
9
+ text.chomp
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require 'bundle_outdated_formatter/formatter'
2
+
3
+ module BundleOutdatedFormatter
4
+ # Formatter for Markdown
5
+ class MarkdownFormatter < Formatter
6
+ def convert
7
+ @outdated_gems.map! do |gem|
8
+ "| #{gem.values.join(' | ')} |".gsub(/ /, ' ')
9
+ end
10
+
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
21
+ end
22
+ end
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
@@ -0,0 +1,17 @@
1
+ require 'csv'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for TSV
6
+ class TSVFormatter < Formatter
7
+ def convert
8
+ text = CSV.generate(force_quotes: true, col_sep: "\t") do |tsv|
9
+ tsv << @columns
10
+ @outdated_gems.each do |gem|
11
+ tsv << gem.values
12
+ end
13
+ end
14
+ text.chomp
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ require 'rexml/document'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for XML
6
+ class XMLFormatter < Formatter
7
+ def initialize(options)
8
+ super(options)
9
+
10
+ @xml = REXML::Document.new(nil, raw: :all)
11
+ @root = REXML::Element.new('gems')
12
+ @root.add_text('')
13
+ @xml.add_element(@root)
14
+ end
15
+
16
+ def convert
17
+ @outdated_gems.each do |gem|
18
+ add_outdated(gem)
19
+ end
20
+
21
+ io = StringIO.new
22
+ io.write('<?xml version="1.0" encoding="UTF-8"?>')
23
+ io.write("\n") if @pretty
24
+ xml_formatter.write(@xml, io)
25
+ io.string.chomp
26
+ end
27
+
28
+ private
29
+
30
+ def add_outdated(gem)
31
+ elements = @root.add_element(REXML::Element.new('outdated'))
32
+
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)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ require 'psych'
2
+ require 'bundle_outdated_formatter/formatter'
3
+
4
+ module BundleOutdatedFormatter
5
+ # Formatter for YAML
6
+ class YAMLFormatter < Formatter
7
+ def convert
8
+ @outdated_gems.to_yaml.chomp
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,103 @@
1
+ require 'rexml/document'
2
+
3
+ module BundleOutdatedFormatter
4
+ # Formatter for all formats
5
+ class Formatter
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
11
+ TABLE_FORMAT_REGEXP = /Gem +Current +Latest +Requested +Groups/.freeze
12
+
13
+ def initialize(options)
14
+ @pretty = options[:pretty]
15
+ @style = options[:style]
16
+ @columns = options[:column]
17
+ @outdated_gems = []
18
+ end
19
+
20
+ def read_stdin
21
+ @outdated_gems = STDIN.each.to_a.map(&:strip).reject(&:empty?)
22
+
23
+ if (header_index = find_table_header_index(@outdated_gems))
24
+ header = @outdated_gems[header_index]
25
+ pos = table_pos(header)
26
+ @outdated_gems.map!.with_index do |line, index|
27
+ find_gem_for_table_format(line, pos) if header_index < index
28
+ end
29
+ else
30
+ @outdated_gems.map! do |line|
31
+ find_gem(line)
32
+ end
33
+ end
34
+ @outdated_gems.compact!
35
+ end
36
+
37
+ private
38
+
39
+ def find_gem(line)
40
+ matched = match_gem(line)
41
+ return unless match_gem?(matched)
42
+
43
+ gems = {}
44
+ @columns.each do |column|
45
+ gems[column] = gem_text(matched[column.to_sym], column.to_sym)
46
+ end
47
+ gems
48
+ end
49
+
50
+ def match_gem(line)
51
+ gems = {}
52
+ @columns.each do |column|
53
+ gems[column.to_sym] = self.class.const_get("#{column.upcase}_REGEXP").match(line)
54
+ end
55
+ gems
56
+ end
57
+
58
+ def match_gem?(matched)
59
+ @columns.any? do |column|
60
+ !matched[column.to_sym].nil?
61
+ end
62
+ end
63
+
64
+ def gem_text(text, name)
65
+ text ? text[name] : ''
66
+ end
67
+
68
+ def find_table_header_index(lines)
69
+ lines.find_index { |line| line =~ TABLE_FORMAT_REGEXP }
70
+ end
71
+
72
+ def table_pos(header)
73
+ current_pos = header.index('Current')
74
+ latest_pos = header.index('Latest')
75
+ requested_pos = header.index('Requested')
76
+ groups_pos = header.index('Groups')
77
+ {
78
+ 'gem' => 0..current_pos.pred,
79
+ 'newest' => latest_pos..requested_pos.pred,
80
+ 'installed' => current_pos..latest_pos.pred,
81
+ 'requested' => requested_pos..groups_pos.pred,
82
+ 'groups' => groups_pos..-1
83
+ }
84
+ end
85
+
86
+ def find_gem_for_table_format(line, pos)
87
+ gems = {}
88
+ @columns.each do |column|
89
+ range = pos[column]
90
+ gems[column] = line[range].to_s.strip
91
+ end
92
+ gems
93
+ end
94
+
95
+ def xml_formatter
96
+ return REXML::Formatters::Default.new unless @pretty
97
+
98
+ formatter = REXML::Formatters::Pretty.new
99
+ formatter.compact = true
100
+ formatter
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,3 @@
1
+ module BundleOutdatedFormatter
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundle_outdated_formatter/version'
2
+ require 'bundle_outdated_formatter/cli'
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bof
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - emsk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: psych
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
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'
41
+ - !ruby/object:Gem::Dependency
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
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: BundleOutdatedFormatter is a command-line tool to format output of `bundle
154
+ outdated`
155
+ email:
156
+ - emsk1987@gmail.com
157
+ executables:
158
+ - bof
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - ".github/dependabot.yml"
163
+ - ".github/workflows/build.yml"
164
+ - ".gitignore"
165
+ - ".rspec"
166
+ - ".rubocop.yml"
167
+ - ".rubocop_todo.yml"
168
+ - CHANGELOG.md
169
+ - Gemfile
170
+ - LICENSE.txt
171
+ - README.md
172
+ - Rakefile
173
+ - bin/console
174
+ - bin/setup
175
+ - bundle_outdated_formatter.gemspec
176
+ - exe/bof
177
+ - lib/bundle_outdated_formatter.rb
178
+ - lib/bundle_outdated_formatter/cli.rb
179
+ - lib/bundle_outdated_formatter/error.rb
180
+ - lib/bundle_outdated_formatter/formatter.rb
181
+ - lib/bundle_outdated_formatter/formatter/csv_formatter.rb
182
+ - lib/bundle_outdated_formatter/formatter/html_formatter.rb
183
+ - lib/bundle_outdated_formatter/formatter/json_formatter.rb
184
+ - lib/bundle_outdated_formatter/formatter/markdown_formatter.rb
185
+ - lib/bundle_outdated_formatter/formatter/terminal_formatter.rb
186
+ - lib/bundle_outdated_formatter/formatter/tsv_formatter.rb
187
+ - lib/bundle_outdated_formatter/formatter/xml_formatter.rb
188
+ - lib/bundle_outdated_formatter/formatter/yaml_formatter.rb
189
+ - lib/bundle_outdated_formatter/version.rb
190
+ homepage: https://github.com/ytkg/bundle_outdated_formatter
191
+ licenses:
192
+ - MIT
193
+ metadata: {}
194
+ post_install_message:
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 2.6.0
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ requirements: []
209
+ rubygems_version: 3.3.26
210
+ signing_key:
211
+ specification_version: 4
212
+ summary: Formatter for `bundle outdated`
213
+ test_files: []