bundle_outdated_formatter 0.5.1 → 0.6.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
2
  SHA256:
3
- metadata.gz: f47dcda47ea3c0f7c8dfbd5ebc63a27a12f46e67e726bc4ace59ee20fa62a20b
4
- data.tar.gz: 781f7d3b98a88606cc0688c28600aaea47e993b616c6dcde27c5eadc8d95a0be
3
+ metadata.gz: 631d2803ff9f26d891b814e101887ae001bca0a1b4e5e0c09f0849c3e8926105
4
+ data.tar.gz: 4740cd39c6dbcf80b688ce3fcf92cd0036826b903dbb7c6edcb1f2332919de49
5
5
  SHA512:
6
- metadata.gz: 37371a3d107f4c25728fc8378b0d00e28830f980d7fa36ad00b89c38b4e7d0b5b6e2ce52b57a2eb161c913c246cbd120f0dd1b99020095c583505580b77d4fa3
7
- data.tar.gz: '09063924575630f2ebdfb5892dd4a17e98347e3e9e9246348e270ff8894171f357f2421f41cbd1550bb8fe44a1002d9eb9c5474fd572a2acf4afa6064acb121f'
6
+ metadata.gz: a160748e719e376549a1ab06b4def7e3696b24f1f66f1a9e6a3990cbe1c970fcea3e89117f750377907c447ff3632ec72781882020caa5ad40dc0de55bfb40c4
7
+ data.tar.gz: 2f35c72c6d0d24a79d6a2f9a8d20e3c99b1481cf7cb3f9104600b85646de82d8676f9297c0c9bb79b642fe4f69875d0c7c5288beccc56c5154e9c0ee961865e7
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,8 +1,15 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+ require: rubocop-rspec
2
3
 
3
4
  AllCops:
4
5
  DisplayCopNames: true
5
6
 
7
+ Bundler/DuplicatedGem:
8
+ Enabled: false
9
+
10
+ Layout/AlignHash:
11
+ EnforcedHashRocketStyle: table
12
+
6
13
  Layout/IndentHeredoc:
7
14
  Enabled: false
8
15
 
@@ -24,6 +31,15 @@ Metrics/LineLength:
24
31
  Naming/HeredocDelimiterNaming:
25
32
  Enabled: false
26
33
 
34
+ Style/FrozenStringLiteralComment:
35
+ Enabled: false
36
+
27
37
  Style/IfUnlessModifier:
28
38
  Exclude:
29
39
  - 'Gemfile'
40
+
41
+ RSpec/FilePath:
42
+ Enabled: false
43
+
44
+ RSpec/NestedGroups:
45
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-05-24 00:00:09 +0900 using RuboCop version 0.56.0.
3
+ # on 2019-11-20 00:16:16 +0900 using RuboCop version 0.76.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
@@ -8,13 +8,7 @@
8
8
 
9
9
  # Offense count: 1
10
10
  # Configuration parameters: Include.
11
- # Include: **/*.gemspec
11
+ # Include: **/*.gemspec,
12
12
  Gemspec/RequiredRubyVersion:
13
13
  Exclude:
14
14
  - 'bundle_outdated_formatter.gemspec'
15
-
16
- # Offense count: 14
17
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
18
- # URISchemes: http, https
19
- Metrics/LineLength:
20
- Max: 140
data/.travis.yml CHANGED
@@ -1,13 +1,12 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
3
  - 2.0.0
5
4
  - 2.1.10
6
5
  - 2.2.10
7
6
  - 2.3.8
8
- - 2.4.5
9
- - 2.5.3
10
- - 2.6.0
7
+ - 2.4.7
8
+ - 2.5.6
9
+ - 2.6.4
11
10
  - ruby-head
12
11
  before_install:
13
12
  - |
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.6.0 (2019-11-24)
4
+
5
+ ### Features
6
+
7
+ * Add `--column` option for `output` command (#3)
8
+
9
+ ### Bug Fixes
10
+
11
+ * Fix error of Terminal format with empty outdated gems
12
+ * Fix tests against Terminal (Unicode table) format
13
+
14
+ ## Miscellaneous
15
+
16
+ * Suppress output in tests
17
+
3
18
  ## 0.5.1 (2019-04-16)
4
19
 
5
20
  ### Bug Fixes
data/Gemfile CHANGED
@@ -7,8 +7,18 @@ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.3.0')
7
7
  gem 'psych', '< 3.0.0'
8
8
  end
9
9
 
10
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.2.0') && Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.3.0')
11
+ gem 'rubocop', '< 0.69.0'
12
+ gem 'rubocop-rspec', '< 1.33.0'
13
+ end
14
+
10
15
  if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.2.0')
11
16
  gem 'parallel', '< 1.17.0'
17
+ gem 'rubocop-rspec', '< 1.5.2'
18
+ end
19
+
20
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.1.0') && Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.2.0')
21
+ gem 'rubocop', '< 0.58.0'
12
22
  end
13
23
 
14
24
  if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.1.0')
data/README.md CHANGED
@@ -43,6 +43,7 @@ $ bundle outdated | bof
43
43
  | `--format` | `-f` | Format. `terminal`, `markdown`, `json`, `yaml`, `csv`, `tsv`, `xml`, or `html`. | `terminal` |
44
44
  | `--pretty` | `-p` | `true` if pretty output.<br>This option is available in `json`, `xml`, or `html` formats. | `false` |
45
45
  | `--style` | `-s` | Terminal table style. `unicode` or `ascii`.<br>This option is available in `terminal` format. | `unicode` |
46
+ | `--column` | `-c` | Output columns. The columns are sorted in specified order. | `gem newest installed requested groups` |
46
47
 
47
48
  ## Examples
48
49
 
data/appveyor.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  version: 1.0.{build}-{branch}
2
2
 
3
3
  environment:
4
+ RUBYOPT: -Eutf-8
4
5
  matrix:
5
6
  - RUBY_VERSION: 200
6
7
  - RUBY_VERSION: 200-x64
@@ -27,8 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'tty-table', '~> 0.10'
28
28
  spec.add_development_dependency 'bundler', '>= 1.16'
29
29
  spec.add_development_dependency 'codecov', '~> 0.1'
30
- spec.add_development_dependency 'rake', '~> 12.3'
31
- spec.add_development_dependency 'rspec', '~> 3.7'
32
- spec.add_development_dependency 'rubocop', '~> 0.56'
33
- spec.add_development_dependency 'simplecov', '~> 0.16'
30
+ spec.add_development_dependency 'rake', '>= 12.3'
31
+ spec.add_development_dependency 'rspec', '~> 3.8'
32
+ spec.add_development_dependency 'rubocop', '~> 0.76'
33
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.36'
34
+ spec.add_development_dependency 'simplecov', '~> 0.17'
34
35
  end
@@ -23,6 +23,7 @@ module BundleOutdatedFormatter
23
23
  'html' => HTMLFormatter
24
24
  }.freeze
25
25
  STYLES = %w[unicode ascii].freeze
26
+ COLUMNS = %w[gem newest installed requested groups].freeze
26
27
 
27
28
  default_command :output
28
29
 
@@ -30,10 +31,12 @@ module BundleOutdatedFormatter
30
31
  option :format, type: :string, aliases: '-f', default: 'terminal', desc: 'Format. (terminal, markdown, json, yaml, csv, tsv, xml, html)'
31
32
  option :pretty, type: :boolean, aliases: '-p', desc: '`true` if pretty output.'
32
33
  option :style, type: :string, aliases: '-s', default: 'unicode', desc: 'Terminal table style. (unicode, ascii)'
34
+ option :column, type: :array, aliases: '-c', default: %w[gem newest installed requested groups], desc: 'Output columns. (columns are sorted in specified order)'
33
35
 
34
36
  def output
35
37
  raise BundleOutdatedFormatter::UnknownFormatError, options[:format] unless allow_format?
36
38
  raise BundleOutdatedFormatter::UnknownStyleError, options[:style] unless allow_style?
39
+ raise BundleOutdatedFormatter::UnknownColumnError, options[:column] unless allow_column?
37
40
  return if STDIN.tty?
38
41
 
39
42
  formatter = create_formatter
@@ -58,6 +61,12 @@ module BundleOutdatedFormatter
58
61
  STYLES.include?(options[:style])
59
62
  end
60
63
 
64
+ def allow_column?
65
+ options[:column].all? do |column|
66
+ COLUMNS.include?(column)
67
+ end
68
+ end
69
+
61
70
  def create_formatter
62
71
  FORMATTERS[options[:format]].new(options)
63
72
  end
@@ -2,4 +2,5 @@ module BundleOutdatedFormatter
2
2
  class Error < StandardError; end
3
3
  class UnknownFormatError < Error; end
4
4
  class UnknownStyleError < Error; end
5
+ class UnknownColumnError < Error; end
5
6
  end
@@ -3,17 +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]
16
14
  @style = options[:style]
15
+ @columns = options[:column]
17
16
  @outdated_gems = []
18
17
  end
19
18
 
@@ -33,27 +32,23 @@ module BundleOutdatedFormatter
33
32
  matched = match_gem(line)
34
33
  return unless match_gem?(matched)
35
34
 
36
- {
37
- 'gem' => gem_text(matched[:gem], :gem),
38
- 'newest' => gem_text(matched[:newest], :newest),
39
- 'installed' => gem_text(matched[:installed], :installed),
40
- 'requested' => gem_text(matched[:requested], :requested),
41
- 'groups' => gem_text(matched[:groups], :groups)
42
- }
35
+ gems = {}
36
+ @columns.each do |column|
37
+ gems[column] = gem_text(matched[column.to_sym], column.to_sym)
38
+ end
39
+ gems
43
40
  end
44
41
 
45
42
  def match_gem(line)
46
- {
47
- gem: GEM_REGEXP.match(line),
48
- newest: NEWEST_REGEXP.match(line),
49
- installed: INSTALLED_REGEXP.match(line),
50
- requested: REQUESTED_REGEXP.match(line),
51
- groups: GROUPS_REGEXP.match(line)
52
- }
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
53
48
  end
54
49
 
55
50
  def match_gem?(matched)
56
- COLUMNS.any? do |column|
51
+ @columns.any? do |column|
57
52
  !matched[column.to_sym].nil?
58
53
  end
59
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,7 +37,7 @@ 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|
40
+ @columns.each do |column|
41
41
  escaped_text = REXML::Text.new(gem[column], false, nil, false)
42
42
  elements.add_element('td').add_text(escaped_text)
43
43
  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
@@ -5,12 +5,19 @@ module BundleOutdatedFormatter
5
5
  # Formatter for Terminal
6
6
  class TerminalFormatter < Formatter
7
7
  def convert
8
- table = TTY::Table.new(header: COLUMNS) do |t|
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|
9
17
  @outdated_gems.each do |gem|
10
18
  t << gem.values
11
19
  end
12
20
  end
13
- table.render(@style.to_sym, padding: [0, 1]).chomp
14
21
  end
15
22
  end
16
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
@@ -30,7 +30,7 @@ module BundleOutdatedFormatter
30
30
  def add_outdated(gem)
31
31
  elements = @root.add_element(REXML::Element.new('outdated'))
32
32
 
33
- COLUMNS.each do |column|
33
+ @columns.each do |column|
34
34
  escaped_text = REXML::Text.new(gem[column], false, nil, false)
35
35
  elements.add_element(column).add_text(escaped_text)
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module BundleOutdatedFormatter
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundle_outdated_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - emsk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '12.3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '12.3'
97
97
  - !ruby/object:Gem::Dependency
@@ -100,42 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.7'
103
+ version: '3.8'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.7'
110
+ version: '3.8'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.56'
117
+ version: '0.76'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.76'
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: '1.36'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '0.56'
138
+ version: '1.36'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: simplecov
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '0.16'
145
+ version: '0.17'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '0.16'
152
+ version: '0.17'
139
153
  description: BundleOutdatedFormatter is a command-line tool to format output of `bundle
140
154
  outdated`
141
155
  email: