trailblazer-wizard 0.0.7 → 0.0.8
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/.rubocop.yml +3 -0
- data/README.md +10 -9
- data/bin/wizard +7 -3
- data/lib/{wizard → trailblazer_wizard}/concept_generator.rb +5 -5
- data/lib/{wizard → trailblazer_wizard}/concept_type.rb +1 -1
- data/lib/{wizard → trailblazer_wizard}/configuration.rb +1 -1
- data/lib/{wizard → trailblazer_wizard}/file_helper.rb +1 -1
- data/lib/trailblazer_wizard/version.rb +5 -0
- data/lib/wizard.rb +25 -6
- data/sig/wizard/configuration.rbs +1 -1
- data/sig/wizard.rbs +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab2f0037895c7dce9a15bddc6abe0de612614cd26cc2cf550ae5bf5c6a18ddf2
|
|
4
|
+
data.tar.gz: 1fd29f8f553cbc10888f5031bb8a658c7c23c7c2c58f347fedb3e605e5cf4e4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c756f059d4c75a9b2cd87dd25516a8728c6aaef8d850a952e7d81e3047ee691b453ed0d7c60f549aa932e3c8f029a6bc8b4174a0b80cdd1482b90a748ecfa3a3
|
|
7
|
+
data.tar.gz: 6fcd62a5bb88db3b05e13f05990dcdccc0c5e2169cd5afe1f38edde9a84f095f83570be7015ee860e78493e3de2ec173bf77a912be1eb2dc7f6f7b6a4ffa19df
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
|
@@ -18,15 +18,16 @@ All concept files are generated inside the `app/concepts` directory.
|
|
|
18
18
|
|
|
19
19
|
To generate files, simply run this command:
|
|
20
20
|
|
|
21
|
-
$ wizard [--model] [--actions] [--only] [--except] [--context]
|
|
21
|
+
$ wizard [--model] [--full] [--actions] [--only] [--except] [--context]
|
|
22
22
|
|
|
23
|
-
| Argument | Type
|
|
24
|
-
|
|
25
|
-
| model | String
|
|
26
|
-
| actions | Array
|
|
27
|
-
| only | Array
|
|
28
|
-
| except | Array
|
|
29
|
-
| context | String
|
|
23
|
+
| Argument | Type | Presence | Description |
|
|
24
|
+
|----------|---------|--------------|--------------------------------------------------------------------------|
|
|
25
|
+
| model | String | **Required** | The model. |
|
|
26
|
+
| actions | Array | **Required** | The files' names. |
|
|
27
|
+
| only | Array | Optional | Only the specified *concept types*. |
|
|
28
|
+
| except | Array | Optional | Except the specified *concept types*. |
|
|
29
|
+
| context | String | Optional | A directory to group concept files, `nil` by default. |
|
|
30
|
+
| full | Boolean | Optional | Generate the whole batch of concepts for this model, `false` by default. |
|
|
30
31
|
|
|
31
32
|
Allowed concept types are: `operation | finder | form (meant for contracts) | view (meant for representables)`
|
|
32
33
|
|
|
@@ -54,7 +55,7 @@ concept type names... there is the possibility to apply these tweaks by creating
|
|
|
54
55
|
|
|
55
56
|
# config/initializers/trailblazer_wizard.rb
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
TrailblazerWizard.configure do |config|
|
|
58
59
|
config.base_directory = "example/example"
|
|
59
60
|
config.puralize = true
|
|
60
61
|
config.alt_types = {
|
data/bin/wizard
CHANGED
|
@@ -7,7 +7,7 @@ require "wizard"
|
|
|
7
7
|
options = {}
|
|
8
8
|
|
|
9
9
|
OptionParser.new do |opts|
|
|
10
|
-
opts.banner = "Usage:
|
|
10
|
+
opts.banner = "Usage: wizard [options]"
|
|
11
11
|
|
|
12
12
|
opts.on("-m", "--model MODEL", String, "Target model") do |model|
|
|
13
13
|
options[:model] = model
|
|
@@ -25,9 +25,13 @@ OptionParser.new do |opts|
|
|
|
25
25
|
options[:except] = concepts
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
opts.on("-c", "--context CONTEXT", String, "
|
|
28
|
+
opts.on("-c", "--context CONTEXT", String, "Context of these concepts") do |context|
|
|
29
29
|
options[:context] = context
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
opts.on("-f", "--[no-]full", "Generate the whole batch of concepts") do |full|
|
|
33
|
+
options[:full] = full
|
|
34
|
+
end
|
|
31
35
|
end.parse!
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
TrailblazerWizard.generate options[:model], **options
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "active_support/inflector"
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module TrailblazerWizard
|
|
6
6
|
class ConceptGenerator
|
|
7
7
|
attr_reader :type
|
|
8
8
|
|
|
@@ -10,16 +10,16 @@ module Wizard
|
|
|
10
10
|
@type = args[:type]
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def true_type = (
|
|
13
|
+
def true_type = (TrailblazerWizard.configuration.alt_types[type.to_sym] || type).to_s
|
|
14
14
|
|
|
15
|
-
def type_dirname =
|
|
15
|
+
def type_dirname = TrailblazerWizard.configuration.pluralize ? ActiveSupport::Inflector.pluralize(true_type) : true_type
|
|
16
16
|
|
|
17
17
|
def generate(model, name, context = nil)
|
|
18
18
|
materials = [model, type_dirname, name]
|
|
19
19
|
materials.insert(1, context) unless context.nil?
|
|
20
20
|
|
|
21
21
|
filename = materials.map { |material| ActiveSupport::Inflector.underscore(material) }.join("/")
|
|
22
|
-
filename = "#{
|
|
22
|
+
filename = "#{TrailblazerWizard.configuration.base_directory}/#{filename}.rb"
|
|
23
23
|
|
|
24
24
|
false if File.exist?(filename)
|
|
25
25
|
|
|
@@ -33,7 +33,7 @@ module Wizard
|
|
|
33
33
|
|
|
34
34
|
def copy(model, name, context)
|
|
35
35
|
template = File.dirname(__FILE__)
|
|
36
|
-
template["lib/
|
|
36
|
+
template["lib/trailblazer_wizard"] = "lib/concept.txt"
|
|
37
37
|
|
|
38
38
|
content = File.read(template)
|
|
39
39
|
|
data/lib/wizard.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
6
|
-
require_relative "
|
|
7
|
-
require_relative "
|
|
3
|
+
require_relative "trailblazer_wizard/version"
|
|
4
|
+
require_relative "trailblazer_wizard/concept_type"
|
|
5
|
+
require_relative "trailblazer_wizard/concept_generator"
|
|
6
|
+
require_relative "trailblazer_wizard/file_helper"
|
|
7
|
+
require_relative "trailblazer_wizard/configuration"
|
|
8
8
|
|
|
9
|
-
module
|
|
9
|
+
module TrailblazerWizard
|
|
10
10
|
def self.pool
|
|
11
11
|
@pool ||= {}
|
|
12
12
|
end
|
|
@@ -26,6 +26,8 @@ module Wizard
|
|
|
26
26
|
def self.generate(model, **args)
|
|
27
27
|
raise StandardError, "[model] arg is required" if model.nil?
|
|
28
28
|
|
|
29
|
+
return generate_full(model, **args) if args.key?(:full) && args[:full]
|
|
30
|
+
|
|
29
31
|
raise StandardError, "[actions] arg is required" unless args.key? :actions
|
|
30
32
|
|
|
31
33
|
concepts = ConceptType::ALL.values
|
|
@@ -47,4 +49,21 @@ module Wizard
|
|
|
47
49
|
|
|
48
50
|
output
|
|
49
51
|
end
|
|
52
|
+
|
|
53
|
+
def self.generate_full(model, **args)
|
|
54
|
+
batch = {
|
|
55
|
+
operation: %w[index show create update destroy],
|
|
56
|
+
form: %w[create update],
|
|
57
|
+
finder: %w[base],
|
|
58
|
+
view: %w[index show]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
batch.each_key do |concept|
|
|
62
|
+
batch[concept].each do |action|
|
|
63
|
+
file = fetch_generator(concept.to_s).generate(model, action.to_s, args[:context]&.to_s)
|
|
64
|
+
|
|
65
|
+
puts file if file.length.positive?
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
50
69
|
end
|
data/sig/wizard.rbs
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trailblazer-wizard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- aredda
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-08-
|
|
11
|
+
date: 2025-08-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -46,11 +46,12 @@ files:
|
|
|
46
46
|
- Rakefile
|
|
47
47
|
- bin/wizard
|
|
48
48
|
- lib/concept.txt
|
|
49
|
+
- lib/trailblazer_wizard/concept_generator.rb
|
|
50
|
+
- lib/trailblazer_wizard/concept_type.rb
|
|
51
|
+
- lib/trailblazer_wizard/configuration.rb
|
|
52
|
+
- lib/trailblazer_wizard/file_helper.rb
|
|
53
|
+
- lib/trailblazer_wizard/version.rb
|
|
49
54
|
- lib/wizard.rb
|
|
50
|
-
- lib/wizard/concept_generator.rb
|
|
51
|
-
- lib/wizard/concept_type.rb
|
|
52
|
-
- lib/wizard/configuration.rb
|
|
53
|
-
- lib/wizard/file_helper.rb
|
|
54
55
|
- lib/wizard/version.rb
|
|
55
56
|
- sig/wizard.rbs
|
|
56
57
|
- sig/wizard/configuration.rbs
|