easy_gen 1.1.0 → 1.1.2
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/README.md +4 -4
- data/lib/easy_gen/null/null_generator.rb +8 -0
- data/lib/easy_gen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c73b60e1c24075a1662af912505f2da6d3c4c716b5573e5c2186ff0684d4d0c0
|
4
|
+
data.tar.gz: 0eb19ee899681fc035827e937926ec526a87e79dc93d03b39b3e9af339065c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1f84b24cd3c5591b0dfe4e3c3a73e3e43012a3d904577c68258e261783aa100fce4262a8312d7aedb25325816b5f129c193ae64e905941aaef3221660dded9
|
7
|
+
data.tar.gz: 05d0904c0759b3a0d23a0bf66c54d361c3c0371a59629225a217bdf4ab9dee3a7074d6ea3833249457dc3033d4af15826cbe7b7372d0abbf34e7d3de291b7d48
|
data/README.md
CHANGED
@@ -18,10 +18,10 @@ In the usual way.
|
|
18
18
|
|
19
19
|
## Using generators
|
20
20
|
|
21
|
-
#Service Objects:
|
21
|
+
#Service Objects (See this link for example usage: https://www.honeybadger.io/blog/refactor-ruby-rails-service-object/):
|
22
22
|
|
23
23
|
```sh
|
24
|
-
bundle exec rails g service
|
24
|
+
bundle exec rails g service serviceclassname
|
25
25
|
```
|
26
26
|
|
27
27
|
The command above:
|
@@ -42,9 +42,9 @@ The command above:
|
|
42
42
|
|
43
43
|
- Creates '/app/domain' directory if it doesnt exist.
|
44
44
|
- Installs new application domain class in '/app/domain' with the name 'ApplicationNull' in file '/app/domain/application_null.rb.'
|
45
|
-
- Installs new domain class in '/app/domain' with the class name '
|
45
|
+
- Installs new domain class in '/app/domain' with the class name 'ModelnameNull' in the file /app/domain/modelname_null.rb. This will inherit from /app/domain/application_null.rb.'
|
46
46
|
- Creates '/test/domain' directory if it doesnt exist.
|
47
|
-
- Installs new test class in '/test/domain' with the name '
|
47
|
+
- Installs new test class in '/test/domain' with the name 'ModelnameNullTest' in the file '/test/domain/modelname_null_test.rb'.
|
48
48
|
|
49
49
|
|
50
50
|
** Nothing clever - just saves a bit of typing
|
@@ -28,11 +28,19 @@ class NullGenerator < Rails::Generators::NamedBase
|
|
28
28
|
argument :model, type: :string, default: "ERROR", banner: "model"
|
29
29
|
|
30
30
|
def main
|
31
|
+
raise "No such model - please check naming" unless model_exists?
|
31
32
|
copy_templates
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
36
|
|
37
|
+
def model_exists?
|
38
|
+
files = Dir[Rails.root + 'app/models/*.rb']
|
39
|
+
models = files.map{ |m| File.basename(m, '.rb').camelize }
|
40
|
+
|
41
|
+
models.include? model_name.camelize
|
42
|
+
end
|
43
|
+
|
36
44
|
def model_name
|
37
45
|
model == "ERROR" ? class_name : model
|
38
46
|
end
|
data/lib/easy_gen/version.rb
CHANGED