katapult 0.2.0 → 0.3.0
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 +5 -5
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +9 -0
- data/README.md +122 -94
- data/Rakefile +13 -0
- data/bin/katapult +59 -25
- data/features/application_model.feature +55 -0
- data/features/authenticate.feature +88 -62
- data/features/basics.feature +64 -402
- data/features/binary.feature +56 -42
- data/features/configuration.feature +4 -4
- data/features/model.feature +21 -30
- data/features/navigation.feature +35 -48
- data/features/step_definitions/aruba_steps.rb +3 -0
- data/features/step_definitions/katapult_steps.rb +307 -8
- data/features/step_definitions/rails_steps.rb +74 -14
- data/features/step_definitions/test_steps.rb +5 -5
- data/features/step_definitions/version_steps.rb +22 -0
- data/features/support/env.rb +11 -3
- data/features/{wui.feature → web_ui.feature} +175 -148
- data/katapult.gemspec +8 -13
- data/lib/generators/katapult/app_model/app_model_generator.rb +12 -0
- data/lib/generators/katapult/app_model/templates/lib/katapult/application_model.rb +40 -0
- data/lib/generators/katapult/basics/basics_generator.rb +186 -51
- data/lib/generators/katapult/basics/templates/.browserslistrc +1 -0
- data/lib/generators/katapult/basics/templates/.gitignore +20 -21
- data/lib/generators/katapult/basics/templates/.rspec_parallel +3 -0
- data/lib/generators/katapult/basics/templates/Capfile +5 -1
- data/lib/generators/katapult/basics/templates/Gemfile +23 -34
- data/lib/generators/katapult/basics/templates/Guardfile +0 -12
- data/lib/generators/katapult/basics/templates/app/controllers/errors_controller.rb +9 -0
- data/lib/generators/katapult/basics/templates/app/helpers/unpoly_helper.rb +13 -0
- data/lib/generators/katapult/{haml → basics}/templates/app/views/layouts/_flashes.html.haml +1 -1
- data/lib/generators/katapult/basics/templates/app/views/layouts/_menu_bar.html.haml.tt +12 -0
- data/lib/generators/katapult/basics/templates/app/views/layouts/application.html.haml.tt +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/images/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/index.js +16 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/application.js +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/bootstrap.js +12 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/compilers/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/content_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/modal_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/unpoly.js +9 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_definitions.sass +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_environment.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_mixins.sass +3 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/blocks/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/custom_bootstrap.sass +50 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/bootstrap/navbar.sass +83 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/theme.sass +11 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/unpoly.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/packs/application.js +13 -0
- data/lib/generators/katapult/basics/templates/config/database.sample.yml +1 -1
- data/lib/generators/katapult/basics/templates/config/deploy.rb +3 -4
- data/lib/generators/katapult/basics/templates/config/environments/staging.rb +5 -0
- data/lib/generators/katapult/basics/templates/config/initializers/better_errors.rb +23 -0
- data/lib/generators/katapult/basics/templates/config/initializers/exception_notification.rb.tt +1 -1
- data/lib/generators/katapult/basics/templates/config/initializers/ext.rb +1 -1
- data/lib/generators/katapult/basics/templates/config/webpack/loaders/unpoly.js +4 -0
- data/lib/generators/katapult/basics/templates/features/support/capybara_screenshot.rb +7 -0
- data/lib/generators/katapult/basics/templates/features/support/factory_bot.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/paths.rb +7 -2
- data/lib/generators/katapult/basics/templates/features/support/rspec_doubles.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/selectors.rb +3 -3
- data/lib/generators/katapult/basics/templates/features/support/selenium.rb +13 -0
- data/lib/generators/katapult/basics/templates/features/support/{env-custom.rb → spreewald.rb} +0 -0
- data/lib/generators/katapult/basics/templates/features/support/webpacker.rb +35 -0
- data/lib/generators/katapult/basics/templates/lib/ext/action_view/form_for_with_development_errors.rb +31 -31
- data/lib/generators/katapult/basics/templates/lib/ext/active_record/find_by_anything.rb +4 -3
- data/lib/generators/katapult/basics/templates/public/robots.txt +5 -0
- data/lib/generators/katapult/basics/templates/spec/assets/sample.pdf +0 -0
- data/lib/generators/katapult/basics/templates/spec/factories/factories.rb +1 -1
- data/lib/generators/katapult/basics/templates/spec/support/database_cleaner.rb +20 -0
- data/lib/generators/katapult/basics/templates/spec/support/factory_bot.rb +3 -0
- data/lib/generators/katapult/basics/templates/spec/support/fixture_file.rb +6 -0
- data/lib/generators/katapult/basics/templates/spec/support/postgresql_sequences.rb +15 -0
- data/lib/generators/katapult/basics/templates/spec/support/timecop.rb +3 -0
- data/lib/generators/katapult/clearance/clearance_generator.rb +14 -2
- data/lib/generators/katapult/clearance/templates/app/views/layouts/_current_user.html.haml +11 -0
- data/lib/generators/katapult/clearance/templates/app/views/passwords/create.html.haml +10 -4
- data/lib/generators/katapult/clearance/templates/app/views/passwords/edit.html.haml +12 -12
- data/lib/generators/katapult/clearance/templates/app/views/passwords/new.html.haml +14 -11
- data/lib/generators/katapult/clearance/templates/app/views/sessions/new.html.haml +16 -15
- data/lib/generators/katapult/clearance/templates/features/authentication.feature +3 -3
- data/lib/generators/katapult/cucumber_features/templates/feature.feature +1 -1
- data/lib/generators/katapult/model_specs/templates/model_spec.rb +3 -5
- data/lib/generators/katapult/navigation/navigation_generator.rb +7 -1
- data/lib/generators/katapult/navigation/templates/app/views/layouts/_navigation.html.haml +15 -0
- data/lib/generators/katapult/transform/transform_generator.rb +12 -17
- data/lib/generators/katapult/views/templates/_form.html.haml +48 -0
- data/lib/generators/katapult/views/templates/app/helpers/table_helper.rb +14 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/action_bar.sass +22 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/title.sass +11 -0
- data/lib/generators/katapult/views/templates/custom_action.html.haml +5 -0
- data/lib/generators/katapult/views/templates/edit.html.haml +4 -0
- data/lib/generators/katapult/views/templates/index.html.haml +26 -0
- data/lib/generators/katapult/{haml → views}/templates/new.html.haml +1 -1
- data/lib/generators/katapult/views/templates/show.html.haml +39 -0
- data/lib/generators/katapult/{haml/haml_generator.rb → views/views_generator.rb} +19 -25
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/_route.rb +3 -3
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/controller.rb +21 -23
- data/lib/generators/katapult/{w_u_i/w_u_i_generator.rb → web_ui/web_ui_generator.rb} +7 -12
- data/lib/katapult/action.rb +1 -1
- data/lib/katapult/application_model.rb +8 -8
- data/lib/katapult/binary_util.rb +48 -10
- data/lib/katapult/generator.rb +2 -10
- data/lib/katapult/generator_goodies.rb +23 -0
- data/lib/katapult/navigation.rb +10 -5
- data/lib/katapult/parser.rb +15 -8
- data/lib/katapult/version.rb +5 -1
- data/lib/katapult/{wui.rb → web_ui.rb} +19 -4
- data/lib/katapult.rb +0 -5
- data/script/console +5 -2
- data/script/kta +8 -0
- data/script/update +80 -0
- data/spec/action_spec.rb +0 -1
- data/spec/attribute_spec.rb +0 -1
- data/spec/element_spec.rb +0 -1
- data/spec/model_spec.rb +0 -1
- data/spec/parser_spec.rb +26 -0
- data/spec/util_spec.rb +0 -1
- data/spec/{wui_spec.rb → web_ui_spec.rb} +24 -12
- metadata +86 -124
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_all.sass +0 -4
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_items.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_layout.sass +0 -26
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_navigation.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_tools.sass +0 -12
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application.sass +0 -6
- data/lib/generators/katapult/basics/templates/config/spring.rb +0 -3
- data/lib/generators/katapult/basics/templates/features/support/factory_girl.rb +0 -1
- data/lib/generators/katapult/basics/templates/spec/support/factory_girl.rb +0 -3
- data/lib/generators/katapult/haml/templates/_form.html.haml +0 -38
- data/lib/generators/katapult/haml/templates/app/views/layouts/application.html.haml +0 -33
- data/lib/generators/katapult/haml/templates/custom_action.html.haml +0 -5
- data/lib/generators/katapult/haml/templates/edit.html.haml +0 -4
- data/lib/generators/katapult/haml/templates/index.html.haml +0 -29
- data/lib/generators/katapult/haml/templates/show.html.haml +0 -39
- data/lib/generators/katapult/install/install_generator.rb +0 -14
- data/lib/generators/katapult/install/templates/lib/katapult/application_model.rb +0 -20
- data/lib/generators/katapult/navigation/templates/app/models/navigation.rb +0 -12
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
#@announce-output
|
|
2
|
+
#@announce-stderr
|
|
1
3
|
Feature: Web User Interface
|
|
2
4
|
|
|
3
5
|
Background:
|
|
4
|
-
Given a
|
|
5
|
-
And I install katapult
|
|
6
|
-
And I generate katapult basics
|
|
6
|
+
Given a new Rails application with Katapult basics installed
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Scenario: Generate a Web User Interface
|
|
10
|
-
When I
|
|
10
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
11
11
|
"""
|
|
12
12
|
model 'customer' do |customer|
|
|
13
13
|
customer.attr :name
|
|
@@ -24,15 +24,11 @@ Feature: Web User Interface
|
|
|
24
24
|
customer.attr :plain_data, type: :plain_json
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
wui.action :get_member, method: :get, scope: :member
|
|
30
|
-
wui.action :post_member, method: :post, scope: :member
|
|
31
|
-
wui.action :get_collection, method: :get, scope: :collection
|
|
32
|
-
wui.action :put_collection, method: :put, scope: :collection
|
|
27
|
+
web_ui 'customer', model: 'customer' do |web_ui|
|
|
28
|
+
web_ui.crud
|
|
33
29
|
end
|
|
34
30
|
"""
|
|
35
|
-
And I successfully transform the application model
|
|
31
|
+
And I successfully transform the application model including migrations
|
|
36
32
|
Then the file "app/controllers/customers_controller.rb" should contain exactly:
|
|
37
33
|
"""
|
|
38
34
|
class CustomersController < ApplicationController
|
|
@@ -51,7 +47,7 @@ Feature: Web User Interface
|
|
|
51
47
|
|
|
52
48
|
def create
|
|
53
49
|
build_customer
|
|
54
|
-
save_customer
|
|
50
|
+
save_customer
|
|
55
51
|
end
|
|
56
52
|
|
|
57
53
|
def edit
|
|
@@ -62,7 +58,7 @@ Feature: Web User Interface
|
|
|
62
58
|
def update
|
|
63
59
|
load_customer
|
|
64
60
|
build_customer
|
|
65
|
-
save_customer
|
|
61
|
+
save_customer
|
|
66
62
|
end
|
|
67
63
|
|
|
68
64
|
def destroy
|
|
@@ -71,24 +67,6 @@ Feature: Web User Interface
|
|
|
71
67
|
redirect_to customers_path
|
|
72
68
|
end
|
|
73
69
|
|
|
74
|
-
def get_member
|
|
75
|
-
load_customer
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def post_member
|
|
79
|
-
load_customer
|
|
80
|
-
redirect_to @customer
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def get_collection
|
|
84
|
-
load_customers
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def put_collection
|
|
88
|
-
load_customers
|
|
89
|
-
redirect_to customers_path
|
|
90
|
-
end
|
|
91
|
-
|
|
92
70
|
private
|
|
93
71
|
|
|
94
72
|
def load_customers
|
|
@@ -100,19 +78,36 @@ Feature: Web User Interface
|
|
|
100
78
|
end
|
|
101
79
|
|
|
102
80
|
def build_customer
|
|
103
|
-
@customer ||= customer_scope.
|
|
81
|
+
@customer ||= customer_scope.new
|
|
104
82
|
@customer.attributes = customer_params
|
|
105
83
|
end
|
|
106
84
|
|
|
107
85
|
def save_customer
|
|
108
86
|
if @customer.save
|
|
109
87
|
redirect_to @customer
|
|
88
|
+
else
|
|
89
|
+
action = @customer.new_record? ? 'new' : 'edit'
|
|
90
|
+
render action, status: :unprocessable_entity
|
|
110
91
|
end
|
|
111
92
|
end
|
|
112
93
|
|
|
113
94
|
def customer_params
|
|
114
95
|
customer_params = params[:customer]
|
|
115
|
-
|
|
96
|
+
return {} if customer_params.blank?
|
|
97
|
+
|
|
98
|
+
customer_params.permit(
|
|
99
|
+
:name,
|
|
100
|
+
:age,
|
|
101
|
+
:email,
|
|
102
|
+
:password,
|
|
103
|
+
:revenue,
|
|
104
|
+
:homepage,
|
|
105
|
+
:locked,
|
|
106
|
+
:notes,
|
|
107
|
+
:first_visit,
|
|
108
|
+
:indexable_data,
|
|
109
|
+
:plain_data,
|
|
110
|
+
)
|
|
116
111
|
end
|
|
117
112
|
|
|
118
113
|
def customer_scope
|
|
@@ -124,58 +119,49 @@ Feature: Web User Interface
|
|
|
124
119
|
"""
|
|
125
120
|
And the file "config/routes.rb" should contain:
|
|
126
121
|
"""
|
|
127
|
-
resources :customers
|
|
128
|
-
member do
|
|
129
|
-
get 'get_member'
|
|
130
|
-
post 'post_member'
|
|
131
|
-
end
|
|
132
|
-
collection do
|
|
133
|
-
get 'get_collection'
|
|
134
|
-
put 'put_collection'
|
|
135
|
-
end
|
|
136
|
-
end
|
|
122
|
+
resources :customers
|
|
137
123
|
"""
|
|
124
|
+
And the file "app/helpers/table_helper.rb" should contain "def table(*headers, &block)"
|
|
125
|
+
|
|
126
|
+
And a file named "app/webpack/assets/stylesheets/blocks/action_bar.sass" should exist
|
|
127
|
+
And a file named "app/webpack/assets/stylesheets/blocks/title.sass" should exist
|
|
128
|
+
|
|
138
129
|
And the file "app/views/customers/index.html.haml" should contain exactly:
|
|
139
130
|
"""
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
.action-bar.-main.btn-group
|
|
132
|
+
= link_to 'Add customer', new_customer_path, class: 'btn btn-default'
|
|
142
133
|
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
= link_to 'Get Collection', get_collection_customers_path, class: 'tools__button'
|
|
146
|
-
= link_to 'Put Collection', put_collection_customers_path, class: 'tools__button'
|
|
134
|
+
%h1.title
|
|
135
|
+
Customers
|
|
147
136
|
|
|
148
137
|
- if @customers.any?
|
|
149
|
-
|
|
138
|
+
|
|
139
|
+
= table 'Name', 'Actions' do
|
|
150
140
|
- @customers.each do |customer|
|
|
151
|
-
%tr
|
|
141
|
+
%tr(up-expand)
|
|
142
|
+
%td(width='40%')
|
|
143
|
+
= link_to customer, customer
|
|
152
144
|
%td
|
|
153
|
-
= link_to
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
= link_to 'Destroy', customer_path(customer), method: :delete, class: 'items__action', data: { confirm: 'Really destroy?' }, title: "Destroy #{customer.to_s}"
|
|
158
|
-
= link_to 'Get Member', get_member_customer_path(customer), class: 'items__action'
|
|
159
|
-
= link_to 'Post Member', post_member_customer_path(customer), class: 'items__action', method: :post
|
|
145
|
+
= link_to 'Edit', edit_customer_path(customer)
|
|
146
|
+
= link_to 'Destroy', customer_path(customer), method: :delete,
|
|
147
|
+
class: 'text-danger',
|
|
148
|
+
data: { confirm: 'Really destroy?' }, title: "Destroy #{customer}"
|
|
160
149
|
|
|
161
150
|
- else
|
|
162
151
|
%p.help-block
|
|
163
|
-
|
|
152
|
+
No customers found.
|
|
164
153
|
|
|
165
154
|
"""
|
|
166
155
|
And the file "app/views/customers/show.html.haml" should contain exactly:
|
|
167
156
|
"""
|
|
168
|
-
|
|
169
|
-
=
|
|
157
|
+
.action-bar.-main.btn-group
|
|
158
|
+
= link_to 'All customers', customers_path, class: 'btn btn-default'
|
|
159
|
+
= link_to 'Edit', edit_customer_path(@customer), class: 'btn btn-default'
|
|
170
160
|
|
|
171
|
-
.
|
|
172
|
-
=
|
|
173
|
-
= link_to 'Edit', edit_customer_path(@customer), class: 'tools__button is_primary'
|
|
174
|
-
= link_to 'Destroy', customer_path(@customer), method: :delete, class: 'tools__button', confirm: 'Really destroy?'
|
|
175
|
-
= link_to 'Get Member', get_member_customer_path(@customer), class: 'tools__button'
|
|
176
|
-
= link_to 'Post Member', post_member_customer_path(@customer), class: 'tools__button', method: :post
|
|
161
|
+
%h1.title
|
|
162
|
+
= @customer
|
|
177
163
|
|
|
178
|
-
%dl
|
|
164
|
+
%dl
|
|
179
165
|
%dt
|
|
180
166
|
= Customer.human_attribute_name(:name)
|
|
181
167
|
%dd
|
|
@@ -187,7 +173,7 @@ Feature: Web User Interface
|
|
|
187
173
|
%dt
|
|
188
174
|
= Customer.human_attribute_name(:email)
|
|
189
175
|
%dd
|
|
190
|
-
= mail_to @customer.email, nil
|
|
176
|
+
= mail_to @customer.email, nil
|
|
191
177
|
%dt
|
|
192
178
|
= Customer.human_attribute_name(:revenue)
|
|
193
179
|
%dd
|
|
@@ -196,7 +182,7 @@ Feature: Web User Interface
|
|
|
196
182
|
%dt
|
|
197
183
|
= Customer.human_attribute_name(:homepage)
|
|
198
184
|
%dd
|
|
199
|
-
= link_to @customer.homepage, @customer.homepage
|
|
185
|
+
= link_to @customer.homepage, @customer.homepage
|
|
200
186
|
%dt
|
|
201
187
|
= Customer.human_attribute_name(:locked)
|
|
202
188
|
%dd
|
|
@@ -211,12 +197,9 @@ Feature: Web User Interface
|
|
|
211
197
|
= l(@customer.first_visit.to_date) if @customer.first_visit
|
|
212
198
|
|
|
213
199
|
"""
|
|
214
|
-
# Note that no views are generated for JSON fields, as they are mainly data
|
|
215
|
-
# storage fields
|
|
216
|
-
|
|
217
200
|
And the file "app/views/customers/new.html.haml" should contain exactly:
|
|
218
201
|
"""
|
|
219
|
-
%h1
|
|
202
|
+
%h1.title
|
|
220
203
|
Add customer
|
|
221
204
|
|
|
222
205
|
= render 'form'
|
|
@@ -224,8 +207,8 @@ Feature: Web User Interface
|
|
|
224
207
|
"""
|
|
225
208
|
And the file "app/views/customers/edit.html.haml" should contain exactly:
|
|
226
209
|
"""
|
|
227
|
-
%h1
|
|
228
|
-
= @customer
|
|
210
|
+
%h1.title
|
|
211
|
+
= @customer
|
|
229
212
|
|
|
230
213
|
= render 'form'
|
|
231
214
|
|
|
@@ -234,71 +217,55 @@ Feature: Web User Interface
|
|
|
234
217
|
"""
|
|
235
218
|
= form_for @customer do |form|
|
|
236
219
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
= form.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
= form.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
= form.label :first_visit
|
|
273
|
-
%dd
|
|
274
|
-
= form.date_field :first_visit
|
|
275
|
-
|
|
276
|
-
.tools
|
|
277
|
-
= form.submit 'Save', class: 'tools__button is_primary'
|
|
220
|
+
.form-group
|
|
221
|
+
= form.label :name
|
|
222
|
+
= form.text_field :name, class: 'form-control'
|
|
223
|
+
.form-group
|
|
224
|
+
= form.label :age
|
|
225
|
+
= form.number_field :age, class: 'form-control'
|
|
226
|
+
.form-group
|
|
227
|
+
= form.label :email
|
|
228
|
+
= form.email_field :email, class: 'form-control'
|
|
229
|
+
.form-group
|
|
230
|
+
= form.label :password
|
|
231
|
+
= form.password_field :password, class: 'form-control',
|
|
232
|
+
autocomplete: 'new-password'
|
|
233
|
+
.form-group
|
|
234
|
+
= form.label :revenue
|
|
235
|
+
.input-group
|
|
236
|
+
= form.number_field :revenue, class: 'form-control'
|
|
237
|
+
.input-group-addon
|
|
238
|
+
€
|
|
239
|
+
.form-group
|
|
240
|
+
= form.label :homepage
|
|
241
|
+
= form.url_field :homepage, class: 'form-control'
|
|
242
|
+
.form-group
|
|
243
|
+
= form.label :locked
|
|
244
|
+
.checkbox
|
|
245
|
+
= form.label :locked do
|
|
246
|
+
= form.check_box :locked
|
|
247
|
+
.form-group
|
|
248
|
+
= form.label :notes
|
|
249
|
+
= form.text_area :notes, rows: 5, class: 'form-control'
|
|
250
|
+
.form-group
|
|
251
|
+
= form.label :first_visit
|
|
252
|
+
= form.date_field :first_visit, class: 'form-control'
|
|
253
|
+
|
|
254
|
+
.action-bar
|
|
278
255
|
- cancel_path = @customer.new_record? ? customers_path : customer_path(@customer)
|
|
279
|
-
= link_to 'Cancel', cancel_path, class: 'tools__button'
|
|
280
256
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
Get Member
|
|
257
|
+
.pull-right
|
|
258
|
+
- if @customer.persisted?
|
|
259
|
+
= link_to "Destroy customer", customer_path(@customer), method: :delete,
|
|
260
|
+
class: 'btn btn-danger', data: { confirm: 'Really destroy?' }
|
|
286
261
|
|
|
287
|
-
|
|
288
|
-
|
|
262
|
+
= form.submit 'Save', class: 'btn btn-primary'
|
|
263
|
+
= link_to 'Cancel', cancel_path, class: 'btn btn-link'
|
|
289
264
|
|
|
290
265
|
"""
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
"""
|
|
294
|
-
%h1
|
|
295
|
-
Get Collection
|
|
296
|
-
|
|
297
|
-
.tools
|
|
298
|
-
= link_to 'All customers', customers_path, class: 'tools__button'
|
|
266
|
+
# Note that no form fields are generated for JSON fields, as they are mainly
|
|
267
|
+
# data storage fields
|
|
299
268
|
|
|
300
|
-
"""
|
|
301
|
-
But a file named "app/views/customers/put_collection.html.haml" should not exist
|
|
302
269
|
And the file "features/customers.feature" should contain exactly:
|
|
303
270
|
"""
|
|
304
271
|
Feature: Customers
|
|
@@ -348,7 +315,7 @@ Feature: Web User Interface
|
|
|
348
315
|
|
|
349
316
|
When I follow "Destroy name-string"
|
|
350
317
|
Then I should be on the list of customers
|
|
351
|
-
|
|
318
|
+
But I should not see "name-string"
|
|
352
319
|
|
|
353
320
|
"""
|
|
354
321
|
|
|
@@ -356,24 +323,84 @@ Feature: Web User Interface
|
|
|
356
323
|
Then the features should pass
|
|
357
324
|
|
|
358
325
|
|
|
359
|
-
Scenario:
|
|
360
|
-
When I
|
|
326
|
+
Scenario: Generate a Web User Interface with custom actions
|
|
327
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
361
328
|
"""
|
|
362
|
-
model '
|
|
363
|
-
|
|
329
|
+
model 'customer' do |customer|
|
|
330
|
+
customer.attr :name
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
web_ui 'customer', model: 'customer' do |web_ui|
|
|
334
|
+
web_ui.crud
|
|
335
|
+
web_ui.action :get_member, method: :get, scope: :member
|
|
336
|
+
web_ui.action :post_member, method: :post, scope: :member
|
|
337
|
+
web_ui.action :get_collection, method: :get, scope: :collection
|
|
338
|
+
web_ui.action :put_collection, method: :put, scope: :collection
|
|
339
|
+
end
|
|
364
340
|
"""
|
|
365
341
|
And I successfully transform the application model
|
|
366
|
-
Then the file "app/
|
|
342
|
+
Then the file "app/controllers/customers_controller.rb" should contain:
|
|
367
343
|
"""
|
|
368
|
-
|
|
344
|
+
|
|
345
|
+
def get_member
|
|
346
|
+
load_customer
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def post_member
|
|
350
|
+
load_customer
|
|
351
|
+
redirect_to @customer
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def get_collection
|
|
355
|
+
load_customers
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def put_collection
|
|
359
|
+
load_customers
|
|
360
|
+
redirect_to customers_path
|
|
361
|
+
end
|
|
362
|
+
|
|
369
363
|
"""
|
|
370
|
-
And the file "
|
|
364
|
+
And the file "config/routes.rb" should contain:
|
|
371
365
|
"""
|
|
372
|
-
|
|
366
|
+
resources :customers, only: [:index, :show, :new, :create, :edit, :update, :destroy] do
|
|
367
|
+
member do
|
|
368
|
+
get 'get_member'
|
|
369
|
+
post 'post_member'
|
|
370
|
+
end
|
|
371
|
+
collection do
|
|
372
|
+
get 'get_collection'
|
|
373
|
+
put 'put_collection'
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
"""
|
|
377
|
+
And the file "app/views/customers/index.html.haml" should contain:
|
|
378
|
+
"""
|
|
379
|
+
= link_to 'Get Collection', get_collection_customers_path, class: 'btn btn-default'
|
|
380
|
+
= link_to 'Put Collection', put_collection_customers_path, class: 'btn btn-default'
|
|
381
|
+
"""
|
|
382
|
+
And the file "app/views/customers/show.html.haml" should contain:
|
|
383
|
+
"""
|
|
384
|
+
= link_to 'Get Member', get_member_customer_path(@customer), class: 'btn btn-default'
|
|
385
|
+
= link_to 'Post Member', post_member_customer_path(@customer), class: 'btn btn-default', method: :post
|
|
373
386
|
"""
|
|
374
|
-
And the file "app/views/
|
|
387
|
+
And the file "app/views/customers/get_member.html.haml" should contain exactly:
|
|
388
|
+
"""
|
|
389
|
+
.action-bar
|
|
390
|
+
= link_to 'All customers', customers_path, class: 'btn btn-default'
|
|
391
|
+
|
|
392
|
+
%h1.title
|
|
393
|
+
Get Member
|
|
394
|
+
|
|
395
|
+
"""
|
|
396
|
+
But a file named "app/views/customers/post_member.html.haml" should not exist
|
|
397
|
+
And the file "app/views/customers/get_collection.html.haml" should contain exactly:
|
|
375
398
|
"""
|
|
376
|
-
-
|
|
377
|
-
|
|
378
|
-
|
|
399
|
+
.action-bar
|
|
400
|
+
= link_to 'All customers', customers_path, class: 'btn btn-default'
|
|
401
|
+
|
|
402
|
+
%h1.title
|
|
403
|
+
Get Collection
|
|
404
|
+
|
|
379
405
|
"""
|
|
406
|
+
But a file named "app/views/customers/put_collection.html.haml" should not exist
|
data/katapult.gemspec
CHANGED
|
@@ -9,7 +9,12 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ['Dominik Schöler']
|
|
10
10
|
spec.email = ['dominik.schoeler@makandra.de']
|
|
11
11
|
spec.summary = %q{Kickstart Rails development}
|
|
12
|
-
spec.description = %q{
|
|
12
|
+
spec.description = %q{
|
|
13
|
+
Katapult is a framework for generating base code for Rails applications in
|
|
14
|
+
two leaps. Basics Generation prepares a new Rails application with lots of
|
|
15
|
+
best practices, Model Transformation generates application code from a model
|
|
16
|
+
of the application.
|
|
17
|
+
}
|
|
13
18
|
spec.homepage = 'https://github.com/makandra/katapult'
|
|
14
19
|
spec.license = 'MIT'
|
|
15
20
|
|
|
@@ -18,18 +23,8 @@ Gem::Specification.new do |spec|
|
|
|
18
23
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
|
19
24
|
spec.require_paths = ['lib']
|
|
20
25
|
|
|
21
|
-
spec.required_ruby_version =
|
|
26
|
+
# spec.required_ruby_version = Katapult::RUBY_VERSION
|
|
22
27
|
|
|
23
|
-
spec.add_runtime_dependency 'rails'
|
|
28
|
+
spec.add_runtime_dependency 'rails', Katapult::RAILS_VERSION
|
|
24
29
|
spec.add_runtime_dependency 'spring' # speed-up
|
|
25
|
-
|
|
26
|
-
# Development
|
|
27
|
-
spec.add_development_dependency 'bundler', '~> 1.5'
|
|
28
|
-
spec.add_development_dependency 'rake'
|
|
29
|
-
spec.add_development_dependency 'pry'
|
|
30
|
-
|
|
31
|
-
# Testing
|
|
32
|
-
spec.add_development_dependency 'aruba', '~> 0.10.2'
|
|
33
|
-
spec.add_development_dependency 'guard-cucumber'
|
|
34
|
-
spec.add_development_dependency 'rspec', '~> 3.4.0'
|
|
35
30
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Katapult
|
|
2
|
+
class AppModelGenerator < Rails::Generators::Base
|
|
3
|
+
|
|
4
|
+
desc 'Generate the default application model'
|
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
6
|
+
|
|
7
|
+
def generate_application_model
|
|
8
|
+
template 'lib/katapult/application_model.rb'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# In this file, you model your application. Refer to the README or get inspired
|
|
2
|
+
# by the full-fledged example below (which you can generate right away).
|
|
3
|
+
|
|
4
|
+
# Define a model + generate views with CRUD actions
|
|
5
|
+
# Since this generates the first web UI with an index action, the products list
|
|
6
|
+
# will become the home page of the generated app
|
|
7
|
+
crud 'product' do |product|
|
|
8
|
+
# The first attribute of each model is taken as a human identifier/label
|
|
9
|
+
product.attr :title # Default type "string"
|
|
10
|
+
|
|
11
|
+
# The order of attributes is respected when generating the form for that model
|
|
12
|
+
product.attr :price, type: :money
|
|
13
|
+
product.attr :mode, assignable_values: %w[public private]
|
|
14
|
+
product.attr :provider, type: :url
|
|
15
|
+
product.attr :import_data, type: :json
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Define a model
|
|
19
|
+
model 'user' do |user|
|
|
20
|
+
user.attr :email # Type "email" derived from attribute name
|
|
21
|
+
|
|
22
|
+
user.attr :name
|
|
23
|
+
user.attr :last_visit, type: :datetime
|
|
24
|
+
user.attr :locked, type: :flag, default: false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Add a web user interface for the 'user' model
|
|
28
|
+
web_ui 'user' do |web_ui|
|
|
29
|
+
# All CRUD actions: index, show, new, create, edit, update, destroy
|
|
30
|
+
web_ui.crud
|
|
31
|
+
|
|
32
|
+
# Custom action
|
|
33
|
+
web_ui.action :lock, scope: :member, method: :post
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Have a main menu
|
|
37
|
+
navigation
|
|
38
|
+
|
|
39
|
+
# Add authentication
|
|
40
|
+
authenticate 'user', system_email: 'system@example.com'
|