sexpr 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +91 -17
- data/Gemfile +1 -8
- data/README.md +26 -1
- data/Rakefile +0 -12
- data/lib/sexpr/grammar/matching.rb +9 -4
- data/lib/sexpr/grammar/parsing.rb +1 -1
- data/lib/sexpr/grammar/tagging.rb +27 -15
- data/lib/sexpr/matcher/many.rb +16 -1
- data/lib/sexpr/matcher/non_terminal.rb +31 -0
- data/lib/sexpr/matcher/rule.rb +3 -6
- data/lib/sexpr/matcher/terminal.rb +1 -1
- data/lib/sexpr/matcher.rb +3 -2
- data/lib/sexpr/node.rb +1 -1
- data/lib/sexpr/parser.rb +1 -1
- data/lib/sexpr/processor/helper.rb +1 -1
- data/lib/sexpr/processor/sexpr_coercions.rb +6 -14
- data/lib/sexpr/processor.rb +69 -21
- data/lib/sexpr/rewriter.rb +1 -9
- data/lib/sexpr/version.rb +3 -3
- data/lib/sexpr.rb +11 -3
- data/spec/fixtures/bar.rb +9 -0
- data/spec/fixtures/foo.rb +14 -0
- data/spec/fixtures/preprocessed.rb +33 -0
- data/spec/fixtures/simple_processor.rb +19 -0
- data/spec/integration/bool_expr/test_not_push.rb +38 -0
- data/spec/integration/bool_expr/test_parsing.rb +15 -0
- data/spec/integration/bool_expr/test_tagging.rb +25 -0
- data/spec/integration/bool_expr/test_validation.rb +15 -0
- data/spec/{test_readme_examples.rb → integration/test_readme_examples.rb} +4 -4
- data/spec/spec_helper.rb +3 -22
- data/spec/unit/grammar/matching/test_compile_rule.rb +55 -0
- data/spec/{grammar → unit/grammar}/matching/test_compile_rule_defn.rb +26 -2
- data/spec/unit/grammar/matching/test_compile_rules.rb +45 -0
- data/spec/{grammar → unit/grammar}/options/test_install_parser.rb +0 -0
- data/spec/{grammar → unit/grammar}/options/test_install_path.rb +0 -0
- data/spec/{grammar → unit/grammar}/options/test_install_root.rb +0 -0
- data/spec/{grammar → unit/grammar}/tagging/test_looks_a_sexpr.rb +4 -4
- data/spec/{grammar → unit/grammar}/tagging/test_mod2rulename.rb +0 -0
- data/spec/{grammar → unit/grammar}/tagging/test_rule2modname.rb +0 -0
- data/spec/unit/grammar/tagging/test_tag_sexpr.rb +61 -0
- data/spec/unit/grammar/tagging/test_tagging_module_for.rb +72 -0
- data/spec/{grammar → unit/grammar}/test_new.rb +0 -0
- data/spec/{grammar → unit/grammar}/test_parse.rb +0 -0
- data/spec/{grammar → unit/grammar}/test_sexpr.rb +0 -0
- data/spec/{matcher → unit/matcher}/alternative/test_eat.rb +1 -1
- data/spec/{matcher → unit/matcher}/alternative/test_match_q.rb +0 -0
- data/spec/{matcher → unit/matcher}/many/test_eat.rb +0 -0
- data/spec/{matcher → unit/matcher}/many/test_initialize.rb +0 -0
- data/spec/{matcher → unit/matcher}/many/test_match_q.rb +0 -0
- data/spec/unit/matcher/non_terminal/test_eat.rb +31 -0
- data/spec/unit/matcher/non_terminal/test_match_q.rb +32 -0
- data/spec/{matcher → unit/matcher}/reference/test_eat.rb +0 -0
- data/spec/{matcher → unit/matcher}/reference/test_match_q.rb +1 -1
- data/spec/unit/matcher/rule/test_eat.rb +17 -0
- data/spec/unit/matcher/rule/test_match_q.rb +17 -0
- data/spec/{matcher → unit/matcher}/sequence/test_eat.rb +0 -0
- data/spec/{matcher → unit/matcher}/sequence/test_match_q.rb +0 -0
- data/spec/{matcher → unit/matcher}/terminal/test_eat.rb +1 -1
- data/spec/{matcher → unit/matcher}/terminal/test_match_q.rb +3 -3
- data/spec/unit/matcher/terminal/test_terminal_match.rb +108 -0
- data/spec/{node → unit/node}/test_sexpr_body.rb +0 -0
- data/spec/{node → unit/node}/test_sexpr_copy.rb +0 -0
- data/spec/{node → unit/node}/test_sexpr_type.rb +0 -0
- data/spec/{node → unit/node}/test_tracking_markers.rb +0 -0
- data/spec/{parser → unit/parser}/citrus/test_new.rb +0 -0
- data/spec/{parser → unit/parser}/citrus/test_parse.rb +0 -0
- data/spec/{parser → unit/parser}/citrus/test_recognize.rb +1 -1
- data/spec/{parser → unit/parser}/citrus/test_registration.rb +0 -0
- data/spec/{parser → unit/parser}/citrus/test_to_sexpr.rb +0 -0
- data/spec/{parser → unit/parser}/test_factor.rb +0 -0
- data/spec/{parser → unit/parser}/test_input_text.rb +0 -0
- data/spec/{processor → unit/processor}/helper/test_call.rb +0 -0
- data/spec/unit/processor/test_apply.rb +34 -0
- data/spec/{processor → unit/processor}/test_build_helper_chain.rb +0 -0
- data/spec/unit/processor/test_call.rb +47 -0
- data/spec/unit/processor/test_grammar.rb +56 -0
- data/spec/{processor → unit/processor}/test_helper.rb +0 -0
- data/spec/{processor → unit/processor}/test_sexpr_coercions.rb +6 -2
- data/spec/unit/processor/test_use.rb +22 -0
- data/spec/{rewriter → unit/rewriter}/test_copy_and_apply.rb +0 -0
- data/spec/{test_load.rb → unit/test_load.rb} +3 -2
- data/spec/{test_rewriter.rb → unit/test_rewriter.rb} +0 -0
- data/spec/unit/test_sexpr.rb +8 -0
- data/tasks/gem.rake +9 -4
- data/tasks/test.rake +11 -0
- metadata +126 -183
- data/Gemfile.lock +0 -27
- data/LICENCE.md +0 -22
- data/Manifest.txt +0 -16
- data/examples/bool_expr/bool_expr.citrus +0 -72
- data/examples/bool_expr/bool_expr.rb +0 -153
- data/examples/bool_expr/bool_expr.sexp.yml +0 -23
- data/lib/sexpr/loader.rb +0 -0
- data/sexpr.gemspec +0 -189
- data/sexpr.noespec +0 -26
- data/spec/grammar/matching/test_compile_rule.rb +0 -23
- data/spec/grammar/tagging/test_tag_sexpr.rb +0 -28
- data/spec/grammar.yml +0 -24
- data/spec/matcher/rule/test_eat.rb +0 -21
- data/spec/matcher/rule/test_match_q.rb +0 -24
- data/spec/matcher/terminal/test_terminal_match.rb +0 -89
- data/spec/processor/test_call.rb +0 -46
- data/spec/processor/test_main_processor.rb +0 -18
- data/spec/test_sexpr.rb +0 -8
- data/tasks/debug_mail.rake +0 -75
- data/tasks/debug_mail.txt +0 -13
- data/tasks/spec_test.rake +0 -71
- data/tasks/unit_test.rake +0 -76
- data/tasks/yard.rake +0 -51
@@ -1,23 +0,0 @@
|
|
1
|
-
parser:
|
2
|
-
bool_expr.citrus
|
3
|
-
rules:
|
4
|
-
bool_expr:
|
5
|
-
- bool_and
|
6
|
-
- bool_or
|
7
|
-
- bool_not
|
8
|
-
- var_ref
|
9
|
-
- bool_lit
|
10
|
-
bool_and:
|
11
|
-
- [ bool_expr+ ]
|
12
|
-
bool_or:
|
13
|
-
- [ bool_expr+ ]
|
14
|
-
bool_not:
|
15
|
-
- [ bool_expr ]
|
16
|
-
bool_lit:
|
17
|
-
- [ literal ]
|
18
|
-
var_ref:
|
19
|
-
- [ var_name ]
|
20
|
-
var_name:
|
21
|
-
!ruby/regexp /^[a-z]+$/
|
22
|
-
literal:
|
23
|
-
[true, false]
|
data/lib/sexpr/loader.rb
DELETED
File without changes
|
data/sexpr.gemspec
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
# We require your library, mainly to have access to the VERSION number.
|
2
|
-
# Feel free to set $version manually.
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
|
-
require "sexpr/version"
|
5
|
-
$version = Sexpr::Version.to_s
|
6
|
-
|
7
|
-
#
|
8
|
-
# This is your Gem specification. Default values are provided so that your library
|
9
|
-
# should be correctly packaged given what you have described in the .noespec file.
|
10
|
-
#
|
11
|
-
Gem::Specification.new do |s|
|
12
|
-
|
13
|
-
################################################################### ABOUT YOUR GEM
|
14
|
-
|
15
|
-
# Gem name (required)
|
16
|
-
s.name = "sexpr"
|
17
|
-
|
18
|
-
# Gem version (required)
|
19
|
-
s.version = $version
|
20
|
-
|
21
|
-
# A short summary of this gem
|
22
|
-
#
|
23
|
-
# This is displayed in `gem list -d`.
|
24
|
-
s.summary = "A compilation framework around s-expressions"
|
25
|
-
|
26
|
-
# A long description of this gem (required)
|
27
|
-
#
|
28
|
-
# The description should be more detailed than the summary. For example,
|
29
|
-
# you might wish to copy the entire README into the description.
|
30
|
-
s.description = "Sexpr helps manipulating s-expressions in ruby."
|
31
|
-
|
32
|
-
# The URL of this gem home page (optional)
|
33
|
-
s.homepage = "https://github.com/blambeau/sexp"
|
34
|
-
|
35
|
-
# Gem publication date (required but auto)
|
36
|
-
#
|
37
|
-
# Today is automatically used by default, uncomment only if
|
38
|
-
# you know what you do!
|
39
|
-
#
|
40
|
-
# s.date = Time.now.strftime('%Y-%m-%d')
|
41
|
-
|
42
|
-
# The license(s) for the library. Each license must be a short name, no
|
43
|
-
# more than 64 characters.
|
44
|
-
#
|
45
|
-
# s.licences = %w{}
|
46
|
-
|
47
|
-
# The rubyforge project this gem lives under (optional)
|
48
|
-
#
|
49
|
-
# s.rubyforge_project = nil
|
50
|
-
|
51
|
-
################################################################### ABOUT THE AUTHORS
|
52
|
-
|
53
|
-
# The list of author names who wrote this gem.
|
54
|
-
#
|
55
|
-
# If you are providing multiple authors and multiple emails they should be
|
56
|
-
# in the same order.
|
57
|
-
#
|
58
|
-
s.authors = ["Bernard Lambeau"]
|
59
|
-
|
60
|
-
# Contact emails for this gem
|
61
|
-
#
|
62
|
-
# If you are providing multiple authors and multiple emails they should be
|
63
|
-
# in the same order.
|
64
|
-
#
|
65
|
-
# NOTE: Somewhat strangly this attribute is always singular!
|
66
|
-
# Don't replace by s.emails = ...
|
67
|
-
s.email = ["blambeau@gmail.com"]
|
68
|
-
|
69
|
-
################################################################### PATHS, FILES, BINARIES
|
70
|
-
|
71
|
-
# Paths in the gem to add to $LOAD_PATH when this gem is
|
72
|
-
# activated (required).
|
73
|
-
#
|
74
|
-
# The default 'lib' is typically sufficient.
|
75
|
-
s.require_paths = ["lib"]
|
76
|
-
|
77
|
-
# Files included in this gem.
|
78
|
-
#
|
79
|
-
# By default, we take all files included in the Manifest.txt file on root
|
80
|
-
# of the project. Entries of the manifest are interpreted as Dir[...]
|
81
|
-
# patterns so that lazy people may use wilcards like lib/**/*
|
82
|
-
#
|
83
|
-
here = File.expand_path(File.dirname(__FILE__))
|
84
|
-
s.files = File.readlines(File.join(here, 'Manifest.txt')).
|
85
|
-
inject([]){|files, pattern| files + Dir[File.join(here, pattern.strip)]}.
|
86
|
-
collect{|x| x[(1+here.size)..-1]}
|
87
|
-
|
88
|
-
# Test files included in this gem.
|
89
|
-
#
|
90
|
-
s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
|
91
|
-
|
92
|
-
# The path in the gem for executable scripts (optional)
|
93
|
-
#
|
94
|
-
s.bindir = "bin"
|
95
|
-
|
96
|
-
# Executables included in the gem.
|
97
|
-
#
|
98
|
-
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
99
|
-
|
100
|
-
################################################################### REQUIREMENTS & INSTALL
|
101
|
-
# Remember the gem version requirements operators and schemes:
|
102
|
-
# = Equals version
|
103
|
-
# != Not equal to version
|
104
|
-
# > Greater than version
|
105
|
-
# < Less than version
|
106
|
-
# >= Greater than or equal to
|
107
|
-
# <= Less than or equal to
|
108
|
-
# ~> Approximately greater than
|
109
|
-
#
|
110
|
-
# Don't forget to have a look at http://lmgtfy.com/?q=Ruby+Versioning+Policies
|
111
|
-
# for setting your gem version.
|
112
|
-
#
|
113
|
-
# For your requirements to other gems, remember that
|
114
|
-
# ">= 2.2.0" (optimistic: specify minimal version)
|
115
|
-
# ">= 2.2.0", "< 3.0" (pessimistic: not greater than the next major)
|
116
|
-
# "~> 2.2" (shortcut for ">= 2.2.0", "< 3.0")
|
117
|
-
# "~> 2.2.0" (shortcut for ">= 2.2.0", "< 2.3.0")
|
118
|
-
#
|
119
|
-
|
120
|
-
#
|
121
|
-
# One call to add_dependency('gem_name', 'gem version requirement') for each
|
122
|
-
# runtime dependency. These gems will be installed with your gem.
|
123
|
-
# One call to add_development_dependency('gem_name', 'gem version requirement')
|
124
|
-
# for each development dependency. These gems are required for developers
|
125
|
-
#
|
126
|
-
s.add_development_dependency("epath", "~> 0.0.1")
|
127
|
-
s.add_development_dependency("citrus", "~> 2.4")
|
128
|
-
s.add_development_dependency("rake", "~> 0.9.2")
|
129
|
-
s.add_development_dependency("rspec", "~> 2.8.0")
|
130
|
-
s.add_development_dependency("wlang", "~> 0.10.2")
|
131
|
-
|
132
|
-
|
133
|
-
# The version of ruby required by this gem
|
134
|
-
#
|
135
|
-
# Uncomment and set this if your gem requires specific ruby versions.
|
136
|
-
#
|
137
|
-
# s.required_ruby_version = ">= 0"
|
138
|
-
|
139
|
-
# The RubyGems version required by this gem
|
140
|
-
#
|
141
|
-
# s.required_rubygems_version = ">= 0"
|
142
|
-
|
143
|
-
# The platform this gem runs on. See Gem::Platform for details.
|
144
|
-
#
|
145
|
-
# s.platform = nil
|
146
|
-
|
147
|
-
# Extensions to build when installing the gem.
|
148
|
-
#
|
149
|
-
# Valid types of extensions are extconf.rb files, configure scripts
|
150
|
-
# and rakefiles or mkrf_conf files.
|
151
|
-
#
|
152
|
-
s.extensions = []
|
153
|
-
|
154
|
-
# External (to RubyGems) requirements that must be met for this gem to work.
|
155
|
-
# It’s simply information for the user.
|
156
|
-
#
|
157
|
-
s.requirements = nil
|
158
|
-
|
159
|
-
# A message that gets displayed after the gem is installed
|
160
|
-
#
|
161
|
-
# Uncomment and set this if you want to say something to the user
|
162
|
-
# after gem installation
|
163
|
-
#
|
164
|
-
s.post_install_message = nil
|
165
|
-
|
166
|
-
################################################################### SECURITY
|
167
|
-
|
168
|
-
# The key used to sign this gem. See Gem::Security for details.
|
169
|
-
#
|
170
|
-
# s.signing_key = nil
|
171
|
-
|
172
|
-
# The certificate chain used to sign this gem. See Gem::Security for
|
173
|
-
# details.
|
174
|
-
#
|
175
|
-
# s.cert_chain = []
|
176
|
-
|
177
|
-
################################################################### RDOC
|
178
|
-
|
179
|
-
# An ARGV style array of options to RDoc
|
180
|
-
#
|
181
|
-
# See 'rdoc --help' about this
|
182
|
-
#
|
183
|
-
s.rdoc_options = []
|
184
|
-
|
185
|
-
# Extra files to add to RDoc such as README
|
186
|
-
#
|
187
|
-
s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
|
188
|
-
|
189
|
-
end
|
data/sexpr.noespec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
template-info:
|
2
|
-
name: "ruby"
|
3
|
-
version: 1.7.0
|
4
|
-
links:
|
5
|
-
source: https://github.com/blambeau/noe
|
6
|
-
variables:
|
7
|
-
lower:
|
8
|
-
sexpr
|
9
|
-
upper:
|
10
|
-
Sexpr
|
11
|
-
version:
|
12
|
-
0.4.0
|
13
|
-
summary: |-
|
14
|
-
A compilation framework around s-expressions
|
15
|
-
description: |-
|
16
|
-
Sexpr helps manipulating s-expressions in ruby.
|
17
|
-
authors:
|
18
|
-
- {name: Bernard Lambeau, email: blambeau@gmail.com}
|
19
|
-
links:
|
20
|
-
- https://github.com/blambeau/sexp
|
21
|
-
dependencies:
|
22
|
-
- {name: epath, version: "~> 0.0.1", groups: [development]}
|
23
|
-
- {name: citrus, version: "~> 2.4", groups: [development]}
|
24
|
-
- {name: rake, version: "~> 0.9.2", groups: [development]}
|
25
|
-
- {name: rspec, version: "~> 2.8.0", groups: [development]}
|
26
|
-
- {name: wlang, version: "~> 0.10.2", groups: [development]}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr
|
3
|
-
module Grammar
|
4
|
-
describe Matching, "compile_rule" do
|
5
|
-
include Matching
|
6
|
-
|
7
|
-
it 'keep alternatives unchanged' do
|
8
|
-
compile_rule(:hello, Matcher::Alternative.new([]) ).should be_a(Matcher::Alternative)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'keep terminals unchanged' do
|
12
|
-
compile_rule(:hello, Matcher::Terminal.new(true) ).should be_a(Matcher::Terminal)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'keep creates a Rule englobing sequences' do
|
16
|
-
compiled = compile_rule(:hello, Matcher::Sequence.new([]) )
|
17
|
-
compiled.should be_a(Matcher::Rule)
|
18
|
-
compiled.name.should eq(:hello)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr::Grammar
|
3
|
-
describe Tagging, "tag_sexpr" do
|
4
|
-
include Tagging
|
5
|
-
|
6
|
-
module TaggingReference
|
7
|
-
module Not; end
|
8
|
-
module Lit; end
|
9
|
-
end
|
10
|
-
|
11
|
-
def tag(x)
|
12
|
-
res = tag_sexpr(x, TaggingReference)
|
13
|
-
res.should eq(x)
|
14
|
-
res
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'tags a sexpr at first level' do
|
18
|
-
tag([:lit]).should be_a(TaggingReference::Lit)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'tags sexpr recursively' do
|
22
|
-
res = tag([:not, [:lit, true]])
|
23
|
-
res.should be_a(TaggingReference::Not)
|
24
|
-
res.last.should be_a(TaggingReference::Lit)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/spec/grammar.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
rule:
|
2
|
-
- non_terminal
|
3
|
-
- terminal
|
4
|
-
non_terminal:
|
5
|
-
- [ a_rule ]
|
6
|
-
- [ a_rule+ ]
|
7
|
-
- [ a_rule* ]
|
8
|
-
- [ "a_rule?" ]
|
9
|
-
- [ a_rule, a_rule, a_rule ]
|
10
|
-
a_rule:
|
11
|
-
- [ terminal, non_terminal ]
|
12
|
-
terminal:
|
13
|
-
- regexp_nt
|
14
|
-
- true_nt
|
15
|
-
- false_nt
|
16
|
-
- nil_nt
|
17
|
-
regexp_nt:
|
18
|
-
!ruby/regexp /^[a-z]+$/
|
19
|
-
true_nt:
|
20
|
-
true
|
21
|
-
false_nt:
|
22
|
-
false
|
23
|
-
nil_nt:
|
24
|
-
~
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr::Matcher
|
3
|
-
describe Rule, "eat" do
|
4
|
-
|
5
|
-
let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
|
6
|
-
let(:rule){ Rule.new :hello, defn }
|
7
|
-
|
8
|
-
it 'returns the trailing array when match' do
|
9
|
-
rule.eat([[:hello, "world"], "!"]).should eq(["!"])
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns nil when not match' do
|
13
|
-
rule.eat([:hello, "world"]).should be_nil
|
14
|
-
rule.eat([:hello]).should be_nil
|
15
|
-
rule.eat([]).should be_nil
|
16
|
-
rule.eat([[]]).should be_nil
|
17
|
-
rule.eat([nil]).should be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr::Matcher
|
3
|
-
describe Rule, 'match?' do
|
4
|
-
|
5
|
-
let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
|
6
|
-
let(:rule){ Rule.new :hello, defn }
|
7
|
-
|
8
|
-
it 'returns true on match' do
|
9
|
-
rule.should be_match([:hello, "hello"])
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns false on partial match' do
|
13
|
-
rule.should_not be_match([:hello, "hello", "world"])
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'returns false on no match' do
|
17
|
-
rule.should_not be_match(["hello"])
|
18
|
-
rule.should_not be_match([:hello, 12])
|
19
|
-
rule.should_not be_match([])
|
20
|
-
rule.should_not be_match(nil)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr::Matcher
|
3
|
-
describe Terminal, "terminal_match?" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
class Terminal; public :terminal_match?; end
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:terminal){ Terminal.new(arg) }
|
10
|
-
|
11
|
-
context "with a Regexp" do
|
12
|
-
let(:arg){ /^[a-z]+$/ }
|
13
|
-
|
14
|
-
it 'matches a matching string' do
|
15
|
-
terminal.terminal_match?("hello").should be_true
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'matches a non matching string' do
|
19
|
-
terminal.terminal_match?("12").should be_false
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'does not match a sexp' do
|
23
|
-
terminal.terminal_match?([:sexp, "Hello World"]).should be_false
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'does not match nil' do
|
27
|
-
terminal.terminal_match?(nil).should be_false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "with true" do
|
32
|
-
let(:arg){ true }
|
33
|
-
|
34
|
-
it 'matches true' do
|
35
|
-
terminal.terminal_match?(true).should be_true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'does not match false/nil' do
|
39
|
-
terminal.terminal_match?(false).should be_false
|
40
|
-
terminal.terminal_match?(nil).should be_false
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'does not match anything else' do
|
44
|
-
terminal.terminal_match?([]).should be_false
|
45
|
-
terminal.terminal_match?([:sexp]).should be_false
|
46
|
-
terminal.terminal_match?("true").should be_false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with false" do
|
51
|
-
let(:arg){ false }
|
52
|
-
|
53
|
-
it 'matches false' do
|
54
|
-
terminal.terminal_match?(false).should be_true
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'does not match true/nil' do
|
58
|
-
terminal.terminal_match?(true).should be_false
|
59
|
-
terminal.terminal_match?(nil).should be_false
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'does not match anything else' do
|
63
|
-
terminal.terminal_match?([]).should be_false
|
64
|
-
terminal.terminal_match?([:sexp]).should be_false
|
65
|
-
terminal.terminal_match?("false").should be_false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with nil" do
|
70
|
-
let(:arg){ nil }
|
71
|
-
|
72
|
-
it 'matches nil' do
|
73
|
-
terminal.terminal_match?(nil).should be_true
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'does not match true/false' do
|
77
|
-
terminal.terminal_match?(true).should be_false
|
78
|
-
terminal.terminal_match?(false).should be_false
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'does not match anything else' do
|
82
|
-
terminal.terminal_match?([]).should be_false
|
83
|
-
terminal.terminal_match?([:sexp]).should be_false
|
84
|
-
terminal.terminal_match?("nil").should be_false
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
data/spec/processor/test_call.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr
|
3
|
-
describe Processor, 'call' do
|
4
|
-
|
5
|
-
let(:procclass){
|
6
|
-
Class.new(Processor) do
|
7
|
-
|
8
|
-
def on_hello(sexpr)
|
9
|
-
[:seen_hello, sexpr]
|
10
|
-
end
|
11
|
-
|
12
|
-
def on_missing(sexpr)
|
13
|
-
if sexpr.first == :nosuchone
|
14
|
-
[:seen_missing, sexpr]
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
}
|
22
|
-
let(:proc){ procclass.new }
|
23
|
-
|
24
|
-
it 'dispatches to existing methods' do
|
25
|
-
ast = [:hello, "world"]
|
26
|
-
proc.call(ast).should eq([:seen_hello, [:hello, "world"]])
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'calls on_missing when not found' do
|
30
|
-
ast = [:nosuchone, "world"]
|
31
|
-
proc.call(ast).should eq([:seen_missing, [:nosuchone, "world"]])
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'raises unexpected by default in on_missing' do
|
35
|
-
ast = [:nonono, "world"]
|
36
|
-
lambda{ proc.call(ast) }.should raise_error(UnexpectedSexprError, /nonono/)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'raises an ArgumentError unless called on a sexpr' do
|
40
|
-
lambda{
|
41
|
-
proc.call("world").should raise_error(ArgumentError, /world/)
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Sexpr
|
3
|
-
describe Processor, "main_processor" do
|
4
|
-
|
5
|
-
let(:procclass){ Class.new(Processor) }
|
6
|
-
|
7
|
-
it 'defaults to self' do
|
8
|
-
proc = procclass.new
|
9
|
-
proc.main_processor.should eq(proc)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'may be specified through options' do
|
13
|
-
proc = procclass.new(:main_processor => :hello)
|
14
|
-
proc.main_processor.should eq(:hello)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
data/spec/test_sexpr.rb
DELETED
data/tasks/debug_mail.rake
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# Installs a rake task for debuging the announcement mail.
|
2
|
-
#
|
3
|
-
# This file installs the 'rake debug_mail' that flushes an announcement mail
|
4
|
-
# for your library on the standard output. It is automatically generated
|
5
|
-
# by Noe from your .noespec file, and should therefore be configured there,
|
6
|
-
# under the variables/rake_tasks/debug_mail entry, as illustrated below:
|
7
|
-
#
|
8
|
-
# variables:
|
9
|
-
# rake_tasks:
|
10
|
-
# debug_mail:
|
11
|
-
# rx_changelog_sections: /^#/
|
12
|
-
# nb_changelog_sections: 1
|
13
|
-
# ...
|
14
|
-
#
|
15
|
-
# If you have specific needs requiring manual intervention on this file,
|
16
|
-
# don't forget to set safe-override to false in your noe specification:
|
17
|
-
#
|
18
|
-
# template-info:
|
19
|
-
# manifest:
|
20
|
-
# tasks/debug_mail.rake:
|
21
|
-
# safe-override: false
|
22
|
-
#
|
23
|
-
# The mail template used can be found in debug_mail.txt. That file may be
|
24
|
-
# changed to tune the mail you want to send. If you do so, don't forget to
|
25
|
-
# add a manifest entry in your .noespec file to avoid overriding you
|
26
|
-
# changes. The mail template uses wlang, with parentheses for block
|
27
|
-
# delimiters.
|
28
|
-
#
|
29
|
-
# template-info:
|
30
|
-
# manifest:
|
31
|
-
# tasks/debug_mail.txt:
|
32
|
-
# safe-override: false
|
33
|
-
#
|
34
|
-
desc "Debug the release announcement mail"
|
35
|
-
task :debug_mail do
|
36
|
-
begin
|
37
|
-
require 'wlang'
|
38
|
-
rescue LoadError
|
39
|
-
abort "wlang is not available. Try 'gem install wlang'"
|
40
|
-
end
|
41
|
-
require 'yaml'
|
42
|
-
|
43
|
-
# Check that a .noespec file exists
|
44
|
-
noespec_file = File.expand_path('../../sexpr.noespec', __FILE__)
|
45
|
-
unless File.exists?(noespec_file)
|
46
|
-
raise "Unable to find .noespec project file, sorry."
|
47
|
-
end
|
48
|
-
|
49
|
-
# Load it as well as variables and options
|
50
|
-
noespec = YAML::load(File.read(noespec_file))
|
51
|
-
vars = noespec['variables'] || {}
|
52
|
-
|
53
|
-
# Changes are taken from CHANGELOG
|
54
|
-
logs = Dir[File.expand_path("../../CHANGELOG.*", __FILE__)]
|
55
|
-
unless logs.size == 1
|
56
|
-
abort "Unable to find a changelog file"
|
57
|
-
end
|
58
|
-
|
59
|
-
# Load interesting changesets
|
60
|
-
changes, end_found = [], 0
|
61
|
-
File.readlines(logs.first).select{|line|
|
62
|
-
if line =~ /^# /
|
63
|
-
break if end_found >= 1
|
64
|
-
end_found += 1
|
65
|
-
end
|
66
|
-
changes << line
|
67
|
-
}
|
68
|
-
vars['changes'] = changes.join
|
69
|
-
|
70
|
-
# WLang template
|
71
|
-
template = File.expand_path('../debug_mail.txt', __FILE__)
|
72
|
-
|
73
|
-
# Let's go!
|
74
|
-
$stdout << WLang::file_instantiate(template, vars, "wlang/active-text")
|
75
|
-
end
|
data/tasks/debug_mail.txt
DELETED
data/tasks/spec_test.rake
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Installs a rake task for for running examples written using rspec.
|
2
|
-
#
|
3
|
-
# This file installs the 'rake spec_test' (aliased as 'rake spec') as well as
|
4
|
-
# extends 'rake test' to run spec tests, if any. It is automatically generated
|
5
|
-
# by Noe from your .noespec file, and should therefore be configured there,
|
6
|
-
# under the variables/rake_tasks/spec_test entry, as illustrated below:
|
7
|
-
#
|
8
|
-
# variables:
|
9
|
-
# rake_tasks:
|
10
|
-
# spec_test:
|
11
|
-
# pattern: spec/**/*_spec.rb
|
12
|
-
# verbose: true
|
13
|
-
# rspec_opts: [--color, --backtrace]
|
14
|
-
# ...
|
15
|
-
#
|
16
|
-
# If you have specific needs requiring manual intervention on this file,
|
17
|
-
# don't forget to set safe-override to false in your noe specification:
|
18
|
-
#
|
19
|
-
# template-info:
|
20
|
-
# manifest:
|
21
|
-
# tasks/spec_test.rake:
|
22
|
-
# safe-override: false
|
23
|
-
#
|
24
|
-
# This file has been written to conform to RSpec v2.4.0. More information about
|
25
|
-
# rspec and options of the rake task defined below can be found on
|
26
|
-
# http://relishapp.com/rspec
|
27
|
-
#
|
28
|
-
begin
|
29
|
-
require "rspec/core/rake_task"
|
30
|
-
desc "Run RSpec code examples"
|
31
|
-
RSpec::Core::RakeTask.new(:spec_test) do |t|
|
32
|
-
# Glob pattern to match files.
|
33
|
-
t.pattern = "spec/**/test_*.rb"
|
34
|
-
|
35
|
-
# Whether or not to fail Rake when an error occurs (typically when
|
36
|
-
# examples fail).
|
37
|
-
t.fail_on_error = true
|
38
|
-
|
39
|
-
# A message to print to stderr when there are failures.
|
40
|
-
t.failure_message = nil
|
41
|
-
|
42
|
-
# Use verbose output. If this is set to true, the task will print the
|
43
|
-
# executed spec command to stdout.
|
44
|
-
t.verbose = true
|
45
|
-
|
46
|
-
# Use rcov for code coverage?
|
47
|
-
t.rcov = false
|
48
|
-
|
49
|
-
# Path to rcov.
|
50
|
-
t.rcov_path = "rcov"
|
51
|
-
|
52
|
-
# Command line options to pass to rcov. See 'rcov --help' about this
|
53
|
-
t.rcov_opts = []
|
54
|
-
|
55
|
-
# Command line options to pass to ruby. See 'ruby --help' about this
|
56
|
-
t.ruby_opts = []
|
57
|
-
|
58
|
-
# Path to rspec
|
59
|
-
t.rspec_path = "rspec"
|
60
|
-
|
61
|
-
# Command line options to pass to rspec. See 'rspec --help' about this
|
62
|
-
t.rspec_opts = ["--color", "--backtrace"]
|
63
|
-
end
|
64
|
-
rescue LoadError => ex
|
65
|
-
task :spec_test do
|
66
|
-
abort 'rspec is not available. In order to run spec, you must: gem install rspec'
|
67
|
-
end
|
68
|
-
ensure
|
69
|
-
task :spec => [:spec_test]
|
70
|
-
task :test => [:spec_test]
|
71
|
-
end
|