scaffold_plus 1.0.0 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59d4d6a91cc7d9676a1bbbc30337affed0c324da
|
4
|
+
data.tar.gz: e7df5946f9fae05db957991eaa7ab4e6ff1f3651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78184f050386f0ff6eb2f3c116303d904499336fef32de38839a14dbe23facfd09949c879d1d32446e087c9918e5fc6601501eb89d6489c91456cf9b659e0a80
|
7
|
+
data.tar.gz: c1f5a56567b024cc4790f57fdb66e0f7f4c84338eabf1c13abc131c16cff2ae92f3b7a6696ae2db7714922bae1b10a01b07e16d7c4eb44ac8cdac314fcfa79a7
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/README.md
CHANGED
@@ -25,6 +25,12 @@ This helper adds parent#has_many and child#belongs_to to the models
|
|
25
25
|
and updates the mass assignment whitelist in the controller.
|
26
26
|
It can also add a migration for the parent_id and a counter.
|
27
27
|
|
28
|
+
### Add a collection to a resource route
|
29
|
+
rails generate scaffold_plus:collection
|
30
|
+
|
31
|
+
This helper works on config/routes.rb and adds code for a collection
|
32
|
+
to a newly created resource route.
|
33
|
+
|
28
34
|
## Testing
|
29
35
|
|
30
36
|
Since I have no experience with test driven development (yet), this is
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module ScaffoldPlus
|
4
|
+
module Generators
|
5
|
+
class CollectionGenerator < ActiveRecord::Generators::Base
|
6
|
+
desc "Add a collection to a resource route"
|
7
|
+
argument :name, type: :string,
|
8
|
+
desc: "The object for the collection routes and views"
|
9
|
+
argument :routes, type: :array, banner: "route[:verb=get] ...",
|
10
|
+
desc: "The collection(s) to be added to NAME"
|
11
|
+
source_root File.expand_path('../templates', __FILE__)
|
12
|
+
|
13
|
+
def add_routes
|
14
|
+
list = []
|
15
|
+
routes.each do |route|
|
16
|
+
view, verb = route.split(':')
|
17
|
+
list << " #{verb || 'get'} '#{view}'"
|
18
|
+
end
|
19
|
+
result = list.join("\n")
|
20
|
+
gsub_file "config/routes.rb", /(^ resources :#{name.pluralize})$/,
|
21
|
+
"\\1 do\n collection do\n#{result}\n end\n end"
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_views
|
25
|
+
routes.each do |route|
|
26
|
+
@view = route.split(':').first
|
27
|
+
template "view.html.erb", "app/views/#{table_name}/#{@view}.html.erb"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>This is <%= table_name %>#<%= @view %></h1>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volker Wiegand
|
@@ -73,11 +73,14 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".gitignore"
|
76
77
|
- Gemfile
|
77
78
|
- LICENSE.txt
|
78
79
|
- Makefile
|
79
80
|
- README.md
|
80
81
|
- Rakefile
|
82
|
+
- lib/generators/scaffold_plus/collection/collection_generator.rb
|
83
|
+
- lib/generators/scaffold_plus/collection/templates/view.html.erb
|
81
84
|
- lib/generators/scaffold_plus/has_many/has_many_generator.rb
|
82
85
|
- lib/generators/scaffold_plus/has_many/templates/child_migration.rb
|
83
86
|
- lib/generators/scaffold_plus/has_many/templates/counter_migration.rb
|