brew_outdated_formatter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +26 -0
- data/.rubocop_todo.yml +13 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +233 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/brew_outdated_formatter.gemspec +31 -0
- data/exe/brof +5 -0
- data/lib/brew_outdated_formatter.rb +2 -0
- data/lib/brew_outdated_formatter/cli.rb +58 -0
- data/lib/brew_outdated_formatter/error.rb +4 -0
- data/lib/brew_outdated_formatter/formatter.rb +67 -0
- data/lib/brew_outdated_formatter/formatter/csv_formatter.rb +17 -0
- data/lib/brew_outdated_formatter/formatter/html_formatter.rb +45 -0
- data/lib/brew_outdated_formatter/formatter/json_formatter.rb +12 -0
- data/lib/brew_outdated_formatter/formatter/markdown_formatter.rb +19 -0
- data/lib/brew_outdated_formatter/formatter/terminal_formatter.rb +18 -0
- data/lib/brew_outdated_formatter/formatter/tsv_formatter.rb +17 -0
- data/lib/brew_outdated_formatter/formatter/xml_formatter.rb +36 -0
- data/lib/brew_outdated_formatter/formatter/yaml_formatter.rb +11 -0
- data/lib/brew_outdated_formatter/version.rb +3 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7419f50d3100b17e1517584d470b3dec753145d937e32eabd7960b65360df99a
|
4
|
+
data.tar.gz: 1ac128ab2a3b424e2a778db4c2f9c24584cc168ee4d991dc757dbcbe94c29e96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8bb9899852c2d2957f41970269d0bc6493b445f7e1194594b1d7e2dc985d265f0781e6f84dc8846678184d1acb55316af1c8ffface6660395dfb4f58e95e47a
|
7
|
+
data.tar.gz: 4316808545cf2615527d96e4a37dd7f82b20ca1884d99de576f6d55e698ca06003780f129ece03fe61dc0e8149f4ad454f69a90971e26504e35d5b372d872c51
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
|
6
|
+
Layout/IndentHeredoc:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Layout/SpaceInsideBlockBraces:
|
10
|
+
Exclude:
|
11
|
+
- 'Gemfile'
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Exclude:
|
15
|
+
- 'spec/**/*.rb'
|
16
|
+
- '*.gemspec'
|
17
|
+
|
18
|
+
Metrics/LineLength:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Naming/HeredocDelimiterNaming:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/IfUnlessModifier:
|
25
|
+
Exclude:
|
26
|
+
- 'Gemfile'
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-01-01 11:23:11 +0900 using RuboCop version 0.52.1.
|
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: 11
|
10
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
11
|
+
# URISchemes: http, https
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 140
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.1.0 (2018-01-01)
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
* Add `output` command (default)
|
8
|
+
* Support Terminal (ASCII table) format (default)
|
9
|
+
* Support Markdown format
|
10
|
+
* Support JSON format
|
11
|
+
* Support YAML format
|
12
|
+
* Support CSV format
|
13
|
+
* Support TSV format
|
14
|
+
* Support XML format
|
15
|
+
* Support HTML format
|
16
|
+
* Add `version`, `--version`, and `-v` commands
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in brew_outdated_formatter.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.1.0')
|
9
|
+
gem 'rubocop', '< 0.51.0'
|
10
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017-2018 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,233 @@
|
|
1
|
+
# BrewOutdatedFormatter
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/emsk/brew_outdated_formatter.svg?branch=master)](https://travis-ci.org/emsk/brew_outdated_formatter)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/8453393423f70479acd8/maintainability)](https://codeclimate.com/github/emsk/brew_outdated_formatter/maintainability)
|
5
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/emsk/brew_outdated_formatter.svg)](https://gemnasium.com/github.com/emsk/brew_outdated_formatter)
|
6
|
+
[![Inline docs](http://inch-ci.org/github/emsk/brew_outdated_formatter.svg?branch=master)](http://inch-ci.org/github/emsk/brew_outdated_formatter)
|
7
|
+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
|
8
|
+
|
9
|
+
BrewOutdatedFormatter is a command-line tool to format output of `brew outdated --verbose`.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'brew_outdated_formatter'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```sh
|
28
|
+
$ gem install brew_outdated_formatter
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```sh
|
34
|
+
$ brew outdated --verbose | brof
|
35
|
+
```
|
36
|
+
|
37
|
+
## Command Options
|
38
|
+
|
39
|
+
| Option | Alias | Description | Default |
|
40
|
+
| :----- | :---- | :---------- | :------ |
|
41
|
+
| `--format` | `-f` | Format. `terminal`, `markdown`, `json`, `yaml`, `csv`, `tsv`, `xml`, or `html`. | `terminal` |
|
42
|
+
| `--pretty` | `-p` | `true` if pretty output.<br>This option is available in `json`, `xml`, or `html` formats. | `false` |
|
43
|
+
|
44
|
+
## Examples
|
45
|
+
|
46
|
+
Output of `brew outdated --verbose`:
|
47
|
+
|
48
|
+
```
|
49
|
+
test1 (0.0.1) < 0.1
|
50
|
+
test2 (0.0.2) < 0.1 [pinned at 0.0.2]
|
51
|
+
test3 (10.10.1_1) < 11.0.1_1
|
52
|
+
```
|
53
|
+
|
54
|
+
### Convert to Terminal
|
55
|
+
|
56
|
+
```
|
57
|
+
+---------+-----------+----------+--------+
|
58
|
+
| formula | installed | current | pinned |
|
59
|
+
+---------+-----------+----------+--------+
|
60
|
+
| test1 | 0.0.1 | 0.1 | |
|
61
|
+
| test2 | 0.0.2 | 0.1 | 0.0.2 |
|
62
|
+
| test3 | 10.10.1_1 | 11.0.1_1 | |
|
63
|
+
+---------+-----------+----------+--------+
|
64
|
+
```
|
65
|
+
|
66
|
+
### Convert to Markdown
|
67
|
+
|
68
|
+
```
|
69
|
+
| formula | installed | current | pinned |
|
70
|
+
| --- | --- | --- | --- |
|
71
|
+
| test1 | 0.0.1 | 0.1 | |
|
72
|
+
| test2 | 0.0.2 | 0.1 | 0.0.2 |
|
73
|
+
| test3 | 10.10.1_1 | 11.0.1_1 | |
|
74
|
+
```
|
75
|
+
|
76
|
+
### Convert to JSON
|
77
|
+
|
78
|
+
Normal output:
|
79
|
+
|
80
|
+
```
|
81
|
+
[{"formula":"test1","installed":"0.0.1","current":"0.1","pinned":""},{"formula":"test2","installed":"0.0.2","current":"0.1","pinned":"0.0.2"},{"formula":"test3","installed":"10.10.1_1","current":"11.0.1_1","pinned":""}]
|
82
|
+
```
|
83
|
+
|
84
|
+
Pretty output:
|
85
|
+
|
86
|
+
```
|
87
|
+
[
|
88
|
+
{
|
89
|
+
"formula": "test1",
|
90
|
+
"installed": "0.0.1",
|
91
|
+
"current": "0.1",
|
92
|
+
"pinned": ""
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"formula": "test2",
|
96
|
+
"installed": "0.0.2",
|
97
|
+
"current": "0.1",
|
98
|
+
"pinned": "0.0.2"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"formula": "test3",
|
102
|
+
"installed": "10.10.1_1",
|
103
|
+
"current": "11.0.1_1",
|
104
|
+
"pinned": ""
|
105
|
+
}
|
106
|
+
]
|
107
|
+
```
|
108
|
+
|
109
|
+
### Convert to YAML
|
110
|
+
|
111
|
+
```
|
112
|
+
---
|
113
|
+
- formula: test1
|
114
|
+
installed: 0.0.1
|
115
|
+
current: '0.1'
|
116
|
+
pinned: ''
|
117
|
+
- formula: test2
|
118
|
+
installed: 0.0.2
|
119
|
+
current: '0.1'
|
120
|
+
pinned: 0.0.2
|
121
|
+
- formula: test3
|
122
|
+
installed: 10.10.1_1
|
123
|
+
current: 11.0.1_1
|
124
|
+
pinned: ''
|
125
|
+
```
|
126
|
+
|
127
|
+
### Convert to CSV
|
128
|
+
|
129
|
+
```
|
130
|
+
"formula","installed","current","pinned"
|
131
|
+
"test1","0.0.1","0.1",""
|
132
|
+
"test2","0.0.2","0.1","0.0.2"
|
133
|
+
"test3","10.10.1_1","11.0.1_1",""
|
134
|
+
```
|
135
|
+
|
136
|
+
### Convert to TSV
|
137
|
+
|
138
|
+
```
|
139
|
+
"formula" "installed" "current" "pinned"
|
140
|
+
"test1" "0.0.1" "0.1" ""
|
141
|
+
"test2" "0.0.2" "0.1" "0.0.2"
|
142
|
+
"test3" "10.10.1_1" "11.0.1_1" ""
|
143
|
+
```
|
144
|
+
|
145
|
+
### Convert to XML
|
146
|
+
|
147
|
+
Normal output:
|
148
|
+
|
149
|
+
```
|
150
|
+
<?xml version='1.0' encoding='UTF-8'?><formulas><outdated><formula>test1</formula><installed>0.0.1</installed><current>0.1</current><pinned></pinned></outdated><outdated><formula>test2</formula><installed>0.0.2</installed><current>0.1</current><pinned>0.0.2</pinned></outdated><outdated><formula>test3</formula><installed>10.10.1_1</installed><current>11.0.1_1</current><pinned></pinned></outdated></formulas>
|
151
|
+
```
|
152
|
+
|
153
|
+
Pretty output:
|
154
|
+
|
155
|
+
```
|
156
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
157
|
+
<formulas>
|
158
|
+
<outdated>
|
159
|
+
<formula>test1</formula>
|
160
|
+
<installed>0.0.1</installed>
|
161
|
+
<current>0.1</current>
|
162
|
+
<pinned></pinned>
|
163
|
+
</outdated>
|
164
|
+
<outdated>
|
165
|
+
<formula>test2</formula>
|
166
|
+
<installed>0.0.2</installed>
|
167
|
+
<current>0.1</current>
|
168
|
+
<pinned>0.0.2</pinned>
|
169
|
+
</outdated>
|
170
|
+
<outdated>
|
171
|
+
<formula>test3</formula>
|
172
|
+
<installed>10.10.1_1</installed>
|
173
|
+
<current>11.0.1_1</current>
|
174
|
+
<pinned></pinned>
|
175
|
+
</outdated>
|
176
|
+
</formulas>
|
177
|
+
```
|
178
|
+
|
179
|
+
### Convert to HTML
|
180
|
+
|
181
|
+
Normal output:
|
182
|
+
|
183
|
+
```
|
184
|
+
<table><tr><th>formula</th><th>installed</th><th>current</th><th>pinned</th></tr><tr><td>test1</td><td>0.0.1</td><td>0.1</td><td></td></tr><tr><td>test2</td><td>0.0.2</td><td>0.1</td><td>0.0.2</td></tr><tr><td>test3</td><td>10.10.1_1</td><td>11.0.1_1</td><td></td></tr></table>
|
185
|
+
```
|
186
|
+
|
187
|
+
Pretty output:
|
188
|
+
|
189
|
+
```
|
190
|
+
<table>
|
191
|
+
<tr>
|
192
|
+
<th>formula</th>
|
193
|
+
<th>installed</th>
|
194
|
+
<th>current</th>
|
195
|
+
<th>pinned</th>
|
196
|
+
</tr>
|
197
|
+
<tr>
|
198
|
+
<td>test1</td>
|
199
|
+
<td>0.0.1</td>
|
200
|
+
<td>0.1</td>
|
201
|
+
<td></td>
|
202
|
+
</tr>
|
203
|
+
<tr>
|
204
|
+
<td>test2</td>
|
205
|
+
<td>0.0.2</td>
|
206
|
+
<td>0.1</td>
|
207
|
+
<td>0.0.2</td>
|
208
|
+
</tr>
|
209
|
+
<tr>
|
210
|
+
<td>test3</td>
|
211
|
+
<td>10.10.1_1</td>
|
212
|
+
<td>11.0.1_1</td>
|
213
|
+
<td></td>
|
214
|
+
</tr>
|
215
|
+
</table>
|
216
|
+
```
|
217
|
+
|
218
|
+
## Supported Ruby Versions
|
219
|
+
|
220
|
+
* Ruby 2.0.0
|
221
|
+
* Ruby 2.1
|
222
|
+
* Ruby 2.2
|
223
|
+
* Ruby 2.3
|
224
|
+
* Ruby 2.4
|
225
|
+
* Ruby 2.5
|
226
|
+
|
227
|
+
## Contributing
|
228
|
+
|
229
|
+
Bug reports and pull requests are welcome.
|
230
|
+
|
231
|
+
## License
|
232
|
+
|
233
|
+
[MIT](LICENSE.txt)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'brew_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,31 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'brew_outdated_formatter/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'brew_outdated_formatter'
|
7
|
+
spec.version = BrewOutdatedFormatter::VERSION
|
8
|
+
spec.authors = ['emsk']
|
9
|
+
spec.email = ['emsk1987@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Formatter for `brew outdated --verbose`'
|
12
|
+
spec.description = 'BrewOutdatedFormatter is a command-line tool to format output of `brew outdated --verbose`'
|
13
|
+
spec.homepage = 'https://github.com/emsk/brew_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.add_runtime_dependency 'psych', '~> 2.2'
|
24
|
+
spec.add_runtime_dependency 'terminal-table', '~> 1.8'
|
25
|
+
spec.add_runtime_dependency 'thor', '~> 0.20'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 0.52'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.15'
|
31
|
+
end
|
data/exe/brof
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'brew_outdated_formatter/error'
|
3
|
+
require 'brew_outdated_formatter/formatter/terminal_formatter'
|
4
|
+
require 'brew_outdated_formatter/formatter/markdown_formatter'
|
5
|
+
require 'brew_outdated_formatter/formatter/json_formatter'
|
6
|
+
require 'brew_outdated_formatter/formatter/yaml_formatter'
|
7
|
+
require 'brew_outdated_formatter/formatter/csv_formatter'
|
8
|
+
require 'brew_outdated_formatter/formatter/tsv_formatter'
|
9
|
+
require 'brew_outdated_formatter/formatter/xml_formatter'
|
10
|
+
require 'brew_outdated_formatter/formatter/html_formatter'
|
11
|
+
|
12
|
+
module BrewOutdatedFormatter
|
13
|
+
# Command-line interface of {BrewOutdatedFormatter}
|
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
|
+
|
26
|
+
default_command :output
|
27
|
+
|
28
|
+
desc 'output', 'Format output of `brew outdated --verbose`'
|
29
|
+
option :format, type: :string, aliases: '-f', default: 'terminal', desc: 'Format. (terminal, markdown, json, yaml, csv, tsv, xml, html)'
|
30
|
+
option :pretty, type: :boolean, aliases: '-p', desc: '`true` if pretty output.'
|
31
|
+
|
32
|
+
def output
|
33
|
+
raise BrewOutdatedFormatter::UnknownFormatError, options[:format] unless allow_format?
|
34
|
+
return if STDIN.tty?
|
35
|
+
|
36
|
+
formatter = create_formatter
|
37
|
+
formatter.read_stdin
|
38
|
+
puts formatter.convert
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'version, -v, --version', 'Print the version'
|
42
|
+
map %w[-v --version] => :version
|
43
|
+
|
44
|
+
def version
|
45
|
+
puts "brew_outdated_formatter #{BrewOutdatedFormatter::VERSION}"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def allow_format?
|
51
|
+
FORMATTERS.keys.include?(options[:format])
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_formatter
|
55
|
+
FORMATTERS[options[:format]].new(options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module BrewOutdatedFormatter
|
2
|
+
# Formatter for all formats
|
3
|
+
class Formatter
|
4
|
+
FORMULA_REGEXP = /\A(?<formula>.+) \(/
|
5
|
+
INSTALLED_REGEXP = /\((?<installed>.+)\)/
|
6
|
+
CURRENT_REGEXP = /< ((?<current>.+) \[|(?<current>.+)\z)/
|
7
|
+
PINNED_REGEXP = /\[pinned at (?<pinned>.+)\]/
|
8
|
+
|
9
|
+
COLUMNS = %w[formula installed current pinned].freeze
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@pretty = options[:pretty]
|
13
|
+
@outdated_formulas = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def read_stdin
|
17
|
+
@outdated_formulas = STDIN.each.to_a.map(&:strip).reject(&:empty?)
|
18
|
+
|
19
|
+
@outdated_formulas.map! do |line|
|
20
|
+
find_formula(line)
|
21
|
+
end
|
22
|
+
|
23
|
+
@outdated_formulas.compact!
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def find_formula(line)
|
29
|
+
matched = match_formula(line)
|
30
|
+
return unless match_formula?(matched)
|
31
|
+
|
32
|
+
{
|
33
|
+
'formula' => formula_text(matched[:formula], :formula),
|
34
|
+
'installed' => formula_text(matched[:installed], :installed),
|
35
|
+
'current' => formula_text(matched[:current], :current),
|
36
|
+
'pinned' => formula_text(matched[:pinned], :pinned)
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def match_formula(line)
|
41
|
+
{
|
42
|
+
formula: FORMULA_REGEXP.match(line),
|
43
|
+
installed: INSTALLED_REGEXP.match(line),
|
44
|
+
current: CURRENT_REGEXP.match(line),
|
45
|
+
pinned: PINNED_REGEXP.match(line)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def match_formula?(matched)
|
50
|
+
COLUMNS.any? do |column|
|
51
|
+
!matched[column.to_sym].nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def formula_text(text, name)
|
56
|
+
text ? text[name] : ''
|
57
|
+
end
|
58
|
+
|
59
|
+
def xml_formatter
|
60
|
+
return REXML::Formatters::Default.new unless @pretty
|
61
|
+
|
62
|
+
formatter = REXML::Formatters::Pretty.new
|
63
|
+
formatter.compact = true
|
64
|
+
formatter
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'csv'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
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_formulas.each do |formula|
|
11
|
+
csv << formula.values
|
12
|
+
end
|
13
|
+
end
|
14
|
+
text.chomp
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
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_formulas.each do |formula|
|
19
|
+
add_data_row(formula)
|
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(formula)
|
38
|
+
elements = @root.add_element(REXML::Element.new('tr'))
|
39
|
+
|
40
|
+
COLUMNS.each do |column|
|
41
|
+
elements.add_element('td').add_text(formula[column])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
5
|
+
# Formatter for JSON
|
6
|
+
class JSONFormatter < Formatter
|
7
|
+
def convert
|
8
|
+
text = @pretty ? JSON.pretty_generate(@outdated_formulas) : @outdated_formulas.to_json
|
9
|
+
text.chomp
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'brew_outdated_formatter/formatter'
|
2
|
+
|
3
|
+
module BrewOutdatedFormatter
|
4
|
+
# Formatter for Markdown
|
5
|
+
class MarkdownFormatter < Formatter
|
6
|
+
HEADER = <<-EOS.freeze
|
7
|
+
| formula | installed | current | pinned |
|
8
|
+
| --- | --- | --- | --- |
|
9
|
+
EOS
|
10
|
+
|
11
|
+
def convert
|
12
|
+
@outdated_formulas.map! do |formula|
|
13
|
+
"| #{formula.values.join(' | ')} |".gsub(/ /, ' ')
|
14
|
+
end
|
15
|
+
|
16
|
+
(HEADER + @outdated_formulas.join("\n")).chomp
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
5
|
+
# Formatter for Terminal
|
6
|
+
class TerminalFormatter < Formatter
|
7
|
+
def convert
|
8
|
+
table = Terminal::Table.new do |t|
|
9
|
+
t << COLUMNS
|
10
|
+
t << :separator
|
11
|
+
@outdated_formulas.each do |formula|
|
12
|
+
t << formula.values
|
13
|
+
end
|
14
|
+
end
|
15
|
+
table.render.chomp
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'csv'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
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_formulas.each do |formula|
|
11
|
+
tsv << formula.values
|
12
|
+
end
|
13
|
+
end
|
14
|
+
text.chomp
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'brew_outdated_formatter/formatter'
|
3
|
+
|
4
|
+
module BrewOutdatedFormatter
|
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
|
+
@xml << REXML::XMLDecl.new('1.0', 'UTF-8')
|
12
|
+
@root = REXML::Element.new('formulas')
|
13
|
+
@xml.add_element(@root)
|
14
|
+
end
|
15
|
+
|
16
|
+
def convert
|
17
|
+
@outdated_formulas.each do |formula|
|
18
|
+
add_outdated(formula)
|
19
|
+
end
|
20
|
+
|
21
|
+
io = StringIO.new
|
22
|
+
xml_formatter.write(@xml, io)
|
23
|
+
io.string.chomp
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def add_outdated(formula)
|
29
|
+
elements = @root.add_element(REXML::Element.new('outdated'))
|
30
|
+
|
31
|
+
COLUMNS.each do |column|
|
32
|
+
elements.add_element(column).add_text(formula[column])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brew_outdated_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- emsk
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-01 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: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
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: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.52'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.52'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.15'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.15'
|
125
|
+
description: BrewOutdatedFormatter is a command-line tool to format output of `brew
|
126
|
+
outdated --verbose`
|
127
|
+
email:
|
128
|
+
- emsk1987@gmail.com
|
129
|
+
executables:
|
130
|
+
- brof
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".rubocop.yml"
|
137
|
+
- ".rubocop_todo.yml"
|
138
|
+
- ".travis.yml"
|
139
|
+
- CHANGELOG.md
|
140
|
+
- Gemfile
|
141
|
+
- LICENSE.txt
|
142
|
+
- README.md
|
143
|
+
- Rakefile
|
144
|
+
- bin/console
|
145
|
+
- bin/setup
|
146
|
+
- brew_outdated_formatter.gemspec
|
147
|
+
- exe/brof
|
148
|
+
- lib/brew_outdated_formatter.rb
|
149
|
+
- lib/brew_outdated_formatter/cli.rb
|
150
|
+
- lib/brew_outdated_formatter/error.rb
|
151
|
+
- lib/brew_outdated_formatter/formatter.rb
|
152
|
+
- lib/brew_outdated_formatter/formatter/csv_formatter.rb
|
153
|
+
- lib/brew_outdated_formatter/formatter/html_formatter.rb
|
154
|
+
- lib/brew_outdated_formatter/formatter/json_formatter.rb
|
155
|
+
- lib/brew_outdated_formatter/formatter/markdown_formatter.rb
|
156
|
+
- lib/brew_outdated_formatter/formatter/terminal_formatter.rb
|
157
|
+
- lib/brew_outdated_formatter/formatter/tsv_formatter.rb
|
158
|
+
- lib/brew_outdated_formatter/formatter/xml_formatter.rb
|
159
|
+
- lib/brew_outdated_formatter/formatter/yaml_formatter.rb
|
160
|
+
- lib/brew_outdated_formatter/version.rb
|
161
|
+
homepage: https://github.com/emsk/brew_outdated_formatter
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.7.3
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Formatter for `brew outdated --verbose`
|
185
|
+
test_files: []
|