dry_generators_rails 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +38 -0
- data/Rakefile +27 -0
- data/lib/dry_generators_rails.rb +5 -0
- data/lib/dry_generators_rails/railtie.rb +4 -0
- data/lib/dry_generators_rails/version.rb +3 -0
- data/lib/generators/dry.rb +12 -0
- data/lib/generators/dry/struct/USAGE +8 -0
- data/lib/generators/dry/struct/struct_generator.rb +39 -0
- data/lib/generators/dry/struct/templates/struct_spec_template.rb +5 -0
- data/lib/generators/dry/struct/templates/struct_template.rb +5 -0
- data/lib/generators/dry/struct/templates/struct_test_template.rb +5 -0
- data/lib/generators/dry/validation/USAGE +8 -0
- data/lib/generators/dry/validation/templates/validation_spec_template.rb +5 -0
- data/lib/generators/dry/validation/templates/validation_template.rb +9 -0
- data/lib/generators/dry/validation/templates/validation_test_template.rb +5 -0
- data/lib/generators/dry/validation/validation_generator.rb +39 -0
- data/lib/tasks/dry_generators_rails_tasks.rake +4 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: af7577513c479773e534e928dc7ba205a53818a636f5692e807696aa2263e857
|
4
|
+
data.tar.gz: 2bec7b106755a418747897be94268e8478ab97acb69fff37f663f1ab77120a34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aac0cd6e0ffb23ea275c99e9264cf5de0b0d77de5bbb3eb5790344c520feca62898c05fb05ab9f55fa4063b8573ed72c36d746ab28c66a7ecfdc5f15e692312c
|
7
|
+
data.tar.gz: 6d931f04ca9fc9cab5aed22cbd37d232161936f566ee14b44c946ec3cc5dd6285862251ff298a8c66dd45f41466fd0698f00deb40ef58ce6793c5cd513241dbb
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020
|
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,38 @@
|
|
1
|
+
# Dry Generators Rails
|
2
|
+
Dry Generator Rails brings dry-rb to Rails in a consistent
|
3
|
+
manner.
|
4
|
+
|
5
|
+
This is a work in progress by a squishy human that makes mistakes and will
|
6
|
+
eventually die.
|
7
|
+
|
8
|
+
## Available Generators
|
9
|
+
|
10
|
+
- dry:validation
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
`rails g dry:validation User`
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'dry_generators_rails'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
```bash
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
```bash
|
29
|
+
$ gem install dry_generators_rails
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
I would love any help you want to put towards this.
|
34
|
+
|
35
|
+
Bug reports and feature requests are also a form of help.
|
36
|
+
|
37
|
+
## License
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
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 = 'DryGeneratorsRails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dry
|
2
|
+
module Generators
|
3
|
+
class Base < Rails::Generators::NamedBase
|
4
|
+
DRY_PATH = File.join(Rails.root, 'app', 'dry').freeze
|
5
|
+
SPEC_PATH = File.join(Rails.root, 'spec', 'dry').freeze
|
6
|
+
TEST_PATH = File.join(Rails.root, 'test', 'dry').freeze
|
7
|
+
|
8
|
+
VALIDATIONS_PATH = File.join(DRY_PATH, 'validations').freeze
|
9
|
+
STRUCTS_PATH = File.join(DRY_PATH, 'structs').freeze
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'generators/dry'
|
2
|
+
|
3
|
+
module Dry
|
4
|
+
module Generators
|
5
|
+
class StructGenerator < Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
|
8
|
+
def check_requirements
|
9
|
+
raise 'NAME must be provided' unless file_name.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_instance_variables
|
13
|
+
@name = file_name.underscore
|
14
|
+
@class_name = "#{@name.camelize}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def copy_struct
|
18
|
+
path = File.join(STRUCTS_PATH, "#{@name}.rb")
|
19
|
+
template 'struct_template.rb', path
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_spec
|
23
|
+
if Dir.exist? File.join(Rails.root, 'spec')
|
24
|
+
spec_path = File.join(SPEC_PATH, 'structs')
|
25
|
+
path = File.join(spec_path, "#{@name}_spec.rb")
|
26
|
+
template 'struct_spec_template.rb', path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_test
|
31
|
+
if Dir.exist? File.join(Rails.root, 'test')
|
32
|
+
test_path = File.join(TEST_PATH, 'structs')
|
33
|
+
path = File.join(test_path, "#{@name}_test.rb")
|
34
|
+
template 'struct_test_template.rb', path
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'generators/dry'
|
2
|
+
|
3
|
+
module Dry
|
4
|
+
module Generators
|
5
|
+
class ValidationGenerator < Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
|
8
|
+
def check_requirements
|
9
|
+
raise 'NAME must be provided' unless file_name.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_instance_variables
|
13
|
+
@name = file_name.underscore
|
14
|
+
@class_name = "#{@name.camelize}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def copy_validator
|
18
|
+
path = File.join(VALIDATIONS_PATH, "#{@name}.rb")
|
19
|
+
template 'validation_template.rb', path
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_spec
|
23
|
+
if Dir.exist? File.join(Rails.root, 'spec')
|
24
|
+
spec_path = File.join(SPEC_PATH, 'validations')
|
25
|
+
path = File.join(spec_path, "#{@name}_spec.rb")
|
26
|
+
template 'validation_spec_template.rb', path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_test
|
31
|
+
if Dir.exist? File.join(Rails.root, 'test')
|
32
|
+
test_path = File.join(TEST_PATH, 'validations')
|
33
|
+
path = File.join(test_path, "#{@name}_test.rb")
|
34
|
+
template 'validation_test_template.rb', path
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dry_generators_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Turknett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-16 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: 6.0.2
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 6.0.2.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.0.2
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 6.0.2.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: dry-validation
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: dry-struct
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: Generate dry-rb classes for Rails applications
|
76
|
+
email:
|
77
|
+
- johnturknett@gmail.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- MIT-LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- lib/dry_generators_rails.rb
|
86
|
+
- lib/dry_generators_rails/railtie.rb
|
87
|
+
- lib/dry_generators_rails/version.rb
|
88
|
+
- lib/generators/dry.rb
|
89
|
+
- lib/generators/dry/struct/USAGE
|
90
|
+
- lib/generators/dry/struct/struct_generator.rb
|
91
|
+
- lib/generators/dry/struct/templates/struct_spec_template.rb
|
92
|
+
- lib/generators/dry/struct/templates/struct_template.rb
|
93
|
+
- lib/generators/dry/struct/templates/struct_test_template.rb
|
94
|
+
- lib/generators/dry/validation/USAGE
|
95
|
+
- lib/generators/dry/validation/templates/validation_spec_template.rb
|
96
|
+
- lib/generators/dry/validation/templates/validation_template.rb
|
97
|
+
- lib/generators/dry/validation/templates/validation_test_template.rb
|
98
|
+
- lib/generators/dry/validation/validation_generator.rb
|
99
|
+
- lib/tasks/dry_generators_rails_tasks.rake
|
100
|
+
homepage: https://github.com/johnTurknett/dry_generators_rails
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubygems_version: 3.1.2
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: dry-rb generators for Rails
|
123
|
+
test_files: []
|