ruboss4ruby 1.0.2 → 1.0.3

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.
Files changed (99) hide show
  1. data/Generators +5 -0
  2. data/Manifest.txt +39 -41
  3. data/Rakefile +2 -1
  4. data/lib/ruboss4ruby.rb +16 -12
  5. data/lib/ruboss4ruby/active_foo.rb +39 -3
  6. data/lib/ruboss4ruby/recipes.rb +62 -0
  7. data/lib/ruboss4ruby/ruboss_helper.rb +54 -0
  8. data/lib/ruboss4ruby/ruboss_test_helpers.rb +31 -0
  9. data/lib/ruboss4ruby/tasks.rb +0 -2
  10. data/lib/ruboss4ruby/version.rb +2 -2
  11. data/merb_generators/ruboss_config.rb +19 -19
  12. data/merb_generators/ruboss_controller.rb +3 -3
  13. data/merb_generators/ruboss_flex_app.rb +3 -3
  14. data/merb_generators/ruboss_resource_controller.rb +3 -3
  15. data/merb_generators/ruboss_scaffold.rb +47 -47
  16. data/rails_generators/ruboss_config/ruboss_config_generator.rb +2 -2
  17. data/rails_generators/ruboss_config/templates/index.html.erb +2 -2
  18. data/rails_generators/ruboss_config/templates/mainapp-config.xml +21 -0
  19. data/rails_generators/ruboss_config/templates/mainapp.mxml +4 -7
  20. data/rails_generators/ruboss_config/templates/project-textmate.erb +52 -0
  21. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +0 -2
  22. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -2
  23. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +4 -3
  24. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -1
  25. data/test/controllers/application.rb +15 -0
  26. data/test/controllers/locations_controller.rb +93 -0
  27. data/test/controllers/notes_controller.rb +96 -0
  28. data/test/controllers/projects_controller.rb +93 -0
  29. data/test/controllers/tasks_controller.rb +93 -0
  30. data/test/controllers/users_controller.rb +93 -0
  31. data/test/database.yml +4 -0
  32. data/test/fixtures/locations.yml +8 -0
  33. data/test/fixtures/notes.yml +17 -0
  34. data/test/fixtures/projects.yml +25 -0
  35. data/test/fixtures/tasks.yml +46 -0
  36. data/test/fixtures/users.yml +13 -0
  37. data/test/helpers/controllers.log +8 -0
  38. data/test/helpers/functional_test_helper.rb +32 -0
  39. data/test/helpers/models.log +170 -0
  40. data/test/helpers/test_helper.rb +25 -0
  41. data/test/helpers/unit_test_helper.rb +23 -0
  42. data/test/model.yml +35 -0
  43. data/test/models/location.rb +4 -0
  44. data/test/models/note.rb +3 -0
  45. data/test/models/project.rb +6 -0
  46. data/test/models/task.rb +20 -0
  47. data/test/models/user.rb +23 -0
  48. data/test/playing_around_in_a_console.txt +71 -0
  49. data/test/schema.rb +63 -0
  50. data/test/test.sqlite3 +0 -0
  51. data/test/test.swf +1 -0
  52. data/test/test_active_foo.rb +79 -0
  53. data/test/test_ruboss_rails_integration_functional.rb +27 -0
  54. data/test/test_swfobject_helper.rb +63 -0
  55. data/test/to_fxml_test.rb +79 -0
  56. data/test/views/notes/empty_params_action.html.erb +1 -0
  57. data/test/views/notes/index.html.erb +1 -0
  58. metadata +57 -52
  59. data/merb_generators/ruboss_config/USAGE +0 -18
  60. data/merb_generators/ruboss_config/ruboss_config_generator.rb +0 -135
  61. data/merb_generators/ruboss_config/templates/actionscript.properties +0 -16
  62. data/merb_generators/ruboss_config/templates/actionscriptair.properties +0 -16
  63. data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
  64. data/merb_generators/ruboss_config/templates/flex.properties +0 -2
  65. data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +0 -276
  66. data/merb_generators/ruboss_config/templates/html-template/history/history.css +0 -6
  67. data/merb_generators/ruboss_config/templates/html-template/history/history.js +0 -645
  68. data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +0 -29
  69. data/merb_generators/ruboss_config/templates/html-template/index.template.html +0 -121
  70. data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  71. data/merb_generators/ruboss_config/templates/index.html.erb +0 -18
  72. data/merb_generators/ruboss_config/templates/mainair-app.xml +0 -134
  73. data/merb_generators/ruboss_config/templates/mainapp.mxml +0 -34
  74. data/merb_generators/ruboss_config/templates/project.properties +0 -18
  75. data/merb_generators/ruboss_config/templates/projectair.properties +0 -24
  76. data/merb_generators/ruboss_config/templates/swfobject.js +0 -5
  77. data/merb_generators/ruboss_controller/USAGE +0 -11
  78. data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +0 -32
  79. data/merb_generators/ruboss_resource_controller/USAGE +0 -5
  80. data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +0 -70
  81. data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -55
  82. data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
  83. data/merb_generators/ruboss_scaffold/USAGE +0 -5
  84. data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -127
  85. data/merb_generators/ruboss_yaml_scaffold/USAGE +0 -5
  86. data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -53
  87. data/merb_generators/templates/ruboss_scaffold/component.mxml.erb +0 -148
  88. data/merb_generators/templates/ruboss_scaffold/fixtures.yml.erb +0 -35
  89. data/merb_generators/templates/ruboss_scaffold/migration.rb.erb +0 -19
  90. data/merb_generators/templates/ruboss_scaffold/model.as.erb +0 -42
  91. data/merb_generators/templates/ruboss_scaffold/model.rb.erb +0 -11
  92. data/test/active_foo_test.rb +0 -16
  93. data/test/test_generator_helper.rb +0 -29
  94. data/test/test_helper.rb +0 -2
  95. data/test/test_ruboss_config_generator.rb +0 -45
  96. data/test/test_ruboss_controller_generator.rb +0 -45
  97. data/test/test_ruboss_on_ruby.rb +0 -11
  98. data/test/test_ruboss_scaffold_generator.rb +0 -45
  99. data/test/test_ruboss_yaml_scaffold_generator.rb +0 -46
data/Generators ADDED
@@ -0,0 +1,5 @@
1
+ scope 'merb-gen' do
2
+ dir = File.join(File.dirname(__FILE__), 'merb_generators/')
3
+ Merb.add_generators dir + 'ruboss_config', dir + 'ruboss_flex_app', dir + 'ruboss_controller', dir + 'ruboss_scaffold',
4
+ dir + 'ruboss_resource_controller'
5
+ end
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ Generators
1
2
  History.txt
2
3
  Manifest.txt
3
4
  README.txt
@@ -10,41 +11,16 @@ lib/ruboss4ruby/active_foo.rb
10
11
  lib/ruboss4ruby/active_record_tasks.rb
11
12
  lib/ruboss4ruby/configuration.rb
12
13
  lib/ruboss4ruby/generated_attribute.rb
14
+ lib/ruboss4ruby/recipes.rb
15
+ lib/ruboss4ruby/ruboss_helper.rb
16
+ lib/ruboss4ruby/ruboss_test_helpers.rb
13
17
  lib/ruboss4ruby/tasks.rb
14
18
  lib/ruboss4ruby/version.rb
15
19
  merb_generators/ruboss_config.rb
16
- merb_generators/ruboss_config/USAGE
17
- merb_generators/ruboss_config/ruboss_config_generator.rb
18
- merb_generators/ruboss_config/templates/actionscript.properties
19
- merb_generators/ruboss_config/templates/actionscriptair.properties
20
- merb_generators/ruboss_config/templates/expressInstall.swf
21
- merb_generators/ruboss_config/templates/flex.properties
22
- merb_generators/ruboss_config/templates/html-template/AC_OETags.js
23
- merb_generators/ruboss_config/templates/html-template/history/history.css
24
- merb_generators/ruboss_config/templates/html-template/history/history.js
25
- merb_generators/ruboss_config/templates/html-template/history/historyFrame.html
26
- merb_generators/ruboss_config/templates/html-template/index.template.html
27
- merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf
28
- merb_generators/ruboss_config/templates/index.html.erb
29
- merb_generators/ruboss_config/templates/mainair-app.xml
30
- merb_generators/ruboss_config/templates/mainapp.mxml
31
- merb_generators/ruboss_config/templates/project.properties
32
- merb_generators/ruboss_config/templates/projectair.properties
33
- merb_generators/ruboss_config/templates/swfobject.js
34
20
  merb_generators/ruboss_controller.rb
35
- merb_generators/ruboss_controller/USAGE
36
- merb_generators/ruboss_controller/ruboss_controller_generator.rb
37
21
  merb_generators/ruboss_flex_app.rb
38
22
  merb_generators/ruboss_resource_controller.rb
39
- merb_generators/ruboss_resource_controller/USAGE
40
- merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb
41
- merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb
42
- merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb
43
23
  merb_generators/ruboss_scaffold.rb
44
- merb_generators/ruboss_scaffold/USAGE
45
- merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb
46
- merb_generators/ruboss_yaml_scaffold/USAGE
47
- merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb
48
24
  merb_generators/templates/ruboss_config/actionscript.properties
49
25
  merb_generators/templates/ruboss_config/actionscriptair.properties
50
26
  merb_generators/templates/ruboss_config/expressInstall.swf
@@ -64,11 +40,6 @@ merb_generators/templates/ruboss_config/swfobject.js
64
40
  merb_generators/templates/ruboss_controller/controller.as.erb
65
41
  merb_generators/templates/ruboss_flex_app/mainapp.mxml
66
42
  merb_generators/templates/ruboss_resource_controller/controller.rb.erb
67
- merb_generators/templates/ruboss_scaffold/component.mxml.erb
68
- merb_generators/templates/ruboss_scaffold/fixtures.yml.erb
69
- merb_generators/templates/ruboss_scaffold/migration.rb.erb
70
- merb_generators/templates/ruboss_scaffold/model.as.erb
71
- merb_generators/templates/ruboss_scaffold/model.rb.erb
72
43
  rails_generators/ruboss_config/USAGE
73
44
  rails_generators/ruboss_config/ruboss_config_generator.rb
74
45
  rails_generators/ruboss_config/templates/actionscript.properties
@@ -83,7 +54,9 @@ rails_generators/ruboss_config/templates/html-template/index.template.html
83
54
  rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf
84
55
  rails_generators/ruboss_config/templates/index.html.erb
85
56
  rails_generators/ruboss_config/templates/mainair-app.xml
57
+ rails_generators/ruboss_config/templates/mainapp-config.xml
86
58
  rails_generators/ruboss_config/templates/mainapp.mxml
59
+ rails_generators/ruboss_config/templates/project-textmate.erb
87
60
  rails_generators/ruboss_config/templates/project.properties
88
61
  rails_generators/ruboss_config/templates/projectair.properties
89
62
  rails_generators/ruboss_config/templates/ruboss.yml
@@ -111,14 +84,39 @@ setup.rb
111
84
  tasks/deployment.rake
112
85
  tasks/environment.rake
113
86
  tasks/website.rake
114
- test/active_foo_test.rb
115
- test/test_generator_helper.rb
116
- test/test_helper.rb
117
- test/test_ruboss_config_generator.rb
118
- test/test_ruboss_controller_generator.rb
119
- test/test_ruboss_on_ruby.rb
120
- test/test_ruboss_scaffold_generator.rb
121
- test/test_ruboss_yaml_scaffold_generator.rb
87
+ test/controllers/application.rb
88
+ test/controllers/locations_controller.rb
89
+ test/controllers/notes_controller.rb
90
+ test/controllers/projects_controller.rb
91
+ test/controllers/tasks_controller.rb
92
+ test/controllers/users_controller.rb
93
+ test/database.yml
94
+ test/fixtures/locations.yml
95
+ test/fixtures/notes.yml
96
+ test/fixtures/projects.yml
97
+ test/fixtures/tasks.yml
98
+ test/fixtures/users.yml
99
+ test/helpers/controllers.log
100
+ test/helpers/functional_test_helper.rb
101
+ test/helpers/models.log
102
+ test/helpers/test_helper.rb
103
+ test/helpers/unit_test_helper.rb
104
+ test/model.yml
105
+ test/models/location.rb
106
+ test/models/note.rb
107
+ test/models/project.rb
108
+ test/models/task.rb
109
+ test/models/user.rb
110
+ test/playing_around_in_a_console.txt
111
+ test/schema.rb
112
+ test/test.sqlite3
113
+ test/test.swf
114
+ test/test_active_foo.rb
115
+ test/test_ruboss_rails_integration_functional.rb
116
+ test/test_swfobject_helper.rb
117
+ test/to_fxml_test.rb
118
+ test/views/notes/empty_params_action.html.erb
119
+ test/views/notes/index.html.erb
122
120
  website/index.html
123
121
  website/index.txt
124
122
  website/javascripts/rounded_corners_lite.inc.js
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'config/requirements'
2
2
  require 'config/hoe' # setup Hoe + all gem configuration
3
3
 
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
5
+
data/lib/ruboss4ruby.rb CHANGED
@@ -4,12 +4,12 @@ if defined?(Merb::Plugins)
4
4
  Merb::BootLoader.before_app_loads do
5
5
  Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
6
6
 
7
- generators = File.join(File.dirname(__FILE__), '..', 'merb_generators')
8
- Merb.add_generators generators / :ruboss_config
9
- Merb.add_generators generators / :ruboss_flex_app
10
- Merb.add_generators generators / :ruboss_controller
11
- Merb.add_generators generators / :ruboss_scaffold
12
- Merb.add_generators generators / :ruboss_resource_controller
7
+ # generators = File.join(File.dirname(__FILE__), '..', 'merb_generators')
8
+ # Merb.add_generators generators / :ruboss_config
9
+ # Merb.add_generators generators / :ruboss_flex_app
10
+ # Merb.add_generators generators / :ruboss_controller
11
+ # Merb.add_generators generators / :ruboss_scaffold
12
+ # Merb.add_generators generators / :ruboss_resource_controller
13
13
 
14
14
  require 'ruboss4ruby/version'
15
15
  require 'ruboss4ruby/configuration'
@@ -22,9 +22,13 @@ elsif defined?(ActionController::Base)
22
22
  # if we are not running in Merb, we've got to be running in Rails
23
23
  Mime::Type.register_alias "application/xml", :fxml
24
24
 
25
- require 'ruboss4ruby/version'
26
- require 'ruboss4ruby/configuration'
27
- require 'ruboss4ruby/active_foo'
25
+ require File.join(File.dirname(__FILE__),'ruboss4ruby', 'version')
26
+ require File.join(File.dirname(__FILE__),'ruboss4ruby', 'configuration')
27
+ require File.join(File.dirname(__FILE__),'ruboss4ruby', 'active_foo')
28
+ require File.join(File.dirname(__FILE__), 'ruboss4ruby', 'ruboss_helper')
29
+ ActionView::Base.send :include, RubossHelper unless ActionView::Base.included_modules.include?(RubossHelper)
30
+ require File.join(File.dirname(__FILE__), 'ruboss4ruby', 'ruboss_test_helpers')
31
+ Test::Unit::TestCase.send :include, RubossTestHelpers unless Test::Unit::TestCase.included_modules.include?(RubossTestHelpers)
28
32
 
29
33
  module ActionController
30
34
  class Base
@@ -60,9 +64,9 @@ elsif defined?(ActionController::Base)
60
64
  end
61
65
  end
62
66
 
67
+ ActionController::Base.send :include, RubossController
68
+ ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
69
+
63
70
  # temporarily disable forgery protection site-wise
64
71
  ActionController::Base.allow_forgery_protection = false
65
-
66
- ActionController::Base.send :include, RubossController
67
- ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
68
72
  end
@@ -41,7 +41,7 @@ module ActiveRecord
41
41
  # Flex friendly XML serialization patches
42
42
  class Base
43
43
  class << self
44
- alias_method :old_find, :find
44
+ alias_method :old_find, :find unless method_defined?(:old_find)
45
45
 
46
46
  def find(*args)
47
47
  result = old_find(*args)
@@ -69,6 +69,41 @@ module ActiveRecord
69
69
  end
70
70
  END
71
71
  end
72
+
73
+ def default_fxml_hash(already_included = [])
74
+ # return {} unless self.class.respond_to?(:default_fxml_include_params) || self.class.respond_to?(:default_fxml_methods_array)
75
+ default_hash = {:include => {}}
76
+ default_hash[:methods] = self.default_fxml_methods_array if self.respond_to?(:default_fxml_methods_array)
77
+ if self.respond_to?(:default_fxml_include_params)
78
+ default_includes = self.default_fxml_include_params
79
+ default_hash[:include] = default_includes.inject({}) do |include_hash, included|
80
+ next if already_included.include?(included) # We only want to include things once, to avoid infinite loops
81
+ included_class = included.to_s.singularize.camelize.constantize
82
+ include_hash[included] = included_class.default_fxml_hash(already_included + default_includes)
83
+ include_hash
84
+ end
85
+ end
86
+ default_hash
87
+ end
88
+
89
+ # options[:include] can be a Hash, Array, Symbol or nil.
90
+ # We always want it as a Hash. This translates includes to a Hash like this:
91
+ # If it's a nil, return an empty Hash ({})
92
+ # If it's a Hash, then it is just returned
93
+ # If it's an array, then it returns a Hash with each array element as a key, and values of empty Hashes.
94
+ # If it's a symbol, then it returns a Hash with a single key/value pair, with the symbol as the key and an empty Hash as the value.
95
+ def includes_as_hash(includes = nil)
96
+ res = case
97
+ when includes.is_a?(Hash)
98
+ includes
99
+ when includes.nil?
100
+ {}
101
+ else #Deal with arrays and symbols
102
+ res = [includes].flatten.inject({}) {|include_hash, included| include_hash[included] = {} ; include_hash}
103
+ end
104
+ res
105
+ end
106
+
72
107
  end
73
108
  end
74
109
 
@@ -77,10 +112,11 @@ module ActiveRecord
77
112
  options.merge!(:dasherize => false)
78
113
  default_except = [:crypted_password, :salt, :remember_token, :remember_token_expires_at]
79
114
  options[:except] = (options[:except] ? options[:except] + default_except : default_except)
80
- options[:methods] = [options[:methods] || []].flatten + self.class.default_fxml_methods_array if self.class.respond_to?(:default_fxml_methods_array)
81
- options[:include] = [options[:include] || []].flatten + self.class.default_fxml_include_params if self.class.respond_to?(:default_fxml_include_params)
115
+ options[:methods] = [options[:methods] || []].flatten + (self.class.default_fxml_hash[:methods] || [])
116
+ options[:include] = self.class.default_fxml_hash[:include].merge(self.class.includes_as_hash(options[:include]))
82
117
  to_xml(options)
83
118
  end
119
+
84
120
  end
85
121
 
86
122
  # Change the xml serializer so that '?'s are stripped from attribute names.
@@ -0,0 +1,62 @@
1
+ require 'find'
2
+
3
+ # To use these recipes, add the following to your Capfile:
4
+ # require 'ruboss4ruby/recipes'
5
+
6
+ Capistrano::Configuration.instance(:must_exist).load do
7
+
8
+ after "deploy:setup", "deploy:flex:setup"
9
+
10
+ namespace :db do
11
+ desc "runs db:refresh in the latest release directory."
12
+ task :refresh, :roles => :db do
13
+ run("cd #{latest_release} && rake db:refresh RAILS_ENV=production")
14
+ end
15
+ end
16
+
17
+ namespace :deploy do
18
+
19
+ namespace :flex do
20
+
21
+ desc "Creates the flex_files directory in the shared directory"
22
+ task :setup do
23
+ flex_dir = File.join(shared_path, 'flex_files')
24
+ run "#{try_sudo} mkdir -p #{flex_dir} && #{try_sudo} chmod g+w #{flex_dir}"
25
+ end
26
+
27
+ desc "uploads everything in public/bin up to the server"
28
+ task :via_dumb_copy, :roles => :app do
29
+ # the -p flag on mkdir makes intermediate directories (i.e. both /bin and /bin/history),
30
+ # and doesn't raise an error if any of the directories already exist.
31
+ rails_root = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
32
+ base_dir = File.join(rails_root, 'public', 'bin')
33
+ ec2_base_dir = File.join(shared_path, 'flex_files')
34
+
35
+ Find.find(base_dir) do |file|
36
+ filename_without_base_dir = file.sub(base_dir, '')
37
+ if File.directory?(file)
38
+ run "mkdir -p #{File.join(ec2_base_dir, filename_without_base_dir)}"
39
+ else
40
+ content = File.open(file, 'rb') {|f| f.read}
41
+ put content, File.join(ec2_base_dir, filename_without_base_dir)
42
+ end
43
+ end
44
+ end
45
+
46
+ desc "synchronizes the local and remote public/bin directories using rsync"
47
+ task :via_rsync, :roles => :app do
48
+ username = user || ENV['USER']
49
+ rails_root = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
50
+ execute_on_servers do |server|
51
+ `rsync -r -p -v -e \"ssh -i #{ssh_options[:keys]}\" #{File.join(rails_root, 'public', 'bin')}/ #{username}@#{server}:#{File.join(shared_path, 'flex_files')}/`
52
+ end
53
+ end
54
+
55
+ task :make_symlink, :roles => :app do
56
+ run "ln -s #{shared_path}/flex_files #{release_path}/public/bin"
57
+ end
58
+
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,54 @@
1
+ module RubossHelper
2
+
3
+ # Creates a swfObject Javascript call. You must include swfobject.js to use this.
4
+ # See http://code.google.com/p/swfobject/wiki/documentation for full details and documentation
5
+ # of the swfobject js library.
6
+ def swfobject(swf_url, params = {})
7
+ params.reverse_merge!({:width => '100%',
8
+ :height => '100%',
9
+ :id => 'flashContent',
10
+ :version => '9.0.0',
11
+ :express_install_swf => '/expressInstall.swf',
12
+ :flash_vars => nil,
13
+ :params => nil,
14
+ :attributes => nil,
15
+ :create_div => false,
16
+ :include_authenticity_token => true
17
+ })
18
+ arg_order = [:id, :width, :height, :version, :express_install_swf]
19
+ js_params = ["'#{swf_url}?#{rails_asset_id(swf_url)}'"]
20
+ js_params += arg_order.collect {|arg| "'#{params[arg]}'" }
21
+
22
+ # Add authenticity_token to flashVars. This will only work if flashVars is a Hash or nil
23
+ # If it's a string representing the name of a Javascript variable, then you need to add it yourself
24
+ # like this:
25
+ # <script>
26
+ # ... other code that defines flashVars and sets some of its parameters
27
+ # flashVars['authenticity_token'] = <%= form_authenticity_token -%>
28
+ # </script>
29
+ # If you include an authenticity_token parameter in flashVars,
30
+ # then the Flex app will add it to Ruboss.defaultMetadata, so that it will be sent
31
+ # back up to your Rails app with every request.
32
+ if params[:include_authenticity_token] && ActionController::Base.allow_forgery_protection
33
+ params[:flash_vars] = {} if params[:flash_vars].nil?
34
+ if params[:flash_vars].is_a?(Hash)
35
+ params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
36
+ end
37
+ end
38
+
39
+ js_params += [params[:flash_vars], params[:params], params[:attributes]].collect do |hash_or_string|
40
+ if hash_or_string.is_a?(Hash)
41
+ hash_or_string.to_json
42
+ else # If it's not a hash, then it should be a string giving the name of the Javascript variable to use
43
+ hash_or_string
44
+ end
45
+ end.compact
46
+
47
+ swf_tag = javascript_tag do
48
+ "swfobject.embedSWF(#{js_params.join(',')})"
49
+ end
50
+ swf_tag += content_tag(:div, nil, :id => params[:id]) if params[:create_div]
51
+ swf_tag
52
+ end
53
+
54
+ end
@@ -0,0 +1,31 @@
1
+ module RubossTestHelpers
2
+
3
+ # Use this to test xml or fxml responses in unit tests. For example,
4
+ # set_response_to user.to_fxml
5
+ # assert_xml_select 'user name', 'quentin'
6
+ def set_response_to(response, content_type = 'xml')
7
+ @response = MockResponse.new(response, content_type)
8
+ end
9
+
10
+ # Make xml functional testing work.
11
+ # From http://weblog.jamisbuck.org/2007/1/4/assert_xml_select
12
+ def xml_document
13
+ @xml_document ||= HTML::Document.new(@response.body, false, true)
14
+ end
15
+
16
+ def assert_xml_select(*args, &block)
17
+ @html_document = xml_document
18
+ assert_select(*args, &block)
19
+ end
20
+
21
+ end
22
+
23
+ class MockResponse
24
+ attr_reader :body, :content_type
25
+
26
+ def initialize(body, content_type = 'xml')
27
+ @body = body
28
+ @content_type = content_type
29
+ end
30
+
31
+ end
@@ -1,8 +1,6 @@
1
1
  require 'rake'
2
2
  require 'ftools'
3
3
  require 'rexml/document'
4
- require 'ruboss4ruby/version'
5
- require 'ruboss4ruby/configuration'
6
4
 
7
5
  APP_ROOT = Ruboss::Configuration::APP_ROOT
8
6
 
@@ -1,10 +1,10 @@
1
1
  module Ruboss
2
- RUBOSS_FRAMEWORK_VERSION = '1.0.2'
2
+ RUBOSS_FRAMEWORK_VERSION = '1.0.3'
3
3
 
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
- TINY = 2
7
+ TINY = 3
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].join('.')
10
10
  end
@@ -49,36 +49,30 @@ module Merb::Generators
49
49
  File.join(File.dirname(__FILE__), 'templates', 'ruboss_config')
50
50
  end
51
51
 
52
- desc <<-DESC
53
- Generates the primary Ruboss directory structure.
54
- Sets up Flex Builder specific descriptor files and options fetches
55
- the latest published Ruboss Framework SWC file.
56
- DESC
57
-
58
52
  empty_directory :bin, File.join('public', 'bin')
59
53
  empty_directory :javascripts, File.join('public', 'javascripts')
60
54
  empty_directory :schema, 'schema'
61
55
 
62
56
  file :flex_properties, 'flex.properties', '.flexProperties'
63
57
 
64
- template :actionscript_properties do
65
- source("#{extract_config('actionscript')}.properties")
66
- destination('.actionScriptProperties')
58
+ template :actionscript_properties do |t|
59
+ t.source = "#{extract_config('actionscript')}.properties"
60
+ t.destination = '.actionScriptProperties'
67
61
  end
68
62
 
69
- template :project_properties do
70
- source("#{extract_config('project')}.properties")
71
- destination('.project')
63
+ template :project_properties do |t|
64
+ t.source = "#{extract_config('project')}.properties"
65
+ t.destination = '.project'
72
66
  end
73
67
 
74
68
  %w(components controllers commands models events).each do |dir|
75
- empty_directory dir.to_sym do
76
- destination(File.join('app', 'flex', base_folder, dir))
69
+ empty_directory dir.to_sym do |t|
70
+ t.destination = File.join('app', 'flex', base_folder, dir)
77
71
  end
78
72
  end
79
73
 
80
- empty_directory :generated do
81
- File.join('app', 'flex', base_folder, 'components', 'generated')
74
+ empty_directory :generated do |t|
75
+ t.destination = File.join('app', 'flex', base_folder, 'components', 'generated')
82
76
  end
83
77
 
84
78
  glob!('html-template')
@@ -93,10 +87,16 @@ module Merb::Generators
93
87
 
94
88
  invoke :ruboss_flex_app
95
89
 
96
- template :air_descriptor, :air => true do
97
- source('mainair-app.xml')
98
- destination(File.join('app', 'flex', "#{project_name}-app.xml"))
90
+ template :air_descriptor, :air => true do |t|
91
+ t.source = 'mainair-app.xml'
92
+ t.destination = File.join('app', 'flex', "#{project_name}-app.xml")
99
93
  end
94
+
95
+ desc <<-DESC
96
+ Generates the primary Ruboss directory structure.
97
+ Sets up Flex Builder specific descriptor files and options fetches
98
+ the latest published Ruboss Framework SWC file.
99
+ DESC
100
100
 
101
101
  invoke :ruboss_controller
102
102
  end