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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95fcbb1b48e4b5858a5854dadc9fe36ba71f9f3398ca4af37d1c2ca3034ca59d
4
- data.tar.gz: 99967e9153f72da95d478f89588c9a146632fd4620774bad171839dd327e3062
3
+ metadata.gz: c73b60e1c24075a1662af912505f2da6d3c4c716b5573e5c2186ff0684d4d0c0
4
+ data.tar.gz: 0eb19ee899681fc035827e937926ec526a87e79dc93d03b39b3e9af339065c68
5
5
  SHA512:
6
- metadata.gz: 9b22fa93da43aa81936bd2d697b2019b951ef391d2baad23ba9c3144d893459af4fbb2f0cd24f770f2b3a63753428aa41d7f4c6bdaeb44f6ca31a92cd27667ac
7
- data.tar.gz: 1a9b12cd25981af1c3db68fef2f6e0fb1ef7179bc6b33cefe02e3cfbba7128f19b7bc75a5cb7667694c2c07dce0a00ac4aad4843d8785b0f95f579d727325351
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 ServiceClassName
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 'NullModelname' in the file /app/domain/null_modelname.rb. This will inherit from /app/domain/application_null.rb.'
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 'ServiceClassNameTest' in the file '/test/domain/null_modelname_test.rb'.
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
@@ -1,3 +1,3 @@
1
1
  module EasyGen
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Stearn