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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff59526630094c6f2e34602e2d0336105e0ea173f5fd8e0983fdb46d839c9145
4
- data.tar.gz: a1f553b1beef57f710b007493acee5b8b9fd04706179e344f4570b08c4fce68f
3
+ metadata.gz: ab2f0037895c7dce9a15bddc6abe0de612614cd26cc2cf550ae5bf5c6a18ddf2
4
+ data.tar.gz: 1fd29f8f553cbc10888f5031bb8a658c7c23c7c2c58f347fedb3e605e5cf4e4d
5
5
  SHA512:
6
- metadata.gz: c132cdea57a389c99f757fba35ef169c9327e1baf25144b2c6d3f5c3c6f185c8426b2d6b1e5acac053b69a88ae089c717eb11ef61069592513d15ef5340aca4b
7
- data.tar.gz: c26412c7d72eef654cbe238fbfb710c03ade80abff55f17394fbda983eaf5be65608d3475acadf41a86394e54a7ebac6aebe267740dbbaa998e28f94f90387ca
6
+ metadata.gz: c756f059d4c75a9b2cd87dd25516a8728c6aaef8d850a952e7d81e3047ee691b453ed0d7c60f549aa932e3c8f029a6bc8b4174a0b80cdd1482b90a748ecfa3a3
7
+ data.tar.gz: 6fcd62a5bb88db3b05e13f05990dcdccc0c5e2169cd5afe1f38edde9a84f095f83570be7015ee860e78493e3de2ec173bf77a912be1eb2dc7f6f7b6a4ffa19df
data/.rubocop.yml CHANGED
@@ -23,3 +23,6 @@ Metrics/MethodLength:
23
23
 
24
24
  Metrics/PerceivedComplexity:
25
25
  Enabled: false
26
+
27
+ Layout/LineLength:
28
+ Enabled: false
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 | 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. |
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
- Wizard.configure do |config|
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: TODO"
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, "Only these concepts") do |context|
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
- Wizard.generate options[:model], **options
37
+ TrailblazerWizard.generate options[:model], **options
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "active_support/inflector"
4
4
 
5
- module Wizard
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 = (Wizard.configuration.alt_types[type.to_sym] || type).to_s
13
+ def true_type = (TrailblazerWizard.configuration.alt_types[type.to_sym] || type).to_s
14
14
 
15
- def type_dirname = Wizard.configuration.pluralize ? ActiveSupport::Inflector.pluralize(true_type) : true_type
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 = "#{Wizard.configuration.base_directory}/#{filename}.rb"
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/wizard"] = "lib/concept.txt"
36
+ template["lib/trailblazer_wizard"] = "lib/concept.txt"
37
37
 
38
38
  content = File.read(template)
39
39
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Wizard
3
+ module TrailblazerWizard
4
4
  module ConceptType
5
5
  OPERATION = "operation"
6
6
  FINDER = "finder"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Wizard
3
+ module TrailblazerWizard
4
4
  class Configuration
5
5
  attr_accessor :base_directory, :pluralize, :alt_types
6
6
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "fileutils"
4
4
 
5
- module Wizard
5
+ module TrailblazerWizard
6
6
  class FileHelper
7
7
  def self.mkdir(filename)
8
8
  dirs = filename.split "/"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrailblazerWizard
4
+ VERSION = "0.0.8"
5
+ end
data/lib/wizard.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "wizard/version"
4
- require_relative "wizard/concept_type"
5
- require_relative "wizard/concept_generator"
6
- require_relative "wizard/file_helper"
7
- require_relative "wizard/configuration"
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 Wizard
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
@@ -1,4 +1,4 @@
1
- module Wizard
1
+ module TrailblazerWizard
2
2
  class Configuration
3
3
  @base_directory: String
4
4
  @pluralize: bool
data/sig/wizard.rbs CHANGED
@@ -1,4 +1,4 @@
1
- module Wizard
1
+ module TrailblazerWizard
2
2
  VERSION: String
3
3
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
4
  end
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.7
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-21 00:00:00.000000000 Z
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