seeing_is_believing 2.0.4 → 2.1.0
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/Gemfile +1 -0
- data/Readme.md +1 -0
- data/features/support/env.rb +1 -0
- data/lib/seeing_is_believing.rb +1 -2
- data/lib/seeing_is_believing/binary/clean_body.rb +5 -4
- data/lib/seeing_is_believing/binary/commentable_lines.rb +2 -3
- data/lib/seeing_is_believing/binary/parse_args.rb +1 -1
- data/lib/seeing_is_believing/debugger.rb +1 -1
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +6 -8
- data/lib/seeing_is_believing/line.rb +6 -1
- data/lib/seeing_is_believing/parser_helpers.rb +5 -4
- data/lib/seeing_is_believing/version.rb +1 -1
- data/seeing_is_believing.gemspec +1 -1
- data/spec/line_spec.rb +13 -0
- data/spec/seeing_is_believing_spec.rb +1 -1
- data/spec/wrap_expressions_spec.rb +2 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbcb4fd5db54b1a8b6158b07cb9b4705a1d7bc5
|
4
|
+
data.tar.gz: 1201fcec0c2768dae5769a6aca6aa06463992a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63eb02d6a89e340a6f29cb1a49ed31d7ab5153550be46bba89309b193154faab7894dca268bbb9f367be8d3a0ba713d4b30d94a71b70fef7e7bc51e63498c001
|
7
|
+
data.tar.gz: 98fefbaaef519b2e61489c47ce7b9b0425572bd326d9a2d93e6b36b2e1f73349d52fa91f454b15775356d66e615faf32678523664ea31a65e41188114eb862f1
|
data/Gemfile
CHANGED
data/Readme.md
CHANGED
data/features/support/env.rb
CHANGED
data/lib/seeing_is_believing.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# removes annotations
|
4
4
|
# only removes "# =>" when should_clean_values is false
|
5
5
|
|
6
|
+
require 'seeing_is_believing/binary'
|
6
7
|
require 'seeing_is_believing/parser_helpers'
|
7
8
|
|
8
9
|
class SeeingIsBelieving
|
@@ -25,18 +26,18 @@ class SeeingIsBelieving
|
|
25
26
|
|
26
27
|
comments.each do |comment|
|
27
28
|
case comment.text
|
28
|
-
when
|
29
|
+
when VALUE_REGEX
|
29
30
|
if should_clean_values
|
30
31
|
removed_comments[:result] << comment
|
31
32
|
rewriter.remove comment.location.expression
|
32
33
|
end
|
33
|
-
when
|
34
|
+
when EXCEPTION_REGEX
|
34
35
|
removed_comments[:exception] << comment
|
35
36
|
rewriter.remove comment.location.expression
|
36
|
-
when
|
37
|
+
when STDOUT_REGEX
|
37
38
|
removed_comments[:stdout] << comment
|
38
39
|
rewriter.remove comment.location.expression
|
39
|
-
when
|
40
|
+
when STDERR_REGEX
|
40
41
|
removed_comments[:stderr] << comment
|
41
42
|
rewriter.remove comment.location.expression
|
42
43
|
end
|
@@ -81,9 +81,8 @@ class SeeingIsBelieving
|
|
81
81
|
def ranges_of_atomic_expressions(ast, found_ranges)
|
82
82
|
return found_ranges unless ast.kind_of? ::AST::Node
|
83
83
|
if no_comment_zone?(ast) && heredoc?(ast)
|
84
|
-
begin_pos
|
85
|
-
|
86
|
-
end_pos = ast.location.expression.end.end_pos.next
|
84
|
+
begin_pos = ast.location.heredoc_body.begin_pos
|
85
|
+
end_pos = ast.location.heredoc_end.end_pos.next
|
87
86
|
found_ranges << (begin_pos...end_pos)
|
88
87
|
elsif no_comment_zone? ast
|
89
88
|
begin_pos = ast.location.expression.begin.begin_pos
|
@@ -43,7 +43,7 @@ class SeeingIsBelieving
|
|
43
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
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
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] =
|
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
47
|
when '-s', '--alignment-strategy' then extract_alignment_strategy
|
48
48
|
when /\A-K(.+)/ then options[:encoding] = $1
|
49
49
|
when '-K', '--encoding' then next_arg("#{arg} expects an encoding, see `man ruby` for possibile values") { |encoding| options[:encoding] = encoding }
|
@@ -4,12 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# Another option is to replace __FILE__ macros ourselves
|
6
6
|
# and then write to a temp file but evaluate in the context
|
7
|
-
# of the expected directory.
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
7
|
+
# of the expected directory. Some issues could arise with this,
|
8
|
+
# though: if you required the file again, it wouldn't already
|
9
|
+
# be in the loaded features (might be able to just add it)
|
10
|
+
# if you did something like File.read(__FILE__) it would
|
11
|
+
# read the wrong file... of course, since we rewrite the file,
|
12
|
+
# its body will be incorrect, anyway.
|
13
13
|
|
14
14
|
require 'yaml'
|
15
15
|
require 'open3'
|
@@ -52,8 +52,6 @@ class SeeingIsBelieving
|
|
52
52
|
begin
|
53
53
|
evaluate_file
|
54
54
|
deserialize_result.tap { |result| fail if result.bug_in_sib? }
|
55
|
-
# Okay, really, I should wrap this in another exception and raise it on up,
|
56
|
-
# but for now, I'm feeling a little lazy and am not going to do it
|
57
55
|
rescue Exception => error
|
58
56
|
error = wrap_error error if error_implies_bug_in_sib? error
|
59
57
|
raise error
|
@@ -28,7 +28,12 @@ class SeeingIsBelieving
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def record_result(value)
|
31
|
-
|
31
|
+
begin
|
32
|
+
inspected = value.inspect.to_str # only invoke inspect once, b/c the inspection may be recorded
|
33
|
+
rescue NoMethodError
|
34
|
+
inspected = "#<no inspect available>"
|
35
|
+
end
|
36
|
+
|
32
37
|
if size < @max_number_of_captures then @array << inspected
|
33
38
|
elsif size == @max_number_of_captures then @array << '...'
|
34
39
|
end
|
@@ -4,7 +4,7 @@ class SeeingIsBelieving
|
|
4
4
|
|
5
5
|
# override #process so it does not raise an error on
|
6
6
|
# fatal parsings (we want to keep going if possible,
|
7
|
-
# this allows us to find comments in syntactically invalid files
|
7
|
+
# this allows us to find comments in syntactically invalid files)
|
8
8
|
class NullDiagnostics < Parser::Diagnostic::Engine
|
9
9
|
def process(*)
|
10
10
|
# no op
|
@@ -38,12 +38,12 @@ class SeeingIsBelieving
|
|
38
38
|
def heredoc?(ast)
|
39
39
|
# some strings are fucking weird.
|
40
40
|
# e.g. the "1" in `%w[1]` returns nil for ast.location.begin
|
41
|
-
# and `__FILE__` is a string whose location is a Parser::Source::Map instead of a Parser::Source::Map::Collection,
|
41
|
+
# and `__FILE__` is a string whose location is a Parser::Source::Map instead of a Parser::Source::Map::Collection,
|
42
|
+
# so it has no #begin
|
42
43
|
ast.kind_of?(Parser::AST::Node) &&
|
43
44
|
(ast.type == :dstr || ast.type == :str) &&
|
44
45
|
(location = ast.location) &&
|
45
|
-
(
|
46
|
-
(the_begin.source =~ /^\<\<-?/)
|
46
|
+
(ast.location.kind_of? Parser::Source::Map::Heredoc)
|
47
47
|
end
|
48
48
|
|
49
49
|
def void_value?(ast)
|
@@ -62,6 +62,7 @@ class SeeingIsBelieving
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def heredoc_hack(ast)
|
65
|
+
return ast
|
65
66
|
return ast unless heredoc? ast
|
66
67
|
Parser::AST::Node.new :str,
|
67
68
|
[],
|
data/seeing_is_believing.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "parser", "~> 2.
|
22
|
+
s.add_dependency "parser", "~> 2.1.4"
|
23
23
|
|
24
24
|
s.add_development_dependency "haiti", "~> 0.0.3"
|
25
25
|
s.add_development_dependency "rake", "~> 10.0.3"
|
data/spec/line_spec.rb
CHANGED
@@ -19,6 +19,19 @@ describe SeeingIsBelieving::Line, t:true do
|
|
19
19
|
line.inspect.should == '#<SIB:Line[] (0, 0) RuntimeError:"omg">'
|
20
20
|
end
|
21
21
|
|
22
|
+
it "doesn't blow up when there is no #inspect available e.g. BasicObject" do
|
23
|
+
obj = BasicObject.new
|
24
|
+
line_for(obj).inspect.should == '#<SIB:Line["#<no inspect available>"] (1, 23) no exception>'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "doesn't blow up when #inspect returns a not-String (e.g. pathalogical libraries like FactoryGirl)" do
|
28
|
+
obj = BasicObject.new
|
29
|
+
def obj.inspect
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
line_for(obj).inspect.should == '#<SIB:Line["#<no inspect available>"] (1, 23) no exception>'
|
33
|
+
end
|
34
|
+
|
22
35
|
it 'knows when it has an exception' do
|
23
36
|
exception = RuntimeError.new 'omg'
|
24
37
|
line = Line.new
|
@@ -314,7 +314,7 @@ describe SeeingIsBelieving do
|
|
314
314
|
it 'can evaluate under a different ruby executable' do
|
315
315
|
Dir.chdir proving_grounds_dir do
|
316
316
|
File.write 'omg-ruby', "#!/usr/bin/env ruby
|
317
|
-
$LOAD_PATH.unshift '#{File.expand_path '
|
317
|
+
$LOAD_PATH.unshift '#{File.expand_path '../../lib', __FILE__}'
|
318
318
|
|
319
319
|
require 'seeing_is_believing'
|
320
320
|
result = SeeingIsBelieving::Result.new
|
@@ -39,7 +39,7 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
example 'multiple heredocs' do
|
42
|
-
# a stupid
|
42
|
+
# a stupid implementation issue from hacking around heredocs
|
43
43
|
# causes the toplevel begin to wrap the whole file.
|
44
44
|
# It's fine b/c it is ultimately the same, but that's why it's
|
45
45
|
# "[<<<<A>\nA\n<<B>]\nB"
|
@@ -598,9 +598,7 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
598
598
|
end
|
599
599
|
|
600
600
|
it 'wraps heredocs with call defined on them (edge cases on edge cases *sigh*)' do
|
601
|
-
|
602
|
-
wrap("<<HERE.()\na\nHERE").should == "<<<HERE.()>\na\nHERE"
|
603
|
-
end
|
601
|
+
wrap("<<HERE.()\na\nHERE").should == "<<<HERE.()>\na\nHERE"
|
604
602
|
end
|
605
603
|
end
|
606
604
|
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Cheek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: haiti
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|