seeing_is_believing 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d761a62840425753a50b764d74caad42f1ff790
4
- data.tar.gz: eb674e4076644502c643453699d1744de4161315
3
+ metadata.gz: 1663f4160aa363ccacf2b2f4646c1c5be0e71e3e
4
+ data.tar.gz: fc685e0084fe91671948e717199f5737366ee23e
5
5
  SHA512:
6
- metadata.gz: 4e51b01ba8efe1a01b3602132ebb81a7ef935af700dfe05dbf4671cec579729dd3bb86cb83bba124c595bd7623e4612752e7266724fc7f9d3a6ba61b3cee5bba
7
- data.tar.gz: 70bd344383af51e11e3edf04dcadfdee0c37535dbda6fbe6c1fe4ff582c9c5603a106db38e6b752e0cac47bc710bac803cdd82d7c37c932fe377cc2e605a5407
6
+ metadata.gz: 9f3d90bd96f298ccbce4326dee5fa075c1dea4db0e8832fae93bfcdb1d07c02b12fd150863c39d52fbe169024e50abca2e7e4d8da7d37bfd4dd560e82dd9394b
7
+ data.tar.gz: 651eb6819c8f776e156a8e7a6cde6836eeed51f067b714246837f8a391f5e06cc7c24e51076c56094ed30526e05ead111184b07cd0d078fb0f09a557c27fd62d
@@ -346,6 +346,14 @@ Feature: Using flags
346
346
  Then stderr is empty
347
347
  And the exit status is 0
348
348
  And stdout includes "Usage"
349
+ And stdout does not include "Examples:"
350
+
351
+ Scenario: --help+
352
+ When I run "seeing_is_believing --help+"
353
+ Then stderr is empty
354
+ And the exit status is 0
355
+ And stdout includes "Usage"
356
+ And stdout includes "Examples:"
349
357
 
350
358
 
351
359
  Scenario: --timeout
@@ -25,25 +25,26 @@ class SeeingIsBelieving
25
25
  @result ||= begin
26
26
  until args.empty?
27
27
  case (arg = args.shift)
28
- when '-h', '--help' then options[:help] = self.class.help_screen
29
- when '-c', '--clean' then options[:clean] = true
30
- when '-v', '--version' then options[:version] = true
31
- when '-x', '--xmpfilter-style' then options[:xmpfilter_style] = true
32
- when '-i', '--inherit-exit-status' then options[:inherit_exit_status] = true
33
- when '-j', '--json' then options[:result_as_json] = true
34
- when '-g', '--debug' then options[:debugger] = Debugger.new(stream: outstream, colour: true)
35
- when '-l', '--start-line' then extract_positive_int_for :start_line, arg
36
- when '-L', '--end-line' then extract_positive_int_for :end_line, arg
37
- when '-d', '--line-length' then extract_positive_int_for :max_line_length, arg
38
- when '-D', '--result-length' then extract_positive_int_for :max_result_length, arg
39
- when '-n', '--number-of-captures' then extract_positive_int_for :number_of_captures, arg
40
- when '-t', '--timeout' then extract_non_negative_float_for :timeout, arg
41
- when '-r', '--require' then next_arg("#{arg} expected a filename as the following argument but did not see one") { |filename| options[:require] << filename }
42
- when '-I', '--load-path' then next_arg("#{arg} expected a directory as the following argument but did not see one") { |dir| options[:load_path] << dir }
43
- when '-e', '--program' then next_arg("#{arg} expected a program as the following argument but did not see one") { |program| options[:program] = program }
44
- when '-a', '--as' then next_arg("#{arg} expected a filename as the following argument but did not see one") { |filename| options[:as] = filename }
45
- when '--shebang' then next_arg("#{arg} expects a ruby executable as the following argument but did not see one") { |executable| options[:shebang] = executable }
46
- when '-s', '--alignment-strategy' then extract_alignment_strategy
28
+ when '-h', '--help' then options[:help] = self.class.help_screen(false)
29
+ when '-h+', '--help+' then options[:help] = self.class.help_screen(true)
30
+ when '-c', '--clean' then options[:clean] = true
31
+ when '-v', '--version' then options[:version] = true
32
+ when '-x', '--xmpfilter-style' then options[:xmpfilter_style] = true
33
+ when '-i', '--inherit-exit-status' then options[:inherit_exit_status] = true
34
+ when '-j', '--json' then options[:result_as_json] = true
35
+ when '-g', '--debug' then options[:debugger] = Debugger.new(stream: outstream, colour: true)
36
+ when '-l', '--start-line' then extract_positive_int_for :start_line, arg
37
+ when '-L', '--end-line' then extract_positive_int_for :end_line, arg
38
+ when '-d', '--line-length' then extract_positive_int_for :max_line_length, arg
39
+ when '-D', '--result-length' then extract_positive_int_for :max_result_length, arg
40
+ when '-n', '--number-of-captures' then extract_positive_int_for :number_of_captures, arg
41
+ when '-t', '--timeout' then extract_non_negative_float_for :timeout, arg
42
+ when '-r', '--require' then next_arg("#{arg} expected a filename as the following argument but did not see one") { |filename| options[:require] << filename }
43
+ when '-I', '--load-path' then next_arg("#{arg} expected a directory as the following argument but did not see one") { |dir| options[:load_path] << dir }
44
+ when '-e', '--program' then next_arg("#{arg} expected a program as the following argument but did not see one") { |program| options[:program] = program }
45
+ when '-a', '--as' then next_arg("#{arg} expected a filename as the following argument but did not see one") { |filename| options[:as] = filename }
46
+ when '--shebang' then next_arg("#{arg} expects a ruby executable as the following argument but did not see one") { |executable| options[:shebang] = executable }
47
+ when '-s', '--alignment-strategy' then extract_alignment_strategy
47
48
  when /\A-K(.+)/ then options[:encoding] = $1
48
49
  when '-K', '--encoding' then next_arg("#{arg} expects an encoding, see `man ruby` for possibile values") { |encoding| options[:encoding] = encoding }
49
50
  when /^-/ then options[:errors] << "Unknown option: #{arg.inspect}" # unknown flags
@@ -139,39 +140,41 @@ class SeeingIsBelieving
139
140
 
140
141
  end
141
142
 
142
- def ParseArgs.help_screen
143
- <<HELP_SCREEN
143
+ def ParseArgs.help_screen(include_examples)
144
+ <<FLAGS + if include_examples then <<EXAMPLES else '' end
144
145
  Usage: seeing_is_believing [options] [filename]
145
146
 
146
147
  seeing_is_believing is a program and library that will evaluate a Ruby file and capture/display the results.
147
148
 
148
149
  If no filename is provided, the binary will read the program from standard input.
149
150
 
150
- -l, --start-line n # line number to begin showing results on
151
- -L, --end-line n # line number to stop showing results on
152
- -d, --line-length n # max length of the entire line (only truncates results, not source lines)
153
- -D, --result-length n # max length of the portion after the "#{VALUE_MARKER}"
154
- -n, --number-of-captures n # how many results to capture for a given line
155
- if you had 1 million results on a line, it could take a long time to record
156
- and serialize them, you might limit it to 1000 results as an optimization
157
- -s, --alignment-strategy name # select the alignment strategy:
158
- chunk (DEFAULT) => each chunk of code is at the same alignment
159
- file => the entire file is at the same alignment
160
- line => each line is at its own alignment
161
- -t, --timeout n # timeout limit in seconds when evaluating source file (ex. -t 0.3 or -t 3)
162
- -I, --load-path dir # a dir that should be added to the $LOAD_PATH
163
- -r, --require file # additional files to be required before running the program
164
- -e, --program program # Pass the program to execute as an argument
165
- -K, --encoding encoding # sets file encoding, equivalent to Ruby's -Kx (see `man ruby` for valid values)
166
- -a, --as filename # run the program as if it was the specified filename
167
- -c, --clean # remove annotations from previous runs of seeing_is_believing
168
- -g, --debug # print debugging information (useful if program is fucking up, or if you want to brag)
169
- -x, --xmpfilter-style # annotate marked lines instead of every line
170
- -j, --json # print results in json format (i.e. so another program can consume them)
171
- -i, --inherit-exit-status # exit with the exit status of the program being eval
172
- --shebang ruby-executable # if you want SiB to use some ruby other than the one in the path
173
- -v, --version # print the version (#{VERSION})
174
- -h, --help # this help screen
151
+ -l, --start-line n # line number to begin showing results on
152
+ -L, --end-line n # line number to stop showing results on
153
+ -d, --line-length n # max length of the entire line (only truncates results, not source lines)
154
+ -D, --result-length n # max length of the portion after the "#{VALUE_MARKER}"
155
+ -n, --number-of-captures n # how many results to capture for a given line
156
+ if you had 1 million results on a line, it could take a long time to record
157
+ and serialize them, you might limit it to 1000 results as an optimization
158
+ -s, --alignment-strategy name # select the alignment strategy:
159
+ chunk (DEFAULT) => each chunk of code is at the same alignment
160
+ file => the entire file is at the same alignment
161
+ line => each line is at its own alignment
162
+ -t, --timeout n # timeout limit in seconds when evaluating source file (ex. -t 0.3 or -t 3)
163
+ -I, --load-path dir # a dir that should be added to the $LOAD_PATH
164
+ -r, --require file # additional files to be required before running the program
165
+ -e, --program program # Pass the program to execute as an argument
166
+ -K, --encoding encoding # sets file encoding, equivalent to Ruby's -Kx (see `man ruby` for valid values)
167
+ -a, --as filename # run the program as if it was the specified filename
168
+ -c, --clean # remove annotations from previous runs of seeing_is_believing
169
+ -g, --debug # print debugging information (useful if program is fucking up, or if you want to brag)
170
+ -x, --xmpfilter-style # annotate marked lines instead of every line
171
+ -j, --json # print results in json format (i.e. so another program can consume them)
172
+ -i, --inherit-exit-status # exit with the exit status of the program being eval
173
+ --shebang ruby-executable # if you want SiB to use some ruby other than the one in the path
174
+ -v, --version # print the version (#{VERSION})
175
+ -h, --help # help screen without examples
176
+ -h+, --help+ # help screen with examples
177
+ FLAGS
175
178
 
176
179
  Examples: A few examples, for a more comprehensive set of examples, check out features/flags.feature
177
180
 
@@ -254,8 +257,7 @@ Examples: A few examples, for a more comprehensive set of examples, check out fe
254
257
  If your Ruby binary is named something else (e.g. ruby2.0)
255
258
  $ ruby2.0 -S seeing_is_believing --shebang ruby2.0 -e '123'
256
259
  123 #{VALUE_MARKER}123
257
-
258
- HELP_SCREEN
260
+ EXAMPLES
259
261
  end
260
262
  end
261
263
  end
@@ -1,3 +1,3 @@
1
1
  class SeeingIsBelieving
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -152,17 +152,18 @@ class SeeingIsBelieving
152
152
  when :masgn
153
153
  # we must look at RHS because [1,<<A] and 1,<<A are both allowed
154
154
  #
155
- # in the first case, we must take the end_pos of the array, or we'll insert the after_each in the wrong location
155
+ # in the first case, we must take the end_pos of the array,
156
+ # or we'll insert the after_each in the wrong location
156
157
  #
157
158
  # in the second, there is an implicit Array wrapped around it, with the wrong end_pos,
158
159
  # so we must take the end_pos of the last arg
159
160
  array = ast.children.last
160
- if array.type != :array # e.g. `a, g = c`
161
+ if array.type != :array # e.g. `a, b = c`
161
162
  add_to_wrappings ast
162
- add_to_wrappings ast.children.last
163
+ add_children ast, true
163
164
  elsif array.location.expression.source.start_with? '['
164
165
  add_to_wrappings ast
165
- find_wrappings array
166
+ add_children ast, true
166
167
  else
167
168
  begin_pos = ast.location.expression.begin_pos
168
169
  end_pos = heredoc_hack(array.children.last).location.expression.end_pos
@@ -167,9 +167,20 @@ describe SeeingIsBelieving::Binary::ParseArgs do
167
167
  parse([])[:help].should be_nil
168
168
  end
169
169
 
170
- it 'is set to the help screen with -h and --help and -help' do
171
- parse(['-h'])[:help].should == described_class.help_screen
172
- parse(['--help'])[:help].should == described_class.help_screen
170
+ it 'is set to the flag only help screen with -h and --help and -help' do
171
+ parse(['-h'])[:help].should include 'Usage:'
172
+ parse(['--help'])[:help].should include 'Usage:'
173
+
174
+ parse(['-h'])[:help].should_not include 'Examples:'
175
+ parse(['--help'])[:help].should_not include 'Examples:'
176
+ end
177
+
178
+ it 'is set to the flag with examples help screen with --help+ and -h+' do
179
+ parse(['-h+'])[:help].should include 'Usage:'
180
+ parse(['--help+'])[:help].should include 'Usage:'
181
+
182
+ parse(['-h+'])[:help].should include 'Examples:'
183
+ parse(['--help+'])[:help].should include 'Examples:'
173
184
  end
174
185
  end
175
186
 
@@ -347,6 +347,8 @@ describe SeeingIsBelieving::WrapExpressions do
347
347
 
348
348
  it 'wraps multiple assignment on each line' do
349
349
  wrap("a,b=1,\n2").should == "<a,b=<1>,\n2>"
350
+ wrap("a,b=[1,2]\n.map(&:to_s)").should == "<a,b=<[1,2]>\n.map(&:to_s)>"
351
+ wrap("a,b=[1,\n2\n.even?\n]").should == "<a,b=[<1>,\n<<2>\n.even?>\n]>"
350
352
  end
351
353
 
352
354
  it 'wraps multiple assignment with splats' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seeing_is_believing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cheek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-07 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser