sourcify 0.5.0 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/HISTORY.txt +5 -0
- data/README.rdoc +86 -3
- data/Rakefile +47 -15
- data/lib/sourcify.rb +13 -0
- data/lib/sourcify/common/parser/converter.rb +29 -0
- data/lib/sourcify/common/parser/raw_scanner/comment.rb +23 -0
- data/lib/sourcify/common/parser/raw_scanner/counter.rb +43 -0
- data/lib/sourcify/common/parser/raw_scanner/dstring.rb +60 -0
- data/lib/sourcify/common/parser/raw_scanner/extensions.rb +121 -0
- data/lib/sourcify/common/parser/raw_scanner/heredoc.rb +26 -0
- data/lib/sourcify/common/parser/source_code.rb +33 -0
- data/lib/sourcify/common/ragel/common.rl +5 -0
- data/lib/sourcify/common/ragel/expressions.rl +38 -0
- data/lib/sourcify/{proc/scanner.rl → common/ragel/machines.rl} +10 -178
- data/lib/sourcify/errors.rb +4 -0
- data/lib/sourcify/method.rb +134 -0
- data/lib/sourcify/method/methods.rb +3 -0
- data/lib/sourcify/method/methods/to_raw_source.rb +30 -0
- data/lib/sourcify/method/methods/to_sexp.rb +30 -0
- data/lib/sourcify/method/methods/to_source.rb +30 -0
- data/lib/sourcify/method/parser.rb +104 -0
- data/lib/sourcify/method/parser/converter.rb +8 -0
- data/lib/sourcify/method/parser/raw_scanner.rb +2494 -0
- data/lib/sourcify/method/parser/raw_scanner.rl +144 -0
- data/lib/sourcify/method/parser/raw_scanner_extensions.rb +64 -0
- data/lib/sourcify/method/parser/scanner.rb +48 -0
- data/lib/sourcify/method/parser/source_code.rb +8 -0
- data/lib/sourcify/proc.rb +0 -2
- data/lib/sourcify/proc/parser.rb +2 -5
- data/lib/sourcify/proc/parser/converter.rb +2 -23
- data/lib/sourcify/proc/{scanner.rb → parser/raw_scanner.rb} +808 -806
- data/lib/sourcify/proc/parser/raw_scanner.rl +149 -0
- data/lib/sourcify/proc/parser/raw_scanner_extensions.rb +72 -0
- data/lib/sourcify/proc/parser/{code_scanner.rb → scanner.rb} +9 -5
- data/lib/sourcify/proc/parser/source_code.rb +2 -27
- data/lib/sourcify/version.rb +1 -1
- data/spec/method/others_from_def_end_block_spec.rb +49 -0
- data/spec/method/others_from_define_method_spec.rb +62 -0
- data/spec/method/raw_scanner/block_comment_spec.rb +8 -0
- data/spec/method/raw_scanner/double_colons_spec.rb +8 -0
- data/spec/method/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
- data/spec/method/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
- data/spec/method/raw_scanner/heredoc_w_indent_spec.rb +8 -0
- data/spec/method/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
- data/spec/method/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
- data/spec/method/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
- data/spec/method/raw_scanner/per_line_comment_spec.rb +8 -0
- data/spec/method/raw_scanner/single_quote_str_spec.rb +8 -0
- data/spec/method/raw_scanner/slash_operator_spec.rb +8 -0
- data/spec/method/raw_scanner/spec_helper.rb +80 -0
- data/spec/method/spec_helper.rb +1 -0
- data/spec/method/to_raw_source_spec.rb +31 -0
- data/spec/method/to_raw_source_w_specified_strip_enclosure_spec.rb +148 -0
- data/spec/method/to_sexp_from_def_end_block_w_variables_spec.rb +46 -0
- data/spec/method/to_sexp_from_def_end_block_within_irb_spec.rb +38 -0
- data/spec/method/to_sexp_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +56 -0
- data/spec/method/to_sexp_from_define_method_w_variables_spec.rb +52 -0
- data/spec/method/to_sexp_from_define_method_within_irb_spec.rb +42 -0
- data/spec/method/to_sexp_w_specified_strip_enclosure_spec.rb +74 -0
- data/spec/method/to_source_from_def_end_block_w_19_extras_spec.rb +23 -0
- data/spec/method/to_source_from_def_end_block_w_nested_begin_spec.rb +35 -0
- data/spec/method/to_source_from_def_end_block_w_nested_case_spec.rb +35 -0
- data/spec/method/to_source_from_def_end_block_w_nested_class_spec.rb +51 -0
- data/spec/method/to_source_from_def_end_block_w_nested_do_end_block_spec.rb +33 -0
- data/spec/method/to_source_from_def_end_block_w_nested_for_spec.rb +126 -0
- data/spec/method/to_source_from_def_end_block_w_nested_if_spec.rb +82 -0
- data/spec/method/to_source_from_def_end_block_w_nested_literal_keyword_spec.rb +141 -0
- data/spec/method/to_source_from_def_end_block_w_nested_method_spec.rb +33 -0
- data/spec/method/to_source_from_def_end_block_w_nested_module_spec.rb +59 -0
- data/spec/method/to_source_from_def_end_block_w_nested_unless_spec.rb +82 -0
- data/spec/method/to_source_from_def_end_block_w_nested_until_spec.rb +179 -0
- data/spec/method/to_source_from_def_end_block_w_nested_while_spec.rb +179 -0
- data/spec/method/to_source_from_def_end_block_w_singleton_method_spec.rb +19 -0
- data/spec/method/to_source_from_def_end_block_within_irb_spec.rb +30 -0
- data/spec/method/to_source_from_def_end_w_multi_blocks_and_many_matches_spec.rb +30 -0
- data/spec/method/to_source_from_def_end_w_multi_blocks_and_single_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_braced_block_spec.rb +113 -0
- data/spec/method/to_source_from_define_method_w_do_end_block_spec.rb +145 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_many_matches_spec.rb +56 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_single_match_spec.rb +73 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_many_matches_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_no_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_single_match_spec.rb +28 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +103 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_many_matches_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_no_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_single_match_spec.rb +28 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_ignore_nested_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_within_irb_spec.rb +32 -0
- data/spec/method/to_source_magic_file_var_spec.rb +176 -0
- data/spec/method/to_source_magic_line_var_spec.rb +298 -0
- data/spec/method/to_source_w_specified_strip_enclosure_spec.rb +39 -0
- data/spec/no_method/unsupported_platform_spec.rb +26 -0
- data/spec/proc/raw_scanner/block_comment_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_colons_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
- data/spec/proc/raw_scanner/heredoc_w_indent_spec.rb +8 -0
- data/spec/proc/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
- data/spec/proc/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
- data/spec/proc/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
- data/spec/proc/raw_scanner/per_line_comment_spec.rb +8 -0
- data/spec/proc/raw_scanner/single_quote_str_spec.rb +8 -0
- data/spec/proc/raw_scanner/slash_operator_spec.rb +8 -0
- data/spec/proc/raw_scanner/spec_helper.rb +63 -0
- data/spec/{proc_scanner/block_comment_spec.rb → raw_scanner/block_comment_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_colons_spec.rb → raw_scanner/double_colons_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_quote_str_w_interpolation_spec.rb → raw_scanner/double_quote_str_w_interpolation_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_quote_str_wo_interpolation_spec.rb → raw_scanner/double_quote_str_wo_interpolation_shared_spec.rb} +1 -5
- data/spec/raw_scanner/heredoc_w_indent_shared_spec.rb +69 -0
- data/spec/raw_scanner/heredoc_wo_indent_shared_spec.rb +70 -0
- data/spec/{proc_scanner/kw_do_alias1_spec.rb → raw_scanner/kw_block_start_alias1_shared_spec.rb} +10 -26
- data/spec/{proc_scanner/kw_do_alias2_spec.rb → raw_scanner/kw_block_start_alias2_shared_spec.rb} +10 -25
- data/spec/{proc_scanner/per_line_comment_spec.rb → raw_scanner/per_line_comment_shared_spec.rb} +1 -5
- data/spec/raw_scanner/shared_specs.rb +3 -0
- data/spec/{proc_scanner/single_quote_str_spec.rb → raw_scanner/single_quote_str_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/slash_operator_spec.rb → raw_scanner/slash_operator_shared_spec.rb} +1 -5
- data/spec/run_spec.sh +7 -1
- data/spec/spec_helper.rb +8 -25
- metadata +204 -47
- data/.rvmrc +0 -1
- data/VERSION +0 -1
- data/lib/sourcify/proc/scanner/comment.rb +0 -21
- data/lib/sourcify/proc/scanner/counter.rb +0 -44
- data/lib/sourcify/proc/scanner/dstring.rb +0 -59
- data/lib/sourcify/proc/scanner/extensions.rb +0 -171
- data/lib/sourcify/proc/scanner/heredoc.rb +0 -24
- data/spec/proc_scanner/heredoc_spec.rb +0 -144
- data/spec/proc_scanner/spec_helper.rb +0 -33
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.2-p180@sourcify
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.2
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Sourcify
|
2
|
-
module Proc
|
3
|
-
module Scanner #:nodoc:all
|
4
|
-
class Comment
|
5
|
-
|
6
|
-
def <<(content)
|
7
|
-
(@contents ||= []) << content
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
@contents.join
|
12
|
-
end
|
13
|
-
|
14
|
-
def closed?
|
15
|
-
@contents[-1].split("\n")[-1].strip == '=end'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Sourcify
|
2
|
-
module Proc
|
3
|
-
module Scanner #:nodoc:all
|
4
|
-
class Counter
|
5
|
-
|
6
|
-
attr_reader :counts
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@counts = [0,0]
|
10
|
-
end
|
11
|
-
|
12
|
-
def started?
|
13
|
-
@counts.any?(&:nonzero?)
|
14
|
-
end
|
15
|
-
|
16
|
-
def just_started?
|
17
|
-
@counts.any?{|count| count == 1 }
|
18
|
-
end
|
19
|
-
|
20
|
-
def balanced?
|
21
|
-
@counts.any?(&:zero?)
|
22
|
-
end
|
23
|
-
|
24
|
-
def decrement
|
25
|
-
(0..1).each{|i| @counts[i] -= 1 unless @counts[i].zero? }
|
26
|
-
end
|
27
|
-
|
28
|
-
def increment(val = 1)
|
29
|
-
if val.is_a?(Range)
|
30
|
-
@counts[0] += val.first
|
31
|
-
@counts[1] += val.last
|
32
|
-
else
|
33
|
-
(0..1).each{|i| @counts[i] += 1 }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
class DoEndBlockCounter < Counter; end
|
40
|
-
class BraceBlockCounter < Counter; end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Sourcify
|
2
|
-
module Proc
|
3
|
-
module Scanner #:nodoc:all
|
4
|
-
class DString < Struct.new(:tag)
|
5
|
-
|
6
|
-
# To suppress 'warning: Object#type is deprecated; use Object#class' when
|
7
|
-
# evaluating string
|
8
|
-
attr_reader :type
|
9
|
-
|
10
|
-
def <<(content)
|
11
|
-
(@contents ||= []) << content
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_s
|
15
|
-
@contents.join
|
16
|
-
end
|
17
|
-
|
18
|
-
def closed?
|
19
|
-
evaluable? && parsable?
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
CLOSING_TAGS = {'(' => ')', '[' => ']', '<' => '>', '{' => '}'}
|
25
|
-
|
26
|
-
def evaluable?
|
27
|
-
@contents[-1][-1].chr == end_tag
|
28
|
-
end
|
29
|
-
|
30
|
-
def parsable?
|
31
|
-
begin
|
32
|
-
Parser::Converter.to_sexp <<-SOURCIFIED_HEREDOKIE.strip
|
33
|
-
#{safe_contents}
|
34
|
-
SOURCIFIED_HEREDOKIE
|
35
|
-
rescue Exception
|
36
|
-
true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def safe_contents
|
41
|
-
# NOTE: %x & ` strings are dangerous to eval cos they execute shell commands,
|
42
|
-
# thus we convert them to normal strings 1st
|
43
|
-
to_s.gsub(/(%x)(\W|\_)/, '%Q\2').gsub(/.{0,2}(`)/) do |s|
|
44
|
-
s =~ /^(%Q|%W|%r|%x|.?%|.?\\)/ ? s : s.sub(/`$/,'%Q`')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def start_tag
|
49
|
-
@start_tag ||= tag[-1].chr
|
50
|
-
end
|
51
|
-
|
52
|
-
def end_tag
|
53
|
-
@end_tag ||= (CLOSING_TAGS[start_tag] || start_tag)
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
%w{heredoc comment dstring counter}.each do |f|
|
2
|
-
Sourcify.require_rb('proc', 'scanner', f)
|
3
|
-
end
|
4
|
-
|
5
|
-
module Sourcify
|
6
|
-
module Proc
|
7
|
-
module Scanner #:nodoc:all
|
8
|
-
module Extensions
|
9
|
-
|
10
|
-
class Escape < Exception; end
|
11
|
-
RUBY_PARSER = RubyParser.new
|
12
|
-
|
13
|
-
def process(data, opts={})
|
14
|
-
begin
|
15
|
-
@start_pattern = opts[:start_pattern] || /.*/
|
16
|
-
@body_matcher = opts[:body_matcher] || lambda{|_| true }
|
17
|
-
@stop_on_newline = opts[:stop_on_newline]
|
18
|
-
@results, @data = [], data.unpack("c*")
|
19
|
-
reset_attributes
|
20
|
-
execute!
|
21
|
-
rescue Escape
|
22
|
-
@results
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def data_frag(range)
|
27
|
-
@data[range].pack('c*')
|
28
|
-
end
|
29
|
-
|
30
|
-
def push(key, ts, te)
|
31
|
-
@tokens << [key, data_frag(ts .. te.pred)]
|
32
|
-
end
|
33
|
-
|
34
|
-
def push_dstring(ts, te)
|
35
|
-
data = data_frag(ts .. te.pred)
|
36
|
-
@dstring ||= DString.new(data[%r{^("|`|/|%(?:Q|W|r|x|)(?:\W|_))},1])
|
37
|
-
@dstring << data
|
38
|
-
return true unless @dstring.closed?
|
39
|
-
@tokens << [:dstring, @dstring.to_s]
|
40
|
-
@dstring = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def push_comment(ts, te)
|
44
|
-
data = data_frag(ts .. te.pred)
|
45
|
-
@comment ||= Comment.new
|
46
|
-
@comment << data
|
47
|
-
return true unless @comment.closed?
|
48
|
-
@tokens << [:comment, @comment.to_s]
|
49
|
-
@comment = nil
|
50
|
-
end
|
51
|
-
|
52
|
-
def push_heredoc(ts, te)
|
53
|
-
data = data_frag(ts .. te.pred)
|
54
|
-
unless @heredoc
|
55
|
-
indented, tag = data.match(/\<\<(\-?)['"]?(\w+)['"]?$/)[1..3]
|
56
|
-
@heredoc = Heredoc.new(tag, !indented.empty?)
|
57
|
-
end
|
58
|
-
@heredoc << data
|
59
|
-
return true unless @heredoc.closed?(data_frag(te .. te))
|
60
|
-
@tokens << [:heredoc, @heredoc.to_s]
|
61
|
-
@heredoc = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def push_label(ts, te)
|
65
|
-
# NOTE: 1.9.* supports label key, which RubyParser cannot handle, thus
|
66
|
-
# conversion is needed.
|
67
|
-
data = data_frag(ts .. te.pred)
|
68
|
-
@tokens << [:symbol, data.sub(/^(.*)\:$/, ':\1')]
|
69
|
-
@tokens << [:space, ' ']
|
70
|
-
@tokens << [:assoc, '=>']
|
71
|
-
end
|
72
|
-
|
73
|
-
def preceded_with?(*args)
|
74
|
-
begin
|
75
|
-
prev_token = @tokens[-1][0] == :space ? @tokens[-2] : @tokens[-1]
|
76
|
-
!([args].flatten & prev_token).empty?
|
77
|
-
rescue
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def increment_lineno
|
82
|
-
@lineno += 1
|
83
|
-
if @stop_on_newline || !@results.empty? || (@results.empty? && @rejecting_block)
|
84
|
-
raise Escape
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def increment_counter(key, count = 1)
|
89
|
-
return if other_counter(key).started?
|
90
|
-
unless (counter = this_counter(key)).started?
|
91
|
-
return if (@rejecting_block = codified_tokens !~ @start_pattern)
|
92
|
-
@false_start_backup = @tokens.dup if key == :brace
|
93
|
-
offset_attributes
|
94
|
-
end
|
95
|
-
counter.increment(count)
|
96
|
-
end
|
97
|
-
|
98
|
-
def decrement_counter(key)
|
99
|
-
return unless (counter = this_counter(key)).started?
|
100
|
-
counter.decrement
|
101
|
-
construct_result_code if counter.balanced?
|
102
|
-
end
|
103
|
-
|
104
|
-
def fix_counter_false_start(key)
|
105
|
-
return unless this_counter(key).just_started?
|
106
|
-
return unless really_false_started?
|
107
|
-
reset_attributes
|
108
|
-
@tokens, @false_start_backup = @false_start_backup.dup, nil if @false_start_backup
|
109
|
-
end
|
110
|
-
|
111
|
-
def other_counter(type)
|
112
|
-
{:do_end => @brace_counter, :brace => @do_end_counter}[type]
|
113
|
-
end
|
114
|
-
|
115
|
-
def this_counter(type)
|
116
|
-
{:brace => @brace_counter, :do_end => @do_end_counter}[type]
|
117
|
-
end
|
118
|
-
|
119
|
-
def construct_result_code
|
120
|
-
code = <<-SOURCIFIED_HEREDOKIE.strip
|
121
|
-
proc #{codified_tokens}
|
122
|
-
SOURCIFIED_HEREDOKIE
|
123
|
-
|
124
|
-
begin
|
125
|
-
if safe_eval(code) && @body_matcher.call(code)
|
126
|
-
@results << code
|
127
|
-
raise Escape if @stop_on_newline or @lineno != 1
|
128
|
-
reset_attributes
|
129
|
-
end
|
130
|
-
rescue Exception
|
131
|
-
raise if $!.is_a?(Escape)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def codified_tokens
|
136
|
-
@tokens.map(&:last).join
|
137
|
-
end
|
138
|
-
|
139
|
-
def reset_attributes
|
140
|
-
@tokens = []
|
141
|
-
@lineno = 1
|
142
|
-
@heredoc, @dstring, @comment = nil
|
143
|
-
@do_end_counter = DoEndBlockCounter.new
|
144
|
-
@brace_counter = BraceBlockCounter.new
|
145
|
-
@rejecting_block = false
|
146
|
-
end
|
147
|
-
|
148
|
-
def really_false_started?
|
149
|
-
safe_eval(<<-SOURCIFIED_HEREDOKIE.strip
|
150
|
-
#{codified_tokens} 1}
|
151
|
-
SOURCIFIED_HEREDOKIE
|
152
|
-
) && true
|
153
|
-
end
|
154
|
-
|
155
|
-
def offset_attributes
|
156
|
-
@lineno = 1 # Fixing JRuby's lineno bug (see http://jira.codehaus.org/browse/JRUBY-5014)
|
157
|
-
unless @tokens.empty?
|
158
|
-
last = @tokens[-1]
|
159
|
-
@tokens.clear
|
160
|
-
@tokens << last
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def safe_eval(string)
|
165
|
-
Parser::Converter.to_sexp(string)
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Sourcify
|
2
|
-
module Proc
|
3
|
-
module Scanner #:nodoc:all
|
4
|
-
class Heredoc < Struct.new(:tag, :indented)
|
5
|
-
|
6
|
-
def <<(content)
|
7
|
-
(@contents ||= []) << content
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
@contents.join
|
12
|
-
end
|
13
|
-
|
14
|
-
def closed?(sealer)
|
15
|
-
return false unless sealer == "\n"
|
16
|
-
parts = @contents[-1].split("\n")
|
17
|
-
return true if parts[-1] == tag
|
18
|
-
indented && parts[-1].sub(/^\s*(.*)$/,'\1') == tag
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
-
|
3
|
-
unless has_parsetree?
|
4
|
-
describe "Heredoc (wo indent)" do
|
5
|
-
%w{X "X" 'X'}.each do |tag|
|
6
|
-
|
7
|
-
should "handle <<#{tag}\\n .. \\nX\\n" do
|
8
|
-
process(%Q(
|
9
|
-
s <<#{tag}
|
10
|
-
aa
|
11
|
-
X
|
12
|
-
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
13
|
-
end
|
14
|
-
|
15
|
-
should "not handle <<#{tag} \\n .. \\nX\\n" do
|
16
|
-
process(%Q(
|
17
|
-
s << #{tag}
|
18
|
-
aa
|
19
|
-
X
|
20
|
-
)).should.not.include([:heredoc, "<<#{tag} \n aa \nX"])
|
21
|
-
end
|
22
|
-
|
23
|
-
should "not handle <<#{tag}\\n .. \\n X\\n" do
|
24
|
-
process(%Q(
|
25
|
-
s <<#{tag}
|
26
|
-
aa
|
27
|
-
X
|
28
|
-
)).should.not.include([:heredoc, "<<#{tag} \n aa \n X"])
|
29
|
-
end
|
30
|
-
|
31
|
-
should "not handle <<#{tag}\\n .. \\nX \\n" do
|
32
|
-
process(%Q(
|
33
|
-
s <<#{tag}
|
34
|
-
aa
|
35
|
-
X
|
36
|
-
)).should.not.include([:heredoc, "<<#{tag} \n aa \nX "])
|
37
|
-
end
|
38
|
-
|
39
|
-
should "not handle class <<#{tag}\\n .. \\nX \\n" do
|
40
|
-
process(%Q(
|
41
|
-
|
42
|
-
class <<#{tag}
|
43
|
-
aa
|
44
|
-
X
|
45
|
-
)).should.not.include([:heredoc, "<<#{tag}\n aa \nX"])
|
46
|
-
end
|
47
|
-
|
48
|
-
should "handle xclass <<#{tag}\\n .. \\nX \\n" do
|
49
|
-
process(%Q(
|
50
|
-
xclass <<#{tag}
|
51
|
-
aa
|
52
|
-
X
|
53
|
-
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
54
|
-
end
|
55
|
-
|
56
|
-
should "handle classx <<#{tag}\\n .. \\nX \\n" do
|
57
|
-
process(%Q(
|
58
|
-
classx <<#{tag}
|
59
|
-
aa
|
60
|
-
X
|
61
|
-
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
62
|
-
end
|
63
|
-
|
64
|
-
should "handle <<#{tag}\\n .. \\nX \\n" do
|
65
|
-
process(%Q(
|
66
|
-
<<#{tag}
|
67
|
-
aa
|
68
|
-
X
|
69
|
-
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "Heredoc (w indent)" do
|
76
|
-
%w{X "X" 'X'}.each do |tag|
|
77
|
-
|
78
|
-
should "handle <<-#{tag}\\n .. \\nX\\n" do
|
79
|
-
process(%Q(
|
80
|
-
s <<-#{tag}
|
81
|
-
aa
|
82
|
-
X
|
83
|
-
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
84
|
-
end
|
85
|
-
|
86
|
-
should "handle <<-#{tag}\\n .. \\n X\\n" do
|
87
|
-
process(%Q(
|
88
|
-
s <<-#{tag}
|
89
|
-
aa
|
90
|
-
X
|
91
|
-
)).should.include([:heredoc, "<<-#{tag}\n aa \n X"])
|
92
|
-
end
|
93
|
-
|
94
|
-
should "not handle <<-#{tag} \\n .. \\nX\\n" do
|
95
|
-
process(%Q(
|
96
|
-
s <<-#{tag}
|
97
|
-
aa
|
98
|
-
X
|
99
|
-
)).should.not.include([:heredoc, "<<-#{tag} \n aa \n X"])
|
100
|
-
end
|
101
|
-
|
102
|
-
should "not handle <<-#{tag}\\n .. \\nX \\n" do
|
103
|
-
process(%Q(
|
104
|
-
s <<-#{tag}
|
105
|
-
aa
|
106
|
-
X
|
107
|
-
)).should.not.include([:heredoc, "<<-#{tag}\n aa \nX "])
|
108
|
-
end
|
109
|
-
|
110
|
-
should "not handle class <<-#{tag}\\n .. \\nX \\n" do
|
111
|
-
process(%Q(
|
112
|
-
class <<-#{tag}
|
113
|
-
aa
|
114
|
-
X
|
115
|
-
)).should.not.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
116
|
-
end
|
117
|
-
|
118
|
-
should "handle xclass <<-#{tag}\\n .. \\nX \\n" do
|
119
|
-
process(%Q(
|
120
|
-
xclass <<-#{tag}
|
121
|
-
aa
|
122
|
-
X
|
123
|
-
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
124
|
-
end
|
125
|
-
|
126
|
-
should "handle classx <<-#{tag}\\n .. \\nX \\n" do
|
127
|
-
process(%Q(
|
128
|
-
classx <<-#{tag}
|
129
|
-
aa
|
130
|
-
X
|
131
|
-
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
132
|
-
end
|
133
|
-
|
134
|
-
should "handle <<-#{tag}\\n .. \\nX \\n" do
|
135
|
-
process(%Q(
|
136
|
-
<<-#{tag}
|
137
|
-
aa
|
138
|
-
X
|
139
|
-
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|