riveter 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +147 -0
- data/LICENSE.txt +23 -0
- data/README.md +77 -0
- data/Rakefile +7 -0
- data/app/helpers/riveter/command_form_helper.rb +15 -0
- data/app/helpers/riveter/enquiry_form_helper.rb +16 -0
- data/app/helpers/riveter/query_filter_form_helper.rb +16 -0
- data/config/locales/forms.en.yml +25 -0
- data/config/locales/validators.en.yml +26 -0
- data/init.rb +25 -0
- data/lib/generators/erb/TODO +1 -0
- data/lib/generators/haml/command_controller/USAGE +0 -0
- data/lib/generators/haml/command_controller/command_controller_generator.rb +56 -0
- data/lib/generators/haml/command_controller/templates/new.html.haml +26 -0
- data/lib/generators/haml/enquiry_controller/USAGE +0 -0
- data/lib/generators/haml/enquiry_controller/enquiry_controller_generator.rb +56 -0
- data/lib/generators/haml/enquiry_controller/templates/index.html.haml +57 -0
- data/lib/generators/riveter/command/USAGE +0 -0
- data/lib/generators/riveter/command/command_generator.rb +55 -0
- data/lib/generators/riveter/command/templates/command.rb +40 -0
- data/lib/generators/riveter/command/templates/commands.en.yml +57 -0
- data/lib/generators/riveter/command/templates/module.rb +4 -0
- data/lib/generators/riveter/command_controller/USAGE +0 -0
- data/lib/generators/riveter/command_controller/command_controller_generator.rb +40 -0
- data/lib/generators/riveter/command_controller/templates/command_controller.rb +18 -0
- data/lib/generators/riveter/command_controller/templates/module.rb +4 -0
- data/lib/generators/riveter/enquiry/USAGE +0 -0
- data/lib/generators/riveter/enquiry/enquiry_generator.rb +29 -0
- data/lib/generators/riveter/enquiry/templates/enquiry.rb +11 -0
- data/lib/generators/riveter/enquiry/templates/module.rb +4 -0
- data/lib/generators/riveter/enquiry_controller/USAGE +0 -0
- data/lib/generators/riveter/enquiry_controller/enquiry_controller_generator.rb +34 -0
- data/lib/generators/riveter/enquiry_controller/templates/enquiry_controller.rb +9 -0
- data/lib/generators/riveter/enquiry_controller/templates/module.rb +4 -0
- data/lib/generators/riveter/enum/USAGE +41 -0
- data/lib/generators/riveter/enum/enum_generator.rb +51 -0
- data/lib/generators/riveter/enum/templates/enum.rb +17 -0
- data/lib/generators/riveter/enum/templates/enums.en.yml +35 -0
- data/lib/generators/riveter/enum/templates/module.rb +4 -0
- data/lib/generators/riveter/install/USAGE +0 -0
- data/lib/generators/riveter/install/install_generator.rb +14 -0
- data/lib/generators/riveter/presenter/USAGE +0 -0
- data/lib/generators/riveter/presenter/presenter_generator.rb +20 -0
- data/lib/generators/riveter/presenter/templates/module.rb +4 -0
- data/lib/generators/riveter/presenter/templates/presenter.rb +7 -0
- data/lib/generators/riveter/query/USAGE +22 -0
- data/lib/generators/riveter/query/query_generator.rb +20 -0
- data/lib/generators/riveter/query/templates/module.rb +4 -0
- data/lib/generators/riveter/query/templates/query.rb +31 -0
- data/lib/generators/riveter/query_filter/USAGE +0 -0
- data/lib/generators/riveter/query_filter/query_filter_generator.rb +52 -0
- data/lib/generators/riveter/query_filter/templates/module.rb +4 -0
- data/lib/generators/riveter/query_filter/templates/query_filter.rb +40 -0
- data/lib/generators/riveter/query_filter/templates/query_filters.en.yml +49 -0
- data/lib/generators/riveter/service/USAGE +0 -0
- data/lib/generators/riveter/service/service_generator.rb +20 -0
- data/lib/generators/riveter/service/templates/module.rb +4 -0
- data/lib/generators/riveter/service/templates/service.rb +12 -0
- data/lib/generators/riveter/worker/USAGE +0 -0
- data/lib/generators/riveter/worker/templates/module.rb +4 -0
- data/lib/generators/riveter/worker/templates/worker.rb +7 -0
- data/lib/generators/riveter/worker/worker_generator.rb +20 -0
- data/lib/generators/rspec/command/USAGE +0 -0
- data/lib/generators/rspec/command/command_generator.rb +11 -0
- data/lib/generators/rspec/command/templates/command_spec.rb +8 -0
- data/lib/generators/rspec/command_controller/USAGE +0 -0
- data/lib/generators/rspec/command_controller/command_controller_generator.rb +21 -0
- data/lib/generators/rspec/command_controller/templates/command_controller_spec.rb +70 -0
- data/lib/generators/rspec/enquiry/USAGE +0 -0
- data/lib/generators/rspec/enquiry/enquiry_generator.rb +11 -0
- data/lib/generators/rspec/enquiry/templates/enquiry_spec.rb +69 -0
- data/lib/generators/rspec/enquiry_controller/USAGE +0 -0
- data/lib/generators/rspec/enquiry_controller/enquiry_controller_generator.rb +16 -0
- data/lib/generators/rspec/enquiry_controller/templates/enquiry_controller_spec.rb +32 -0
- data/lib/generators/rspec/enum/USAGE +0 -0
- data/lib/generators/rspec/enum/enum_generator.rb +11 -0
- data/lib/generators/rspec/enum/templates/enum_spec.rb +8 -0
- data/lib/generators/rspec/presenter/USAGE +0 -0
- data/lib/generators/rspec/presenter/presenter_generator.rb +11 -0
- data/lib/generators/rspec/presenter/templates/presenter_spec.rb +8 -0
- data/lib/generators/rspec/query/USAGE +0 -0
- data/lib/generators/rspec/query/query_generator.rb +11 -0
- data/lib/generators/rspec/query/templates/query_spec.rb +41 -0
- data/lib/generators/rspec/query_filter/USAGE +0 -0
- data/lib/generators/rspec/query_filter/query_filter_generator.rb +11 -0
- data/lib/generators/rspec/query_filter/templates/query_filter_spec.rb +8 -0
- data/lib/generators/rspec/service/USAGE +0 -0
- data/lib/generators/rspec/service/service_generator.rb +11 -0
- data/lib/generators/rspec/service/templates/service_spec.rb +8 -0
- data/lib/generators/rspec/worker/USAGE +0 -0
- data/lib/generators/rspec/worker/templates/worker_spec.rb +8 -0
- data/lib/generators/rspec/worker/worker_generator.rb +11 -0
- data/lib/generators/test_unit/TODO +1 -0
- data/lib/riveter/associated_type_registry.rb +63 -0
- data/lib/riveter/attribute_default_values.rb +67 -0
- data/lib/riveter/attributes.rb +443 -0
- data/lib/riveter/booleaness_validator.rb +20 -0
- data/lib/riveter/command.rb +59 -0
- data/lib/riveter/command_controller.rb +93 -0
- data/lib/riveter/command_routes.rb +73 -0
- data/lib/riveter/core_extensions.rb +246 -0
- data/lib/riveter/email_validator.rb +20 -0
- data/lib/riveter/enquiry.rb +137 -0
- data/lib/riveter/enquiry_controller.rb +80 -0
- data/lib/riveter/enquiry_routes.rb +69 -0
- data/lib/riveter/enumerated.rb +107 -0
- data/lib/riveter/errors.rb +11 -0
- data/lib/riveter/form_builder_extensions.rb +21 -0
- data/lib/riveter/hash_with_dependency.rb +12 -0
- data/lib/riveter/presenter.rb +73 -0
- data/lib/riveter/query.rb +45 -0
- data/lib/riveter/query_filter.rb +22 -0
- data/lib/riveter/rails/engine.rb +6 -0
- data/lib/riveter/rails/railtie.rb +50 -0
- data/lib/riveter/service.rb +45 -0
- data/lib/riveter/spec_helper.rb +55 -0
- data/lib/riveter/tasks/.keep +0 -0
- data/lib/riveter/version.rb +3 -0
- data/lib/riveter/worker.rb +20 -0
- data/lib/riveter.rb +47 -0
- data/riveter.gemspec +40 -0
- data/spec/examples/attribute_examples.rb +57 -0
- data/spec/generators/haml/command_controller/command_controller_generator_spec.rb +34 -0
- data/spec/generators/haml/enquiry_controller/enquiry_controller_generator_spec.rb +34 -0
- data/spec/generators/riveter/command/command_generator_spec.rb +58 -0
- data/spec/generators/riveter/command_controller/command_controller_generator_spec.rb +0 -0
- data/spec/generators/riveter/enquiry/enquiry_generator_spec.rb +0 -0
- data/spec/generators/riveter/query_filter/query_filter_generator_spec.rb +58 -0
- data/spec/riveter/associated_type_registry_spec.rb +158 -0
- data/spec/riveter/attribute_default_value_spec.rb +69 -0
- data/spec/riveter/attributes_spec.rb +228 -0
- data/spec/riveter/command_controller_spec.rb +116 -0
- data/spec/riveter/command_routes_spec.rb +116 -0
- data/spec/riveter/command_spec.rb +66 -0
- data/spec/riveter/core_extensions_spec.rb +209 -0
- data/spec/riveter/enquiry_controller_spec.rb +128 -0
- data/spec/riveter/enquiry_routes_spec.rb +101 -0
- data/spec/riveter/enquiry_spec.rb +299 -0
- data/spec/riveter/enumerated_spec.rb +47 -0
- data/spec/riveter/form_builder_extensions_spec.rb +28 -0
- data/spec/riveter/presenter_spec.rb +131 -0
- data/spec/riveter/query_filter_spec.rb +19 -0
- data/spec/riveter/query_spec.rb +72 -0
- data/spec/riveter/service_spec.rb +49 -0
- data/spec/riveter/spec_helper_spec.rb +21 -0
- data/spec/riveter/worker_spec.rb +11 -0
- data/spec/spec_helper.rb +54 -0
- data/spec/support/test_associated_class.rb +2 -0
- data/spec/support/test_class_with_attributes.rb +17 -0
- data/spec/support/test_command.rb +4 -0
- data/spec/support/test_command_controller.rb +12 -0
- data/spec/support/test_command_routes.rb +3 -0
- data/spec/support/test_enquiry.rb +7 -0
- data/spec/support/test_enquiry_controller.rb +12 -0
- data/spec/support/test_enquiry_routes.rb +3 -0
- data/spec/support/test_enum.rb +8 -0
- data/spec/support/test_form_builder.rb +3 -0
- data/spec/support/test_model.rb +2 -0
- data/spec/support/test_model_with_attribute_default_values.rb +29 -0
- data/spec/support/test_presenter.rb +2 -0
- data/spec/support/test_query.rb +5 -0
- data/spec/support/test_query_filter.rb +4 -0
- data/spec/support/test_service.rb +7 -0
- data/spec/support/validate_booleaness_of_matcher.rb +17 -0
- data/spec/support/validate_timeliness_of_matcher.rb +17 -0
- data/spec/support/validator_detector.rb +48 -0
- metadata +487 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9b51c150059867905f381fcd4a303bcae0464683
|
|
4
|
+
data.tar.gz: e2aa27934831b4e6066b63e6c7edc7577beed1cb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 72454455538bb878d56831daf6ec8281e749e0f2118852f4107d2191d2bc656412e8f38e031722a9a9b1be7f8d6df14d77d8250e749c3571104dacfd23908269
|
|
7
|
+
data.tar.gz: 952dc079df4c947453484ab371d8fe1920368d111e23d7c66c0912a3383d05ea8ebae7375b1ef36902cfc01c6c2ce0ec6ed71285947c5ce0d9d797a49c73ee73
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
riveter
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.1.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
riveter (0.0.1)
|
|
5
|
+
actionpack
|
|
6
|
+
activemodel
|
|
7
|
+
activerecord
|
|
8
|
+
activesupport
|
|
9
|
+
railties (~> 4.0.0)
|
|
10
|
+
validates_timeliness
|
|
11
|
+
|
|
12
|
+
GEM
|
|
13
|
+
remote: https://rubygems.org/
|
|
14
|
+
specs:
|
|
15
|
+
actionmailer (4.0.5)
|
|
16
|
+
actionpack (= 4.0.5)
|
|
17
|
+
mail (~> 2.5.4)
|
|
18
|
+
actionpack (4.0.5)
|
|
19
|
+
activesupport (= 4.0.5)
|
|
20
|
+
builder (~> 3.1.0)
|
|
21
|
+
erubis (~> 2.7.0)
|
|
22
|
+
rack (~> 1.5.2)
|
|
23
|
+
rack-test (~> 0.6.2)
|
|
24
|
+
activemodel (4.0.5)
|
|
25
|
+
activesupport (= 4.0.5)
|
|
26
|
+
builder (~> 3.1.0)
|
|
27
|
+
activerecord (4.0.5)
|
|
28
|
+
activemodel (= 4.0.5)
|
|
29
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
|
30
|
+
activesupport (= 4.0.5)
|
|
31
|
+
arel (~> 4.0.0)
|
|
32
|
+
activerecord-deprecated_finders (1.0.3)
|
|
33
|
+
activesupport (4.0.5)
|
|
34
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
35
|
+
minitest (~> 4.2)
|
|
36
|
+
multi_json (~> 1.3)
|
|
37
|
+
thread_safe (~> 0.1)
|
|
38
|
+
tzinfo (~> 0.3.37)
|
|
39
|
+
ammeter (1.0.0)
|
|
40
|
+
activesupport (>= 3.0)
|
|
41
|
+
railties (>= 3.0)
|
|
42
|
+
rspec-rails (>= 2.2)
|
|
43
|
+
arel (4.0.2)
|
|
44
|
+
builder (3.1.4)
|
|
45
|
+
byebug (2.7.0)
|
|
46
|
+
columnize (~> 0.3)
|
|
47
|
+
debugger-linecache (~> 1.2)
|
|
48
|
+
coderay (1.1.0)
|
|
49
|
+
columnize (0.8.9)
|
|
50
|
+
debugger-linecache (1.2.0)
|
|
51
|
+
diff-lcs (1.2.5)
|
|
52
|
+
erubis (2.7.0)
|
|
53
|
+
haml (4.0.5)
|
|
54
|
+
tilt
|
|
55
|
+
haml-rails (0.5.3)
|
|
56
|
+
actionpack (>= 4.0.1)
|
|
57
|
+
activesupport (>= 4.0.1)
|
|
58
|
+
haml (>= 3.1, < 5.0)
|
|
59
|
+
railties (>= 4.0.1)
|
|
60
|
+
hike (1.2.3)
|
|
61
|
+
i18n (0.6.9)
|
|
62
|
+
mail (2.5.4)
|
|
63
|
+
mime-types (~> 1.16)
|
|
64
|
+
treetop (~> 1.4.8)
|
|
65
|
+
method_source (0.8.2)
|
|
66
|
+
mime-types (1.25.1)
|
|
67
|
+
minitest (4.7.5)
|
|
68
|
+
multi_json (1.10.0)
|
|
69
|
+
polyglot (0.3.4)
|
|
70
|
+
pry (0.9.12.6)
|
|
71
|
+
coderay (~> 1.0)
|
|
72
|
+
method_source (~> 0.8)
|
|
73
|
+
slop (~> 3.4)
|
|
74
|
+
pry-byebug (1.3.2)
|
|
75
|
+
byebug (~> 2.7)
|
|
76
|
+
pry (~> 0.9.12)
|
|
77
|
+
rack (1.5.2)
|
|
78
|
+
rack-test (0.6.2)
|
|
79
|
+
rack (>= 1.0)
|
|
80
|
+
rails (4.0.5)
|
|
81
|
+
actionmailer (= 4.0.5)
|
|
82
|
+
actionpack (= 4.0.5)
|
|
83
|
+
activerecord (= 4.0.5)
|
|
84
|
+
activesupport (= 4.0.5)
|
|
85
|
+
bundler (>= 1.3.0, < 2.0)
|
|
86
|
+
railties (= 4.0.5)
|
|
87
|
+
sprockets-rails (~> 2.0.0)
|
|
88
|
+
railties (4.0.5)
|
|
89
|
+
actionpack (= 4.0.5)
|
|
90
|
+
activesupport (= 4.0.5)
|
|
91
|
+
rake (>= 0.8.7)
|
|
92
|
+
thor (>= 0.18.1, < 2.0)
|
|
93
|
+
rake (10.3.1)
|
|
94
|
+
rspec-core (2.14.8)
|
|
95
|
+
rspec-expectations (2.14.5)
|
|
96
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
97
|
+
rspec-mocks (2.14.6)
|
|
98
|
+
rspec-rails (2.14.2)
|
|
99
|
+
actionpack (>= 3.0)
|
|
100
|
+
activemodel (>= 3.0)
|
|
101
|
+
activesupport (>= 3.0)
|
|
102
|
+
railties (>= 3.0)
|
|
103
|
+
rspec-core (~> 2.14.0)
|
|
104
|
+
rspec-expectations (~> 2.14.0)
|
|
105
|
+
rspec-mocks (~> 2.14.0)
|
|
106
|
+
shoulda-matchers (2.6.1)
|
|
107
|
+
activesupport (>= 3.0.0)
|
|
108
|
+
simplecov (0.7.1)
|
|
109
|
+
multi_json (~> 1.0)
|
|
110
|
+
simplecov-html (~> 0.7.1)
|
|
111
|
+
simplecov-html (0.7.1)
|
|
112
|
+
slop (3.5.0)
|
|
113
|
+
sprockets (2.11.0)
|
|
114
|
+
hike (~> 1.2)
|
|
115
|
+
multi_json (~> 1.0)
|
|
116
|
+
rack (~> 1.0)
|
|
117
|
+
tilt (~> 1.1, != 1.3.0)
|
|
118
|
+
sprockets-rails (2.0.1)
|
|
119
|
+
actionpack (>= 3.0)
|
|
120
|
+
activesupport (>= 3.0)
|
|
121
|
+
sprockets (~> 2.8)
|
|
122
|
+
thor (0.19.1)
|
|
123
|
+
thread_safe (0.3.3)
|
|
124
|
+
tilt (1.4.1)
|
|
125
|
+
timeliness (0.3.7)
|
|
126
|
+
treetop (1.4.15)
|
|
127
|
+
polyglot
|
|
128
|
+
polyglot (>= 0.3.1)
|
|
129
|
+
tzinfo (0.3.39)
|
|
130
|
+
validates_timeliness (3.0.14)
|
|
131
|
+
timeliness (~> 0.3.6)
|
|
132
|
+
|
|
133
|
+
PLATFORMS
|
|
134
|
+
ruby
|
|
135
|
+
|
|
136
|
+
DEPENDENCIES
|
|
137
|
+
ammeter
|
|
138
|
+
bundler (~> 1.5)
|
|
139
|
+
haml-rails
|
|
140
|
+
pry
|
|
141
|
+
pry-byebug
|
|
142
|
+
rails (~> 4.0.5)
|
|
143
|
+
rake
|
|
144
|
+
riveter!
|
|
145
|
+
rspec-rails
|
|
146
|
+
shoulda-matchers (~> 2.6.1)
|
|
147
|
+
simplecov (~> 0.7.1)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2014 Chris Stefano
|
|
2
|
+
virtualstaticvoid@gmail.com
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Riveter [](http://travis-ci.org/virtualstaticvoid/riveter) [](https://codeclimate.com/github/virtualstaticvoid/riveter)
|
|
2
|
+
|
|
3
|
+
Provides several useful patterns, packaged in a gem, for use in Rails.
|
|
4
|
+
Includes generators to help you improve consistency in your applications.
|
|
5
|
+
|
|
6
|
+
* Enumerated
|
|
7
|
+
* Query
|
|
8
|
+
* QueryFilter
|
|
9
|
+
* Enquiry
|
|
10
|
+
* EnquiryController
|
|
11
|
+
* Command
|
|
12
|
+
* CommandController
|
|
13
|
+
* Service
|
|
14
|
+
* Presenter
|
|
15
|
+
* Worker
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Add this line to your application's Gemfile:
|
|
20
|
+
|
|
21
|
+
gem 'riveter'
|
|
22
|
+
|
|
23
|
+
And then execute:
|
|
24
|
+
|
|
25
|
+
$ bundle install
|
|
26
|
+
|
|
27
|
+
Or install it yourself as:
|
|
28
|
+
|
|
29
|
+
$ gem install riveter
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Riverter provides generators for creating boilerplate code necessary for each pattern.
|
|
34
|
+
|
|
35
|
+
To get the list of available generators, execute:
|
|
36
|
+
|
|
37
|
+
$ rails generate
|
|
38
|
+
|
|
39
|
+
The generator names are prefixed with `riveter`.
|
|
40
|
+
|
|
41
|
+
E.g.
|
|
42
|
+
|
|
43
|
+
To generate an enquiry controller, query filter, query, views and associated specs, execute:
|
|
44
|
+
|
|
45
|
+
$ rails generate riveter:enquiry SomeEnquiryName filter1:string filter2:integer:required
|
|
46
|
+
|
|
47
|
+
This will create a query with `filter1` string attribute and `filter2` integer attribute, a query, a controller and views:
|
|
48
|
+
|
|
49
|
+
invoke enquiry_controller
|
|
50
|
+
create app/controllers/my_enquiry_name_enquiry_controller.rb
|
|
51
|
+
route enquiry :my_enquiry_name
|
|
52
|
+
invoke haml
|
|
53
|
+
create app/views/my_enquiry_name_enquiry/index.html.haml
|
|
54
|
+
invoke rspec
|
|
55
|
+
create spec/controllers/my_enquiry_name_enquiry_controller_spec.rb
|
|
56
|
+
invoke query
|
|
57
|
+
create app/queries/my_enquiry_name_query.rb
|
|
58
|
+
invoke rspec
|
|
59
|
+
create spec/queries/my_enquiry_name_query_spec.rb
|
|
60
|
+
invoke query_filter
|
|
61
|
+
create app/query_filters/my_enquiry_name_query_filter.rb
|
|
62
|
+
invoke rspec
|
|
63
|
+
create spec/query_filters/my_enquiry_name_query_filter_spec.rb
|
|
64
|
+
create app/enquiries/my_enquiry_name_enquiry.rb
|
|
65
|
+
invoke rspec
|
|
66
|
+
create spec/enquiries/my_enquiry_name_enquiry_spec.rb
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
1. Fork it ( http://github.com/virtualstaticvoid/riveter/fork )
|
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
74
|
+
5. Create new Pull Request
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
Released under the MIT License. See the [LICENSE](LICENSE.txt) file for further details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Riveter
|
|
2
|
+
module CommandFormHelper
|
|
3
|
+
def command_form_for(command, options={}, &block)
|
|
4
|
+
command_class_name = command.class.name.underscore
|
|
5
|
+
options = {
|
|
6
|
+
:as => command_class_name.gsub(/_command$/, ''),
|
|
7
|
+
:url => command_class_name.gsub(/_command$/, '')
|
|
8
|
+
}.merge(options)
|
|
9
|
+
|
|
10
|
+
respond_to?(:simple_form_for) ?
|
|
11
|
+
simple_form_for(command, options, &block) :
|
|
12
|
+
form_for(command, options, &block)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Riveter
|
|
2
|
+
module EnquiryFormHelper
|
|
3
|
+
def enquiry_form_for(enquiry, options={}, &block)
|
|
4
|
+
enquiry_class_name = enquiry.class.name.underscore
|
|
5
|
+
options = {
|
|
6
|
+
:as => enquiry_class_name.gsub(/_enquiry$/, ''),
|
|
7
|
+
:url => enquiry_class_name.gsub(/_enquiry$/, ''),
|
|
8
|
+
:method => :get
|
|
9
|
+
}.merge(options)
|
|
10
|
+
|
|
11
|
+
respond_to?(:simple_form_for) ?
|
|
12
|
+
simple_form_for(enquiry.query_filter, options, &block) :
|
|
13
|
+
form_for(enquiry.query_filter, options, &block)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Riveter
|
|
2
|
+
module QueryFilterFormHelper
|
|
3
|
+
def query_filter_form_for(query_filter, options={}, &block)
|
|
4
|
+
query_filter_class_name = query_filter.class.name.underscore
|
|
5
|
+
options = {
|
|
6
|
+
:as => query_filter_class_name.gsub(/_query_filter$/, ''),
|
|
7
|
+
:url => query_filter_class_name,
|
|
8
|
+
:method => :get
|
|
9
|
+
}.merge(options)
|
|
10
|
+
|
|
11
|
+
respond_to?(:simple_form_for) ?
|
|
12
|
+
simple_form_for(query_filter, options, &block) :
|
|
13
|
+
form_for(query_filter, options, &block)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
|
3
|
+
# than English, add the necessary files in this directory.
|
|
4
|
+
#
|
|
5
|
+
# To use the locales, use `I18n.t`:
|
|
6
|
+
#
|
|
7
|
+
# I18n.t 'hello'
|
|
8
|
+
#
|
|
9
|
+
# In views, this is aliased to just `t`:
|
|
10
|
+
#
|
|
11
|
+
# <%= t('hello') %>
|
|
12
|
+
#
|
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
|
14
|
+
#
|
|
15
|
+
# I18n.locale = :es
|
|
16
|
+
#
|
|
17
|
+
# This would use the information in config/locales/es.yml.
|
|
18
|
+
#
|
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
|
21
|
+
|
|
22
|
+
en:
|
|
23
|
+
forms:
|
|
24
|
+
search: Search
|
|
25
|
+
reset: Reset
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
|
3
|
+
# than English, add the necessary files in this directory.
|
|
4
|
+
#
|
|
5
|
+
# To use the locales, use `I18n.t`:
|
|
6
|
+
#
|
|
7
|
+
# I18n.t 'hello'
|
|
8
|
+
#
|
|
9
|
+
# In views, this is aliased to just `t`:
|
|
10
|
+
#
|
|
11
|
+
# <%= t('hello') %>
|
|
12
|
+
#
|
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
|
14
|
+
#
|
|
15
|
+
# I18n.locale = :es
|
|
16
|
+
#
|
|
17
|
+
# This would use the information in config/locales/es.yml.
|
|
18
|
+
#
|
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
|
21
|
+
|
|
22
|
+
en:
|
|
23
|
+
errors:
|
|
24
|
+
messages:
|
|
25
|
+
booleaness: is not valid
|
|
26
|
+
email: is not valid
|
data/init.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) 2014 Chris Stefano
|
|
2
|
+
# virtualstaticvoid@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# MIT License
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
# a copy of this software and associated documentation files (the
|
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
# the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be
|
|
15
|
+
# included in all copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
|
|
25
|
+
require 'riveter'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Create generators and templates for ERB implementation
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Haml
|
|
2
|
+
module Generators
|
|
3
|
+
class CommandControllerGenerator < ::Rails::Generators::NamedBase
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
|
|
6
|
+
check_class_collision :suffix => 'Command'
|
|
7
|
+
|
|
8
|
+
argument :new_action,
|
|
9
|
+
:type => :string,
|
|
10
|
+
:default => 'new',
|
|
11
|
+
:banner => 'new_action'
|
|
12
|
+
|
|
13
|
+
argument :command_attributes,
|
|
14
|
+
:type => :array,
|
|
15
|
+
:default => [],
|
|
16
|
+
:banner => "[name[:type[:required]] name[:type[:required]]]"
|
|
17
|
+
|
|
18
|
+
def initialize(args, *options)
|
|
19
|
+
super
|
|
20
|
+
parse_command_attributes!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_template_file
|
|
24
|
+
template 'new.html.haml', File.join('app/views', class_path, "#{file_name}_command", "#{new_action}.html.haml")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
|
|
29
|
+
def parse_command_attributes!
|
|
30
|
+
self.command_attributes = (command_attributes || []).map do |attribute|
|
|
31
|
+
# expected in the form "name", "name:type" or "name:type:required"
|
|
32
|
+
parts = attribute.split(':')
|
|
33
|
+
name = parts.first.underscore
|
|
34
|
+
type = ((parts.length > 1) ? parts[1] : 'string')
|
|
35
|
+
|
|
36
|
+
additional_options = case type.to_sym
|
|
37
|
+
when :integer, :decimal, :boolean, :date, :time, :datetime
|
|
38
|
+
", :as => :#{type}"
|
|
39
|
+
when :enum
|
|
40
|
+
", :collection => #{name.titleize}.collection"
|
|
41
|
+
when :model
|
|
42
|
+
", :collection => #{name.titleize}.all"
|
|
43
|
+
else
|
|
44
|
+
''
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
OpenStruct.new(
|
|
48
|
+
:name => name,
|
|
49
|
+
:type => type,
|
|
50
|
+
:inject_options => additional_options
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
%h1 <%= class_name %>Command
|
|
2
|
+
%p Find me in '<%= args.first %>'.
|
|
3
|
+
|
|
4
|
+
= command_form_for(@command, :html => {:class => 'form-vertical'}) do |f|
|
|
5
|
+
<% if defined?(SimpleForm) -%>
|
|
6
|
+
= f.error_notification
|
|
7
|
+
<% else -%>
|
|
8
|
+
- if @command.errors.any?
|
|
9
|
+
#error_explanation
|
|
10
|
+
%h2= "#{pluralize(@command.errors.count, "error")} prohibited performing this action:"
|
|
11
|
+
%ul
|
|
12
|
+
- @command.errors.full_messages.each do |msg|
|
|
13
|
+
%li= msg
|
|
14
|
+
<%end -%>
|
|
15
|
+
|
|
16
|
+
.form-inputs
|
|
17
|
+
<% if command_attributes.any? -%>
|
|
18
|
+
<% command_attributes.each do |attribute| -%>
|
|
19
|
+
= f.input :<%= attribute.name %><%= attribute.inject_options %>
|
|
20
|
+
<% end -%>
|
|
21
|
+
<% else -%>
|
|
22
|
+
-# TODO: provide inputs for each attribute
|
|
23
|
+
<% end -%>
|
|
24
|
+
|
|
25
|
+
.form-actions
|
|
26
|
+
= f.submit
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Haml
|
|
2
|
+
module Generators
|
|
3
|
+
class EnquiryControllerGenerator < ::Rails::Generators::NamedBase
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
|
|
6
|
+
check_class_collision :suffix => 'Enquiry'
|
|
7
|
+
|
|
8
|
+
argument :action_name,
|
|
9
|
+
:type => :string,
|
|
10
|
+
:default => 'index',
|
|
11
|
+
:banner => 'action_name'
|
|
12
|
+
|
|
13
|
+
argument :filter_attributes,
|
|
14
|
+
:type => :array,
|
|
15
|
+
:default => [],
|
|
16
|
+
:banner => "[attribute[:type[:required]] attribute[:type[:required]]]"
|
|
17
|
+
|
|
18
|
+
def initialize(args, *options)
|
|
19
|
+
super
|
|
20
|
+
parse_filter_attributes!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_template_file
|
|
24
|
+
template 'index.html.haml', File.join('app/views', class_path, "#{file_name}_enquiry", "#{action_name}.html.haml")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
|
|
29
|
+
def parse_filter_attributes!
|
|
30
|
+
self.filter_attributes = (filter_attributes || []).map do |attribute|
|
|
31
|
+
# expected in the form "name", "name:type" or "name:type:required"
|
|
32
|
+
parts = attribute.split(':')
|
|
33
|
+
name = parts.first.underscore
|
|
34
|
+
type = ((parts.length > 1) ? parts[1] : 'string')
|
|
35
|
+
|
|
36
|
+
additional_options = case type.to_sym
|
|
37
|
+
when :integer, :decimal, :boolean, :date, :time, :datetime
|
|
38
|
+
", :as => :#{type}"
|
|
39
|
+
when :enum
|
|
40
|
+
", :collection => #{name.titleize}.collection"
|
|
41
|
+
when :model
|
|
42
|
+
", :collection => #{name.titleize}.all"
|
|
43
|
+
else
|
|
44
|
+
''
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
OpenStruct.new(
|
|
48
|
+
:name => name,
|
|
49
|
+
:type => type,
|
|
50
|
+
:inject_options => additional_options
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
%h1 <%= class_name %>Enquiry
|
|
2
|
+
%p Find me in '<%= args.first %>'.
|
|
3
|
+
|
|
4
|
+
.filter
|
|
5
|
+
|
|
6
|
+
%h2 Search
|
|
7
|
+
|
|
8
|
+
= enquiry_form_for(@enquiry, :html => {:class => 'form-horizontal'}) do |f|
|
|
9
|
+
<% if defined?(SimpleForm) -%>
|
|
10
|
+
= f.error_notification
|
|
11
|
+
<% else -%>
|
|
12
|
+
- if f.object.errors.any?
|
|
13
|
+
#error_explanation
|
|
14
|
+
%h2= "#{pluralize(f.object.errors.count, "error")} prohibited performing this enquiry:"
|
|
15
|
+
%ul
|
|
16
|
+
- f.object.errors.full_messages.each do |msg|
|
|
17
|
+
%li= msg
|
|
18
|
+
<%end -%>
|
|
19
|
+
|
|
20
|
+
.form-inputs
|
|
21
|
+
<% if filter_attributes.any? -%>
|
|
22
|
+
<% filter_attributes.each do |attribute| -%>
|
|
23
|
+
= f.input :<%= attribute.name %><%= attribute.inject_options %>
|
|
24
|
+
<% end -%>
|
|
25
|
+
<% else -%>
|
|
26
|
+
-# TODO: provide inputs for each attribute
|
|
27
|
+
<% end -%>
|
|
28
|
+
|
|
29
|
+
.form-actions
|
|
30
|
+
= f.submit
|
|
31
|
+
= f.reset
|
|
32
|
+
|
|
33
|
+
.results
|
|
34
|
+
|
|
35
|
+
%h2 Listing <%= class_name.underscore.humanize.pluralize %>
|
|
36
|
+
|
|
37
|
+
%table.table.table-bordered
|
|
38
|
+
%tr
|
|
39
|
+
%th Col1
|
|
40
|
+
%th Col2
|
|
41
|
+
|
|
42
|
+
- unless @enquiry.has_data?
|
|
43
|
+
%tr
|
|
44
|
+
%td(colspan="2")
|
|
45
|
+
.no-data-message Invalid criteria or no items found...
|
|
46
|
+
- else
|
|
47
|
+
- @enquiry.find_each do |result|
|
|
48
|
+
%tr
|
|
49
|
+
%td= result.col1
|
|
50
|
+
%td= result.col2
|
|
51
|
+
|
|
52
|
+
- if @enquiry.has_data?
|
|
53
|
+
<% if defined?(Kaminari) -%>
|
|
54
|
+
= paginate @enquiry.query.relation
|
|
55
|
+
<% else -%>
|
|
56
|
+
-# TODO: provide pagination outputs against `@enquiry.query.relation`
|
|
57
|
+
<% end -%>
|
|
File without changes
|