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 +4 -4
- data/features/flags.feature +8 -0
- data/lib/seeing_is_believing/binary/parse_args.rb +50 -48
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +5 -4
- data/spec/binary/parse_args_spec.rb +14 -3
- data/spec/wrap_expressions_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1663f4160aa363ccacf2b2f4646c1c5be0e71e3e
|
4
|
+
data.tar.gz: fc685e0084fe91671948e717199f5737366ee23e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3d90bd96f298ccbce4326dee5fa075c1dea4db0e8832fae93bfcdb1d07c02b12fd150863c39d52fbe169024e50abca2e7e4d8da7d37bfd4dd560e82dd9394b
|
7
|
+
data.tar.gz: 651eb6819c8f776e156a8e7a6cde6836eeed51f067b714246837f8a391f5e06cc7c24e51076c56094ed30526e05ead111184b07cd0d078fb0f09a557c27fd62d
|
data/features/flags.feature
CHANGED
@@ -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',
|
29
|
-
when '-
|
30
|
-
when '-
|
31
|
-
when '-
|
32
|
-
when '-
|
33
|
-
when '-
|
34
|
-
when '-
|
35
|
-
when '-
|
36
|
-
when '-
|
37
|
-
when '-
|
38
|
-
when '-
|
39
|
-
when '-
|
40
|
-
when '-
|
41
|
-
when '-
|
42
|
-
when '-
|
43
|
-
when '-
|
44
|
-
when '-
|
45
|
-
when
|
46
|
-
when
|
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
|
-
<<
|
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,
|
151
|
-
-L,
|
152
|
-
-d,
|
153
|
-
-D,
|
154
|
-
-n,
|
155
|
-
|
156
|
-
|
157
|
-
-s,
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
-t,
|
162
|
-
-I,
|
163
|
-
-r,
|
164
|
-
-e,
|
165
|
-
-K,
|
166
|
-
-a,
|
167
|
-
-c,
|
168
|
-
-g,
|
169
|
-
-x,
|
170
|
-
-j,
|
171
|
-
-i,
|
172
|
-
|
173
|
-
-v,
|
174
|
-
-h,
|
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
|
@@ -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,
|
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,
|
161
|
+
if array.type != :array # e.g. `a, b = c`
|
161
162
|
add_to_wrappings ast
|
162
|
-
|
163
|
+
add_children ast, true
|
163
164
|
elsif array.location.expression.source.start_with? '['
|
164
165
|
add_to_wrappings ast
|
165
|
-
|
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
|
172
|
-
parse(['--help'])[:help].should
|
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.
|
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-
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|