ruboss4ruby 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -41,9 +41,9 @@ module Merb::Generators
41
41
  File.join(File.dirname(__FILE__), 'templates', 'ruboss_controller')
42
42
  end
43
43
 
44
- template :controller do
45
- source('controller.as.erb')
46
- destination(File.join('app', 'flex', base_folder, 'controllers', "#{command_controller_name}.as"))
44
+ template :controller do |t|
45
+ t.source = 'controller.as.erb'
46
+ t.destination = File.join('app', 'flex', base_folder, 'controllers', "#{command_controller_name}.as")
47
47
  end
48
48
 
49
49
  desc <<-DESC
@@ -59,9 +59,9 @@ module Merb::Generators
59
59
  Generates main flex application file.
60
60
  DESC
61
61
 
62
- template :main_app do
63
- source('mainapp.mxml')
64
- destination(File.join('app', 'flex', "#{project_name}.mxml"))
62
+ template :main_app do |t|
63
+ t.source = 'mainapp.mxml'
64
+ t.destination = File.join('app', 'flex', "#{project_name}.mxml")
65
65
  end
66
66
  end
67
67
 
@@ -1,4 +1,4 @@
1
- Merb::Generators::ResourceControllerGenerator.template :ruboss_resource_controller do
2
- source(File.dirname(__FILE__), "templates/ruboss_resource_controller/controller.rb.erb")
3
- destination("app/controllers", base_path, "#{file_name}.rb")
1
+ Merb::Generators::ResourceControllerGenerator.template :ruboss_resource_controller, :orm => :activerecord do |t|
2
+ t.source = File.dirname(__FILE__) / "templates/ruboss_resource_controller/controller.rb.erb"
3
+ t.destination = "app/controllers" / base_path / "#{file_name}.rb"
4
4
  end
@@ -1,6 +1,8 @@
1
1
  require 'ruboss4ruby/configuration'
2
2
  require 'ruboss4ruby/generated_attribute'
3
3
 
4
+ #NOTE: this is currently (merb 0.9.9 broken and needs to be rethought anyway. This line of thinking was based
5
+ # on the kind of code generation you could do with rails, it's a different code generation paradigm with Merb anyway)
4
6
  module Merb::Generators
5
7
  class RubossScaffoldGenerator < NamespacedGenerator
6
8
  include Ruboss::Configuration
@@ -12,35 +14,8 @@ module Merb::Generators
12
14
  second_argument :properties, :as => :hash, :required => true, :default => {}, :desc => "space separated model properties in form of name:type. Example: state:string"
13
15
 
14
16
  def initialize(*args)
15
- super
16
17
  @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
17
-
18
- @belongs_tos = []
19
- @has_ones = []
20
- @has_manies = []
21
- # Figure out has_one, has_many and belongs_to based on args
22
- self.properties.each do |key,value|
23
- puts key + value
24
- key = key.to_sym
25
- if key == :has_one
26
- # arg = "has_one:arg1,arg2", so all the has_one are together
27
- @has_ones = value.split(',')
28
- elsif key == :has_many
29
- # arg = "has_many:arg1,arg2", so all the has_many are together
30
- @has_manies = value.split(",")
31
- elsif key == :belongs_to # belongs_to:arg1,arg2
32
- @belongs_tos = value.split(',')
33
- end
34
- end
35
-
36
- puts belongs_tos
37
- puts has_manies
38
-
39
- # Remove the has_one and has_many arguments since they are
40
- # not for consumption by the scaffold generator, and since
41
- # we have already used them to set the @belongs_tos, @has_ones and
42
- # @has_manies.
43
- self.properties.delete_if { |key, value| key =~ /^(has_one|has_many|belongs_to)/ }
18
+ super
44
19
  end
45
20
 
46
21
  def table_name
@@ -90,6 +65,35 @@ module Merb::Generators
90
65
  end
91
66
 
92
67
  def attributes
68
+ @belongs_tos = []
69
+ @has_ones = []
70
+ @has_manies = []
71
+ # Figure out has_one, has_many and belongs_to based on args
72
+ self.properties.each do |key,value|
73
+ puts key + value
74
+ key = key.to_sym
75
+ if key == :has_one
76
+ # arg = "has_one:arg1,arg2", so all the has_one are together
77
+ @has_ones = value.split(',')
78
+ elsif key == :has_many
79
+ # arg = "has_many:arg1,arg2", so all the has_many are together
80
+ @has_manies = value.split(",")
81
+ elsif key == :belongs_to # belongs_to:arg1,arg2
82
+ @belongs_tos = value.split(',')
83
+ end
84
+ end
85
+
86
+ puts "does this even run?"
87
+
88
+ puts belongs_tos
89
+ puts has_manies
90
+
91
+ # Remove the has_one and has_many arguments since they are
92
+ # not for consumption by the scaffold generator, and since
93
+ # we have already used them to set the @belongs_tos, @has_ones and
94
+ # @has_manies.
95
+ self.properties.delete_if { |key, value| key =~ /^(has_one|has_many|belongs_to)/ }
96
+
93
97
  @attributes ||= self.properties.collect do |key, value|
94
98
  Ruboss::Generator::GeneratedAttribute.new(key, value)
95
99
  end
@@ -99,41 +103,37 @@ module Merb::Generators
99
103
  File.join(File.dirname(__FILE__), 'templates', 'ruboss_scaffold')
100
104
  end
101
105
 
102
- # invoke :model do |generator|
103
- # generator.new(destination_root, options, model_name, self.properties)
104
- # end
105
-
106
106
  invoke :ruboss_resource_controller do |generator|
107
107
  generator.new(destination_root, options, controller_name)
108
108
  end
109
109
 
110
- template :ar_model, :flex_only => false do
111
- source('model.rb.erb')
112
- destination(File.join('app', 'models', "#{file_name}.rb"))
110
+ template :ar_model, :flex_only => false do |t|
111
+ t.source = 'model.rb.erb'
112
+ t.destination = File.join('app', 'models', "#{file_name}.rb")
113
113
  end
114
114
 
115
115
  empty_directory :fixtures, File.join('spec', 'fixtures')
116
116
 
117
- template :fixture, :flex_only => false do
118
- source('fixtures.yml.erb')
119
- destination(File.join('spec', 'fixtures', "#{table_name}.yml"))
117
+ template :fixture, :flex_only => false do |t|
118
+ t.source = 'fixtures.yml.erb'
119
+ t.destination = File.join('spec', 'fixtures', "#{table_name}.yml")
120
120
  end
121
121
 
122
122
  empty_directory :migrations, File.join('schema', 'migrations')
123
123
 
124
- template :migration, :flex_only => false, :skip_migration => false do
125
- source('migration.rb.erb')
126
- destination(File.join('schema', 'migrations', "#{migration_file_name}.rb"))
124
+ template :migration, :flex_only => false, :skip_migration => false do |t|
125
+ t.source = 'migration.rb.erb'
126
+ t.destination = File.join('schema', 'migrations', "#{migration_file_name}.rb")
127
127
  end
128
128
 
129
- template :as_model do
130
- source('model.as.erb')
131
- destination(File.join('app', 'flex', base_folder, 'models', "#{class_name}.as"))
129
+ template :as_model do |t|
130
+ t.source = 'model.as.erb'
131
+ t.destination = File.join('app', 'flex', base_folder, 'models', "#{class_name}.as")
132
132
  end
133
133
 
134
- template :flex_component do
135
- source('component.mxml.erb')
136
- destination(File.join('app', 'flex', base_folder, 'components', 'generated', "#{class_name}Box.mxml"))
134
+ template :flex_component do |t|
135
+ t.source = 'component.mxml.erb'
136
+ t.destination = File.join('app', 'flex', base_folder, 'components', 'generated', "#{class_name}Box.mxml")
137
137
  end
138
138
 
139
139
  invoke :ruboss_controller do |generator|
@@ -12,8 +12,6 @@
12
12
  # commercial license, please go to http://ruboss.com.
13
13
  ################################################################################
14
14
  require 'open-uri'
15
- require 'ruboss4ruby/version'
16
- require 'ruboss4ruby/configuration'
17
15
 
18
16
  class RubossConfigGenerator < Rails::Generator::Base
19
17
  include Ruboss::Configuration
@@ -104,7 +102,9 @@ class RubossConfigGenerator < Rails::Generator::Base
104
102
 
105
103
  m.dependency 'ruboss_controller', @args
106
104
  end
105
+ m.template 'project-textmate.erb', "#{project_name.underscore}.tmproj"
107
106
  m.template 'mainapp.mxml', File.join('app/flex', "#{project_name}.mxml")
107
+ m.template 'mainapp-config.xml', File.join('app/flex', "#{project_name}-config.xml")
108
108
  m.template 'mainair-app.xml', File.join('app/flex', "#{project_name}-app.xml") if @use_air
109
109
  end
110
110
  end
@@ -2,9 +2,9 @@
2
2
  <head>
3
3
  <title><%= project_name %></title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
- <script type="text/javascript" src="/javascripts/swfobject.js"></script>
5
+ <script type="text/javascript" src="javascripts/swfobject.js"></script>
6
6
  <script type="text/javascript">
7
- swfobject.embedSWF("/bin/<%= project_name %>.swf", "mainApp", "100%", "100%", "9.0.0", "expressInstall.swf");
7
+ swfobject.embedSWF("bin/<%= project_name %>.swf", "mainApp", "100%", "100%", "9.0.0", "expressInstall.swf");
8
8
  </script>
9
9
  <style>
10
10
  body { margin: 0px; overflow: hidden; }
@@ -0,0 +1,21 @@
1
+ <flex-config>
2
+ <benchmark>false</benchmark>
3
+ <default-background-color>#FFFFFF</default-background-color>
4
+ <compiler>
5
+ <incremental>true</incremental>
6
+ <keep-as3-metadata append="true">
7
+ <name>Resource</name>
8
+ <name>HasOne</name>
9
+ <name>HasMany</name>
10
+ <name>BelongsTo</name>
11
+ <name>DateTime</name>
12
+ <name>Lazy</name>
13
+ <name>Ignored</name>
14
+ </keep-as3-metadata>
15
+ <optimize>true</optimize>
16
+ <keep-generated-actionscript>false</keep-generated-actionscript>
17
+ <warn-no-constructor>false</warn-no-constructor>
18
+ <warn-no-explicit-super-call-in-constructor>false</warn-no-explicit-super-call-in-constructor>
19
+ <debug>false</debug>
20
+ </compiler>
21
+ </flex-config>
@@ -1,15 +1,14 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <mx:<%= application_tag %> xmlns:mx="http://www.adobe.com/2006/mxml"
3
3
  xmlns:generated="<%= base_package %>.components.generated.*"
4
- layout="vertical"
5
- styleName="plain"
6
- initialize="init()">
4
+ paddingBottom="8" paddingLeft="8" paddingRight="8" paddingTop="8"
5
+ layout="horizontal" styleName="plain" initialize="init()">
7
6
  <mx:Script>
8
7
  <![CDATA[
9
8
  <% if use_air -%>
10
9
  import org.ruboss.services.air.AIRServiceProvider;
11
10
  <% end -%>
12
- import org.ruboss.Ruboss;
11
+ import org.ruboss.Ruboss;
13
12
  import <%= base_package %>.controllers.<%= command_controller_name %>;
14
13
 
15
14
  private function init():void {
@@ -21,9 +20,7 @@
21
20
  }
22
21
  ]]>
23
22
  </mx:Script>
24
- <mx:ApplicationControlBar dock="true" width="100%">
25
- <mx:LinkBar dataProvider="{mainViewStack}"/>
26
- </mx:ApplicationControlBar>
23
+ <mx:LinkBar dataProvider="{mainViewStack}" direction="vertical" borderStyle="solid" backgroundColor="#EEEEEE"/>
27
24
  <mx:ViewStack id="mainViewStack" width="100%" height="100%">
28
25
  <!-- For a simple demo, put all the components here. -->
29
26
  <% for component in component_names -%>
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>currentDocument</key>
6
+ <string>app/flex/<%= project_name %>.mxml</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string><%= project_name.underscore %></string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>sourceDirectory</key>
17
+ <string></string>
18
+ </dict>
19
+ </array>
20
+ <key>fileHierarchyDrawerWidth</key>
21
+ <integer>299</integer>
22
+ <key>metaData</key>
23
+ <dict/>
24
+ <key>openDocuments</key>
25
+ <array>
26
+ <string>app/flex/<%= project_name %>.mxml</string>
27
+ </array>
28
+ <key>shellVariables</key>
29
+ <array>
30
+ <dict>
31
+ <key>enabled</key>
32
+ <true/>
33
+ <key>value</key>
34
+ <string>app/flex/<%= project_name %>.mxml</string>
35
+ <key>variable</key>
36
+ <string>TM_FLEX_FILE_SPECS</string>
37
+ </dict>
38
+ <dict>
39
+ <key>enabled</key>
40
+ <true/>
41
+ <key>value</key>
42
+ <string>public/bin/<%= project_name %>.swf</string>
43
+ <key>variable</key>
44
+ <string>TM_FLEX_OUTPUT</string>
45
+ </dict>
46
+ </array>
47
+ <key>showFileHierarchyDrawer</key>
48
+ <false/>
49
+ <key>windowFrame</key>
50
+ <string>{{5, 15}, {1073, 860}}</string>
51
+ </dict>
52
+ </plist>
@@ -11,8 +11,6 @@
11
11
  # RCL v1 applies; otherwise, only the GPL v3 applies. To learn more or to buy a
12
12
  # commercial license, please go to http://ruboss.com.
13
13
  ################################################################################
14
- require 'ruboss4ruby/configuration'
15
-
16
14
  class RubossControllerGenerator < Rails::Generator::Base
17
15
  include Ruboss::Configuration
18
16
 
@@ -11,8 +11,6 @@
11
11
  # RCL v1 applies; otherwise, only the GPL v3 applies. To learn more or to buy a
12
12
  # commercial license, please go to http://ruboss.com.
13
13
  ################################################################################
14
- require 'ruboss4ruby/configuration'
15
-
16
14
  module Rails
17
15
  module Generator
18
16
  class GeneratedAttribute
@@ -98,8 +98,8 @@
98
98
  }
99
99
  ]]></mx:Script>
100
100
  <mx:Panel id="<%= class_name.downcase_first_letter.pluralize %>Panel"
101
- title="<%= class_name.pluralize %>"
102
- width="25%" height="100%">
101
+ title="<%= class_name.pluralize %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
102
+ borderThickness="1" backgroundColor="#EEEEEE" width="25%" height="100%">
103
103
  <mx:List id="<%= class_name.downcase_first_letter.pluralize %>List"
104
104
  width="100%" height="100%"
105
105
  dataProvider="{Ruboss.models.index(<%= class_name %>)}"
@@ -109,7 +109,8 @@
109
109
  click="new<%= class_name %>()"/>
110
110
  </mx:ControlBar>
111
111
  </mx:Panel>
112
- <mx:Panel title="Edit <%= class_name %>" width="75%" height="100%">
112
+ <mx:Panel title="Edit <%= class_name %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
113
+ borderThickness="1" backgroundColor="#EEEEEE" width="75%" height="100%">
113
114
  <mx:Form width="100%" height="100%">
114
115
  <% for attribute in attributes -%>
115
116
  <mx:FormItem label="<%= attribute.flex_name.capitalize_without_downcasing %>" width="100%">
@@ -1,5 +1,4 @@
1
1
  require 'yaml'
2
- require 'ruboss4ruby/configuration'
3
2
 
4
3
  class RubossYamlScaffoldGenerator < Rails::Generator::Base
5
4
  def extract_attrs(line, attrs)
@@ -0,0 +1,15 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+
7
+ # See ActionController::RequestForgeryProtection for details
8
+ # Uncomment the :secret if you're not using the cookie session store
9
+ protect_from_forgery # :secret => 'c83e3ff98f15718c4544ca8821f2b6d4'
10
+
11
+ # See ActionController::Base for details
12
+ # Uncomment this to filter the contents of submitted sensitive data parameters
13
+ # from your application log (in this case, all fields with names like "password").
14
+ # filter_parameter_logging :password
15
+ end
@@ -0,0 +1,93 @@
1
+ class LocationsController < ApplicationController
2
+ # GET /locations
3
+ # GET /locations.xml
4
+ def index
5
+ @locations = Location.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @locations }
10
+ format.fxml { render :fxml => @locations }
11
+ end
12
+ end
13
+
14
+ # GET /locations/1
15
+ # GET /locations/1.xml
16
+ def show
17
+ @location = Location.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.xml { render :xml => @location }
22
+ format.fxml { render :fxml => @location }
23
+ end
24
+ end
25
+
26
+ # GET /locations/new
27
+ # GET /locations/new.xml
28
+ def new
29
+ @location = Location.new
30
+
31
+ respond_to do |format|
32
+ format.html # new.html.erb
33
+ format.xml { render :xml => @location }
34
+ format.fxml { render :fxml => @location }
35
+ end
36
+ end
37
+
38
+ # GET /locations/1/edit
39
+ def edit
40
+ @location = Location.find(params[:id])
41
+ end
42
+
43
+ # POST /locations
44
+ # POST /locations.xml
45
+ def create
46
+ @location = Location.new(params[:location])
47
+
48
+ respond_to do |format|
49
+ if @location.save
50
+ flash[:notice] = 'Location was successfully created.'
51
+ format.html { redirect_to(@location) }
52
+ format.xml { render :xml => @location, :status => :created, :location => @location }
53
+ format.fxml { render :fxml => @location }
54
+ else
55
+ format.html { render :action => "new" }
56
+ format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
57
+ format.fxml { render :fxml => @location.errors }
58
+ end
59
+ end
60
+ end
61
+
62
+ # PUT /locations/1
63
+ # PUT /locations/1.xml
64
+ def update
65
+ @location = Location.find(params[:id])
66
+
67
+ respond_to do |format|
68
+ if @location.update_attributes(params[:location])
69
+ flash[:notice] = 'Location was successfully updated.'
70
+ format.html { redirect_to(@location) }
71
+ format.xml { head :ok }
72
+ format.fxml { render :fxml => @location }
73
+ else
74
+ format.html { render :action => "edit" }
75
+ format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
76
+ format.fxml { render :fxml => @location.errors }
77
+ end
78
+ end
79
+ end
80
+
81
+ # DELETE /locations/1
82
+ # DELETE /locations/1.xml
83
+ def destroy
84
+ @location = Location.find(params[:id])
85
+ @location.destroy
86
+
87
+ respond_to do |format|
88
+ format.html { redirect_to(locations_url) }
89
+ format.xml { head :ok }
90
+ format.fxml { render :fxml => @location }
91
+ end
92
+ end
93
+ end