question_chain 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +18 -0
  3. data/Licence.txt +20 -0
  4. data/README.rdoc +34 -0
  5. data/Rakefile +2 -0
  6. data/config/initializers/mustache.rb +2 -0
  7. data/lib/question_chain/answerable.rb +142 -0
  8. data/lib/question_chain/answers.rb +290 -0
  9. data/lib/question_chain/models/answers/question_view.rb +21 -0
  10. data/lib/question_chain/models/answers/ui_object_view.rb +67 -0
  11. data/lib/question_chain/models/answers/ui_objects_check_box_view.rb +17 -0
  12. data/lib/question_chain/models/answers/ui_objects_drop_down_view.rb +16 -0
  13. data/lib/question_chain/models/answers/ui_objects_hidden_field_view.rb +8 -0
  14. data/lib/question_chain/models/answers/ui_objects_object_reference_drop_down_view.rb +18 -0
  15. data/lib/question_chain/models/answers/ui_objects_object_search_view.rb +22 -0
  16. data/lib/question_chain/models/answers/ui_objects_relatable_category_drop_down_view.rb +18 -0
  17. data/lib/question_chain/models/answers/ui_objects_text_field_view.rb +8 -0
  18. data/lib/question_chain/models/chain_template.rb +43 -0
  19. data/lib/question_chain/models/question.rb +37 -0
  20. data/lib/question_chain/models/relatable_category_filter.rb +15 -0
  21. data/lib/question_chain/models/rule.rb +27 -0
  22. data/lib/question_chain/models/rules/attribute_change.rb +28 -0
  23. data/lib/question_chain/models/rules/choice_genenerator.rb +5 -0
  24. data/lib/question_chain/models/rules/populate_drop_down.rb +30 -0
  25. data/lib/question_chain/models/rules/search.rb +19 -0
  26. data/lib/question_chain/models/rules/value_change.rb +22 -0
  27. data/lib/question_chain/models/ui_group.rb +71 -0
  28. data/lib/question_chain/models/ui_object.rb +92 -0
  29. data/lib/question_chain/models/ui_object_answer.rb +17 -0
  30. data/lib/question_chain/models/ui_objects/check_box.rb +8 -0
  31. data/lib/question_chain/models/ui_objects/drop_down.rb +17 -0
  32. data/lib/question_chain/models/ui_objects/hidden_field.rb +5 -0
  33. data/lib/question_chain/models/ui_objects/object_reference_drop_down.rb +67 -0
  34. data/lib/question_chain/models/ui_objects/object_search.rb +44 -0
  35. data/lib/question_chain/models/ui_objects/radio_button.rb +5 -0
  36. data/lib/question_chain/models/ui_objects/radio_button_group.rb +5 -0
  37. data/lib/question_chain/models/ui_objects/relatable_category_drop_down.rb +70 -0
  38. data/lib/question_chain/models/ui_objects/text_field.rb +11 -0
  39. data/lib/question_chain/mongo_serialization.rb +62 -0
  40. data/lib/question_chain/mustache_handler.rb +16 -0
  41. data/lib/question_chain/mustache_rails.rb +50 -0
  42. data/lib/question_chain/state_machine.rb +29 -0
  43. data/lib/question_chain/stored_template.rb +30 -0
  44. data/lib/question_chain/version.rb +3 -0
  45. data/lib/question_chain/views/answers/_edit.html.haml +62 -0
  46. data/lib/question_chain/views/answers/_new.html.haml +62 -0
  47. data/lib/question_chain/views/answers/_question.html.mustache +11 -0
  48. data/lib/question_chain/views/answers/_ui_objects_check_box.html.mustache +19 -0
  49. data/lib/question_chain/views/answers/_ui_objects_drop_down.html.mustache +26 -0
  50. data/lib/question_chain/views/answers/_ui_objects_hidden_field.html.mustache +3 -0
  51. data/lib/question_chain/views/answers/_ui_objects_object_reference_drop_down.html.mustache +27 -0
  52. data/lib/question_chain/views/answers/_ui_objects_object_search.html.mustache +20 -0
  53. data/lib/question_chain/views/answers/_ui_objects_relatable_category_drop_down.html.mustache +26 -0
  54. data/lib/question_chain/views/answers/_ui_objects_text_field.html.mustache +19 -0
  55. data/lib/question_chain/views/layouts/application.html.haml +10 -0
  56. data/lib/question_chain.rb +35 -0
  57. data/question_chain.gemspec +31 -0
  58. data/test_app/.gitignore +4 -0
  59. data/test_app/Gemfile +29 -0
  60. data/test_app/Rakefile +16 -0
  61. data/test_app/app/controllers/answers_controller.rb +13 -0
  62. data/test_app/app/controllers/application_controller.rb +4 -0
  63. data/test_app/app/models/container.rb +10 -0
  64. data/test_app/app/models/flight.rb +20 -0
  65. data/test_app/app/views/answers/edit.html.haml +1 -0
  66. data/test_app/app/views/answers/new.html.haml +1 -0
  67. data/test_app/config/application.rb +18 -0
  68. data/test_app/config/boot.rb +13 -0
  69. data/test_app/config/database.yml +15 -0
  70. data/test_app/config/environment.rb +5 -0
  71. data/test_app/config/initializers/app.rb +5 -0
  72. data/test_app/config/initializers/cookie_verification_secret.rb +7 -0
  73. data/test_app/config/initializers/mongodb.rb +2 -0
  74. data/test_app/config/initializers/session_store.rb +3 -0
  75. data/test_app/config/routes.rb +30 -0
  76. data/test_app/config.ru +2 -0
  77. data/test_app/environments/development.rb +19 -0
  78. data/test_app/environments/test.rb +30 -0
  79. data/test_app/lib/tasks/rspec.rake +69 -0
  80. data/test_app/lib/tasks/yard.rake +4 -0
  81. data/test_app/public/.gitkeep +0 -0
  82. data/test_app/script/rails +10 -0
  83. data/test_app/spec/acceptance/new_spec +30 -0
  84. data/test_app/spec/factories.rb +81 -0
  85. data/test_app/spec/models/chain_template_spec.rb +53 -0
  86. data/test_app/spec/models/flight_spec.rb +101 -0
  87. data/test_app/spec/models/question_spec.rb +13 -0
  88. data/test_app/spec/models/rules/value_change_spec.rb +31 -0
  89. data/test_app/spec/models/ui_group_spec.rb +55 -0
  90. data/test_app/spec/models/ui_object_spec.rb +33 -0
  91. data/test_app/spec/models/ui_objects/drop_down_spec.rb +28 -0
  92. data/test_app/spec/models/ui_objects/relatable_category_drop_down_spec.rb +13 -0
  93. data/test_app/spec/spec_helper.rb +25 -0
  94. metadata +325 -0
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ # @todo should be shared spec
4
+ describe "UiObject" do
5
+ describe "when valiating" do
6
+ before(:each) do
7
+ @ui_object = Factory.build(:ui_object)
8
+ end
9
+
10
+ it "should be cool from the factory" do
11
+ @ui_object.should be_valid
12
+ end
13
+
14
+ it "should be cool to save" do
15
+ @ui_object.save!
16
+ end
17
+
18
+ it "should not be cool without a label" do
19
+ @ui_object.label = nil
20
+ @ui_object.should_not be_valid
21
+ end
22
+
23
+ it "should not be cool if it is not attached group" do
24
+ @ui_object.ui_group_id = nil
25
+ @ui_object.should_not be_valid
26
+ end
27
+
28
+ it "should set default attributes" do
29
+ @ui_object.valid?
30
+ @ui_object.ui_attributes.should == {"visible" => true, "enabled" => true, "value" => ""}
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe "UiObjects::DropDown" do
4
+ describe "when validating" do
5
+ before(:each) do
6
+ @ui_object = Factory(:drop_down)
7
+ end
8
+
9
+ it "should be cool to save" do
10
+ @ui_object.save!
11
+ end
12
+
13
+ it "should be cool from factory" do
14
+ @ui_object.should be_valid
15
+ end
16
+ end
17
+
18
+ describe "when saving and setting ui_attributes" do
19
+ before(:each) do
20
+ @ui_object = Factory(:drop_down, :ui_attributes => {:visible => "false"})
21
+ @ui_object.save!
22
+ end
23
+
24
+ it "should add the ui_attribute along with the defaults" do
25
+ @ui_object.ui_attributes.should == {"visible"=>"false", "enabled"=>true, "value"=>""}
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe "RelatableCategoryDropDown" do
4
+ describe "when validating" do
5
+ before(:each) do
6
+ @rc_drop_down = Factory(:relatable_category_drop_down)
7
+ end
8
+
9
+ it "should be valid from the factory" do
10
+ @rc_drop_down.should be_valid
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+
5
+ # Requires supporting files with custom matchers and macros, etc,
6
+ # in ./support/ and its subdirectories.
7
+ require File.expand_path("../factories", __FILE__)
8
+
9
+ require "database_cleaner"
10
+ DatabaseCleaner[:mongo_mapper].strategy = :truncation
11
+ DatabaseCleaner.clean_with(:truncation)
12
+
13
+ Rspec.configure do |config|
14
+ config.before(:suite) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+
22
+ config.filter_run :focus => true
23
+ config.run_all_when_everything_filtered = true
24
+ config.mock_with :rspec
25
+ end
metadata ADDED
@@ -0,0 +1,325 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: question_chain
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Richard Hooker
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-29 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: mustache
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 98
31
+ - 0
32
+ version: 0.98.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: mongo_mapper
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 8
46
+ - 1
47
+ version: 0.8.1
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: mustache
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 98
61
+ - 0
62
+ version: 0.98.0
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: hashie
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 2
76
+ - 1
77
+ version: 0.2.1
78
+ type: :runtime
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: crack
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ - 1
91
+ - 8
92
+ version: 0.1.8
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: calculated
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ - 1
106
+ - 5
107
+ version: 0.1.5
108
+ type: :runtime
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: rails
112
+ prerelease: false
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ segments:
119
+ - 3
120
+ - 0
121
+ - 0
122
+ version: 3.0.0
123
+ type: :runtime
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: inherited_resources
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ segments:
134
+ - 1
135
+ - 2
136
+ - 0
137
+ version: 1.2.0
138
+ type: :runtime
139
+ version_requirements: *id008
140
+ - !ruby/object:Gem::Dependency
141
+ name: hunt
142
+ prerelease: false
143
+ requirement: &id009 !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ~>
147
+ - !ruby/object:Gem::Version
148
+ segments:
149
+ - 0
150
+ - 3
151
+ - 0
152
+ version: 0.3.0
153
+ type: :runtime
154
+ version_requirements: *id009
155
+ description: Rails3 Gem to Generate Carbon Calculated Application
156
+ email:
157
+ - richard.hooker@carboncalculated.com
158
+ executables: []
159
+
160
+ extensions: []
161
+
162
+ extra_rdoc_files: []
163
+
164
+ files:
165
+ - .gitignore
166
+ - Gemfile
167
+ - Licence.txt
168
+ - README.rdoc
169
+ - Rakefile
170
+ - config/initializers/mustache.rb
171
+ - lib/question_chain.rb
172
+ - lib/question_chain/answerable.rb
173
+ - lib/question_chain/answers.rb
174
+ - lib/question_chain/models/answers/question_view.rb
175
+ - lib/question_chain/models/answers/ui_object_view.rb
176
+ - lib/question_chain/models/answers/ui_objects_check_box_view.rb
177
+ - lib/question_chain/models/answers/ui_objects_drop_down_view.rb
178
+ - lib/question_chain/models/answers/ui_objects_hidden_field_view.rb
179
+ - lib/question_chain/models/answers/ui_objects_object_reference_drop_down_view.rb
180
+ - lib/question_chain/models/answers/ui_objects_object_search_view.rb
181
+ - lib/question_chain/models/answers/ui_objects_relatable_category_drop_down_view.rb
182
+ - lib/question_chain/models/answers/ui_objects_text_field_view.rb
183
+ - lib/question_chain/models/chain_template.rb
184
+ - lib/question_chain/models/question.rb
185
+ - lib/question_chain/models/relatable_category_filter.rb
186
+ - lib/question_chain/models/rule.rb
187
+ - lib/question_chain/models/rules/attribute_change.rb
188
+ - lib/question_chain/models/rules/choice_genenerator.rb
189
+ - lib/question_chain/models/rules/populate_drop_down.rb
190
+ - lib/question_chain/models/rules/search.rb
191
+ - lib/question_chain/models/rules/value_change.rb
192
+ - lib/question_chain/models/ui_group.rb
193
+ - lib/question_chain/models/ui_object.rb
194
+ - lib/question_chain/models/ui_object_answer.rb
195
+ - lib/question_chain/models/ui_objects/check_box.rb
196
+ - lib/question_chain/models/ui_objects/drop_down.rb
197
+ - lib/question_chain/models/ui_objects/hidden_field.rb
198
+ - lib/question_chain/models/ui_objects/object_reference_drop_down.rb
199
+ - lib/question_chain/models/ui_objects/object_search.rb
200
+ - lib/question_chain/models/ui_objects/radio_button.rb
201
+ - lib/question_chain/models/ui_objects/radio_button_group.rb
202
+ - lib/question_chain/models/ui_objects/relatable_category_drop_down.rb
203
+ - lib/question_chain/models/ui_objects/text_field.rb
204
+ - lib/question_chain/mongo_serialization.rb
205
+ - lib/question_chain/mustache_handler.rb
206
+ - lib/question_chain/mustache_rails.rb
207
+ - lib/question_chain/state_machine.rb
208
+ - lib/question_chain/stored_template.rb
209
+ - lib/question_chain/version.rb
210
+ - lib/question_chain/views/answers/_edit.html.haml
211
+ - lib/question_chain/views/answers/_new.html.haml
212
+ - lib/question_chain/views/answers/_question.html.mustache
213
+ - lib/question_chain/views/answers/_ui_objects_check_box.html.mustache
214
+ - lib/question_chain/views/answers/_ui_objects_drop_down.html.mustache
215
+ - lib/question_chain/views/answers/_ui_objects_hidden_field.html.mustache
216
+ - lib/question_chain/views/answers/_ui_objects_object_reference_drop_down.html.mustache
217
+ - lib/question_chain/views/answers/_ui_objects_object_search.html.mustache
218
+ - lib/question_chain/views/answers/_ui_objects_relatable_category_drop_down.html.mustache
219
+ - lib/question_chain/views/answers/_ui_objects_text_field.html.mustache
220
+ - lib/question_chain/views/layouts/application.html.haml
221
+ - question_chain.gemspec
222
+ - test_app/.gitignore
223
+ - test_app/Gemfile
224
+ - test_app/Rakefile
225
+ - test_app/app/controllers/answers_controller.rb
226
+ - test_app/app/controllers/application_controller.rb
227
+ - test_app/app/models/container.rb
228
+ - test_app/app/models/flight.rb
229
+ - test_app/app/views/answers/edit.html.haml
230
+ - test_app/app/views/answers/new.html.haml
231
+ - test_app/config.ru
232
+ - test_app/config/application.rb
233
+ - test_app/config/boot.rb
234
+ - test_app/config/database.yml
235
+ - test_app/config/environment.rb
236
+ - test_app/config/initializers/app.rb
237
+ - test_app/config/initializers/cookie_verification_secret.rb
238
+ - test_app/config/initializers/mongodb.rb
239
+ - test_app/config/initializers/session_store.rb
240
+ - test_app/config/routes.rb
241
+ - test_app/environments/development.rb
242
+ - test_app/environments/test.rb
243
+ - test_app/lib/tasks/rspec.rake
244
+ - test_app/lib/tasks/yard.rake
245
+ - test_app/public/.gitkeep
246
+ - test_app/script/rails
247
+ - test_app/spec/acceptance/new_spec
248
+ - test_app/spec/factories.rb
249
+ - test_app/spec/models/chain_template_spec.rb
250
+ - test_app/spec/models/flight_spec.rb
251
+ - test_app/spec/models/question_spec.rb
252
+ - test_app/spec/models/rules/value_change_spec.rb
253
+ - test_app/spec/models/ui_group_spec.rb
254
+ - test_app/spec/models/ui_object_spec.rb
255
+ - test_app/spec/models/ui_objects/drop_down_spec.rb
256
+ - test_app/spec/models/ui_objects/relatable_category_drop_down_spec.rb
257
+ - test_app/spec/spec_helper.rb
258
+ has_rdoc: true
259
+ homepage: ""
260
+ licenses: []
261
+
262
+ post_install_message:
263
+ rdoc_options: []
264
+
265
+ require_paths:
266
+ - lib
267
+ required_ruby_version: !ruby/object:Gem::Requirement
268
+ none: false
269
+ requirements:
270
+ - - ">="
271
+ - !ruby/object:Gem::Version
272
+ segments:
273
+ - 0
274
+ version: "0"
275
+ required_rubygems_version: !ruby/object:Gem::Requirement
276
+ none: false
277
+ requirements:
278
+ - - ">="
279
+ - !ruby/object:Gem::Version
280
+ segments:
281
+ - 0
282
+ version: "0"
283
+ requirements: []
284
+
285
+ rubyforge_project: question_chain
286
+ rubygems_version: 1.3.7
287
+ signing_key:
288
+ specification_version: 3
289
+ summary: Rails3 Gem to Generate Carbon Calculated Application
290
+ test_files:
291
+ - test_app/Gemfile
292
+ - test_app/Rakefile
293
+ - test_app/app/controllers/answers_controller.rb
294
+ - test_app/app/controllers/application_controller.rb
295
+ - test_app/app/models/container.rb
296
+ - test_app/app/models/flight.rb
297
+ - test_app/app/views/answers/edit.html.haml
298
+ - test_app/app/views/answers/new.html.haml
299
+ - test_app/config.ru
300
+ - test_app/config/application.rb
301
+ - test_app/config/boot.rb
302
+ - test_app/config/database.yml
303
+ - test_app/config/environment.rb
304
+ - test_app/config/initializers/app.rb
305
+ - test_app/config/initializers/cookie_verification_secret.rb
306
+ - test_app/config/initializers/mongodb.rb
307
+ - test_app/config/initializers/session_store.rb
308
+ - test_app/config/routes.rb
309
+ - test_app/environments/development.rb
310
+ - test_app/environments/test.rb
311
+ - test_app/lib/tasks/rspec.rake
312
+ - test_app/lib/tasks/yard.rake
313
+ - test_app/public/.gitkeep
314
+ - test_app/script/rails
315
+ - test_app/spec/acceptance/new_spec
316
+ - test_app/spec/factories.rb
317
+ - test_app/spec/models/chain_template_spec.rb
318
+ - test_app/spec/models/flight_spec.rb
319
+ - test_app/spec/models/question_spec.rb
320
+ - test_app/spec/models/rules/value_change_spec.rb
321
+ - test_app/spec/models/ui_group_spec.rb
322
+ - test_app/spec/models/ui_object_spec.rb
323
+ - test_app/spec/models/ui_objects/drop_down_spec.rb
324
+ - test_app/spec/models/ui_objects/relatable_category_drop_down_spec.rb
325
+ - test_app/spec/spec_helper.rb