actionscaffold 0.1.4.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 960dcf0b17d4bf268655b70aaa356206e7e327d0
4
+ data.tar.gz: 3a7c91c63acc40b5d2232e8dc338b327fdbe1618
5
+ SHA512:
6
+ metadata.gz: 92bb3b6ccb56a1b7682007ca4f76dc1665edfa476e053b061446d3ca0af88715accfcab780cbcb9b6a5cb1e8b90fe50396f2cdee8461ce0863178765752a8a52
7
+ data.tar.gz: 4e352066e24a6d5d7a79c328904b57410246133a87dcb684f40caab06badef71b2393f04d0256b1aab9fa6a87d9746b4c04b45443e1d95776cf587c4b45db0bc
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Action Scaffold
2
+
3
+ * Clean & DRY Rails controllers.
4
+ * View support for bootstrap 4, uikit, skeleton and html5boilerplate.
5
+ * Select box for a belongs_to relationship.
6
+ * Nested resources
7
+
8
+
9
+ ## Usage
10
+ Controller generator (respond_with by default):
11
+ ```bash
12
+ $ rails g actionscaffold:install
13
+ ```
14
+ Result:
15
+ ```ruby
16
+ class BooksController < ApplicationController
17
+ before_action :set_book,
18
+ only: [:show, :edit, :update, :destroy]
19
+
20
+ # GET /books
21
+ def index
22
+ @books = Book.all
23
+ respond_with(@books)
24
+ end
25
+
26
+ # GET /books/1
27
+ def show
28
+ respond_with(@book)
29
+ end
30
+
31
+ # GET /books/new
32
+ def new
33
+ @book = Book.new
34
+ respond_with(@book)
35
+ end
36
+
37
+ # GET /books/1/edit
38
+ def edit
39
+ end
40
+
41
+ # POST /books
42
+ def create
43
+ @book = Book.new(book_params)
44
+ @book.save
45
+ respond_with(@book)
46
+ end
47
+
48
+ # PATCH/PUT /books/1
49
+ def update
50
+ @book.update(book_params)
51
+ respond_with(@book)
52
+ end
53
+
54
+ # DELETE /books/1
55
+ def destroy
56
+ @book.destroy
57
+ respond_with(@book)
58
+ end
59
+
60
+ private
61
+
62
+ def set_book
63
+ @book = Book.find(params[:id])
64
+ end
65
+
66
+ # Only allow a trusted parameter "white list" through.
67
+ def book_params
68
+ params.require(:book).
69
+ permit(:title, :author)
70
+ end
71
+ end
72
+ ```
73
+
74
+ View generator (Bootstrap by default):
75
+ ```bash
76
+ $ rails g view:install --ui=bootstrap
77
+ ```
78
+ Or with custom theme:
79
+ ```bash
80
+ $ rails g view User name password
81
+ ```
82
+
83
+ Result:
84
+ ```erb
85
+ <div class="form-group">
86
+ <%= f.label :email %>
87
+ <%= f.email_field :email, autofocus: true, class: "form-control" %>
88
+ </div>
89
+ ```
90
+
91
+
92
+ ## Installation
93
+ Add this line to your application's Gemfile:
94
+
95
+ ```ruby
96
+ gem 'scaffolder'
97
+ ```
98
+
99
+ And then execute:
100
+ ```bash
101
+ $ bundle
102
+ ```
103
+
104
+ Or install it yourself as:
105
+ ```bash
106
+ $ gem install scaffolder
107
+ ```
108
+
109
+ # To do
110
+ - [X] [bootstrap 4](http://getbootstrap.com)
111
+ - [ ] [uikit](http://getuikit.com)
112
+ - [ ] [skeleton](http://getskeleton.com)
113
+ - [ ] [html5boilerplate](https://html5boilerplate.com)
114
+
115
+ ## Contributing
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mtunjic/scaffolder.
117
+
118
+ ## License
119
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Scaffolder'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,9 @@
1
+ #
2
+ # actionscaffold.rb
3
+ #
4
+ # Created by Marko Tunjic on 15/07/16.
5
+ # Copyright © 2016 Marko Tunjic. All rights reserved.
6
+ #
7
+ module ActionScaffold
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ module ActionScaffold
2
+ VERSION = '0.1.4.pre'
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 ActionsSaffold
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,64 @@
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
+ # Only allow a trusted parameter "white list" through.
55
+ def <%= "#{singular_table_name}_params" %>
56
+ <%- if attributes_names.empty? -%>
57
+ params[<%= ":#{singular_table_name}" %>]
58
+ <%- else -%>
59
+ params.require(<%= ":#{singular_table_name}" %>).
60
+ permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
61
+ <%- end -%>
62
+ end
63
+ end
64
+ <% end -%>
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :scaffolder do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actionscaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4.pre
5
+ platform: ruby
6
+ authors:
7
+ - Marko Tunjic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |-
42
+ Make Rails controllers clean & DRY.
43
+ Rails view support for bootstrap 4, uikit, skeleton and html5boilerplate.
44
+ email:
45
+ - marko.tunjic@live.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - MIT-LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - lib/actionscaffold.rb
54
+ - lib/actionscaffold/version.rb
55
+ - lib/generators/actionscaffold/install_generator.rb
56
+ - lib/generators/actionscaffold/templates/controller.rb
57
+ - lib/tasks/scaffolder_tasks.rake
58
+ homepage: https://github.com/mtunjic/actionscaffold
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.1
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.4
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Better default templates for Rails scaffold generator.
82
+ test_files: []