surveyor 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +26 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.rails_version +13 -0
  4. data/README.md +40 -22
  5. data/Rakefile +92 -29
  6. data/app/helpers/survey_form_builder.rb +37 -0
  7. data/app/helpers/surveyor_helper.rb +9 -9
  8. data/app/views/partials/_answer.html.haml +1 -1
  9. data/app/views/partials/_question.html.haml +3 -3
  10. data/app/views/partials/_question_group.html.haml +2 -2
  11. data/app/views/partials/_section.html.haml +1 -1
  12. data/app/views/surveyor/edit.html.haml +11 -3
  13. data/app/views/surveyor/new.html.haml +8 -1
  14. data/ci-exec.sh +50 -0
  15. data/config/routes.rb +9 -13
  16. data/cucumber.yml +10 -0
  17. data/doc/question types.png +0 -0
  18. data/features/redcap_parser.feature +1 -1
  19. data/features/step_definitions/common_setps.rb +3 -0
  20. data/features/step_definitions/parser_steps.rb +8 -1
  21. data/features/step_definitions/surveyor_steps.rb +33 -9
  22. data/features/step_definitions/web_steps.rb +85 -165
  23. data/features/support/env.rb +40 -46
  24. data/features/support/paths.rb +4 -4
  25. data/features/support/selectors.rb +39 -0
  26. data/features/surveyor.feature +63 -13
  27. data/features/surveyor_dependencies.feature +289 -0
  28. data/features/surveyor_parser.feature +29 -20
  29. data/lib/formtastic/surveyor_builder.rb +9 -9
  30. data/lib/generators/surveyor/custom_generator.rb +17 -0
  31. data/lib/generators/surveyor/install_generator.rb +50 -0
  32. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/controllers}/surveyor_controller.rb +0 -0
  33. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/views/layouts}/surveyor_custom.html.erb +0 -0
  34. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_en.yml +0 -0
  35. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_es.yml +0 -0
  36. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_he.yml +0 -0
  37. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_api_ids.rb +0 -0
  38. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_correct_answer_id_to_questions.rb +0 -0
  39. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_default_value_to_answers.rb +0 -0
  40. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_order_to_surveys.rb +0 -0
  41. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_type_to_answers.rb +0 -0
  42. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_response_sets.rb +0 -0
  43. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_surveys.rb +0 -0
  44. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_section_id_to_responses.rb +0 -0
  45. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_unique_indicies.rb +0 -0
  46. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_answers.rb +0 -0
  47. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependencies.rb +0 -0
  48. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependency_conditions.rb +0 -0
  49. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_question_groups.rb +0 -0
  50. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_questions.rb +0 -0
  51. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_response_sets.rb +0 -0
  52. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_responses.rb +0 -0
  53. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_survey_sections.rb +0 -0
  54. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_surveys.rb +0 -0
  55. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validation_conditions.rb +0 -0
  56. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validations.rb +0 -0
  57. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/next.gif +0 -0
  58. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/prev.gif +0 -0
  59. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +499 -0
  60. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.surveyor.js +47 -4
  61. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.tools.min.js +0 -0
  62. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/custom.sass +0 -0
  63. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/surveyor.sass +2 -2
  64. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/dateinput.css +0 -0
  65. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/reset.css +0 -0
  66. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/results.css +0 -0
  67. data/{generators/extend_surveyor/templates/EXTENDING_SURVEYOR → lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md} +0 -0
  68. data/{generators → lib/generators}/surveyor/templates/surveys/kitchen_sink_survey.rb +0 -0
  69. data/{generators → lib/generators}/surveyor/templates/surveys/quiz.rb +0 -0
  70. data/lib/surveyor.rb +7 -0
  71. data/lib/surveyor/engine.rb +12 -0
  72. data/lib/surveyor/models/answer_methods.rb +0 -1
  73. data/lib/surveyor/models/dependency_condition_methods.rb +1 -3
  74. data/lib/surveyor/models/question_methods.rb +0 -1
  75. data/lib/surveyor/models/response_methods.rb +2 -2
  76. data/lib/surveyor/models/response_set_methods.rb +30 -14
  77. data/lib/surveyor/models/survey_methods.rb +2 -1
  78. data/lib/surveyor/models/survey_section_methods.rb +1 -2
  79. data/lib/surveyor/parser.rb +9 -7
  80. data/lib/surveyor/redcap_parser.rb +10 -7
  81. data/lib/surveyor/surveyor_controller_methods.rb +45 -11
  82. data/lib/surveyor/version.rb +3 -0
  83. data/lib/tasks/surveyor_tasks.rake +2 -2
  84. data/rails/init.rb +0 -1
  85. data/spec/controllers/surveyor_controller_spec.rb +81 -35
  86. data/spec/helpers/surveyor_helper_spec.rb +7 -1
  87. data/spec/models/dependency_condition_spec.rb +76 -63
  88. data/spec/models/response_set_spec.rb +52 -47
  89. data/spec/models/response_spec.rb +19 -16
  90. data/spec/spec_helper.rb +21 -44
  91. data/surveyor.gemspec +25 -176
  92. metadata +302 -77
  93. data/CHANGELOG +0 -335
  94. data/VERSION +0 -1
  95. data/ci-env.sh +0 -29
  96. data/generators/extend_surveyor/extend_surveyor_generator.rb +0 -21
  97. data/generators/surveyor/surveyor_generator.rb +0 -69
  98. data/generators/surveyor/templates/README +0 -10
  99. data/generators/surveyor/templates/tasks/surveyor.rb +0 -4
  100. data/hudson.rakefile +0 -33
  101. data/init_testbed.rakefile +0 -55
  102. data/testbed/Gemfile +0 -13
data/CHANGELOG DELETED
@@ -1,335 +0,0 @@
1
- 0.20.0
2
-
3
- * allow answers to be images. closes #171
4
- * moving from answer.hide_label => true to answer.display_type => 'hidden_label'
5
- * don't parse redcap formulas. really closes #179
6
- * allow more of less whitespace in answer options. closes #179
7
- * fixing date, time, and datetime saving via ajax. closes #133
8
- * not using separate gemset, using passenger in development
9
- * fixed an issue where the last date was sent instead of the currently choosen date for a date field
10
- * Save grid responses and ids. Closes #161
11
- * dropdowns should save their response ids. closes #180
12
- * README should reflect that it is 2011
13
- * separate file for custom css and gem upgrade message. closes #151
14
- * benchmarking surveyor dump for #166
15
- * two-lettered rule keys. this one actually closes #159
16
- * two-lettered rule keys. closes #159
17
- * fix parsing of question and answer references with q_ and a_ in their names. closes #170
18
- * more redcap branching logic. closes #177
19
- * dynamically require some columns. closes #178
20
- * Fixes problem with updating checkboxes on postgers.
21
- * Fix problem when calling Answer.exists?('') under postgers.
22
-
23
- 0.19.7
24
-
25
- * fix accidentally allowing through blank pick => any answers
26
- * rewrote a test to reflect re-saving a survey via an admin controller
27
- * stop survey titles from appending '1' to itself when calling update attributes
28
- * fix response saving and dependencies on pick one/many with string. closes #158
29
- * changed fastercsv to csv for ruby 1.9. closes #111
30
- * changed .to_s to .join for ruby 1.9
31
- * Merge pull request #137 from keviniano/master
32
- * surveyor models
33
-
34
- 0.19.6
35
-
36
- * fix parsing of group questions with dependencies. closes #160
37
- * update homepage
38
- * lock ci to ree-1.8.7-2010.02
39
- * Fixed safari issue with conditional questions not hiding/showing.
40
- * add checkbox + text renderer. closes #107
41
- * add sass, since Haml will no longer do so
42
- * adjusting testbed cucumber to avoid 'uninitialized constant Gherkin::Formatter::Model::PyString' error
43
- * Fixed error when user answers a checkbox question.
44
-
45
- 0.19.5
46
-
47
- * Fixed dependent questions not appearing under certain conditions. Closes #143.
48
- * Fixed question grids not showing when dependent on another question. Closes #149.
49
- * Fixed testbed generation failure. Closes #145.
50
- * Fixed UUID errors. Closes #144.
51
-
52
- 0.19.4
53
-
54
- * add api ids
55
- * Saving response set completion time when a survey is finished.
56
- * Fixed pick one and pick any not saving when an answer of type string exists within the options.
57
- * Fixed problem with dropdowns inside of repeaters appearing as radio buttons.
58
- * Updated method to get unanswered dependencies within ResultSet to also return question groups.
59
- * Added a conditional question group to the kitchen sink survey.
60
- * add support for question reference syntax in redcap parser. closes #124
61
- * adding checkbox grid to kitchen sink
62
- * hide labels on checkbox grids too. closes #121. thanks jdzak
63
-
64
- 0.19.3
65
-
66
- * add authenticity token into ajax requests. closes #120
67
- * Adding the custom_class attribute to text answer fields. Fixes #113.
68
- * reverting some styles
69
- * Add padding to dependent questions
70
- * Change colors in surveyor.sass
71
- * Fix dependent questions css and alternate column color in grid questions
72
-
73
- 0.19.2
74
-
75
- * quiz example
76
- * support correct answers for quizes through dsl. closes #105
77
- * test dependency issues. closes #73
78
- * fixing feature, section menu doens't appear until three sections exist
79
- * fixing default values to only appear when response is blank
80
- * fixing typo in specs. fixing cucumber on hudson due to residual objects in db from specs
81
- * tweak to check hudson cucumber issue
82
- * added dump rake task. thanks bnadav. closes #100
83
-
84
- 0.19.1
85
-
86
- * require formtastic. closes #104
87
- * new custom layout to match surveyor layout changes
88
-
89
- 0.19.0
90
-
91
- * reload to correctly calculate dependencies
92
- * date picker. closes #58
93
- * hide section menu for fewer than three sections
94
- * cleaning up features from merge
95
- * correcing spec to reject blank radio responses. fixing response set spec
96
- * modifications for repeaters and response groups
97
- * merge formtastic
98
- * default value for pick none answers. closes #103.
99
- * view changes and updates.
100
-
101
- 0.18.2
102
-
103
- * redcap text and string answers. closes #99
104
- * return survey objects from parsers. closes #98
105
- * delete survey components when deleting survey. closes #97
106
-
107
- 0.18.1
108
-
109
- * group dependencies. closes #96
110
- * fixing grid answers error with parser. closes #95
111
- * prevent double inclusion of validations
112
- * cleaner setup for hudson
113
- * only resolve dependencies during redcap parsing
114
- * forgot to uncomment
115
- * fix hudson env setup
116
- * setup hudson env after rails
117
- * add hudson env to testbed init
118
- * ci setup
119
- * changing path for features files with new testbed
120
- * don't double include model methods in unparser
121
- * new testbed setup
122
- * don't double include model methods in unparser
123
- * don't double include model methods in redcap parser
124
- * don't double include model methods
125
-
126
- 0.18.0
127
-
128
- * finalizing redcap feature. parse dependencies. closes #93
129
- * finished decomposing redcap branching logic rules
130
- * working on redcap parser spec, question/answer reference lookup table
131
- * skipping calcuated answers for now
132
- * validations
133
- * more progress on redcap parser
134
- * working on redcap parser
135
-
136
- 0.17.0
137
-
138
- * cucumber tests now work
139
- * correction to post install notes in rakefile
140
- * fix to rakefile instructions
141
- * un-dryed the gemfile to try to fix a gem location problem
142
- * added test boot file for test app usage, modified the rake task to copy in this file as well
143
- * removed unparser from specs, it was breakin a bunch of them. deferred investigation
144
- * got specs running and passing by adding internal rails app
145
- * added rvmrc to create default gemset and added bundler
146
- * Plugin installation is no longer supported
147
- * wrong information in readme
148
- * Merge branch 'master' into issue87
149
- * Add count operator example to kitchen sink survey
150
- * Generalize count operator to handle < <= >= !=
151
- * Parse/unparse surveys w/ count> DC operator
152
- * Add custom validation to handle count operator
153
- * Remove count> "operator."
154
-
155
- 0.16.1
156
-
157
- * fixed surveyor.sections translation line
158
- * changed map resources order to access results survey success
159
- * add translations for Sections title
160
- * Add I18n to Sections title
161
- * updated date on license
162
- * updating results views and controller for new paths
163
- * new results routes
164
-
165
- 0.16.0
166
-
167
- * minor fixes to unparsing
168
- * refining unparser. added rake task to unparse survey. closes #79
169
- * unparsing for groups, dependencies, validations
170
- * starting work on unparser for basic survey, section and question.
171
-
172
- 0.15.0
173
-
174
- * prevent duplicate survey titles by appending incrementing numbers
175
- * rake task to remove a survey. closes #64
176
- * cleanup of old parsing strategy
177
- * features and specs and new parser. closes #62
178
- * first test driven work on parser
179
- * moving parser and common specs so they run automatically. fixing some spec errors
180
- * first shot a surveyor parser. some parts untested, but coded to determine style. references #62
181
- * refactoring counters
182
- * fixing failing specs. fixes acts\_as\_response issues
183
-
184
- 0.14.5
185
-
186
- * use modules to include model methods. re-closes #77
187
- * rails init. destroy dependent models
188
-
189
- 0.14.4
190
-
191
- * explicitly require surveyor models and helper. update sweeper syntax. closes #77
192
- * cleanup and requires
193
- * fixing instructions for extending surveyor. closes #76
194
-
195
- 0.14.3
196
-
197
- * remove manual numbering until it works. refactoring to use common methods.
198
-
199
- 0.14.2
200
-
201
- * lowercase localization. feature instead of story in cucumber feature
202
- * add results section
203
- * add simple admin section for displaying survey result set
204
- * Added manual numbering to labels as well
205
-
206
- 0.14.1
207
-
208
- * typo in repeaters - use survey\_section\_id instead of section\_id
209
-
210
- 0.14.0
211
-
212
- * view my survey specs fixed, fragment caching for surveyor#edit, localization. thanks bnadav
213
-
214
- 0.13.0
215
-
216
- * simpler customization of surveyor.
217
- * spec plugins task
218
- * Feature instead of Story for cucumber. http://wiki.github.com/aslakhellesoy/cucumber/upgrading
219
-
220
- 0.12.0
221
-
222
- * fix parser error in ruby 1.9, where instance_variables are symbols. closes #61
223
- * added fastercsv as dependency. closes #59
224
- * typo fix and test
225
- * fixed broken spec for survey urls, made pending surveyor_controller specs pass
226
- * Added explicit dependencycondition and validationcondition to DSL
227
- * have authentication work with authlogic
228
- * added "correct_answer" to parser, so you can specify one correct answer per question
229
-
230
- 0.11.0
231
-
232
- * basic csv export. closes #21
233
- * add unique indicies. closes #45
234
- * add one_integer renderer. closes #51
235
- * constrain surveys to have unique access_codes. closes #45. closes #42
236
- * covering the extremely unlikely case that response_sets may have a non-unique access_code. closes #46. thanks jakewendt.
237
- * current user id not needed in the view, set in SurveyorController. closes #48. thanks jakewendt
238
-
239
- 0.10.0
240
-
241
- * surveyor config['extend'] is now an array. custom modules (e.g. SurveyExtensions are now included from within surveyor models, allowing
242
- the customizations to work on every request in development. closes #39. thanks to mgurley and jakewendt for the suggestions.
243
- * remove comment from surveyor_includes
244
- * css tweak
245
- * automatically add backslashes and eliminate multiple backslashes in relative root for routes
246
- * readme spelling and line breaks
247
- * fixing a failing spec with factory instead of mock parent model
248
- * upgrading cucumber to 0.6
249
-
250
- 0.9.11
251
-
252
- * adding rails init.rb to make gem loading work. thanks mike gurley. closes #52.
253
- * Repeater changed to only have +1, not +3 as previous
254
- * added locking and transaction to surveyor update action. Prevents bug that caused duplicated answers
255
- * some light re-factoring and code readability changes
256
- * some code formatting changes
257
- * added require statement to specs so the factory_girl test dependency was more clear
258
- * spiced up the readme... may have some typos
259
- * readme update
260
-
261
- 0.9.10
262
-
263
- * styles, adding labels for dates, correcting labels for radio buttons
264
-
265
- 0.9.9
266
-
267
- * count label and image questions complete when mandatory. closes #38
268
- * validate by other responses. closes #35
269
-
270
- 0.9.8
271
-
272
- * @current\_user.id if @current\_user isn't nil. Closes #37
273
-
274
- 0.9.7
275
-
276
- * fixing typos
277
- * remove surveyor controller from load\_once\_paths. fixes issue with dependencies and unloading in development. closes #36
278
-
279
- 0.9.6
280
-
281
- * response set reports progress and mandatory questions completeness. closes #33
282
- * adding correctness to response sets
283
- * adding correctness to responses
284
-
285
- 0.9.5
286
-
287
- * allow append for survey parser. closes #32
288
-
289
- 0.9.4
290
-
291
- * making tinycode compatible with ruby 1.8.6
292
-
293
- 0.9.3
294
-
295
- * fix for survey parser require
296
-
297
- 0.9.2
298
-
299
- * fixing specs for namespacing and move of tinycode
300
- * namespacing SurveyParser models to avoid conflict with model extensions
301
-
302
- 0.9.1
303
-
304
- * fix for tinycode, more descriptive missing method
305
-
306
- 0.9.0
307
-
308
- * validations in dsl and surveyor models
309
- * preserve underscores in reference identifiers
310
- * dsl specs, refactoring into base class
311
- * adding display order to surveys
312
- * moving columnizer and tiny column functionality to surveyor module
313
- * columnizer (and tiny code) refactoring, columnizer spec extracted from answer spec
314
- * cleanup of scopes with joins
315
- * refactoring dependency
316
-
317
- 0.8.0
318
-
319
- * question group dependencies
320
- * expanded examples in kitchen sink survey
321
- * specs
322
-
323
- 0.7.1
324
-
325
- * custom index page
326
- * custom classes and renderers
327
- * fixing typo in kitchen sink survey
328
-
329
- 0.7.0
330
-
331
- * new kitchen sink survey with better documentation of DSL
332
- * migration misspelling
333
- * fixing ordering, dependency conditions evaluation, and changing named scopes for now
334
- * DRYing up surveyor DSL models
335
- * working on adding dependencies for question groups
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.20.0
data/ci-env.sh DELETED
@@ -1,29 +0,0 @@
1
- ######
2
- # This is not an executable script. It selects and configures rvm for
3
- # bcsec's CI process based on the RVM_RUBY environment variable.
4
- #
5
- # Use it by sourcing it:
6
- #
7
- # . ci-env.sh
8
- #
9
- # Assumes that the create-on-use settings are set in your ~/.rvmrc:
10
- #
11
- # rvm_install_on_use_flag=1
12
- # rvm_gemset_create_on_use_flag=1
13
- #
14
- # Hudson Build Execute Shell Commands:
15
- #
16
- # source ci-env.sh
17
- # rake -f hudson.rakefile --trace
18
- # cd testbed
19
- # export RAILS_ENV="hudson"
20
- # bundle exec rake spec cucumber
21
-
22
- export rvm_gemset_create_on_use_flag=1
23
- export rvm_project_rvmrc=0
24
-
25
- set +xe
26
- echo "Loading RVM ree@surveyor-dev"
27
- source ~/.rvm/scripts/rvm
28
- rvm use ree-1.8.7-2010.02@surveyor-dev
29
- set -xe
@@ -1,21 +0,0 @@
1
- class ExtendSurveyorGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
-
5
- # Copy README to your app
6
- m.file "EXTENDING_SURVEYOR", "surveys/EXTENDING_SURVEYOR"
7
-
8
- # Custom layout
9
- m.directory "app/views/layouts"
10
- m.file "extensions/surveyor_custom.html.erb", "app/views/layouts/surveyor_custom.html.erb"
11
-
12
- # Model, helper, and controller extensions
13
- # http://www.redmine.org/boards/3/topics/4095#message-4136
14
- # http://blog.mattwynne.net/2009/07/11/rails-tip-use-polymorphism-to-extend-your-controllers-at-runtime/
15
- m.file "extensions/surveyor_controller.rb", "app/controllers/surveyor_controller.rb"
16
-
17
- m.readme "EXTENDING_SURVEYOR"
18
-
19
- end
20
- end
21
- end
@@ -1,69 +0,0 @@
1
- class SurveyorGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
-
5
- m.directory "surveys"
6
-
7
- # Copy README to your app
8
- # m.file "../../../README.md", "surveys/README.md"
9
-
10
- # Gem plugin rake tasks
11
- m.file "tasks/surveyor.rb", "lib/tasks/surveyor.rb"
12
- if file_has_line(destination_path('Rakefile'), /^require 'tasks\/surveyor'$/ )
13
- logger.skipped 'Rakefile'
14
- else
15
- File.open(destination_path('Rakefile'), 'ab') {|file| file.write("\nrequire 'tasks/surveyor'\n") }
16
- # http://ggr.com/how-to-include-a-gems-rake-tasks-in-your-rails-app.html
17
- logger.appended 'Rakefile'
18
- end
19
-
20
- # Migrate
21
- # not using m.migration_template because all migration timestamps end up the same, causing a collision when running rake db:migrate
22
- # coped functionality from RAILS_GEM_PATH/lib/rails_generator/commands.rb
23
- m.directory "db/migrate"
24
- [ "create_surveys", "create_survey_sections", "create_questions", "create_question_groups", "create_answers",
25
- "create_response_sets", "create_responses",
26
- "create_dependencies", "create_dependency_conditions",
27
- "create_validations", "create_validation_conditions",
28
- "add_display_order_to_surveys", "add_correct_answer_id_to_questions",
29
- "add_index_to_response_sets", "add_index_to_surveys",
30
- "add_unique_indicies", "add_section_id_to_responses",
31
- "add_default_value_to_answers", "add_api_ids",
32
- "add_display_type_to_answers"].each_with_index do |model, i|
33
- unless (prev_migrations = Dir.glob("db/migrate/[0-9]*_*.rb").grep(/[0-9]+_#{model}.rb$/)).empty?
34
- prev_migration_timestamp = prev_migrations[0].match(/([0-9]+)_#{model}.rb$/)[1]
35
- end
36
- # raise "Another migration is already named #{model}" if not Dir.glob("db/migrate/[0-9]*_*.rb").grep(/[0-9]+_#{model}.rb$/).empty?
37
- m.template("migrate/#{model}.rb", "db/migrate/#{(prev_migration_timestamp || Time.now.utc.strftime("%Y%m%d%H%M%S").to_i + i).to_s}_#{model}.rb")
38
- end
39
-
40
- # Assets
41
- ["images", "javascripts", "stylesheets"].each do |asset_type|
42
- m.directory "public/#{asset_type}/surveyor"
43
- Dir.glob(File.join(File.dirname(__FILE__), "templates", "assets", asset_type, "*.*")).map{|path| File.basename(path)}.each do |filename|
44
- m.file "assets/#{asset_type}/#{filename}", "public/#{asset_type}/surveyor/#{filename}"
45
- end
46
- end
47
- m.directory "public/stylesheets/sass"
48
- m.file "assets/stylesheets/sass/surveyor.sass", "public/stylesheets/sass/surveyor.sass"
49
- m.file "assets/stylesheets/sass/custom.sass", "public/stylesheets/sass/custom.sass"
50
-
51
- # Locales
52
- m.directory "config/locales"
53
- Dir.glob(File.join(File.dirname(__FILE__), "templates", "locales", "*.yml")).map{|path| File.basename(path)}.each do |filename|
54
- m.file "locales/#{filename}", "config/locales/#{filename}"
55
- end
56
-
57
- # Surveys
58
- m.file "surveys/kitchen_sink_survey.rb", "surveys/kitchen_sink_survey.rb"
59
- m.file "surveys/quiz.rb", "surveys/quiz.rb"
60
-
61
- m.readme "README"
62
-
63
- end
64
- end
65
- def file_has_line(filename, rxp)
66
- File.readlines(filename).each{ |line| return true if line =~ rxp }
67
- false
68
- end
69
- end