irreverent 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 3b755303b2ed2f0795463bbb89a80f8505f8f61f
4
- data.tar.gz: 90af122d4b4dbd3d4f1d6ddb6615c2ba01037fd3
3
+ metadata.gz: 49de80c2ae2b21b9143b1d00330c892185d1b741
4
+ data.tar.gz: 107b77edbd4d9bbef14bc1b823c4bd461dacbda5
5
5
  SHA512:
6
- metadata.gz: f270130dd8a2952ebfdf0245b6c5aa9650f6961c3d3867cefb4f44b3904779ee8143c923790b3fbf190b3697c088fd4526f9870a34120bc7bb6b2a26d02b3812
7
- data.tar.gz: 68e58ec054721c4a014d314ade5ab0638819643f02c8bf713bff531672bf1bf35a6d4ec8ea68eeb06e449ee86f8df47ce132150f3f7fbb85200b404060a4814c
6
+ metadata.gz: a672a87473f961c3908e78c86e6f3d0c5f5e33b105f18dc687a636c5922f4345e003a8254d04688a0b280c64270b4df501eebd132a24fe7f3d532c1811b20fa2
7
+ data.tar.gz: 5fe0989414b17863b296ab35a6ea16da90f8a725fc02409b9758ec9ef5fc03038561dd865954846dca60e66ddf91567ec42dd40c6ae557966a3de1fcfba9b451
@@ -0,0 +1,12 @@
1
+ module Irreverent
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def copy_template_file
7
+ copy_file 'controller.rb',
8
+ 'lib/templates/rails/scaffold_controller/controller.rb'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ <% module_namespacing do -%>
2
+ class <%= controller_class_name %>Controller < ApplicationController
3
+ before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
4
+
5
+ # GET <%= route_url %>
6
+ def index
7
+ @<%= plural_table_name %> = <%= orm_class.all class_name %>
8
+ respond_with @<%= plural_table_name %>
9
+ end
10
+
11
+ # GET <%= route_url %>/1
12
+ def show
13
+ respond_with @<%= singular_table_name %>
14
+ end
15
+
16
+ # GET <%= route_url %>/new
17
+ def new
18
+ @<%= singular_table_name %> = <%= orm_class.build class_name %>
19
+ respond_with @<%= singular_table_name %>
20
+ end
21
+
22
+ # GET <%= route_url %>/1/edit
23
+ def edit
24
+ end
25
+
26
+ # POST <%= route_url %>
27
+ def create
28
+ @<%= singular_table_name %> = <%= orm_class.build class_name, "#{singular_table_name}_params" %>
29
+ @<%= orm_instance.save %>
30
+ respond_with @<%= singular_table_name %>
31
+ end
32
+
33
+ # PATCH/PUT <%= route_url %>/1
34
+ def update
35
+ @<%= orm_instance.update "#{singular_table_name}_params" %>
36
+ respond_with @<%= singular_table_name %>
37
+ end
38
+
39
+ # DELETE <%= route_url %>/1
40
+ def destroy
41
+ @<%= orm_instance.destroy %>
42
+ respond_with @<%= singular_table_name %>
43
+ end
44
+
45
+ private
46
+
47
+ # Use callbacks to share common setup or constraints between actions.
48
+ def set_<%= singular_table_name %>
49
+ @<%= singular_table_name %> = <%= orm_class.find class_name, 'params[:id]' %>
50
+ end
51
+
52
+ # Only allow a trusted parameter "white list" through.
53
+ def <%= "#{singular_table_name}_params" %>
54
+ <%- if attributes_names.empty? -%>
55
+ params[<%= ":#{singular_table_name}" %>]
56
+ <%- else -%>
57
+ params.require(<%= ":#{singular_table_name}" %>).permit <%= attributes_names.map { |name| ":#{name}" }.join(', ') %>
58
+ <%- end -%>
59
+ end
60
+ end
61
+ <% end -%>
@@ -1,3 +1,3 @@
1
1
  module Irreverent
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irreverent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Catena
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -48,6 +48,8 @@ files:
48
48
  - MIT-LICENSE
49
49
  - README.rdoc
50
50
  - Rakefile
51
+ - lib/generators/irreverent/install/install_generator.rb
52
+ - lib/generators/irreverent/install/templates/controller.rb
51
53
  - lib/irreverent.rb
52
54
  - lib/irreverent/flash.rb
53
55
  - lib/irreverent/locales/en.yml