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
data/do_profile.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
if ENV["_"] =~ /ruby\-prof/
|
|
2
|
+
if ARGV.empty?
|
|
3
|
+
ARGV.concat Dir[File.join(File.dirname(__FILE__), 'spec/**/*_spec.rb')]
|
|
4
|
+
end
|
|
5
|
+
ARGV.each do |fi|
|
|
6
|
+
next unless File.file? fi
|
|
7
|
+
load fi
|
|
8
|
+
end
|
|
9
|
+
else
|
|
10
|
+
puts <<-end_banner
|
|
11
|
+
This script will use ruby-prof to run the specs.
|
|
12
|
+
|
|
13
|
+
Usage: ruby-prof do_profile.rb
|
|
14
|
+
end_banner
|
|
15
|
+
end
|
|
@@ -8,23 +8,5 @@ module ActionController
|
|
|
8
8
|
end
|
|
9
9
|
body.valid_tml?
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
# Verifies that the produced TML resembles the given structure. See +Rtml::Rules::DomValidation#validate_tml_dom+
|
|
13
|
-
# for more information.
|
|
14
|
-
def tml_should_resemble(structure)
|
|
15
|
-
body.validate_tml_structure(structure)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Verifies that the produced TML does NOT resemble the given structure.
|
|
19
|
-
# See +Rtml::Rules::DomValidation#validate_tml_dom+ for more information.
|
|
20
|
-
def tml_should_not_resemble(structure)
|
|
21
|
-
inspected = structure.inspect
|
|
22
|
-
begin
|
|
23
|
-
body.validate_tml_structure(structure)
|
|
24
|
-
rescue
|
|
25
|
-
return true
|
|
26
|
-
end
|
|
27
|
-
raise Rtml::Errors::ProcessingError, "TML was expected not to resemble #{inspected}, but it did!", caller
|
|
28
|
-
end
|
|
29
11
|
end
|
|
30
12
|
end
|
|
@@ -9,32 +9,42 @@ module ActionController
|
|
|
9
9
|
# options, the /index.tml path will be updated to reflect the new options.
|
|
10
10
|
#
|
|
11
11
|
# To use, just add the following to your /config/routes.rb file:
|
|
12
|
-
#
|
|
12
|
+
# map.connect_rtml :controller => "start_page"
|
|
13
|
+
#
|
|
14
|
+
# Note that you should do this for each RTML controller in your application. To prevent
|
|
15
|
+
# overriding the /index.tml page, pass :no_index => true:
|
|
16
|
+
# map.connect_rtml :controller => "another_page", :no_index => true
|
|
13
17
|
#
|
|
14
18
|
def connect_rtml(options = {})
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
make_rtml_connection('/:
|
|
19
|
+
no_index = options.delete(:no_index)
|
|
20
|
+
|
|
21
|
+
make_rtml_connection('/rtml/:action.:format', '/rtml/index.rtml', :controller => 'rtml')
|
|
22
|
+
make_rtml_connection('/rtml/:action.:id.:format', '/rtml/index.1.rtml', :controller => 'rtml')
|
|
23
|
+
#make_rtml_connection('/:controller/:action/:id', '/rtml/index/1')
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
segs = route.segments.to_s[0...-1]
|
|
22
|
-
if segs =~ /^\/index.tml(\/|)$/ && connect_options
|
|
23
|
-
route.requirements.merge! options.reverse_merge(:format => 'rtml')
|
|
24
|
-
connect_options = false
|
|
25
|
-
end
|
|
25
|
+
unless options.empty? || no_index
|
|
26
|
+
connect '/index.tml', options.reverse_merge(:format => 'rtml')
|
|
26
27
|
end
|
|
27
|
-
|
|
28
|
-
if
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
if options[:controller]
|
|
30
|
+
controller = options[:controller]
|
|
31
|
+
make_rtml_connection("/#{controller}/:action.:format", "/#{controller}/index.rtml", :controller => controller)
|
|
32
|
+
make_rtml_connection("/#{controller}/:action.:id.:format", "/#{controller}/index.1.rtml", :controller => controller)
|
|
30
33
|
end
|
|
31
34
|
end
|
|
32
35
|
|
|
33
36
|
private
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
def route_exists?(path)
|
|
38
|
+
path = "/#{path}" unless path[0] == ?/
|
|
39
|
+
ActionController::Routing::Routes.routes.each do |route|
|
|
40
|
+
segs = route.segments.to_s
|
|
41
|
+
return true if segs =~ /^#{Regexp::escape path}(\/|)$/
|
|
42
|
+
end
|
|
43
|
+
false
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def make_rtml_connection(connection, example, options = {})
|
|
47
|
+
connect connection, options unless route_exists?(example)
|
|
38
48
|
end
|
|
39
49
|
end
|
|
40
50
|
end
|
data/lib/extensions/string.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
class String
|
|
2
2
|
include Rtml::Rules::DomValidation
|
|
3
|
-
include Rtml::ReverseEngineering::Simulator::Casting
|
|
4
3
|
|
|
5
4
|
def to_controller
|
|
6
5
|
camel = self.camelize
|
|
@@ -14,22 +13,7 @@ class String
|
|
|
14
13
|
true
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Verifies that the produced TML does NOT resemble the given structure.
|
|
23
|
-
# See +Rtml::Rules::DomValidation#validate_tml_dom+ for more information.
|
|
24
|
-
def tml_should_not_resemble(structure)
|
|
25
|
-
inspected = structure.inspect
|
|
26
|
-
begin
|
|
27
|
-
validate_tml_dom(self, structure)
|
|
28
|
-
rescue
|
|
29
|
-
return true
|
|
30
|
-
end
|
|
31
|
-
raise Rtml::ProcessingError, "TML was expected not to resemble #{inspected}, but it did!", caller
|
|
16
|
+
def to_tml_simulator
|
|
17
|
+
Rtml::Test::Simulator.new(self)
|
|
32
18
|
end
|
|
33
|
-
|
|
34
|
-
alias tml_should_resemble validate_tml_structure
|
|
35
19
|
end
|
data/lib/rtml.rb
CHANGED
|
@@ -68,18 +68,6 @@ module Rtml
|
|
|
68
68
|
controller.rtml_actions.concat new_methods
|
|
69
69
|
|
|
70
70
|
new_methods.each do |method_name|
|
|
71
|
-
unless helpers.hidden_action?(method_name)
|
|
72
|
-
helpers.class_eval(<<-end_code, __FILE__, __LINE__+1)
|
|
73
|
-
def #{method_name}_with_ivars
|
|
74
|
-
copy_ivars_from(controller)
|
|
75
|
-
# Give rtml actions access to the controller's view helpers
|
|
76
|
-
(class << self; self; end).send(:include, controller.response.template.helpers)
|
|
77
|
-
#{method_name}_without_ivars
|
|
78
|
-
end
|
|
79
|
-
end_code
|
|
80
|
-
|
|
81
|
-
helpers.send(:alias_method_chain, method_name, :ivars)
|
|
82
|
-
end
|
|
83
71
|
unless helpers.hidden_action?(method_name) || controller.instance_methods.include?(method_name)
|
|
84
72
|
controller.add_rtml_proxy_action(method_name)
|
|
85
73
|
end
|
data/lib/rtml/assigns.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Included into most RTML classes
|
|
2
|
+
module Rtml::Assigns
|
|
3
|
+
# Returns all instance variables EXCEPT those returned by #protected_instance_variables or
|
|
4
|
+
# #rtml_protected_instance_variables. If one of those methods doesn't exist, it is ignored.
|
|
5
|
+
#
|
|
6
|
+
# The returned instance variables are mapped to a hash so that they are ready to be passed
|
|
7
|
+
# (for example) into ActionController#render as a value for the :assigns option.
|
|
8
|
+
#
|
|
9
|
+
# If this object responds to 'parent', then the return value is merged with parent#assigns.
|
|
10
|
+
#
|
|
11
|
+
# If the :without option is specified, the variables in that array are omitted.
|
|
12
|
+
def assigns(options = {})
|
|
13
|
+
ivars = assignment_names(options)
|
|
14
|
+
|
|
15
|
+
assigns = ivars.inject({}) { |hash, ivar| hash[ivar[1..-1]] = instance_variable_get(ivar); hash }
|
|
16
|
+
if respond_to?(:parent) && parent.respond_to?(:assigns)
|
|
17
|
+
parent.assigns(:without => (options[:without] || []) + ivars).merge(assigns)
|
|
18
|
+
else
|
|
19
|
+
assigns
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Returns the name of each variable that would be returned by #assigns. The options are
|
|
24
|
+
# the same.
|
|
25
|
+
def assignment_names(options = {})
|
|
26
|
+
ivars = instance_variables
|
|
27
|
+
ivars -= options[:without] if options[:without]
|
|
28
|
+
ivars -= protected_instance_variables if respond_to?(:protected_instance_variables)
|
|
29
|
+
ivars -= rtml_protected_instance_variables if respond_to?(:rtml_protected_instance_variables)
|
|
30
|
+
ivars
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -40,14 +40,23 @@ module Rtml::Controller::DocumentGenerator
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def method_missing(name, *args, &block)
|
|
43
|
+
rtml_document.copy_ivars_from(self)
|
|
43
44
|
rtml_document.send(name, *args, &block)
|
|
44
45
|
rescue
|
|
45
46
|
raise $!, $!.message, caller
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
def fire_action(action_name)
|
|
50
|
+
copy_ivars_from(controller)
|
|
51
|
+
# Give rtml actions access to the controller's view helpers
|
|
52
|
+
(class << self; self; end).send(:include, controller.response.template.helpers)
|
|
53
|
+
__send__(action_name)
|
|
54
|
+
end
|
|
55
|
+
|
|
48
56
|
def copy_ivars_from(source)
|
|
49
57
|
ivars = source.instance_variables
|
|
50
58
|
ivars -= source.protected_instance_variables if source.respond_to?(:protected_instance_variables)
|
|
59
|
+
ivars -= source.rtml_protected_instance_variables if source.respond_to?(:rtml_protected_instance_variables)
|
|
51
60
|
ivars.each { |ivar| instance_variable_set(ivar, source.instance_variable_get(ivar)) }
|
|
52
61
|
rtml_document.copy_ivars_from(self)
|
|
53
62
|
end
|
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
module Rtml::Controller::RenderHelpers
|
|
2
2
|
def render_with_rtml_option(options = nil, extra_options = {}, &block)
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
if rtml_action =
|
|
6
|
-
|
|
7
|
-
request.format = :rtml
|
|
8
|
-
rtml_helpers.send(rtml_action)
|
|
9
|
-
set_rtml_headers
|
|
10
|
-
response.template.template_format = :rtml
|
|
11
|
-
tml = rtml_document.to_tml
|
|
12
|
-
if Rtml.configuration.log_tml
|
|
13
|
-
Rails.logger.debug tml
|
|
14
|
-
end
|
|
15
|
-
return render_without_rtml_option(h.merge(:text => tml))
|
|
16
|
-
else
|
|
17
|
-
raise Rtml::Errors::UnknownRtmlAction,
|
|
18
|
-
"No RTML action responded to #{rtml_action}. RTML actions: #{rtml_actions.sort.to_sentence(:locale => :en)}",
|
|
19
|
-
caller
|
|
20
|
-
end
|
|
3
|
+
if (rtml_options = options).is_a?(Hash) || (rtml_options = extra_options).is_a?(Hash)
|
|
4
|
+
rtml_options = extra_options if !rtml_options.key?(:rtml) && extra_options.is_a?(Hash)
|
|
5
|
+
if rtml_action = rtml_options.delete(:rtml)
|
|
6
|
+
return attempt_rtml_action(rtml_action)
|
|
21
7
|
end
|
|
22
8
|
end
|
|
23
9
|
render_without_rtml_option(options, extra_options, &block)
|
|
24
10
|
end
|
|
25
11
|
|
|
12
|
+
def attempt_rtml_action(rtml_action, options = {})
|
|
13
|
+
if rtml_helpers.respond_to?(rtml_action)
|
|
14
|
+
tml = perform_rtml_action(rtml_action)
|
|
15
|
+
return render_without_rtml_option(options.merge(:text => tml))
|
|
16
|
+
else
|
|
17
|
+
raise Rtml::Errors::UnknownRtmlAction,
|
|
18
|
+
"No RTML action responded to #{rtml_action}. RTML actions: #{rtml_actions.sort.to_sentence(:locale => :en)}",
|
|
19
|
+
caller
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def perform_rtml_action(rtml_action)
|
|
24
|
+
request.format = :rtml
|
|
25
|
+
feigning_action(rtml_action) do
|
|
26
|
+
rtml_helpers.fire_action(rtml_action)
|
|
27
|
+
end
|
|
28
|
+
force_rtml_format
|
|
29
|
+
|
|
30
|
+
returning rtml_document.to_tml do |tml|
|
|
31
|
+
if Rtml.configuration.log_tml
|
|
32
|
+
Rails.logger.debug "(RTML: Response Headers: " + response.headers.inspect + ")"
|
|
33
|
+
Rails.logger.debug tml
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def feigning_action(name)
|
|
39
|
+
action_name, self.action_name = self.action_name, name
|
|
40
|
+
yield
|
|
41
|
+
self.action_name = action_name
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def force_rtml_format
|
|
45
|
+
set_rtml_headers
|
|
46
|
+
response.template.template_format = :rtml
|
|
47
|
+
end
|
|
48
|
+
|
|
26
49
|
def self.included(base)
|
|
27
50
|
base.send(:alias_method_chain, :render, :rtml_option)
|
|
51
|
+
base.send(:hide_action, :attempt_rtml_action, :perform_rtml_action, :feigning_action, :force_rtml_format)
|
|
28
52
|
end
|
|
29
53
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Rtml::Controller::State
|
|
2
2
|
def find_or_build_state
|
|
3
|
+
headers = request.headers
|
|
3
4
|
if params[:terminal] && params[:terminal][:itid]
|
|
4
5
|
itid = params[:terminal][:itid]
|
|
5
6
|
elsif request.terminal?
|
|
@@ -27,7 +28,7 @@ module Rtml::Controller::State
|
|
|
27
28
|
value = nil
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
|
-
state[state_attribute] = value
|
|
31
|
+
state[state_attribute] = value if value
|
|
31
32
|
end
|
|
32
33
|
end
|
|
33
34
|
|
data/lib/rtml/dependencies.rb
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
gem '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
if defined?(Rails)
|
|
2
|
+
Rails.configuration.gem 'hpricot', '>= 0.8.2'
|
|
3
|
+
Rails.configuration.gem 'sc-core-ext', '>= 1.1.1'
|
|
4
|
+
else
|
|
5
|
+
unless defined?(Gem) && defined?(ActiveSupport::Dependencies) && defined?(ActionController::Base)
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
gem 'hpricot', ">= 0.8.2"
|
|
8
|
+
gem 'sc-core-ext', ">= 1.1.1"
|
|
9
|
+
gem 'activesupport', '>= 2.3.5'
|
|
10
|
+
gem 'actionpack', '>= 2.3.5'
|
|
11
|
+
gem 'activerecord', '>= 2.3.5'
|
|
12
|
+
|
|
13
|
+
require 'active_support'
|
|
14
|
+
require 'action_controller'
|
|
15
|
+
require 'action_view'
|
|
16
|
+
require 'active_record'
|
|
17
|
+
require 'active_resource'
|
|
18
|
+
end
|
|
8
19
|
|
|
9
|
-
require '
|
|
10
|
-
require '
|
|
11
|
-
require 'action_view'
|
|
12
|
-
require 'active_record'
|
|
13
|
-
require 'active_resource'
|
|
20
|
+
require 'hpricot'
|
|
21
|
+
require 'sc-core-ext'
|
|
14
22
|
end
|
|
15
23
|
|
|
16
|
-
require 'hpricot'
|
|
17
|
-
require 'sc-core-ext'
|
|
18
|
-
|
|
19
24
|
path = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
|
20
25
|
%w(lib
|
|
21
26
|
builtin/controllers
|
data/lib/rtml/dsl.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Rtml::DSL
|
|
|
38
38
|
rescue NameError
|
|
39
39
|
Rtml::Dom::Element
|
|
40
40
|
end
|
|
41
|
-
if new_record? || changed?
|
|
41
|
+
#if new_record? || changed?
|
|
42
42
|
element = type.new(:name => name, :document => document)
|
|
43
43
|
if respond_to?(:elements)
|
|
44
44
|
elements << element
|
|
@@ -48,15 +48,15 @@ module Rtml::DSL
|
|
|
48
48
|
# element = elements.build(:name => name, :document => document, :type => type.to_s)
|
|
49
49
|
# element.document = document if element.respond_to?(:document)
|
|
50
50
|
element.parent = self if element.respond_to?(:parent)
|
|
51
|
-
else
|
|
52
|
-
element = type.create!(:name => name, :document => document)
|
|
53
|
-
if respond_to?(:elements)
|
|
54
|
-
elements << element
|
|
55
|
-
elsif respond_to?(:root)
|
|
56
|
-
self.root = element
|
|
57
|
-
end
|
|
58
|
-
#element = elements.create!(:name => name, :document => document, :type => type.to_s)
|
|
59
|
-
end
|
|
51
|
+
# else
|
|
52
|
+
# element = type.create!(:name => name, :document => document)
|
|
53
|
+
# if respond_to?(:elements)
|
|
54
|
+
# elements << element
|
|
55
|
+
# elsif respond_to?(:root)
|
|
56
|
+
# self.root = element
|
|
57
|
+
# end
|
|
58
|
+
# #element = elements.create!(:name => name, :document => document, :type => type.to_s)
|
|
59
|
+
# end
|
|
60
60
|
#element = type.new(:name => name, :document => document)
|
|
61
61
|
#self.elements << element if respond_to?(:elements)
|
|
62
62
|
# element = if respond_to?(:elements) && elements.respond_to?(:build)
|
data/lib/rtml/environment.rb
CHANGED
|
@@ -19,10 +19,22 @@ end
|
|
|
19
19
|
require File.join(path, 'builtin/rtml_helpers/rtml/get_state')
|
|
20
20
|
require File.join(path, 'builtin/rtml_helpers/rtml/rescue_action')
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if defined?(Rails)
|
|
23
|
+
Rails.configuration.after_initialize do
|
|
24
|
+
Dir[File.join(path, 'lib/extensions/**/*.rb')].each { |fi| require fi if File.file?(fi) }
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
Dir[File.join(path, 'lib/extensions/**/*.rb')].each { |fi| require fi if File.file?(fi) }
|
|
28
|
+
end
|
|
23
29
|
|
|
24
30
|
# Add RTML routes
|
|
25
31
|
routes_file = File.join(Rtml.root, 'lib/rtml_routes.rb')
|
|
26
32
|
unless ActionController::Routing::Routes.configuration_files.include? routes_file
|
|
27
33
|
ActionController::Routing::Routes.configuration_files << routes_file
|
|
28
34
|
end
|
|
35
|
+
|
|
36
|
+
Mime::TML = Mime::Type.lookup("text/tml")
|
|
37
|
+
require File.join(path, "lib/rtml/rules/tml_param_parser")
|
|
38
|
+
ActionController::Base.param_parsers[Mime::TML] = proc { |data|
|
|
39
|
+
Rtml::Rules::TmlParamParser.new(data).params
|
|
40
|
+
}
|
|
@@ -3,14 +3,18 @@ class Rtml::HighLevel::VariableManager
|
|
|
3
3
|
|
|
4
4
|
def initialize()
|
|
5
5
|
@vars = HashWithIndifferentAccess.new
|
|
6
|
+
Rtml::Test::BuiltinVariables::BUILTIN_VARIABLES.each do |name, options|
|
|
7
|
+
@vars[name] = Rtml::HighLevel::ManagedVariable.new(name)
|
|
8
|
+
end
|
|
6
9
|
end
|
|
7
10
|
|
|
8
11
|
def [](variable_name)
|
|
9
|
-
variable_name = variable_name.to_s
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
variable_name = variable_name.to_s unless variable_name.kind_of?(String)
|
|
13
|
+
if !@vars.key?(variable_name)
|
|
14
|
+
vardec = screen.document.variable_names.include?(variable_name)
|
|
15
|
+
raise Rtml::Errors::MissingVariableError, "Could not find a TML variable named #{variable_name.inspect}. "+
|
|
16
|
+
"Did you forget to declare it?" unless vardec
|
|
17
|
+
end
|
|
14
18
|
@vars[variable_name] ||= Rtml::HighLevel::ManagedVariable.new(variable_name)
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -25,9 +29,9 @@ class Rtml::HighLevel::VariableManager
|
|
|
25
29
|
|
|
26
30
|
def method_missing(name, *args, &block)
|
|
27
31
|
if args.empty? && !block_given?
|
|
28
|
-
self.send(
|
|
32
|
+
self.send(:[], name)
|
|
29
33
|
elsif name.to_s[-1] == ?= && args.length == 1 && !block_given?
|
|
30
|
-
self.send(
|
|
34
|
+
self.send(:[]=, name.to_s[0...-1], *args)
|
|
31
35
|
else
|
|
32
36
|
super
|
|
33
37
|
end
|