easy_gen 1.5.0 → 1.5.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afdc2c7d450b407a19e0b5a82f98940bd963e5c2834d60e21779dfd9d13d957b
|
4
|
+
data.tar.gz: 4fc94179b298f2d5fcf1d86616ff0a97f305f4a0f44251d7a5624087fa5e7969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30a98e94af6ca028739c7e19ae5eb9e2c830faf35ad2ba55627317cf7ea52dd4e4f7d772ded27626db44771e06c5dc55e9000e0d8a8d98a5e474418a9b6f1084
|
7
|
+
data.tar.gz: eb49eaf5177912c6f5820797523b437435c2c8cf9f36c2d1577199956da1b8e2bf95847f15bf76037d42e47c3d375f536c595b255ec13d3c4884b00b2d6875b1
|
@@ -18,21 +18,8 @@ class DecoratorGenerator < Rails::Generators::NamedBase
|
|
18
18
|
class_option :module, type: :string
|
19
19
|
|
20
20
|
def main
|
21
|
-
raise "No such model - please check naming" unless model_exists?
|
21
|
+
raise "No such model - #{model_name} - in #{model_path} (#{Dir.pwd})- please check naming" unless model_exists?
|
22
22
|
copy_templates
|
23
23
|
end
|
24
24
|
|
25
|
-
private
|
26
|
-
|
27
|
-
def model_exists?
|
28
|
-
files = Dir[Rails.root + 'app/models/*.rb']
|
29
|
-
models = files.map{ |m| File.basename(m, '.rb').camelize }
|
30
|
-
|
31
|
-
models.include? model_name.camelize
|
32
|
-
end
|
33
|
-
|
34
|
-
def model_name
|
35
|
-
model == "ERROR" ? class_name : model
|
36
|
-
end
|
37
|
-
|
38
25
|
end
|
@@ -49,16 +49,19 @@ module EasyGenGenerator
|
|
49
49
|
@generator_type ||= self.class::TYPE
|
50
50
|
end
|
51
51
|
|
52
|
+
def abstract_base_class_count
|
53
|
+
Object.const_defined?("#{self.class}::BASE_CLASSES") ? self.class::BASE_CLASSES : 1
|
54
|
+
end
|
52
55
|
def no_files?
|
53
|
-
|
56
|
+
count_of_files_indicates_empty? && files_are_abstract_class? && no_tests?
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
57
|
-
Dir["./app/#{base_location}/**/*"].reject { | path | File.directory?(path) }.length ==
|
59
|
+
def count_of_files_indicates_empty?
|
60
|
+
Dir["./app/#{base_location}/**/*"].reject { | path | File.directory?(path) }.length == abstract_base_class_count
|
58
61
|
end
|
59
62
|
|
60
|
-
def
|
61
|
-
|
63
|
+
def files_are_abstract_class?
|
64
|
+
Dir["app/#{base_location}/application_*.rb"].length == abstract_base_class_count
|
62
65
|
end
|
63
66
|
|
64
67
|
def no_tests?
|
@@ -77,13 +80,40 @@ module EasyGenGenerator
|
|
77
80
|
Dir["./app/#{location}/**/*"].reject { | path | File.directory?(path) }.length == 0
|
78
81
|
end
|
79
82
|
|
83
|
+
def gem_testing?
|
84
|
+
Rails.root.blank?
|
85
|
+
end
|
86
|
+
|
87
|
+
def application_root_path
|
88
|
+
gem_testing? ? Pathname.new("./") : Rails.root
|
89
|
+
end
|
90
|
+
|
80
91
|
def teardown(places)
|
81
|
-
|
92
|
+
return if (places.blank? || location.blank?)
|
82
93
|
places.each do | place |
|
83
|
-
|
84
|
-
|
94
|
+
FileUtils.rm_rf(application_root_path.join(place,"#{location}"))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def model_exists?
|
99
|
+
@files ||= Dir[model_path + '*.rb']
|
100
|
+
@models ||= @files.map{ |m| File.basename(m, '.rb').camelize }
|
101
|
+
|
102
|
+
@models.include? model_name.camelize
|
103
|
+
end
|
104
|
+
|
105
|
+
def model_path
|
106
|
+
Pathname(application_root_path.to_s + '/app/models/')
|
107
|
+
end
|
108
|
+
|
109
|
+
def model_name
|
110
|
+
model == "ERROR" ? class_name : model
|
111
|
+
end
|
112
|
+
|
113
|
+
def eg_debug(message)
|
114
|
+
File.open("/Users/simon/Documents/Personal/Code/easy_gen/tmp/log.txt", "a") do |f|
|
115
|
+
f.write message + "\n"
|
85
116
|
end
|
86
|
-
puts "- done"
|
87
117
|
end
|
88
118
|
|
89
119
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rails/all'
|
1
2
|
require 'rails/generators'
|
2
3
|
require 'fileutils'
|
3
4
|
|
@@ -35,26 +36,18 @@ class NullGenerator < Rails::Generators::NamedBase
|
|
35
36
|
|
36
37
|
private
|
37
38
|
|
38
|
-
def model_exists?
|
39
|
-
files = Dir[Rails.root + 'app/models/*.rb']
|
40
|
-
models = files.map{ |m| File.basename(m, '.rb').camelize }
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def model_name
|
46
|
-
model == "ERROR" ? class_name : model
|
40
|
+
def clazz_columns
|
41
|
+
clazz.columns_hash.reject { | key, value | key == "id" }
|
47
42
|
end
|
48
43
|
|
49
44
|
def clazz
|
50
|
-
|
45
|
+
eg_debug "**** Model: #{model_name} - #{model_name.class} - #{model_name.method(:constantize).source_location} ****"
|
46
|
+
|
47
|
+
model_name.constantize
|
51
48
|
end
|
52
49
|
|
53
50
|
def default_value(ar_type)
|
54
51
|
return AR_DEFAULTS[ar_type.to_sym]
|
55
52
|
end
|
56
|
-
|
57
|
-
def clazz_columns
|
58
|
-
clazz.columns_hash.reject { | key, value | key == "id" }
|
59
|
-
end
|
60
53
|
end
|
@@ -11,6 +11,7 @@ class StrategyGenerator < Rails::Generators::NamedBase
|
|
11
11
|
|
12
12
|
LOCATION = "strategies"
|
13
13
|
TYPE = "strategy"
|
14
|
+
BASE_CLASSES = 2
|
14
15
|
|
15
16
|
source_root File.expand_path("templates", __dir__)
|
16
17
|
argument :strategies, type: :array, default: [], banner: "strategy strategy.."
|
data/lib/easy_gen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Stearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple generator for some standard design pattern classes and matching
|
14
14
|
minitests.
|