rtml 2.0.3 → 2.0.4
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.
- data/History.txt +3 -0
- data/Manifest.txt +51 -13
- data/Rakefile +6 -1
- data/builtin/controllers/rtml_controller.rb +12 -1
- data/builtin/models/rtml/document.rb +24 -18
- data/builtin/models/rtml/document_model_object.rb +6 -0
- data/builtin/models/rtml/dom/collections/element_set.rb +6 -0
- data/builtin/models/rtml/dom/collections/property_set.rb +11 -0
- data/builtin/models/rtml/dom/element.rb +79 -27
- data/builtin/models/rtml/dom/frontend_element.rb +41 -20
- data/builtin/models/rtml/dom/property.rb +43 -26
- data/builtin/models/rtml/dom/screen_element.rb +13 -0
- data/builtin/widgets/document_variable_processing.rb +42 -18
- data/builtin/widgets/element_builder.rb +4 -4
- data/builtin/widgets/screen_variable_processing.rb +2 -2
- data/builtin/widgets/screen_variants.rb +31 -4
- data/builtin/widgets/screens.rb +13 -1
- data/builtin/widgets/static_content.rb +20 -6
- data/do_profile.rb +15 -0
- data/lib/extensions/action_controller/response.rb +0 -18
- data/lib/extensions/action_controller/routing/route_set.rb +28 -18
- data/lib/extensions/hpricot/doc.rb +3 -3
- data/lib/extensions/hpricot/elem.rb +3 -3
- data/lib/extensions/string.rb +2 -18
- data/lib/rtml.rb +0 -12
- data/lib/rtml/assigns.rb +32 -0
- data/lib/rtml/controller/document_generator.rb +9 -0
- data/lib/rtml/controller/render_helpers.rb +42 -18
- data/lib/rtml/controller/state.rb +2 -1
- data/lib/rtml/dependencies.rb +20 -15
- data/lib/rtml/dsl.rb +10 -10
- data/lib/rtml/environment.rb +13 -1
- data/lib/rtml/errors/application_error.rb +5 -0
- data/lib/rtml/errors/simulation_error.rb +4 -0
- data/lib/rtml/errors/variable_error.rb +5 -0
- data/lib/rtml/high_level/variable_manager.rb +11 -7
- data/lib/rtml/inherited_instance_variables.rb +8 -1
- data/lib/rtml/links.rb +17 -0
- data/lib/rtml/rules/dom_validation.rb +1 -0
- data/lib/rtml/test/builtin_variables.rb +33 -0
- data/lib/rtml/test/resemblance_test.rb +97 -0
- data/lib/rtml/test/screen.rb +126 -0
- data/lib/rtml/test/simulator.rb +240 -0
- data/lib/rtml/test/simulator_post_processors/base.rb +7 -0
- data/lib/rtml/test/simulator_post_processors/card_parsers.rb +32 -0
- data/lib/rtml/test/simulator_post_processors/receipt.rb +15 -0
- data/lib/rtml/test/simulator_post_processors/submit.rb +15 -0
- data/lib/rtml/test/spec.rb +14 -7
- data/lib/rtml/test/spec/matchers.rb +24 -0
- data/lib/rtml/test/tml_application.rb +331 -0
- data/lib/rtml/test/unit.rb +13 -0
- data/lib/rtml/test/variable_scope.rb +146 -0
- data/lib/rtml/version.rb +1 -1
- data/lib/rtml/widget.rb +26 -14
- data/lib/rtml/widget_core/class_methods.rb +8 -4
- data/lib/rtml/widget_core/widget_accessor_instance_methods.rb +6 -6
- data/lib/rtml/widgets.rb +22 -3
- data/lib/rtml_routes.rb +1 -1
- data/rails_generators/rtml/rtml_generator.rb +3 -0
- data/rails_generators/rtml/templates/db/migrate/20100513165226_add_options_to_rtml_documents.rb +9 -0
- data/rails_generators/rtml/templates/db/migrate/20100513165242_remove_dom_elements_mirror.rb +16 -0
- data/rails_generators/rtml/templates/db/migrate/20100513165249_remove_dom_properties_mirror.rb +16 -0
- data/rails_generators/rtml/templates/lib/tasks/rtml.rake +1 -1
- data/rtml.gemspec +65 -0
- data/spec/controllers/rtml_controller_spec.rb +1 -1
- data/spec/integration/post_tests_spec.rb +8 -0
- data/spec/lib/rtml/high_level/variable_manager_spec.rb +8 -0
- data/spec/lib/rtml/routes_spec.rb +23 -22
- data/spec/lib/rtml/test/simulator/receipt_spec.rb +18 -0
- data/spec/lib/rtml/test/simulator_spec.rb +185 -0
- data/spec/lib/rtml/test/tml_application_spec.rb +119 -0
- data/spec/lib/rtml/test/variable_scope_spec.rb +65 -0
- data/spec/lib/rtml/widget_spec.rb +1 -0
- data/spec/lib/rtml/widgets_spec.rb +30 -0
- data/spec/models/rtml/document_spec.rb +8 -0
- data/spec/models/rtml/dom/screen_element_spec.rb +15 -0
- data/spec/models/rtml/instruction_spec.rb +2 -2
- data/spec/rtml_action_spec.rb +25 -0
- data/spec/spec_helper.rb +31 -1
- data/spec/support/app/controllers/post_tests_controller.rb +11 -0
- data/spec/support/app/views/inherited/instance_variables_test/display.rtml.erb +1 -0
- data/spec/support/config/boot.rb +1 -0
- data/spec/support/config/routes.rb +3 -2
- data/spec/support/db/rtml_test_db.sqlite3 +0 -0
- data/spec/support/raw_tml/avs.tml +27 -0
- data/spec/support/raw_tml/document_level_events.tml +18 -0
- data/spec/support/raw_tml/empty_screen.tml +15 -0
- data/spec/support/raw_tml/enter_amount.tml +40 -0
- data/spec/support/raw_tml/foreign_receiver.tml +10 -0
- data/spec/support/raw_tml/foreign_reference.tml +10 -0
- data/spec/support/raw_tml/hello_world.tml +13 -0
- data/spec/support/raw_tml/loop_x_times.tml +39 -0
- data/spec/support/raw_tml/one_screen_with_setvar.tml +8 -0
- data/spec/support/raw_tml/receipt.tml +15 -0
- data/spec/support/raw_tml/simulator.tml +122 -0
- data/spec/support/raw_tml/tmlvar_reference.tml +34 -0
- data/spec/support/raw_tml/user_input.tml +47 -0
- data/spec/support/raw_tml/valid_document.tml +6 -0
- data/spec/support/rspec/example_groups.rb +1 -1
- data/spec/support/rspec/matchers.rb +0 -11
- data/spec/widgets/document_variable_processing_spec.rb +25 -39
- data/spec/widgets/element_builder_spec.rb +4 -0
- data/spec/widgets/event_listener_spec.rb +9 -0
- data/spec/widgets/highlevel_variable_processing_spec.rb +27 -2
- data/spec/widgets/screen_variable_processing_spec.rb +34 -0
- data/spec/widgets/screens_spec.rb +22 -0
- data/spec/widgets/simulator_post_processors/card_parsers_spec.rb +70 -0
- data/spec/widgets/simulator_post_processors/submit_spec.rb +44 -0
- data/tasks/stats.rake +10 -0
- data/test/test_rtml_generator.rb +3 -0
- metadata +55 -49
- data/builtin/widgets/subroutine.rb +0 -54
- data/lib/rtml/high_level/subroutine.rb +0 -22
- data/lib/rtml/reverse_engineering/crawler.rb +0 -58
- data/lib/rtml/reverse_engineering/simulator.rb +0 -269
- data/lib/rtml/reverse_engineering/simulator/casting.rb +0 -9
- data/lib/rtml/reverse_engineering/simulator/snapshot.rb +0 -18
- data/lib/rtml/reverse_engineering/simulator/variable_lookup.rb +0 -32
- data/lib/rtml/reverse_engineering/simulator/variable_value.rb +0 -105
- data/spec/lib/rtml/reverse_engineering/crawler_spec.rb +0 -24
- data/spec/lib/rtml/reverse_engineering/simulator/variable_value_spec.rb +0 -120
- data/spec/lib/rtml/reverse_engineering/simulator_spec.rb +0 -96
- data/spec/support/config/tml_dom_ruleset.rb +0 -82
- data/spec/widgets/subroutine_spec.rb +0 -109
|
@@ -35,6 +35,28 @@ describe Rtml::Widgets::Screens do
|
|
|
35
35
|
@doc.screens.should have(2).items
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
it "should never build a screen tag without a body (TML has issues with it)" do
|
|
39
|
+
xml = Hpricot::XML(@doc.screen(:main).to_tml).root
|
|
40
|
+
(xml.children || []).reject { |i| !i.kind_of?(Hpricot::Elem) }.should_not be_empty
|
|
41
|
+
#.should match(/<screen\sid=['"]main['"]\s*>\s*<\/screen>/)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should never build an screen tag without a <next> element (TML issues)" do
|
|
45
|
+
xml = Hpricot::XML(@doc.screen(:main).to_tml).root
|
|
46
|
+
(xml.children || []).reject { |i| !i.kind_of?(Hpricot::Elem) }.should_not be_empty
|
|
47
|
+
# @doc.screen(:main, :another).to_tml.should match(/<screen\sid=['"]main['"]\s*>\s*<next/)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should be able to find a screen or return nil" do
|
|
51
|
+
# build a few screens
|
|
52
|
+
@doc.screen :init, :main, :timeout => 3
|
|
53
|
+
@doc.screen :main
|
|
54
|
+
|
|
55
|
+
@doc.screen?(:init).should_not be_nil
|
|
56
|
+
@doc.screen?(:main).should_not be_nil
|
|
57
|
+
@doc.screen?(:none).should be_nil
|
|
58
|
+
end
|
|
59
|
+
|
|
38
60
|
it "should allow subelements for screens" do
|
|
39
61
|
# build a few screens
|
|
40
62
|
@doc.screen :init, :main, :timeout => 3 do
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Rtml::Test::SimulatorPostProcessors::CardParsers do
|
|
4
|
+
def tml_for(parser, params)
|
|
5
|
+
<<-end_tml
|
|
6
|
+
<tml>
|
|
7
|
+
<screen id='setup' next='#first'>
|
|
8
|
+
#{setup_tml_for(parser)}
|
|
9
|
+
</screen>
|
|
10
|
+
|
|
11
|
+
<screen id='alt_first'>
|
|
12
|
+
<next uri='#second'>
|
|
13
|
+
<variant uri='#first' key='1' />
|
|
14
|
+
</next>
|
|
15
|
+
#{setup_tml_for(parser)}
|
|
16
|
+
</screen>
|
|
17
|
+
|
|
18
|
+
<screen id='first' next='#second'><tform><card parser='#{parser}' parser_params='#{params}' /></tform></screen>
|
|
19
|
+
<screen id='second'><display>done</display></screen>
|
|
20
|
+
</tml>
|
|
21
|
+
end_tml
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def setup_tml_for(parser)
|
|
25
|
+
case parser.to_s
|
|
26
|
+
when 'mag'
|
|
27
|
+
<<-end_tml
|
|
28
|
+
<tform>
|
|
29
|
+
<card parser="mag" parser_params="read_data" />
|
|
30
|
+
</tform>
|
|
31
|
+
end_tml
|
|
32
|
+
else raise 'no setup code for '+parser.to_s
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
subject do
|
|
37
|
+
Rtml::Test::Simulator.new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "with a 'mag' parser" do
|
|
41
|
+
context "and 'risk_mgmt' params" do
|
|
42
|
+
before(:each) do
|
|
43
|
+
subject.load_tml! tml_for("mag", "risk_mgmt")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should set 'card.parser.verdict' to 'online'" do
|
|
47
|
+
subject.swipe_card(:visa)
|
|
48
|
+
subject.variables['card.parser.verdict'].should == 'online'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should move to the next screen" do
|
|
52
|
+
subject.swipe_card(:visa)
|
|
53
|
+
subject.current_screen_id.should_not == "first"
|
|
54
|
+
subject.current_screen_id.should_not be_nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "given a next element with false variants" do
|
|
58
|
+
it "should follow the next uri" do
|
|
59
|
+
subject.visit("#alt_first")
|
|
60
|
+
subject.current_screen_id.should == "alt_first"
|
|
61
|
+
subject.swipe_card(:visa)
|
|
62
|
+
subject.current_screen_id.should_not == "first"
|
|
63
|
+
subject.current_screen_id.should_not be_nil
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "with an 'emv' reader"
|
|
70
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Rtml::Test::SimulatorPostProcessors::Submit do
|
|
4
|
+
def tml
|
|
5
|
+
<<-end_tml
|
|
6
|
+
<tml>
|
|
7
|
+
<screen id='setup'>
|
|
8
|
+
<setvar name="payment.amount" lo="100" />
|
|
9
|
+
</screen>
|
|
10
|
+
|
|
11
|
+
<screen id='do_submit'>
|
|
12
|
+
<submit tgt='test_location'>
|
|
13
|
+
<getvar name='payment.amount' />
|
|
14
|
+
</submit>
|
|
15
|
+
</screen>
|
|
16
|
+
</tml>
|
|
17
|
+
end_tml
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def mock_response
|
|
21
|
+
resp = Rack::Response.new
|
|
22
|
+
resp.body = "<tml><screen/></tml>"
|
|
23
|
+
resp
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
subject do
|
|
27
|
+
Rtml::Test::Simulator.new()
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
before(:each) do
|
|
31
|
+
subject.load_tml! tml
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should have payment amount assigned" do
|
|
35
|
+
subject.variables['payment.amount'].should == 100
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should dispatch a request" do
|
|
39
|
+
subject.should_receive(:response).at_least(1).and_return(mock_response)
|
|
40
|
+
subject.should_receive(:post).with("test_location", {'payment.amount' => 100}, {})
|
|
41
|
+
|
|
42
|
+
subject.visit "#do_submit"
|
|
43
|
+
end
|
|
44
|
+
end
|
data/tasks/stats.rake
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
desc "Code Statistics"
|
|
2
|
+
task :stats do
|
|
3
|
+
require 'code_statistics'
|
|
4
|
+
CodeStatistics.new(['RubyTML Libraries', './lib'],
|
|
5
|
+
['Built-in', './builtin'],
|
|
6
|
+
['App Generators', './app_generators'],
|
|
7
|
+
['Rails Generators', './rails_generators'],
|
|
8
|
+
['Unit tests', './spec']).to_s
|
|
9
|
+
CodeStatistics.new(['Entire Project', '.']).to_s
|
|
10
|
+
end
|
data/test/test_rtml_generator.rb
CHANGED
|
@@ -49,6 +49,9 @@ class TestRtmlGenerator < Test::Unit::TestCase
|
|
|
49
49
|
assert_generated_file "db/migrate/20100127173146_add_parent_type_to_rtml_dom_elements.rb"
|
|
50
50
|
assert_generated_file "db/migrate/20100208114234_create_rtml_states.rb"
|
|
51
51
|
assert_generated_file "db/migrate/20100303021609_add_x_and_y_to_rtml_instructions.rb"
|
|
52
|
+
assert_generated_file "db/migrate/20100513165226_add_options_to_rtml_documents.rb"
|
|
53
|
+
assert_generated_file "db/migrate/20100513165242_remove_dom_elements_mirror.rb"
|
|
54
|
+
assert_generated_file "db/migrate/20100513165249_remove_dom_properties_mirror.rb"
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
private
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 2
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 2.0.
|
|
8
|
+
- 4
|
|
9
|
+
version: 2.0.4
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Colin MacKenzie IV
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-07-07 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -129,39 +129,7 @@ dependencies:
|
|
|
129
129
|
version: 2.5.0
|
|
130
130
|
type: :development
|
|
131
131
|
version_requirements: *id008
|
|
132
|
-
description:
|
|
133
|
-
RubyTML (or just RTML) is a Ruby framework for communicating with Ingenico's Incendo-based payment devices.
|
|
134
|
-
|
|
135
|
-
To really understand what RTML is about, you first have to understand what TML is. TML is an XML-like language called
|
|
136
|
-
the "Terminal Markup Language" (yeah, we're really creative with our naming conventions around here). Essentially, it
|
|
137
|
-
allows developers to write terminal applications using a syntax that is essentially XML. This is a step forward for
|
|
138
|
-
terminal developers, who are used to writing their applications in embedded C.
|
|
139
|
-
|
|
140
|
-
The Incendo architecture that runs all of this provides a gateway between an application server, which houses the TML,
|
|
141
|
-
and the terminal. The TML is translated to byte code and then sent to the terminal via SSL. The terminal then executes
|
|
142
|
-
this byte code, and only reconnects when it's ready to download a new TML application. This is another step forward
|
|
143
|
-
from embedded C, because there's no longer any need to manually compile and then download applications to the terminal.
|
|
144
|
-
|
|
145
|
-
However, at the end of the day it's still TML, and someone has to write that TML code. That's where I come in. I was
|
|
146
|
-
brought into Ingenico to write this TML, and I found the task nothing less than daunting. I came from a Java
|
|
147
|
-
background, so of course the first thing I did was start looking at ways to write Java and have it generate TML.
|
|
148
|
-
Unfortunately, that was like drilling a hole with a sledgehammer, and it didn't work out too well. I quickly realized
|
|
149
|
-
that I was going to spend more time writing the supporting Java code than I would on the TML itself, and given fairly
|
|
150
|
-
ambitious deadlines, that just wasn't going to be an option.
|
|
151
|
-
|
|
152
|
-
So I turned to Ruby. I'd been experimenting with Ruby on Rails over the past month or two, and was amazed at how
|
|
153
|
-
brain-dead-simple it made standard Web development. I began to think -- what is a TML application except for a bunch of
|
|
154
|
-
glorified Web services? What if Rails could do to TML and XML what it has already done to HTML?
|
|
155
|
-
|
|
156
|
-
The biggest difference between HTML and TML is that the former is purely (or, in a Web 2.0 world, _almost_ purely) View
|
|
157
|
-
oriented. That is, HTML is designed for marking up and displaying content, not for transforming it. TML is a bit of a
|
|
158
|
-
misnomer in that respect, because it is very much about the transforming of data. It takes care of receiving and
|
|
159
|
-
processing the swipe of magnetic cards, amounts, and so on. In fact, the only thing it doesn't really handle is
|
|
160
|
-
actually processing a payment, which is a job left for the remote server.
|
|
161
|
-
|
|
162
|
-
So the short answer to just what _is_ RTML? It's a giant DSL (Domain Specific Language), basically, designed for
|
|
163
|
-
generating TML with a vast reduction in keystrokes and lines-of-code. Check out the RTML web site at www.rubytml.com
|
|
164
|
-
for more information -- from tutorials to my RTML blog.
|
|
132
|
+
description: RubyTML (or just RTML) is a Ruby framework for communicating with Ingenico's Incendo-based payment devices.
|
|
165
133
|
email:
|
|
166
134
|
- colin.mackenzie4@ingenico.com
|
|
167
135
|
executables:
|
|
@@ -184,6 +152,9 @@ files:
|
|
|
184
152
|
- bin/rtml
|
|
185
153
|
- builtin/controllers/rtml_controller.rb
|
|
186
154
|
- builtin/models/rtml/document.rb
|
|
155
|
+
- builtin/models/rtml/document_model_object.rb
|
|
156
|
+
- builtin/models/rtml/dom/collections/element_set.rb
|
|
157
|
+
- builtin/models/rtml/dom/collections/property_set.rb
|
|
187
158
|
- builtin/models/rtml/dom/element.rb
|
|
188
159
|
- builtin/models/rtml/dom/frontend_element.rb
|
|
189
160
|
- builtin/models/rtml/dom/property.rb
|
|
@@ -208,7 +179,7 @@ files:
|
|
|
208
179
|
- builtin/widgets/screens.rb
|
|
209
180
|
- builtin/widgets/shorthand.rb
|
|
210
181
|
- builtin/widgets/static_content.rb
|
|
211
|
-
-
|
|
182
|
+
- do_profile.rb
|
|
212
183
|
- generators/rtml_widget/USAGE
|
|
213
184
|
- generators/rtml_widget/rtml_widget_generator.rb
|
|
214
185
|
- generators/rtml_widget/templates/default_widget.erb
|
|
@@ -222,6 +193,7 @@ files:
|
|
|
222
193
|
- lib/extensions/hpricot/elem.rb
|
|
223
194
|
- lib/extensions/string.rb
|
|
224
195
|
- lib/rtml.rb
|
|
196
|
+
- lib/rtml/assigns.rb
|
|
225
197
|
- lib/rtml/configuration.rb
|
|
226
198
|
- lib/rtml/controller/before_filters.rb
|
|
227
199
|
- lib/rtml/controller/cache_helpers.rb
|
|
@@ -235,6 +207,7 @@ files:
|
|
|
235
207
|
- lib/rtml/dependencies.rb
|
|
236
208
|
- lib/rtml/dsl.rb
|
|
237
209
|
- lib/rtml/environment.rb
|
|
210
|
+
- lib/rtml/errors/application_error.rb
|
|
238
211
|
- lib/rtml/errors/invalid_format.rb
|
|
239
212
|
- lib/rtml/errors/invalid_operation.rb
|
|
240
213
|
- lib/rtml/errors/invalid_option_error.rb
|
|
@@ -245,25 +218,33 @@ files:
|
|
|
245
218
|
- lib/rtml/errors/rules_violation_error.rb
|
|
246
219
|
- lib/rtml/errors/screen_not_found.rb
|
|
247
220
|
- lib/rtml/errors/screen_variant_error.rb
|
|
221
|
+
- lib/rtml/errors/simulation_error.rb
|
|
248
222
|
- lib/rtml/errors/sti_type_error.rb
|
|
249
223
|
- lib/rtml/errors/subprocessing_not_supported.rb
|
|
250
224
|
- lib/rtml/errors/unknown_rtml_action.rb
|
|
225
|
+
- lib/rtml/errors/variable_error.rb
|
|
251
226
|
- lib/rtml/high_level/managed_variable.rb
|
|
252
|
-
- lib/rtml/high_level/subroutine.rb
|
|
253
227
|
- lib/rtml/high_level/variable_manager.rb
|
|
254
228
|
- lib/rtml/inherited_instance_variables.rb
|
|
255
229
|
- lib/rtml/init.rb
|
|
256
|
-
- lib/rtml/
|
|
257
|
-
- lib/rtml/reverse_engineering/simulator.rb
|
|
258
|
-
- lib/rtml/reverse_engineering/simulator/casting.rb
|
|
259
|
-
- lib/rtml/reverse_engineering/simulator/snapshot.rb
|
|
260
|
-
- lib/rtml/reverse_engineering/simulator/variable_lookup.rb
|
|
261
|
-
- lib/rtml/reverse_engineering/simulator/variable_value.rb
|
|
230
|
+
- lib/rtml/links.rb
|
|
262
231
|
- lib/rtml/rules/dom_ruleset.rb
|
|
263
232
|
- lib/rtml/rules/dom_tag.rb
|
|
264
233
|
- lib/rtml/rules/dom_validation.rb
|
|
265
234
|
- lib/rtml/rules/tml_param_parser.rb
|
|
235
|
+
- lib/rtml/test/builtin_variables.rb
|
|
236
|
+
- lib/rtml/test/resemblance_test.rb
|
|
237
|
+
- lib/rtml/test/screen.rb
|
|
238
|
+
- lib/rtml/test/simulator.rb
|
|
239
|
+
- lib/rtml/test/simulator_post_processors/base.rb
|
|
240
|
+
- lib/rtml/test/simulator_post_processors/card_parsers.rb
|
|
241
|
+
- lib/rtml/test/simulator_post_processors/receipt.rb
|
|
242
|
+
- lib/rtml/test/simulator_post_processors/submit.rb
|
|
266
243
|
- lib/rtml/test/spec.rb
|
|
244
|
+
- lib/rtml/test/spec/matchers.rb
|
|
245
|
+
- lib/rtml/test/tml_application.rb
|
|
246
|
+
- lib/rtml/test/unit.rb
|
|
247
|
+
- lib/rtml/test/variable_scope.rb
|
|
267
248
|
- lib/rtml/tmlized_conditions.rb
|
|
268
249
|
- lib/rtml/version.rb
|
|
269
250
|
- lib/rtml/widget.rb
|
|
@@ -288,6 +269,9 @@ files:
|
|
|
288
269
|
- rails_generators/rtml/templates/db/migrate/20100127173146_add_parent_type_to_rtml_dom_elements.rb
|
|
289
270
|
- rails_generators/rtml/templates/db/migrate/20100208114234_create_rtml_states.rb
|
|
290
271
|
- rails_generators/rtml/templates/db/migrate/20100303021609_add_x_and_y_to_rtml_instructions.rb
|
|
272
|
+
- rails_generators/rtml/templates/db/migrate/20100513165226_add_options_to_rtml_documents.rb
|
|
273
|
+
- rails_generators/rtml/templates/db/migrate/20100513165242_remove_dom_elements_mirror.rb
|
|
274
|
+
- rails_generators/rtml/templates/db/migrate/20100513165249_remove_dom_properties_mirror.rb
|
|
291
275
|
- rails_generators/rtml/templates/doc/io_tml-application-development-guidelines.pdf
|
|
292
276
|
- rails_generators/rtml/templates/lib/tasks/rtml.rake
|
|
293
277
|
- rails_generators/rtml_action/USAGE
|
|
@@ -300,22 +284,26 @@ files:
|
|
|
300
284
|
- rails_generators/widget/templates/default_widget_spec.erb
|
|
301
285
|
- rails_generators/widget/templates/default_widget_test.erb
|
|
302
286
|
- rails_generators/widget/widget_generator.rb
|
|
287
|
+
- rtml.gemspec
|
|
303
288
|
- script/console
|
|
304
289
|
- script/destroy
|
|
305
290
|
- script/generate
|
|
306
291
|
- script/server
|
|
307
292
|
- spec/controllers/inherited_controller_spec.rb
|
|
308
293
|
- spec/controllers/rtml_controller_spec.rb
|
|
294
|
+
- spec/integration/post_tests_spec.rb
|
|
309
295
|
- spec/lib/extensions/hpricot/doc_spec.rb
|
|
310
296
|
- spec/lib/extensions/hpricot/elem_spec.rb
|
|
311
297
|
- spec/lib/extensions/string_spec.rb
|
|
312
298
|
- spec/lib/rtml/extensions_spec.rb
|
|
313
|
-
- spec/lib/rtml/
|
|
314
|
-
- spec/lib/rtml/reverse_engineering/simulator/variable_value_spec.rb
|
|
315
|
-
- spec/lib/rtml/reverse_engineering/simulator_spec.rb
|
|
299
|
+
- spec/lib/rtml/high_level/variable_manager_spec.rb
|
|
316
300
|
- spec/lib/rtml/routes_spec.rb
|
|
317
301
|
- spec/lib/rtml/rules/dom_ruleset_spec.rb
|
|
318
302
|
- spec/lib/rtml/rules/dom_validation_spec.rb
|
|
303
|
+
- spec/lib/rtml/test/simulator/receipt_spec.rb
|
|
304
|
+
- spec/lib/rtml/test/simulator_spec.rb
|
|
305
|
+
- spec/lib/rtml/test/tml_application_spec.rb
|
|
306
|
+
- spec/lib/rtml/test/variable_scope_spec.rb
|
|
319
307
|
- spec/lib/rtml/widget_core/generic_widget_consumer_spec.rb
|
|
320
308
|
- spec/lib/rtml/widget_core/gui_configuration_spec.rb
|
|
321
309
|
- spec/lib/rtml/widget_core/widget_proxy_spec.rb
|
|
@@ -330,29 +318,45 @@ files:
|
|
|
330
318
|
- spec/models/rtml/state/variable_mapping_spec.rb
|
|
331
319
|
- spec/models/rtml/state_spec.rb
|
|
332
320
|
- spec/rcov.opts
|
|
321
|
+
- spec/rtml_action_spec.rb
|
|
333
322
|
- spec/spec.opts
|
|
334
323
|
- spec/spec_helper.rb
|
|
335
324
|
- spec/support/app/controllers/application_controller.rb
|
|
336
325
|
- spec/support/app/controllers/inherited_controller.rb
|
|
326
|
+
- spec/support/app/controllers/post_tests_controller.rb
|
|
337
327
|
- spec/support/app/rtml_helpers/inherited/index.rb
|
|
338
328
|
- spec/support/app/rtml_helpers/rtml/index.rb
|
|
339
329
|
- spec/support/app/views/README.txt
|
|
330
|
+
- spec/support/app/views/inherited/instance_variables_test/display.rtml.erb
|
|
340
331
|
- spec/support/app/views/layouts/layout.rtml.erb
|
|
341
332
|
- spec/support/app/views/magcard/_partial.erb
|
|
342
333
|
- spec/support/app/views/magcard/main.rtml.erb
|
|
343
334
|
- spec/support/app/views/rtml/index.html.erb
|
|
344
335
|
- spec/support/app/views/rtml/index/main.rtml.erb
|
|
336
|
+
- spec/support/config/boot.rb
|
|
345
337
|
- spec/support/config/database.yml
|
|
346
338
|
- spec/support/config/environment.rb
|
|
347
339
|
- spec/support/config/environments/development.rb
|
|
348
340
|
- spec/support/config/initializers/rtml.rb
|
|
349
341
|
- spec/support/config/routes.rb
|
|
350
|
-
- spec/support/config/tml_dom_ruleset.rb
|
|
351
342
|
- spec/support/db/rtml_test_db.sqlite3
|
|
352
343
|
- spec/support/db/schema.rb
|
|
353
344
|
- spec/support/lib/rtml/widgets/test_widget1.rb
|
|
354
345
|
- spec/support/lib/rtml/widgets/test_widget2.rb
|
|
355
346
|
- spec/support/rails.rb
|
|
347
|
+
- spec/support/raw_tml/avs.tml
|
|
348
|
+
- spec/support/raw_tml/document_level_events.tml
|
|
349
|
+
- spec/support/raw_tml/empty_screen.tml
|
|
350
|
+
- spec/support/raw_tml/enter_amount.tml
|
|
351
|
+
- spec/support/raw_tml/foreign_receiver.tml
|
|
352
|
+
- spec/support/raw_tml/foreign_reference.tml
|
|
353
|
+
- spec/support/raw_tml/hello_world.tml
|
|
354
|
+
- spec/support/raw_tml/loop_x_times.tml
|
|
355
|
+
- spec/support/raw_tml/one_screen_with_setvar.tml
|
|
356
|
+
- spec/support/raw_tml/receipt.tml
|
|
357
|
+
- spec/support/raw_tml/simulator.tml
|
|
358
|
+
- spec/support/raw_tml/tmlvar_reference.tml
|
|
359
|
+
- spec/support/raw_tml/user_input.tml
|
|
356
360
|
- spec/support/raw_tml/valid_document.tml
|
|
357
361
|
- spec/support/rspec/example_groups.rb
|
|
358
362
|
- spec/support/rspec/matchers.rb
|
|
@@ -367,11 +371,13 @@ files:
|
|
|
367
371
|
- spec/widgets/screen_variable_processing_spec.rb
|
|
368
372
|
- spec/widgets/screen_variants_spec.rb
|
|
369
373
|
- spec/widgets/screens_spec.rb
|
|
374
|
+
- spec/widgets/simulator_post_processors/card_parsers_spec.rb
|
|
375
|
+
- spec/widgets/simulator_post_processors/submit_spec.rb
|
|
370
376
|
- spec/widgets/static_content_spec.rb
|
|
371
|
-
- spec/widgets/subroutine_spec.rb
|
|
372
377
|
- tasks/db.rake
|
|
373
378
|
- tasks/rspec.rake
|
|
374
379
|
- tasks/rtml.rake
|
|
380
|
+
- tasks/stats.rake
|
|
375
381
|
- test/test_generator_helper.rb
|
|
376
382
|
- test/test_helper.rb
|
|
377
383
|
- test/test_rtml_action_generator.rb
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Subroutines allow you to build reusable blocks of TML code that return some result back to
|
|
2
|
-
# your main TML source.
|
|
3
|
-
#
|
|
4
|
-
# If you are able to make use of Subroutines to fill a role that Widgets don't already fill,
|
|
5
|
-
# let me know so that I have a reason to keep this code around, because I'm considering removing
|
|
6
|
-
# this from RTML.
|
|
7
|
-
#
|
|
8
|
-
class Rtml::Widgets::Subroutine < Rtml::Widget
|
|
9
|
-
affects :document, :element
|
|
10
|
-
entry_point :subroutine, :call, :subroutine?
|
|
11
|
-
disable_subprocessing!
|
|
12
|
-
shared :subroutines => HashWithIndifferentAccess
|
|
13
|
-
|
|
14
|
-
def subroutine(name, options = { }, &block)
|
|
15
|
-
#return document.subroutine(name, options, &block) if document != parent
|
|
16
|
-
|
|
17
|
-
subroutines[name] = Rtml::HighLevel::Subroutine.new(name, parent, options, &block)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def subroutine?(name)
|
|
21
|
-
name = name.to_s if name.kind_of?(Symbol)
|
|
22
|
-
return true if subroutines.key?(name)
|
|
23
|
-
return true if parent != document && parent.parent.subroutine?(name)
|
|
24
|
-
false
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def call(name, arguments = {})
|
|
28
|
-
raise Rtml::Errors::ProcessingError, "Can only call a subroutine from within a screen" unless parent.name == 'screen'
|
|
29
|
-
#return document.call(name, arguments) if document != parent
|
|
30
|
-
name = name.to_s if name.kind_of?(Symbol)
|
|
31
|
-
doc = document
|
|
32
|
-
p = parent
|
|
33
|
-
document.string :rtml_sub_return_val
|
|
34
|
-
while p == doc || p.respond_to?(:parent)
|
|
35
|
-
#unless p.subroutines
|
|
36
|
-
# raise "No subroutines hash for #{p.inspect}"
|
|
37
|
-
#end
|
|
38
|
-
if p.subroutines && p.subroutines.key?(name)
|
|
39
|
-
return_value = p.subroutines[name].call(parent, arguments)
|
|
40
|
-
begin
|
|
41
|
-
parent.set :rtml_sub_return_val => return_value
|
|
42
|
-
rescue ArgumentError
|
|
43
|
-
parent.set :rtml_sub_return_val => ''
|
|
44
|
-
end
|
|
45
|
-
return parent.terminal_variables[:rtml_sub_return_val]
|
|
46
|
-
end
|
|
47
|
-
raise NoMethodError, "Subroutine does not exist: #{name}" if p == doc
|
|
48
|
-
raise Rtml::Errors::ProcessingError, "Parent of #{p.inspect} is nil" unless p.parent
|
|
49
|
-
p = p.parent
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
raise Rtml::Errors::ProcessingError, "Found a parent that is not a parent...? (this shouldn't happen)"
|
|
53
|
-
end
|
|
54
|
-
end
|