trailblazer-wizard 0.0.3 → 0.0.5

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: 6bf7941b9eef1a866dcd05d9c8a6a86d011e969b3b9d92203efa62e0c8992c80
4
- data.tar.gz: afe91daae22d54bf06350ac2e7fe1b57804de9dd095571872964f03190be2e7a
3
+ metadata.gz: facf812ccc5f3049422d317eb80033fc5459ab22a94163c2ba036d125241479e
4
+ data.tar.gz: e6b30c1a557d7f1b4dd501f88ce430e272cdbdde39c16604ecef89381dac4f70
5
5
  SHA512:
6
- metadata.gz: 187f4298b9d8f6a3cc28f2814abcdf2ff96fc2d2b434475cf3894d1985291c474eeb947d6c0b9024fdf8a859e26985a62f5e29b930a1a600cb9ce9de7e449256
7
- data.tar.gz: 3b94513cb1f99400d531bee08c1e0633bdd168ae8a76e3deaeac830003c202482a0a2afa3bf8f16ca2bb16b16640742f9d0c51304c378c8b707c766711cb6c94
6
+ metadata.gz: b0b3ac2e8cd385451a93f148b22798fef289a01bba4fc3f5087a7bd360d28232e82cd4a55f41badb03eba5594e75efac5d5f5e35f415ebc1decbaf7d8765602b
7
+ data.tar.gz: cdf88074a891e6a8f6a55007f1d0d116d41c1e776acb33747ae29519c9032ac86cc96db8fa344f7b03d49ad3278044f5901c5ba858250c183d05eae4418cfef8
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="asdf: 3.1.3" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/wizard.iml" filepath="$PROJECT_DIR$/.idea/wizard.iml" />
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/trailblazer-wizard.iml" filepath="$PROJECT_DIR$/.idea/trailblazer-wizard.iml" />
6
6
  </modules>
7
7
  </component>
8
8
  </project>
@@ -14,7 +14,7 @@
14
14
  <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.1.3.2, asdf: 3.3.0) [gem]" level="application" />
15
15
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, asdf: 3.3.0) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.7, asdf: 3.3.0) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.5.9, asdf: 3.3.0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.5.3, asdf: 3.3.0) [gem]" level="application" />
18
18
  <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.3, asdf: 3.3.0) [gem]" level="application" />
19
19
  <orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.4.1, asdf: 3.3.0) [gem]" level="application" />
20
20
  <orderEntry type="library" scope="PROVIDED" name="drb (v2.2.1, asdf: 3.3.0) [gem]" level="application" />
@@ -39,21 +39,21 @@
39
39
  <option name="myRootTask">
40
40
  <RakeTaskImpl id="rake">
41
41
  <subtasks>
42
- <RakeTaskImpl description="Build wizard-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
42
+ <RakeTaskImpl description="Build trailblazer-wizard-0.0.4.gem into the pkg directory" fullCommand="build" id="build" />
43
43
  <RakeTaskImpl id="build">
44
44
  <subtasks>
45
- <RakeTaskImpl description="Generate SHA512 checksum if wizard-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
45
+ <RakeTaskImpl description="Generate SHA512 checksum if trailblazer-wizard-0.0.4.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
46
46
  </subtasks>
47
47
  </RakeTaskImpl>
48
48
  <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
49
49
  <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
50
- <RakeTaskImpl description="Build and install wizard-0.1.0.gem into system gems" fullCommand="install" id="install" />
50
+ <RakeTaskImpl description="Build and install trailblazer-wizard-0.0.4.gem into system gems" fullCommand="install" id="install" />
51
51
  <RakeTaskImpl id="install">
52
52
  <subtasks>
53
- <RakeTaskImpl description="Build and install wizard-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
53
+ <RakeTaskImpl description="Build and install trailblazer-wizard-0.0.4.gem into system gems without network access" fullCommand="install:local" id="local" />
54
54
  </subtasks>
55
55
  </RakeTaskImpl>
56
- <RakeTaskImpl description="Create tag v0.1.0 and build and push wizard-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
56
+ <RakeTaskImpl description="Create tag v0.0.4 and build and push trailblazer-wizard-0.0.4.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
57
57
  <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
58
58
  <RakeTaskImpl id="rubocop">
59
59
  <subtasks>
data/.rubocop.yml CHANGED
@@ -20,3 +20,6 @@ Metrics/CyclomaticComplexity:
20
20
 
21
21
  Metrics/MethodLength:
22
22
  Enabled: false
23
+
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
data/README.md CHANGED
@@ -6,7 +6,7 @@ A helper to aid you with generating blank Trailblazer concept files including: o
6
6
 
7
7
  Install the gem and add to the application's Gemfile by executing:
8
8
 
9
- $ bundle add trailblazer-wizard
9
+ $ gem 'trailblazer-wizard'
10
10
 
11
11
  If bundler is not being used to manage dependencies, install the gem by executing:
12
12
 
@@ -14,10 +14,55 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
+ All concept files are generated inside the `app/concepts` directory.
18
+
17
19
  To generate files, simply run this command:
18
20
 
19
21
  $ wizard [--model] [--actions] [--only] [--except] [--context]
20
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. |
30
+
31
+ Allowed concept types are: `operation | finder | form (meant for contracts) | view (meant for representables)`
32
+
33
+ #### Example 1:
34
+
35
+ wizard --model=User --actions=create --only=operation,form
36
+
37
+ This command will generate:
38
+
39
+ app/concepts/user/operation/create.rb
40
+ app/concepts/user/form/create.rb
41
+
42
+ #### Example 2: with context
43
+
44
+ wizard --model=User --context=admin --actions=index --only=operation
45
+
46
+ Generates:
47
+
48
+ app/concepts/user/admin/operation/index.rb
49
+
50
+ ## Configuration
51
+
52
+ To change the base directory `app/concepts`, or maybe pluralize concept directories, or even use alternative
53
+ concept type names... there is the possibility to apply these tweaks by creating an initializer:
54
+
55
+ # config/initializers/trailblazer_wizard.rb
56
+
57
+ Wizard.configure do |config|
58
+ config.base_directory = "example/example"
59
+ config.puralize = true
60
+ config.alt_types = {
61
+ form: :contract,
62
+ view: 'representable'
63
+ }
64
+ end
65
+
21
66
  ## Contributing
22
67
 
23
68
  Bug reports and pull requests are welcome on GitHub at https://github.com/aredda/trailblazer-wizard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/wizard/blob/main/CODE_OF_CONDUCT.md).
data/lib/concept.txt ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module _MODEL_::_CONTEXT_::_CONCEPT_
4
+ class _NAME_ < Application_CONCEPT_
5
+
6
+ end
7
+ end
@@ -6,12 +6,16 @@ module Wizard
6
6
  class ConceptGenerator
7
7
  attr_reader :type
8
8
 
9
- def initialize(**args)
9
+ def initialize(**args)\
10
10
  @type = args[:type]
11
11
  end
12
12
 
13
+ def true_type = (Wizard.configuration.alt_types[type.to_sym] || type).to_s
14
+
15
+ def type_dirname = Wizard.configuration.pluralize ? ActiveSupport::Inflector.pluralize(true_type) : true_type
16
+
13
17
  def generate(model, name, context = nil)
14
- materials = [model, type, name]
18
+ materials = [model, type_dirname, name]
15
19
  materials.insert(1, context) unless context.nil?
16
20
 
17
21
  filename = materials.map { |material| ActiveSupport::Inflector.underscore(material) }.join("/")
@@ -28,12 +32,16 @@ module Wizard
28
32
  private
29
33
 
30
34
  def copy(model, name, context)
31
- content = File.read("lib/templates/concept.rb.txt")
35
+ template = File.dirname(__FILE__)
36
+ template["lib/wizard"] = "lib/concept.txt"
37
+
38
+ content = File.read(template)
32
39
 
33
40
  content["_MODEL_"] = model.camelize
34
41
  content["::_CONTEXT_"] = context.nil? ? "" : "::#{context.camelize}"
35
42
  content["_NAME_"] = name.camelize
36
- content["_CONCEPT_"] = type.camelize while content.include?("_CONCEPT_")
43
+ content["_CONCEPT_"] = type_dirname.camelize
44
+ content["_CONCEPT_"] = true_type.camelize
37
45
 
38
46
  content
39
47
  end
@@ -2,10 +2,12 @@
2
2
 
3
3
  module Wizard
4
4
  class Configuration
5
- attr_accessor :base_directory
5
+ attr_accessor :base_directory, :pluralize, :alt_types
6
6
 
7
7
  def initialize
8
8
  @base_directory = "app/concepts"
9
+ @pluralize = false
10
+ @alt_types = {}
9
11
  end
10
12
  end
11
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wizard
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.5"
5
5
  end
data/lib/wizard.rb CHANGED
@@ -34,10 +34,15 @@ module Wizard
34
34
  concepts -= args[:except] if args.key? :except
35
35
  concepts = args[:only] if args.key? :only
36
36
 
37
+ output = []
38
+
37
39
  actions.each do |action|
38
40
  concepts.each do |concept|
39
- fetch_generator(concept.to_s).generate(model, action.to_s, args[:context]&.to_s)
41
+ file = fetch_generator(concept.to_s).generate(model, action.to_s, args[:context]&.to_s)
42
+ output << file if file.length.positive?
40
43
  end
41
44
  end
45
+
46
+ output
42
47
  end
43
48
  end
@@ -0,0 +1,9 @@
1
+ module Wizard
2
+ class Configuration
3
+ @base_directory: String
4
+ @pluralize: bool
5
+
6
+ attr_accessor base_directory: String
7
+ attr_accessor pluralize: bool
8
+ end
9
+ 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.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - aredda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -34,9 +34,10 @@ extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - ".idea/.gitignore"
37
+ - ".idea/misc.xml"
37
38
  - ".idea/modules.xml"
39
+ - ".idea/trailblazer-wizard.iml"
38
40
  - ".idea/vcs.xml"
39
- - ".idea/wizard.iml"
40
41
  - ".rubocop.yml"
41
42
  - CHANGELOG.md
42
43
  - CODE_OF_CONDUCT.md
@@ -44,6 +45,7 @@ files:
44
45
  - README.md
45
46
  - Rakefile
46
47
  - bin/wizard
48
+ - lib/concept.txt
47
49
  - lib/wizard.rb
48
50
  - lib/wizard/concept_generator.rb
49
51
  - lib/wizard/concept_type.rb
@@ -51,6 +53,7 @@ files:
51
53
  - lib/wizard/file_helper.rb
52
54
  - lib/wizard/version.rb
53
55
  - sig/wizard.rbs
56
+ - sig/wizard/configuration.rbs
54
57
  homepage: https://www.github.com/aredda/trailblazer-wizard
55
58
  licenses:
56
59
  - MIT