rails_view_generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/README.md +30 -0
- data/Rakefile +4 -0
- data/lib/generators/rails/USAGE +19 -0
- data/lib/generators/rails/view_generator.rb +16 -0
- data/lib/rails_view_generator/version.rb +5 -0
- data/lib/rails_view_generator.rb +4 -0
- data/sig/rails_view_generator.rbs +4 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8962c9567eb80357773c3d26e7a65a3d31b78fe2f1492ec563dd3ad1efd2bd8
|
4
|
+
data.tar.gz: f2e3eb857393c69eafbefdeb456fdb211f1c6ffd9a0d53d118a5af978c5e8da7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f53b7d72759f5fc5ae1cc7a5ca802d54a8ece0c5601e50069f88efed8525bea96a20ed7b32649b3c42a181edd6ccc4a17e35d14518f8b42e3c7b7ece4df957f6
|
7
|
+
data.tar.gz: 7d6ad6c4def2e6e0592261e579e68e0ad905db5a322ec571336af0c9b92150a05701edcd60e687348988149eb47cbddbb3d04509f5eb97c59958e9d4e91ae9dd
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# RailsViewGenerator
|
2
|
+
|
3
|
+
This gem adds a Rails generator that creates just the view file which would normally generated by a `rails generate scaffold` command.
|
4
|
+
|
5
|
+
## Installation & Usage
|
6
|
+
|
7
|
+
```
|
8
|
+
bundle add rails_view_generator, group: :development
|
9
|
+
|
10
|
+
bundle install
|
11
|
+
|
12
|
+
rails generate view ModelName field_name:field_type field_name2:field_type2 ...
|
13
|
+
```
|
14
|
+
|
15
|
+
This generator utilizes the same look-up for the `.html.erb.tt` files as the original [scaffold generator](https://github.com/rails/rails/blob/main/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb), which can be found in the [`rails/generators/erb/scaffold/templates`](https://github.com/rails/rails/tree/main/railties/lib/rails/generators/erb/scaffold/templates).
|
16
|
+
|
17
|
+
You can customize these views by copying them to `lib/templates/erb/scaffold` and modifying them as needed.
|
18
|
+
|
19
|
+
## Relevant Links:
|
20
|
+
|
21
|
+
- https://guides.rubyonrails.org/generators.htm
|
22
|
+
- https://stackoverflow.com/questions/5666595/how-to-override-a-rails-generator-template-in-a-gem
|
23
|
+
|
24
|
+
## Changelog
|
25
|
+
|
26
|
+
- 0.1.0: Initial release
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/coezbek/rails_view_generator.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Description:
|
2
|
+
Generates the html.erb views (and only those) of the scaffold generator for a given model.
|
3
|
+
Pass the same arguments as you would to the scaffold generator, i.e. pass the name of
|
4
|
+
the model (in singular form), either CamelCased or under_scored, as the first argument,
|
5
|
+
and then a list of attribute pairs ('fieldname:type').
|
6
|
+
|
7
|
+
The following files are generated:
|
8
|
+
- index.html.erb
|
9
|
+
- show.html.erb
|
10
|
+
- new.html.erb
|
11
|
+
- edit.html.erb
|
12
|
+
- _form.html.erb
|
13
|
+
- _<model>.html.erb (partial)
|
14
|
+
|
15
|
+
Example:
|
16
|
+
'bin/rails generate view post'
|
17
|
+
'bin/rails generate view post title:string body:text published:boolean'
|
18
|
+
'bin/rails generate view purchase amount:decimal tracking_id:integer:uniq'
|
19
|
+
'bin/rails generate view user email:uniq password:digest'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators/erb/scaffold/scaffold_generator'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generators
|
5
|
+
class ViewGenerator < ::Erb::Generators::ScaffoldGenerator # Rails::Generators::NamedBase
|
6
|
+
source_root ::Erb::Generators::ScaffoldGenerator.source_root
|
7
|
+
|
8
|
+
def self.usage_path
|
9
|
+
paths = [
|
10
|
+
File.expand_path("USAGE", File.dirname(__FILE__)),
|
11
|
+
]
|
12
|
+
paths.compact.detect { |path| File.exist? path }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_view_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christopher Oezbek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This separates the generator of the html.erb.views from the model/controller
|
14
|
+
generation.
|
15
|
+
email:
|
16
|
+
- c.oezbek@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- CHANGELOG.md
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- lib/generators/rails/USAGE
|
25
|
+
- lib/generators/rails/view_generator.rb
|
26
|
+
- lib/rails_view_generator.rb
|
27
|
+
- lib/rails_view_generator/version.rb
|
28
|
+
- sig/rails_view_generator.rbs
|
29
|
+
homepage: https://github.com/coezbek/rails_view_generator
|
30
|
+
licenses: []
|
31
|
+
metadata:
|
32
|
+
allowed_push_host: https://rubygems.org
|
33
|
+
homepage_uri: https://github.com/coezbek/rails_view_generator
|
34
|
+
source_code_uri: https://github.com/coezbek/rails_view_generator
|
35
|
+
changelog_uri: https://github.com/coezbek/rails_view_generator/README.md#Changelog
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 3.0.0
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.4.19
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Adds a generator for just the scaffold erb views to rails generate
|
55
|
+
test_files: []
|