command_line_reporter 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9f17fc6c5835de05207956fd35a3f0d084066afb
4
+ data.tar.gz: 1d538a2574f787c91d48883dfe07e08042c816f5
5
+ SHA512:
6
+ metadata.gz: 72b7895cec242dca32f1c5522de0877b162c39f5cb1413973ccac7f3d73e8155836b21751a8ec120071f07127b8796e7c8898b19fb9f98e3181dc93354c7fd18
7
+ data.tar.gz: 6e853ae616c1c93387d509cd520767ce070590f8ac8ac8b9ea84e31fa33f82368849baf49433618c85fb3a946e8739cc9a44b0b1d0c325ae69c3d8b03e20a3e1
@@ -140,14 +140,7 @@ module CommandLineReporter
140
140
  private
141
141
 
142
142
  def section(type, options)
143
- validate_options(options, :title, :width, :align, :spacing, :timestamp, :rule, :color, :bold)
144
-
145
- title = options[:title] || 'Report'
146
- width = options[:width] || DEFAULTS[:width]
147
- align = options[:align] || DEFAULTS[:align]
148
- lines = options[:spacing] || 1
149
- color = options[:color]
150
- bold = options[:bold] || false
143
+ title, width, align, lines, color, bold = assign_section_properties(options)
151
144
 
152
145
  # This also ensures that width is a Fixnum
153
146
  raise ArgumentError if title.size > width
@@ -165,4 +158,17 @@ module CommandLineReporter
165
158
  vertical_spacing(lines)
166
159
  end
167
160
  end
161
+
162
+ def assign_section_properties options
163
+ validate_options(options, :title, :width, :align, :spacing, :timestamp, :rule, :color, :bold)
164
+
165
+ title = options[:title] || 'Report'
166
+ width = options[:width] || DEFAULTS[:width]
167
+ align = options[:align] || DEFAULTS[:align]
168
+ lines = options[:spacing] || 1
169
+ color = options[:color]
170
+ bold = options[:bold] || false
171
+
172
+ return [title, width, align, lines, color, bold]
173
+ end
168
174
  end
@@ -46,23 +46,26 @@ module CommandLineReporter
46
46
  # NOTE: For making underline and reversed work Change so that based on the
47
47
  # unformatted text it determines how much spacing to add left and right
48
48
  # then colorize the cell text
49
- cell = if str.empty?
50
- ' ' * self.size
51
- else
52
- case self.align
53
- when 'left'
54
- str.ljust(self.size)
55
- when 'right'
56
- str.rjust(self.size)
57
- when 'center'
58
- str.ljust((self.size - str.size)/2.0 + str.size).rjust(self.size)
59
- end
60
- end
61
-
49
+ cell = str.empty? ? blank_cell : aligned_cell(str)
62
50
  padding_str = ' ' * self.padding
63
51
  padding_str + colorize(cell) + padding_str
64
52
  end
65
53
 
54
+ def blank_cell
55
+ ' ' * self.size
56
+ end
57
+
58
+ def aligned_cell(str)
59
+ case self.align
60
+ when 'left'
61
+ str.ljust(self.size)
62
+ when 'right'
63
+ str.rjust(self.size)
64
+ when 'center'
65
+ str.ljust((self.size - str.size)/2.0 + str.size).rjust(self.size)
66
+ end
67
+ end
68
+
66
69
  def colorize(str)
67
70
  str = str.send(color) if self.color
68
71
  str = str.send('bold') if self.bold
@@ -13,7 +13,7 @@ module CommandLineReporter
13
13
  self.header = options[:header] || false
14
14
  self.color = options[:color]
15
15
  self.bold = options[:bold] || false
16
- self.encoding = options[:encoding] || false
16
+ self.encoding = options[:encoding] || :unicode
17
17
 
18
18
  end
19
19
 
@@ -31,8 +31,10 @@ module CommandLineReporter
31
31
 
32
32
  def output
33
33
  screen_count.times do |sr|
34
- border_char = ("\u2501" == "u2501" || self.encoding == :ascii) ? '|' : "\u2503"
34
+ border_char = use_utf8? ? "\u2503" : '|'
35
+
35
36
  line = (self.border) ? "#{border_char} " : ''
37
+
36
38
  self.columns.size.times do |mc|
37
39
  col = self.columns[mc]
38
40
  # Account for the fact that some columns will have more screen rows than their
@@ -59,8 +61,10 @@ module CommandLineReporter
59
61
  else
60
62
  line << self.columns[mc].screen_rows[sr]
61
63
  end
64
+
62
65
  line << ' ' + ((self.border) ? "#{border_char} " : '')
63
66
  end
67
+
64
68
  puts line
65
69
  end
66
70
  end
@@ -70,5 +74,9 @@ module CommandLineReporter
70
74
  def screen_count
71
75
  @sc ||= self.columns.inject(0) {|max,column| column.screen_rows.size > max ? column.screen_rows.size : max}
72
76
  end
77
+
78
+ def use_utf8?
79
+ self.encoding == :unicode && "\u2501" != "u2501"
80
+ end
73
81
  end
74
82
  end
@@ -58,13 +58,13 @@ module CommandLineReporter
58
58
  private
59
59
 
60
60
  def separator(type = 'middle')
61
- left, right, center, bar = use_utf8? ? ascii_separator : utf8_separator
61
+ left, center, right, bar = use_utf8? ? utf8_separator(type) : ascii_separator
62
62
 
63
63
  left + self.rows[0].columns.map {|c| bar * (c.width + 2)}.join(center) + right
64
64
  end
65
65
 
66
66
  def use_utf8?
67
- self.encoding == :ascii || "\u2501" == "u2501"
67
+ self.encoding == :unicode && "\u2501" != "u2501"
68
68
  end
69
69
 
70
70
  def ascii_separator
@@ -76,7 +76,7 @@ module CommandLineReporter
76
76
  def utf8_separator(type)
77
77
  bar = "\u2501"
78
78
 
79
- left, right, center = case type
79
+ left, center, right = case type
80
80
  when 'first'
81
81
  ["\u250F", "\u2533", "\u2513"]
82
82
  when 'middle'
@@ -85,7 +85,7 @@ module CommandLineReporter
85
85
  ["\u2517", "\u253B", "\u251B"]
86
86
  end
87
87
 
88
- [left, right, center, bar]
88
+ [left, center, right, bar]
89
89
  end
90
90
 
91
91
  def inherit_column_attrs(row)
@@ -1,3 +1,3 @@
1
1
  module CommandLineReporter
2
- VERSION = '3.3.0'
2
+ VERSION = '3.3.1'
3
3
  end
@@ -30,7 +30,7 @@ describe CommandLineReporter::NestedFormatter do
30
30
 
31
31
  describe '#format' do
32
32
  context 'argument validation' do
33
- before :all do
33
+ before :each do
34
34
  @indent_size = subject.indent_size
35
35
  end
36
36
 
@@ -63,7 +63,7 @@ describe CommandLineReporter::NestedFormatter do
63
63
  end
64
64
 
65
65
  context 'not nested' do
66
- before :all do
66
+ before :each do
67
67
  @complete_string = subject.complete_string
68
68
  @indent_size = subject.indent_size
69
69
  end
@@ -155,7 +155,7 @@ describe CommandLineReporter::NestedFormatter do
155
155
  end
156
156
 
157
157
  context 'nested commands' do
158
- before :all do
158
+ before :each do
159
159
  @indent_size = subject.indent_size
160
160
  end
161
161
 
data/spec/row_spec.rb CHANGED
@@ -21,7 +21,7 @@ describe CommandLineReporter::Row do
21
21
  end
22
22
 
23
23
  it 'output encoding should be unicode' do
24
- expect(CommandLineReporter::Row.new.encoding).to be_false
24
+ expect(CommandLineReporter::Row.new.encoding).to eq(:unicode)
25
25
  end
26
26
 
27
27
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_line_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
5
- prerelease:
4
+ version: 3.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Wes
@@ -10,38 +9,34 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-02-17 00:00:00.000000000 Z
12
+ date: 2014-02-26 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 1.0.0
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 1.0.0
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: colored
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '1.2'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '1.2'
47
42
  description: This gem makes it easy to provide a report while your ruby script is
@@ -51,6 +46,8 @@ executables: []
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
49
+ - README.md
50
+ - lib/command_line_reporter.rb
54
51
  - lib/command_line_reporter/column.rb
55
52
  - lib/command_line_reporter/formatter/nested.rb
56
53
  - lib/command_line_reporter/formatter/progress.rb
@@ -58,8 +55,6 @@ files:
58
55
  - lib/command_line_reporter/row.rb
59
56
  - lib/command_line_reporter/table.rb
60
57
  - lib/command_line_reporter/version.rb
61
- - lib/command_line_reporter.rb
62
- - README.md
63
58
  - spec/column_spec.rb
64
59
  - spec/command_line_reporter_spec.rb
65
60
  - spec/nested_formatter_spec.rb
@@ -72,30 +67,26 @@ files:
72
67
  - spec/table_spec.rb
73
68
  homepage: http://github.com/wbailey/command_line_reporter
74
69
  licenses: []
70
+ metadata: {}
75
71
  post_install_message:
76
72
  rdoc_options: []
77
73
  require_paths:
78
74
  - lib
79
75
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
76
  requirements:
82
- - - ! '>='
77
+ - - ">="
83
78
  - !ruby/object:Gem::Version
84
79
  version: '0'
85
- segments:
86
- - 0
87
- hash: -3116512959293506911
88
80
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
81
  requirements:
91
- - - ! '>='
82
+ - - ">="
92
83
  - !ruby/object:Gem::Version
93
84
  version: '0'
94
85
  requirements: []
95
86
  rubyforge_project:
96
- rubygems_version: 1.8.25
87
+ rubygems_version: 2.2.2
97
88
  signing_key:
98
- specification_version: 3
89
+ specification_version: 4
99
90
  summary: A tool for providing interactive command line applications
100
91
  test_files:
101
92
  - spec/column_spec.rb