dry_generators_rails 0.1.0 → 0.2.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 +4 -4
- data/MIT-LICENSE +20 -20
- data/README.md +38 -35
- data/Rakefile +27 -27
- data/lib/dry_generators_rails.rb +5 -5
- data/lib/dry_generators_rails/railtie.rb +4 -4
- data/lib/dry_generators_rails/version.rb +3 -3
- data/lib/generators/dry.rb +6 -6
- data/lib/generators/dry/validation/USAGE +8 -8
- data/lib/generators/dry/validation/templates/validation_spec_template.rb +5 -0
- data/lib/generators/dry/validation/templates/validation_template.rb +7 -8
- data/lib/generators/dry/validation/templates/validation_test_template.rb +5 -0
- data/lib/generators/dry/validation/validation_generator.rb +34 -16
- data/lib/tasks/dry_generators_rails_tasks.rake +4 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6593b9f69a17dd7af47bc3225caadcbf4b1b0ee51312a9159f744f8142d2683e
|
4
|
+
data.tar.gz: 471f4f9f91415105b734325d733128a915c17acee89d8492d76ecf3841137a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f03ef6f6d013a19f718dd6d23d3c01bb154d648f0174f33d97e7f20865ffafa89ca6e2b092a7a8fa109ad9f45b43101a116c9f94b58636e063e69e3d83f0661
|
7
|
+
data.tar.gz: b0665ad6d4ed5471d481ea7bddc09bd1e78076aaf53ca511c4df71a76e1fa6f6cb476f0642224e51743ce9284d5c37ca25352b77aa72e3120205761f105f9dfb
|
data/MIT-LICENSE
CHANGED
@@ -1,20 +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.
|
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
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
-
#
|
2
|
-
Dry Generator Rails brings dry-rb to Rails in a consistent
|
3
|
-
manner.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
##
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
```
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
CHANGED
@@ -1,27 +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
|
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
|
data/lib/dry_generators_rails.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require "dry_generators_rails/railtie"
|
2
|
-
|
3
|
-
module DryGeneratorsRails
|
4
|
-
# Your code goes here...
|
5
|
-
end
|
1
|
+
require "dry_generators_rails/railtie"
|
2
|
+
|
3
|
+
module DryGeneratorsRails
|
4
|
+
# Your code goes here...
|
5
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module DryGeneratorsRails
|
2
|
-
class Railtie < ::Rails::Railtie
|
3
|
-
end
|
4
|
-
end
|
1
|
+
module DryGeneratorsRails
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
end
|
4
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module DryGeneratorsRails
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
1
|
+
module DryGeneratorsRails
|
2
|
+
VERSION = '0.2.0'
|
3
|
+
end
|
data/lib/generators/dry.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module Dry
|
2
|
-
module Generators
|
3
|
-
class Base < Rails::Generators::NamedBase
|
4
|
-
end
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Dry
|
2
|
+
module Generators
|
3
|
+
class Base < Rails::Generators::NamedBase
|
4
|
+
end
|
5
|
+
end
|
6
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Description:
|
2
|
-
Generates a dry-validation contract
|
3
|
-
|
4
|
-
Example:
|
5
|
-
rails generate validation Thing
|
6
|
-
|
7
|
-
This will create:
|
8
|
-
app/dry-validations/thing_validator.rb
|
1
|
+
Description:
|
2
|
+
Generates a dry-validation contract
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate validation Thing
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/dry-validations/thing_validator.rb
|
@@ -1,8 +1,7 @@
|
|
1
|
-
class <%= file_name.camelize %> < Dry::Validation::Contract
|
2
|
-
params do
|
3
|
-
# required(:age).filled(:integer)
|
4
|
-
end
|
5
|
-
|
6
|
-
# rule(:age) { key.failure("must be greater than 18") if value < 18 }
|
7
|
-
end
|
8
|
-
RuB_60326032
|
1
|
+
class <%= file_name.camelize %> < Dry::Validation::Contract
|
2
|
+
params do
|
3
|
+
# required(:age).filled(:integer)
|
4
|
+
end
|
5
|
+
|
6
|
+
# rule(:age) { key.failure("must be greater than 18") if value < 18 }
|
7
|
+
end
|
@@ -1,16 +1,34 @@
|
|
1
|
-
require 'generators/dry'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Generators
|
5
|
-
class ValidationGenerator < Base
|
6
|
-
source_root File.expand_path('templates', __dir__)
|
7
|
-
PATH = File.join(Rails.root, 'dry', 'validators').freeze
|
8
|
-
|
9
|
-
def copy_validator
|
10
|
-
raise 'NAME must be provided' unless file_name.present?
|
11
|
-
name = file_name.underscore
|
12
|
-
template 'validation_template.rb', File.join(PATH, "#{name}_validator.rb")
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
require 'generators/dry'
|
2
|
+
|
3
|
+
module Dry
|
4
|
+
module Generators
|
5
|
+
class ValidationGenerator < Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
PATH = File.join(Rails.root, 'dry', 'validators').freeze
|
8
|
+
|
9
|
+
def copy_validator
|
10
|
+
raise 'NAME must be provided' unless file_name.present?
|
11
|
+
name = file_name.underscore
|
12
|
+
template 'validation_template.rb', File.join(PATH, "#{name}_validator.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_spec
|
16
|
+
if Dir.exist? File.join(Rails.root, 'spec')
|
17
|
+
name = file_name.underscore
|
18
|
+
path = File.join(Rails.root, 'spec', 'dry', 'validators')
|
19
|
+
spec_template = 'validation_spec_template.rb'
|
20
|
+
template spec_template, File.join(path, "#{name}_validator_spec.rb")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_test
|
25
|
+
if Dir.exist? File.join(Rails.root, 'test')
|
26
|
+
name = file_name.underscore
|
27
|
+
path = File.join(Rails.root, 'test', 'dry', 'validators')
|
28
|
+
test_template = 'validation_test_template.rb'
|
29
|
+
template test_template, File.join(path, "#{name}_validator_test.rb")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# desc "Explaining what the task does"
|
2
|
-
# task :dry_generators_rails do
|
3
|
-
# # Task goes here
|
4
|
-
# end
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :dry_generators_rails do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_generators_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Turknett
|
@@ -59,7 +59,9 @@ files:
|
|
59
59
|
- lib/dry_generators_rails/version.rb
|
60
60
|
- lib/generators/dry.rb
|
61
61
|
- lib/generators/dry/validation/USAGE
|
62
|
+
- lib/generators/dry/validation/templates/validation_spec_template.rb
|
62
63
|
- lib/generators/dry/validation/templates/validation_template.rb
|
64
|
+
- lib/generators/dry/validation/templates/validation_test_template.rb
|
63
65
|
- lib/generators/dry/validation/validation_generator.rb
|
64
66
|
- lib/tasks/dry_generators_rails_tasks.rake
|
65
67
|
homepage: https://github.com/johnTurknett/dry_generators_rails
|
@@ -81,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
- !ruby/object:Gem::Version
|
82
84
|
version: '0'
|
83
85
|
requirements: []
|
84
|
-
|
85
|
-
rubygems_version: 2.7.6
|
86
|
+
rubygems_version: 3.1.2
|
86
87
|
signing_key:
|
87
88
|
specification_version: 4
|
88
89
|
summary: dry-rb generators for Rails
|