restfulx 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/History.txt +7 -0
  2. data/Manifest.txt +127 -0
  3. data/README.rdoc +50 -0
  4. data/Rakefile +42 -0
  5. data/app_generators/rx_app/USAGE +22 -0
  6. data/app_generators/rx_app/rx_app_generator.rb +94 -0
  7. data/app_generators/rx_app/templates/actionscript.properties +16 -0
  8. data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
  9. data/app_generators/rx_app/templates/app.yaml.erb +12 -0
  10. data/app_generators/rx_app/templates/default_tasks.rake +51 -0
  11. data/app_generators/rx_app/templates/empty.txt +0 -0
  12. data/app_generators/rx_app/templates/expressInstall.swf +0 -0
  13. data/app_generators/rx_app/templates/flex.properties +2 -0
  14. data/app_generators/rx_app/templates/generate.rb +17 -0
  15. data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
  16. data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
  17. data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
  18. data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
  19. data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
  20. data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
  21. data/app_generators/rx_app/templates/index.html.erb +18 -0
  22. data/app_generators/rx_app/templates/index.yaml +11 -0
  23. data/app_generators/rx_app/templates/mainair-app.xml +134 -0
  24. data/app_generators/rx_app/templates/mainapp-config.xml +21 -0
  25. data/app_generators/rx_app/templates/mainapp.mxml +31 -0
  26. data/app_generators/rx_app/templates/project-textmate.erb +52 -0
  27. data/app_generators/rx_app/templates/project.properties +18 -0
  28. data/app_generators/rx_app/templates/projectair.properties +24 -0
  29. data/app_generators/rx_app/templates/swfobject.js +5 -0
  30. data/bin/rx-gen +31 -0
  31. data/generators/rx_config/USAGE +5 -0
  32. data/generators/rx_config/rx_config_generator.rb +19 -0
  33. data/generators/rx_controller/USAGE +10 -0
  34. data/generators/rx_controller/rx_controller_generator.rb +39 -0
  35. data/generators/rx_controller/templates/assist.py +65 -0
  36. data/generators/rx_controller/templates/controller.as.erb +36 -0
  37. data/generators/rx_controller/templates/restful.py +136 -0
  38. data/generators/rx_main_app/USAGE +8 -0
  39. data/generators/rx_main_app/rx_main_app_generator.rb +60 -0
  40. data/generators/rx_main_app/templates/main.py.erb +29 -0
  41. data/generators/rx_main_app/templates/mainapp.mxml +35 -0
  42. data/generators/rx_scaffold/USAGE +29 -0
  43. data/generators/rx_scaffold/rx_scaffold_generator.rb +146 -0
  44. data/generators/rx_scaffold/templates/component.mxml.erb +149 -0
  45. data/generators/rx_scaffold/templates/controller.py.erb +27 -0
  46. data/generators/rx_scaffold/templates/model.as.erb +42 -0
  47. data/generators/rx_scaffold/templates/model.py.erb +14 -0
  48. data/generators/rx_yaml_scaffold/USAGE +45 -0
  49. data/generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
  50. data/lib/restfulx/active_foo.rb +186 -0
  51. data/lib/restfulx/active_record_tasks.rb +81 -0
  52. data/lib/restfulx/configuration.rb +76 -0
  53. data/lib/restfulx/datamapper_foo.rb +31 -0
  54. data/lib/restfulx/rails/recipes.rb +60 -0
  55. data/lib/restfulx/rails/swf_helper.rb +60 -0
  56. data/lib/restfulx/tasks.rb +85 -0
  57. data/lib/restfulx.rb +117 -0
  58. data/rails_generators/rx_config/USAGE +18 -0
  59. data/rails_generators/rx_config/rx_config_generator.rb +115 -0
  60. data/rails_generators/rx_config/templates/actionscript.properties +16 -0
  61. data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
  62. data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
  63. data/rails_generators/rx_config/templates/flex.properties +2 -0
  64. data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
  65. data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
  66. data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
  67. data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
  68. data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
  69. data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
  70. data/rails_generators/rx_config/templates/index.html.erb +18 -0
  71. data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
  72. data/rails_generators/rx_config/templates/mainapp-config.xml +21 -0
  73. data/rails_generators/rx_config/templates/mainapp.mxml +31 -0
  74. data/rails_generators/rx_config/templates/project-textmate.erb +52 -0
  75. data/rails_generators/rx_config/templates/project.properties +18 -0
  76. data/rails_generators/rx_config/templates/projectair.properties +24 -0
  77. data/rails_generators/rx_config/templates/restfulx.yml +14 -0
  78. data/rails_generators/rx_config/templates/restfulx_tasks.rake +6 -0
  79. data/rails_generators/rx_config/templates/swfobject.js +5 -0
  80. data/rails_generators/rx_controller/USAGE +10 -0
  81. data/rails_generators/rx_controller/rx_controller_generator.rb +28 -0
  82. data/rails_generators/rx_controller/templates/controller.as.erb +40 -0
  83. data/rails_generators/rx_scaffold/USAGE +35 -0
  84. data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +179 -0
  85. data/rails_generators/rx_scaffold/templates/component.mxml.erb +149 -0
  86. data/rails_generators/rx_scaffold/templates/controller.rb.erb +97 -0
  87. data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +35 -0
  88. data/rails_generators/rx_scaffold/templates/migration.rb.erb +19 -0
  89. data/rails_generators/rx_scaffold/templates/model.as.erb +42 -0
  90. data/rails_generators/rx_scaffold/templates/model.rb.erb +11 -0
  91. data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
  92. data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +49 -0
  93. data/rdoc/generators/template/html/jamis.rb +588 -0
  94. data/spec/restfulx_spec.rb +7 -0
  95. data/spec/spec_helper.rb +16 -0
  96. data/tasks/ann.rake +80 -0
  97. data/tasks/bones.rake +20 -0
  98. data/tasks/gem.rake +201 -0
  99. data/tasks/git.rake +40 -0
  100. data/tasks/manifest.rake +48 -0
  101. data/tasks/notes.rake +27 -0
  102. data/tasks/post_load.rake +39 -0
  103. data/tasks/rdoc.rake +50 -0
  104. data/tasks/rubyforge.rake +55 -0
  105. data/tasks/setup.rb +279 -0
  106. data/tasks/spec.rake +54 -0
  107. data/tasks/svn.rake +47 -0
  108. data/tasks/test.rake +40 -0
  109. data/test/rails/controllers/application.rb +15 -0
  110. data/test/rails/controllers/locations_controller.rb +93 -0
  111. data/test/rails/controllers/notes_controller.rb +96 -0
  112. data/test/rails/controllers/projects_controller.rb +93 -0
  113. data/test/rails/controllers/tasks_controller.rb +93 -0
  114. data/test/rails/controllers/users_controller.rb +93 -0
  115. data/test/rails/database.yml +4 -0
  116. data/test/rails/fixtures/locations.yml +8 -0
  117. data/test/rails/fixtures/notes.yml +17 -0
  118. data/test/rails/fixtures/projects.yml +25 -0
  119. data/test/rails/fixtures/simple_properties.yml +19 -0
  120. data/test/rails/fixtures/tasks.yml +46 -0
  121. data/test/rails/fixtures/users.yml +13 -0
  122. data/test/rails/helpers/functional_test_helper.rb +21 -0
  123. data/test/rails/helpers/test_helper.rb +61 -0
  124. data/test/rails/helpers/unit_test_helper.rb +30 -0
  125. data/test/rails/model.yml +35 -0
  126. data/test/rails/models/location.rb +4 -0
  127. data/test/rails/models/note.rb +3 -0
  128. data/test/rails/models/project.rb +4 -0
  129. data/test/rails/models/simple_property.rb +2 -0
  130. data/test/rails/models/task.rb +18 -0
  131. data/test/rails/models/user.rb +20 -0
  132. data/test/rails/playing_around_in_a_console.txt +71 -0
  133. data/test/rails/schema.rb +77 -0
  134. data/test/rails/test.swf +1 -0
  135. data/test/rails/test_active_foo.rb +36 -0
  136. data/test/rails/test_rails_integration_functional.rb +22 -0
  137. data/test/rails/test_to_fxml.rb +35 -0
  138. data/test/rails/test_to_json.rb +23 -0
  139. data/test/rails/views/notes/empty_params_action.html.erb +1 -0
  140. data/test/rails/views/notes/index.html.erb +1 -0
  141. metadata +227 -0
data/tasks/setup.rb ADDED
@@ -0,0 +1,279 @@
1
+
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rake/clean'
5
+ require 'fileutils'
6
+ require 'ostruct'
7
+
8
+ class OpenStruct; undef :gem; end
9
+
10
+ # TODO: make my own openstruct type object that includes descriptions
11
+ # TODO: use the descriptions to output help on the available bones options
12
+
13
+ PROJ = OpenStruct.new(
14
+ # Project Defaults
15
+ :name => nil,
16
+ :summary => nil,
17
+ :description => nil,
18
+ :changes => nil,
19
+ :authors => nil,
20
+ :email => nil,
21
+ :url => "\000",
22
+ :version => ENV['VERSION'] || '0.0.0',
23
+ :exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
24
+ :release_name => ENV['RELEASE'],
25
+
26
+ # System Defaults
27
+ :ruby_opts => %w(-w),
28
+ :libs => [],
29
+ :history_file => 'History.txt',
30
+ :manifest_file => 'Manifest.txt',
31
+ :readme_file => 'README.txt',
32
+
33
+ # Announce
34
+ :ann => OpenStruct.new(
35
+ :file => 'announcement.txt',
36
+ :text => nil,
37
+ :paragraphs => [],
38
+ :email => {
39
+ :from => nil,
40
+ :to => %w(ruby-talk@ruby-lang.org),
41
+ :server => 'localhost',
42
+ :port => 25,
43
+ :domain => ENV['HOSTNAME'],
44
+ :acct => nil,
45
+ :passwd => nil,
46
+ :authtype => :plain
47
+ }
48
+ ),
49
+
50
+ # Gem Packaging
51
+ :gem => OpenStruct.new(
52
+ :dependencies => [],
53
+ :development_dependencies => [],
54
+ :executables => nil,
55
+ :extensions => FileList['ext/**/extconf.rb'],
56
+ :files => nil,
57
+ :need_tar => true,
58
+ :need_zip => false,
59
+ :extras => {}
60
+ ),
61
+
62
+ # File Annotations
63
+ :notes => OpenStruct.new(
64
+ :exclude => %w(^tasks/setup\.rb$),
65
+ :extensions => %w(.txt .rb .erb .rdoc) << '',
66
+ :tags => %w(FIXME OPTIMIZE TODO)
67
+ ),
68
+
69
+ # Rcov
70
+ :rcov => OpenStruct.new(
71
+ :dir => 'coverage',
72
+ :opts => %w[--sort coverage -T],
73
+ :threshold => 90.0,
74
+ :threshold_exact => false
75
+ ),
76
+
77
+ # Rdoc
78
+ :rdoc => OpenStruct.new(
79
+ :opts => [],
80
+ :include => %w(^lib/ ^bin/ ^ext/ \.txt$ \.rdoc$),
81
+ :exclude => %w(extconf\.rb$),
82
+ :main => nil,
83
+ :dir => 'doc',
84
+ :remote_dir => nil
85
+ ),
86
+
87
+ # Rubyforge
88
+ :rubyforge => OpenStruct.new(
89
+ :name => "\000"
90
+ ),
91
+
92
+ # Rspec
93
+ :spec => OpenStruct.new(
94
+ :files => FileList['spec/**/*_spec.rb'],
95
+ :opts => []
96
+ ),
97
+
98
+ # Subversion Repository
99
+ :svn => OpenStruct.new(
100
+ :root => nil,
101
+ :path => '',
102
+ :trunk => 'trunk',
103
+ :tags => 'tags',
104
+ :branches => 'branches'
105
+ ),
106
+
107
+ # Test::Unit
108
+ :test => OpenStruct.new(
109
+ :files => FileList['test/**/test_*.rb'],
110
+ :file => 'test/all.rb',
111
+ :opts => []
112
+ )
113
+ )
114
+
115
+ # Load the other rake files in the tasks folder
116
+ tasks_dir = File.expand_path(File.dirname(__FILE__))
117
+ post_load_fn = File.join(tasks_dir, 'post_load.rake')
118
+ rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
119
+ rakefiles.unshift(rakefiles.delete(post_load_fn)).compact!
120
+ import(*rakefiles)
121
+
122
+ # Setup the project libraries
123
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
124
+
125
+ # Setup some constants
126
+ WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
127
+
128
+ DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
129
+
130
+ def quiet( &block )
131
+ io = [STDOUT.dup, STDERR.dup]
132
+ STDOUT.reopen DEV_NULL
133
+ STDERR.reopen DEV_NULL
134
+ block.call
135
+ ensure
136
+ STDOUT.reopen io.first
137
+ STDERR.reopen io.last
138
+ $stdout, $stderr = STDOUT, STDERR
139
+ end
140
+
141
+ DIFF = if WIN32 then 'diff.exe'
142
+ else
143
+ if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
144
+ else 'diff' end
145
+ end unless defined? DIFF
146
+
147
+ SUDO = if WIN32 then ''
148
+ else
149
+ if quiet {system 'which sudo'} then 'sudo'
150
+ else '' end
151
+ end
152
+
153
+ RCOV = WIN32 ? 'rcov.bat' : 'rcov'
154
+ RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
155
+ GEM = WIN32 ? 'gem.bat' : 'gem'
156
+
157
+ %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
158
+ begin
159
+ require lib
160
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
161
+ rescue LoadError
162
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
163
+ end
164
+ end
165
+ HAVE_SVN = (Dir.entries(Dir.pwd).include?('.svn') and
166
+ system("svn --version 2>&1 > #{DEV_NULL}"))
167
+ HAVE_GIT = (Dir.entries(Dir.pwd).include?('.git') and
168
+ system("git --version 2>&1 > #{DEV_NULL}"))
169
+
170
+ # Add bones as a development dependency
171
+ #
172
+ if HAVE_BONES
173
+ PROJ.gem.development_dependencies << ['bones', ">= #{Bones::VERSION}"]
174
+ end
175
+
176
+ # Reads a file at +path+ and spits out an array of the +paragraphs+
177
+ # specified.
178
+ #
179
+ # changes = paragraphs_of('History.txt', 0..1).join("\n\n")
180
+ # summary, *description = paragraphs_of('README.txt', 3, 3..8)
181
+ #
182
+ def paragraphs_of( path, *paragraphs )
183
+ title = String === paragraphs.first ? paragraphs.shift : nil
184
+ ary = File.read(path).delete("\r").split(/\n\n+/)
185
+
186
+ result = if title
187
+ tmp, matching = [], false
188
+ rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
189
+ paragraphs << (0..-1) if paragraphs.empty?
190
+
191
+ ary.each do |val|
192
+ if val =~ rgxp
193
+ break if matching
194
+ matching = true
195
+ rgxp = %r/^=+/i
196
+ elsif matching
197
+ tmp << val
198
+ end
199
+ end
200
+ tmp
201
+ else ary end
202
+
203
+ result.values_at(*paragraphs)
204
+ end
205
+
206
+ # Adds the given gem _name_ to the current project's dependency list. An
207
+ # optional gem _version_ can be given. If omitted, the newest gem version
208
+ # will be used.
209
+ #
210
+ def depend_on( name, version = nil )
211
+ spec = Gem.source_index.find_name(name).last
212
+ version = spec.version.to_s if version.nil? and !spec.nil?
213
+
214
+ PROJ.gem.dependencies << case version
215
+ when nil; [name]
216
+ when %r/^\d/; [name, ">= #{version}"]
217
+ else [name, version] end
218
+ end
219
+
220
+ # Adds the given arguments to the include path if they are not already there
221
+ #
222
+ def ensure_in_path( *args )
223
+ args.each do |path|
224
+ path = File.expand_path(path)
225
+ $:.unshift(path) if test(?d, path) and not $:.include?(path)
226
+ end
227
+ end
228
+
229
+ # Find a rake task using the task name and remove any description text. This
230
+ # will prevent the task from being displayed in the list of available tasks.
231
+ #
232
+ def remove_desc_for_task( names )
233
+ Array(names).each do |task_name|
234
+ task = Rake.application.tasks.find {|t| t.name == task_name}
235
+ next if task.nil?
236
+ task.instance_variable_set :@comment, nil
237
+ end
238
+ end
239
+
240
+ # Change working directories to _dir_, call the _block_ of code, and then
241
+ # change back to the original working directory (the current directory when
242
+ # this method was called).
243
+ #
244
+ def in_directory( dir, &block )
245
+ curdir = pwd
246
+ begin
247
+ cd dir
248
+ return block.call
249
+ ensure
250
+ cd curdir
251
+ end
252
+ end
253
+
254
+ # Scans the current working directory and creates a list of files that are
255
+ # candidates to be in the manifest.
256
+ #
257
+ def manifest_files
258
+ files = []
259
+ exclude = Regexp.new(PROJ.exclude.join('|'))
260
+ Find.find '.' do |path|
261
+ path.sub! %r/^(\.\/|\/)/o, ''
262
+ next unless test ?f, path
263
+ next if path =~ exclude
264
+ files << path
265
+ end
266
+ files.sort!
267
+ end
268
+
269
+ # We need a "valid" method thtat determines if a string is suitable for use
270
+ # in the gem specification.
271
+ #
272
+ class Object
273
+ def valid?
274
+ return !(self.empty? or self == "\000") if self.respond_to?(:to_str)
275
+ return false
276
+ end
277
+ end
278
+
279
+ # EOF
data/tasks/spec.rake ADDED
@@ -0,0 +1,54 @@
1
+
2
+ if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
3
+ require 'spec/rake/verify_rcov'
4
+
5
+ namespace :spec do
6
+
7
+ desc 'Run all specs with basic output'
8
+ Spec::Rake::SpecTask.new(:run) do |t|
9
+ t.ruby_opts = PROJ.ruby_opts
10
+ t.spec_opts = PROJ.spec.opts
11
+ t.spec_files = PROJ.spec.files
12
+ t.libs += PROJ.libs
13
+ end
14
+
15
+ desc 'Run all specs with text output'
16
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
17
+ t.ruby_opts = PROJ.ruby_opts
18
+ t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
19
+ t.spec_files = PROJ.spec.files
20
+ t.libs += PROJ.libs
21
+ end
22
+
23
+ if HAVE_RCOV
24
+ desc 'Run all specs with RCov'
25
+ Spec::Rake::SpecTask.new(:rcov) do |t|
26
+ t.ruby_opts = PROJ.ruby_opts
27
+ t.spec_opts = PROJ.spec.opts
28
+ t.spec_files = PROJ.spec.files
29
+ t.libs += PROJ.libs
30
+ t.rcov = true
31
+ t.rcov_dir = PROJ.rcov.dir
32
+ t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
33
+ end
34
+
35
+ RCov::VerifyTask.new(:verify) do |t|
36
+ t.threshold = PROJ.rcov.threshold
37
+ t.index_html = File.join(PROJ.rcov.dir, 'index.html')
38
+ t.require_exact_threshold = PROJ.rcov.threshold_exact
39
+ end
40
+
41
+ task :verify => :rcov
42
+ remove_desc_for_task %w(spec:clobber_rcov)
43
+ end
44
+
45
+ end # namespace :spec
46
+
47
+ desc 'Alias to spec:run'
48
+ task :spec => 'spec:run'
49
+
50
+ task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
51
+
52
+ end # if HAVE_SPEC_RAKE_SPECTASK
53
+
54
+ # EOF
data/tasks/svn.rake ADDED
@@ -0,0 +1,47 @@
1
+
2
+ if HAVE_SVN
3
+
4
+ unless PROJ.svn.root
5
+ info = %x/svn info ./
6
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
7
+ PROJ.svn.root = (m.nil? ? '' : m[1])
8
+ end
9
+ PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
10
+
11
+ namespace :svn do
12
+
13
+ # A prerequisites task that all other tasks depend upon
14
+ task :prereqs
15
+
16
+ desc 'Show tags from the SVN repository'
17
+ task :show_tags => 'svn:prereqs' do |t|
18
+ tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
19
+ tags.gsub!(%r/\/$/, '')
20
+ tags = tags.split("\n").sort {|a,b| b <=> a}
21
+ puts tags
22
+ end
23
+
24
+ desc 'Create a new tag in the SVN repository'
25
+ task :create_tag => 'svn:prereqs' do |t|
26
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
27
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
28
+
29
+ svn = PROJ.svn
30
+ trunk = File.join(svn.root, svn.trunk)
31
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
32
+ tag = File.join(svn.root, svn.tags, tag)
33
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
34
+
35
+ puts "Creating SVN tag '#{tag}'"
36
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
37
+ abort "Tag creation failed"
38
+ end
39
+ end
40
+
41
+ end # namespace :svn
42
+
43
+ task 'gem:release' => 'svn:create_tag'
44
+
45
+ end # if PROJ.svn.path
46
+
47
+ # EOF
data/tasks/test.rake ADDED
@@ -0,0 +1,40 @@
1
+
2
+ if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
10
+ else PROJ.test.files end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test.opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
21
+ else PROJ.test.files end
22
+ files = files.join(' ')
23
+ sh "#{RCOV} #{files} #{opts}"
24
+ end
25
+
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ end
39
+
40
+ # EOF
@@ -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
@@ -0,0 +1,96 @@
1
+ class NotesController < ApplicationController
2
+ # GET /notes
3
+ # GET /notes.xml
4
+ def index
5
+ @notes = Note.find(:all)
6
+ respond_to do |format|
7
+ format.html
8
+ format.xml { render :xml => @notes }
9
+ format.fxml { render :fxml => @notes }
10
+ end
11
+ end
12
+
13
+ # GET /notes/1
14
+ # GET /notes/1.xml
15
+ def show
16
+ @note = Note.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @note }
21
+ format.fxml { render :fxml => @note }
22
+ end
23
+ end
24
+
25
+ # GET /notes/new
26
+ # GET /notes/new.xml
27
+ def new
28
+ @note = Note.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.xml { render :xml => @note }
33
+ format.fxml { render :fxml => @note }
34
+ end
35
+ end
36
+
37
+ # GET /notes/1/edit
38
+ def edit
39
+ @note = Note.find(params[:id])
40
+ end
41
+
42
+ # POST /notes
43
+ # POST /notes.xml
44
+ def create
45
+ @note = Note.new(params[:note])
46
+
47
+ respond_to do |format|
48
+ if @note.save
49
+ flash[:notice] = 'Note was successfully created.'
50
+ format.html { redirect_to(@note) }
51
+ format.xml { render :xml => @note, :status => :created, :location => @note }
52
+ format.fxml { render :fxml => @note }
53
+ else
54
+ format.html { render :action => "new" }
55
+ format.xml { render :xml => @note.errors, :status => :unprocessable_entity }
56
+ format.fxml { render :fxml => @note.errors }
57
+ end
58
+ end
59
+ end
60
+
61
+ # PUT /notes/1
62
+ # PUT /notes/1.xml
63
+ def update
64
+ @note = Note.find(params[:id])
65
+
66
+ respond_to do |format|
67
+ if @note.update_attributes(params[:note])
68
+ flash[:notice] = 'Note was successfully updated.'
69
+ format.html { redirect_to(@note) }
70
+ format.xml { head :ok }
71
+ format.fxml { render :fxml => @note }
72
+ else
73
+ format.html { render :action => "edit" }
74
+ format.xml { render :xml => @note.errors, :status => :unprocessable_entity }
75
+ format.fxml { render :fxml => @note.errors }
76
+ end
77
+ end
78
+ end
79
+
80
+ # DELETE /notes/1
81
+ # DELETE /notes/1.xml
82
+ def destroy
83
+ @note = Note.find(params[:id])
84
+ @note.destroy
85
+
86
+ respond_to do |format|
87
+ format.html { redirect_to(notes_url) }
88
+ format.xml { head :ok }
89
+ format.fxml { render :fxml => @note }
90
+ end
91
+ end
92
+
93
+ def empty_params_action
94
+ params = {}
95
+ end
96
+ end