shopapp 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d4f831a62aa4942a1047e5c9a17d6250613b8e124406b66b2e3d10cb2524b6e
4
- data.tar.gz: 6e6e0f71f6175b24edabae63b9a1e7810bc7500f048e5ef3b4c5b045a4b69444
3
+ metadata.gz: a79004b05f353393d4787b77d4261599f671c2d722acd395260748d7f4e572a6
4
+ data.tar.gz: 740821d7b2e7ba2aec300ec2ec9ab5b5243032ad2d3bb7477adf85284f1e11c3
5
5
  SHA512:
6
- metadata.gz: 45676519a6a98347baec3880fdde2090f6e75a42ef71be1273add476104bc0bb6697b099914328aacae76e41d7849ffbe1fbfbb7e9a62a2e8cf8cdf48b2448b4
7
- data.tar.gz: 2e9b3b775e16906716b50d10d341ffcc4d3895f76c52e4c1b209a6be61bd98a484dbe93699c1435d30792e1dc1ec718805becd642f0f3a550c778533deab19af
6
+ metadata.gz: 7901c675fe62f1fb0edc6de6d13d77f3daeffefec6e37d2963ed63ad8650ae8c7c31654bb57e4583d5279df0aedfbea418175ceecfb72d55ab7ea16b77aa5914
7
+ data.tar.gz: a6f8880d72bbab944295f97633b408afc3c5e88fc403141168864b9154cc1be332bca2409ab6a0cf9837d0bc4a96b44890e9bce1cc110589f0fe609f4c1e7177
data/README.md CHANGED
@@ -30,11 +30,6 @@ Just do the following:
30
30
  rails db:migrate
31
31
  rails s
32
32
 
33
- Rename the base controller for SomethingsController to one of
34
- ShopApp base controllers, typically UserAuthenticatedController:
35
-
36
- class ProductsController < UserAuthenticatedController
37
-
38
33
  Hit the newly created route: http://localhost:3999/somethings
39
34
 
40
35
  ### Shopapps side by side - set development port
@@ -18,7 +18,7 @@ gem 'puma'
18
18
  gem 'sass-rails'
19
19
  gem 'shopapp'
20
20
  gem 'uglifier', '>= 1.3.0'
21
- gem 'therubyracer', platforms: :ruby
21
+ gem 'mini_racer'
22
22
  gem 'jbuilder', '~> 2.5'
23
23
  gem 'bootsnap', '>= 1.1.0', require: false
24
24
  gem "audited", "~> 4.7"
@@ -145,6 +145,77 @@ create_file 'config/local.yml', <<~SETTINGS
145
145
  authlift_url: 'https://accounts.shoplift.fi/'
146
146
  SETTINGS
147
147
 
148
+ create_file 'lib/templates/rails/scaffold_controller/controller.rb.tt', <<~TEMPLATE
149
+ <% if namespaced? -%>
150
+ require_dependency "<%= namespaced_path %>/application_controller"
151
+
152
+ <% end -%>
153
+ <% module_namespacing do -%>
154
+ class <%= controller_class_name %>Controller < UserAuthenticatedController
155
+ before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
156
+
157
+ # GET <%= route_url %>
158
+ def index
159
+ @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
160
+ end
161
+
162
+ # GET <%= route_url %>/1
163
+ def show
164
+ end
165
+
166
+ # GET <%= route_url %>/new
167
+ def new
168
+ @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
169
+ end
170
+
171
+ # GET <%= route_url %>/1/edit
172
+ def edit
173
+ end
174
+
175
+ # POST <%= route_url %>
176
+ def create
177
+ @<%= singular_table_name %> = <%= orm_class.build(class_name, "\#{singular_table_name}_params") %>
178
+
179
+ if @<%= orm_instance.save %>
180
+ redirect_to @<%= singular_table_name %>, notice: <%= "'\#{human_name} was successfully created.'" %>
181
+ else
182
+ render :new
183
+ end
184
+ end
185
+
186
+ # PATCH/PUT <%= route_url %>/1
187
+ def update
188
+ if @<%= orm_instance.update("\#{singular_table_name}_params") %>
189
+ redirect_to @<%= singular_table_name %>, notice: <%= "'\#{human_name} was successfully updated.'" %>
190
+ else
191
+ render :edit
192
+ end
193
+ end
194
+
195
+ # DELETE <%= route_url %>/1
196
+ def destroy
197
+ @<%= orm_instance.destroy %>
198
+ redirect_to <%= index_helper %>_url, notice: <%= "'\#{human_name} was successfully destroyed.'" %>
199
+ end
200
+
201
+ private
202
+ # Use callbacks to share common setup or constraints between actions.
203
+ def set_<%= singular_table_name %>
204
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
205
+ end
206
+
207
+ # Only allow a trusted parameter "white list" through.
208
+ def <%= "\#{singular_table_name}_params" %>
209
+ <%- if attributes_names.empty? -%>
210
+ params.fetch(:<%= singular_table_name %>, {})
211
+ <%- else -%>
212
+ params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":\#{name}" }.join(', ') %>)
213
+ <%- end -%>
214
+ end
215
+ end
216
+ <% end -%>
217
+ TEMPLATE
218
+
148
219
  git :init
149
220
  git add: '.'
150
221
  git commit: "-a -m 'shopapp created'"
@@ -164,4 +235,10 @@ puts " app.update_attributes uid: '#{@app_id}',"
164
235
  puts " secret: '#{@app_secret}',"
165
236
  puts " redirect_uri: 'http://localhost:#{@app_dev_port}/auth/'"
166
237
  puts " Company.find_by_code(:zwr).applications << app unless Company.find_by_code(:zwr).applications.include? app"
167
-
238
+ puts
239
+ puts "To see the power of Shopapp, do this (on Mac):"
240
+ puts
241
+ puts " $ cd #{@app_name}"
242
+ puts " $ rails g scaffold dog name:string"
243
+ puts " $ rake db:migrate"
244
+ puts " $ open http://localhost:3999/dogs ; rails s"
data/shopapp.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shopapp'
3
- s.version = '0.2.4'
3
+ s.version = '0.2.6'
4
4
  s.date = '2018-09-13'
5
5
  s.summary = 'Do a shoplift.'
6
6
  s.description = 'Ha! Art thou Bedlam? Dost thou thirst base Trojan, to have me fold up Parca\'s fatal web? Hence!\
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeljko