shatter-rails 0.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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/USAGE +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/shatter/shatter_generator.rb +25 -0
- data/lib/generators/shatter/templates/associations.rb +7 -0
- data/lib/generators/shatter/templates/operations.rb +7 -0
- data/lib/generators/shatter/templates/queries.rb +7 -0
- data/lib/generators/shatter/templates/validations.rb +7 -0
- data/lib/shatter.rb +5 -0
- data/lib/shatter/version.rb +3 -0
- data/shatter.gemspec +26 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd9618c93a7d4a6d27b3b07f4b432c57de6f35af
|
4
|
+
data.tar.gz: 3c5d8798f64bb98c30bfea69f33928e1a992f92a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3740f6687030650a636dcdb7d0323ac66a2cbeb79705ac34a4fb3f3f4cdde1a3685727c7c8d2d432df7716f8a14d99d1d790a61eb304cb0de2a5f2ce585bab9c
|
7
|
+
data.tar.gz: be81d27f0ba4647a489a7098e7c974cd0709bd804107c9090e03361a2f278f5387d7863cabdb3a1b9a0b4b6c65d27604ac49cb05980a997c8b5598e7a740818a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Marcus Orochena
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Shatter
|
2
|
+
|
3
|
+
Shatter is a generator for Rails that seperates an existing model logic into separate files. Shatter uses ActiveSupport::Conern's `included do end` block to call code in the primary model file *in the context* of that model's class.
|
4
|
+
|
5
|
+
When to use Shatter?
|
6
|
+
- Your models are getting too fat.
|
7
|
+
- You don't want to break any existing code.
|
8
|
+
- You want to stay compatible with 'The Rails Way'.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your Rails application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'shatter-rails'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
$ rails g shatter:shatter [model]
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
Description:
|
27
|
+
Shatter is a generator for Rails that seperates an existing model logic into separate files.
|
28
|
+
|
29
|
+
Example:
|
30
|
+
rails generate shatter thing
|
31
|
+
|
32
|
+
This will create:
|
33
|
+
/app/models/thing/assocations.rb
|
34
|
+
/app/models/thing/operations.rb
|
35
|
+
/app/models/thing/queries.rb
|
36
|
+
/app/models/thing/validations.rb
|
37
|
+
|
38
|
+
And will insert the following into /app/models/thing.rb:
|
39
|
+
include Thing::Associations
|
40
|
+
include Thing::Operations
|
41
|
+
include Thing::Queries
|
42
|
+
include Thing::Validations
|
43
|
+
```
|
44
|
+
|
45
|
+
Once you've run the generator, you can copy and paste code from your `thing.rb` model file into the appropriate file.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/morochena/shatter.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/USAGE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
This generator creates new files to put your model logic.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate shatter Thing
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
/app/models/thing/assocations.rb
|
9
|
+
/app/models/thing/operations.rb
|
10
|
+
/app/models/thing/queries.rb
|
11
|
+
/app/models/thing/validations.rb
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "shatter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
|
3
|
+
module Shatter
|
4
|
+
module Generators
|
5
|
+
class Shatter < Rails::Generators::NamedBase
|
6
|
+
|
7
|
+
desc "Generates separate files for a model's association, validation, operation and query logic."
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def generate_refinements
|
11
|
+
template "associations.rb", "app/models/#{file_name}/associations.rb"
|
12
|
+
template "operations.rb", "app/models/#{file_name}/operations.rb"
|
13
|
+
template "queries.rb", "app/models/#{file_name}/queries.rb"
|
14
|
+
template "validations.rb", "app/models/#{file_name}/validations.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
def inject_refinements
|
18
|
+
inject_into_class "app/models/#{file_name}.rb", file_name.singularize.camelcase do
|
19
|
+
"include #{file_name.singularize.camelcase}::Associations\ninclude #{file_name.singularize.camelcase}::Operations\ninclude #{file_name.singularize.camelcase}::Queries\ninclude #{file_name.singularize.camelcase}::Validations\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/shatter.rb
ADDED
data/shatter.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "shatter/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "shatter-rails"
|
8
|
+
spec.version = Shatter::VERSION
|
9
|
+
spec.authors = ["Marcus Orochena"]
|
10
|
+
spec.email = ["marcus@orochena.net"]
|
11
|
+
|
12
|
+
spec.summary = %q{Shatter is a generator for Rails that seperates an existing model logic into separate files. }
|
13
|
+
spec.description = %q{Shatter is a generator for Rails that seperates an existing model logic into separate files. Shatter uses ActiveSupport::Conern's `included do end` block to call code in the primary model file *in the context* of that model's class.}
|
14
|
+
spec.homepage = "https://github.com/morochena/shatter"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shatter-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcus Orochena
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Shatter is a generator for Rails that seperates an existing model logic
|
42
|
+
into separate files. Shatter uses ActiveSupport::Conern's `included do end` block
|
43
|
+
to call code in the primary model file *in the context* of that model's class.
|
44
|
+
email:
|
45
|
+
- marcus@orochena.net
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- USAGE
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- lib/generators/shatter/shatter_generator.rb
|
59
|
+
- lib/generators/shatter/templates/associations.rb
|
60
|
+
- lib/generators/shatter/templates/operations.rb
|
61
|
+
- lib/generators/shatter/templates/queries.rb
|
62
|
+
- lib/generators/shatter/templates/validations.rb
|
63
|
+
- lib/shatter.rb
|
64
|
+
- lib/shatter/version.rb
|
65
|
+
- shatter.gemspec
|
66
|
+
homepage: https://github.com/morochena/shatter
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Shatter is a generator for Rails that seperates an existing model logic into
|
90
|
+
separate files.
|
91
|
+
test_files: []
|