dry_generators_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b4c5054b02f10d81321b40073038ce8bbbd605329301343a84228f19c44f5520
4
+ data.tar.gz: 2959854ace11289865dc77a0865a7f9b9c60e1065fb6ca3ff55755f38bcbd3da
5
+ SHA512:
6
+ metadata.gz: a844ad0d3e0eb21fcd39503afc404ad963f7e1ed05f89492838b7d90bd351ddac8da5df5b0b869016c49511a9ef3e0e7977a871ffd024ac8437528e6314ac4f1
7
+ data.tar.gz: 77cb56bf7736a5fe92b67a862bcc53f6e52a76efc1cc36efff980d9c8b2e999b9bab6f5f54554a702af2705f0086c22d71ca5ee4d6cd1b126e9b4d3f3786a7d0
@@ -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.
@@ -0,0 +1,35 @@
1
+ # DryGeneratorsRails
2
+ Dry Generator Rails brings dry-rb to Rails in a consistent
3
+ manner.
4
+
5
+ ## Available Generators
6
+
7
+ - dry:validation
8
+
9
+ ## Usage
10
+ `rails g dry:validation User`
11
+
12
+ ## Installation
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'dry_generators_rails'
17
+ ```
18
+
19
+ And then execute:
20
+ ```bash
21
+ $ bundle
22
+ ```
23
+
24
+ Or install it yourself as:
25
+ ```bash
26
+ $ gem install dry_generators_rails
27
+ ```
28
+
29
+ ## Contributing
30
+ I would love any help you want to put towards this.
31
+
32
+ Bug reports and feature requests are also a form of help.
33
+
34
+ ## License
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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,5 @@
1
+ require "dry_generators_rails/railtie"
2
+
3
+ module DryGeneratorsRails
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ module DryGeneratorsRails
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module DryGeneratorsRails
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,6 @@
1
+ module Dry
2
+ module Generators
3
+ class Base < Rails::Generators::NamedBase
4
+ end
5
+ end
6
+ end
@@ -0,0 +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
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,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
+ end
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :dry_generators_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dry_generators_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Turknett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-15 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
+ description: Generate dry-rb classes for Rails applications
48
+ email:
49
+ - johnturknett@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/dry_generators_rails.rb
58
+ - lib/dry_generators_rails/railtie.rb
59
+ - lib/dry_generators_rails/version.rb
60
+ - lib/generators/dry.rb
61
+ - lib/generators/dry/validation/USAGE
62
+ - lib/generators/dry/validation/templates/validation_template.rb
63
+ - lib/generators/dry/validation/validation_generator.rb
64
+ - lib/tasks/dry_generators_rails_tasks.rake
65
+ homepage: https://github.com/johnTurknett/dry_generators_rails
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.7.6
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: dry-rb generators for Rails
89
+ test_files: []