actionscaffold 0.1.5.pre → 0.2.0.pre

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: 9c218b93253d693fbf1b27ac1c5e6efceb9deb15
4
- data.tar.gz: 70700e39bf9001e4857cabfad66b5c6570dab1f3
3
+ metadata.gz: 340a4627eede4f5a6360c3b105825a96067d0858
4
+ data.tar.gz: af88e6f20bd55c7db7f809120a19eaebf6c6a0a4
5
5
  SHA512:
6
- metadata.gz: 166f1bb4fc0567c3aaa382283eda496e0c5f390ad6ab14918eaeecd09d0b3bed883e46206cd976c52a43ef8ba5f3692c3515fd83f837137a8015a9334646b1bd
7
- data.tar.gz: bd716ad1662ee1e20790f89c00e7be9921c841dc68ad509508fc7f1c4b94548ffc8abb92a66ff192803b4352ec217df0c5cb7ec5e7d4fc31761f3aa1a8cb9f35
6
+ metadata.gz: 6fa9ae9f04a9dcfe0666cd06a35d55e4a5fa8f9246c165f8fb309b0803ebdb2bdfb007d1c4b5a4f4b652ff7a1c44fef4890f043d631e43c7cce26e667f9c5f66
7
+ data.tar.gz: 00f2b6297a8c15fec20a394a5c0d02f64b76e83aec40021121834bb5b463dc7b5b51b24b6dc1e4e4ef4dcfb88571530756b5b4a640d6a95e44af71555eb03175
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  ## Usage
10
10
  Controller generator (respond_with by default):
11
11
  ```bash
12
- $ rails g actionscaffold:install
12
+ $ rails g scaffold_controller:install
13
13
  ```
14
14
  Result:
15
15
  ```ruby
@@ -63,7 +63,6 @@ class BooksController < ApplicationController
63
63
  @book = Book.find(params[:id])
64
64
  end
65
65
 
66
- # Only allow a trusted parameter "white list" through.
67
66
  def book_params
68
67
  params.require(:book).
69
68
  permit(:title, :author)
@@ -73,7 +72,7 @@ end
73
72
 
74
73
  View generator (Bootstrap by default):
75
74
  ```bash
76
- $ rails g view:install --ui=bootstrap
75
+ $ rails g scaffold_view:install --ui=bootstrap
77
76
  ```
78
77
  Or with custom theme:
79
78
  ```bash
@@ -93,7 +92,7 @@ Result:
93
92
  Add this line to your application's Gemfile:
94
93
 
95
94
  ```ruby
96
- gem 'scaffolder'
95
+ gem 'actionscaffold'
97
96
  ```
98
97
 
99
98
  And then execute:
@@ -103,7 +102,7 @@ $ bundle
103
102
 
104
103
  Or install it yourself as:
105
104
  ```bash
106
- $ gem install scaffolder
105
+ $ gem install actionscaffold
107
106
  ```
108
107
 
109
108
  # To do
@@ -113,7 +112,7 @@ $ gem install scaffolder
113
112
  - [ ] [html5boilerplate](https://html5boilerplate.com)
114
113
 
115
114
  ## Contributing
116
- Bug reports and pull requests are welcome on GitHub at https://github.com/mtunjic/scaffolder.
115
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mtunjic/actionscaffold.
117
116
 
118
117
  ## License
119
118
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module ActionScaffold
2
- VERSION = '0.1.5.pre'
2
+ VERSION = '0.2.0.pre'
3
3
  end
@@ -0,0 +1,19 @@
1
+ #
2
+ # controller_generator.rb
3
+ #
4
+ # Created by Marko Tunjic on 15/07/16.
5
+ # Copyright © 2016 Marko Tunjic. All rights reserved.
6
+ #
7
+ module ScaffoldController
8
+ module Generators
9
+ class InstallGenerator < Rails::Generators::Base
10
+ desc "This generator override default scaffold generator for controllers."
11
+ source_root File.expand_path("../templates", __FILE__)
12
+ def copy_template_file
13
+ copy_file "controller.rb",
14
+ "lib/templates/rails/scaffold_controller/controller.rb"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,63 @@
1
+ <% module_namespacing do -%>
2
+
3
+ class <%= controller_class_name %>Controller < ApplicationController
4
+ before_action :set_<%= singular_table_name %>,
5
+ only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET <%= route_url %>
8
+ def index
9
+ @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
10
+ respond_with(@<%= plural_table_name %>)
11
+ end
12
+
13
+ # GET <%= route_url %>/1
14
+ def show
15
+ respond_with(@<%= singular_table_name %>)
16
+ end
17
+
18
+ # GET <%= route_url %>/new
19
+ def new
20
+ @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
21
+ respond_with(@<%= singular_table_name %>)
22
+ end
23
+
24
+ # GET <%= route_url %>/1/edit
25
+ def edit
26
+ end
27
+
28
+ # POST <%= route_url %>
29
+ def create
30
+ @<%= singular_table_name %> = <%= orm_class.build(class_name,
31
+ "#{singular_table_name}_params") %>
32
+ @<%= orm_instance.save %>
33
+ respond_with(@<%= singular_table_name %>)
34
+ end
35
+
36
+ # PATCH/PUT <%= route_url %>/1
37
+ def update
38
+ @<%= orm_instance.update("#{singular_table_name}_params") %>
39
+ respond_with(@<%= singular_table_name %>)
40
+ end
41
+
42
+ # DELETE <%= route_url %>/1
43
+ def destroy
44
+ @<%= orm_instance.destroy %>
45
+ respond_with(@<%= singular_table_name %>)
46
+ end
47
+
48
+ private
49
+
50
+ def set_<%= singular_table_name %>
51
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
52
+ end
53
+
54
+ def <%= "#{singular_table_name}_params" %>
55
+ <%- if attributes_names.empty? -%>
56
+ params[<%= ":#{singular_table_name}" %>]
57
+ <%- else -%>
58
+ params.require(<%= ":#{singular_table_name}" %>).
59
+ permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
60
+ <%- end -%>
61
+ end
62
+ end
63
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ #
2
+ # controller_generator.rb
3
+ #
4
+ # Created by Marko Tunjic on 15/07/16.
5
+ # Copyright © 2016 Marko Tunjic. All rights reserved.
6
+ #
7
+ module ScaffoldView
8
+ module Generators
9
+ class InstallGenerator < Rails::Generators::Base
10
+ desc "This generator override default scaffold generator for views."
11
+ source_root File.expand_path("../templates", __FILE__)
12
+ def copy_template_file
13
+ copy_file "_form.html.erb",
14
+ "lib/templates/erb/scaffold/_form.html.erb"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,37 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%% if @<%= singular_table_name %>.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
8
+ <li><%%= msg %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% attributes.each do |attribute| -%>
15
+ <div class="form-group">
16
+ <% if attribute.password_digest? -%>
17
+ <%%= f.label :password %>
18
+ <%%= f.password_field :password, class: "form-control" %>
19
+ </div>
20
+ <div>
21
+ <%%= f.label :password_confirmation %>
22
+ <%%= f.password_field :password_confirmation, class: "form-control" %>
23
+ <% else -%>
24
+ <%- if attribute.reference? -%>
25
+ <%%= f.label :<%= attribute.column_name %> %>
26
+ <%%= f.collection_select :<%= attribute.column_name %>, <%= attribute.name.camelize %>.all, :id, :name, prompt: true %>
27
+ <%- else -%>
28
+ <%%= f.label :<%= attribute.name %> %>
29
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %>, class: "form-control" %>
30
+ <%- end -%>
31
+ <% end -%>
32
+ </div>
33
+ <% end -%>
34
+ <div class="form-group actions">
35
+ <%%= f.submit :Submit, class: "btn btn-primary" %>
36
+ </div>
37
+ <%% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionscaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.pre
4
+ version: 0.2.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marko Tunjic
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 4.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: responders
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sqlite3
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,10 @@ files:
52
66
  - lib/actionscaffold/version.rb
53
67
  - lib/generators/actionscaffold/install_generator.rb
54
68
  - lib/generators/actionscaffold/templates/controller.rb
69
+ - lib/generators/scaffold_controller/install_generator.rb
70
+ - lib/generators/scaffold_controller/templates/controller.rb
71
+ - lib/generators/scaffold_view/install_generator.rb
72
+ - lib/generators/scaffold_view/templates/_form.html.erb
55
73
  - lib/tasks/scaffolder_tasks.rake
56
74
  homepage: https://github.com/mtunjic/actionscaffold
57
75
  licenses: