trailblazer-wizard 0.0.4 → 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 +4 -4
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +1 -1
- data/.idea/{wizard.iml → trailblazer-wizard.iml} +6 -6
- data/.rubocop.yml +3 -0
- data/README.md +46 -1
- data/lib/wizard/concept_generator.rb +8 -3
- data/lib/wizard/configuration.rb +3 -1
- data/lib/wizard/version.rb +1 -1
- data/lib/wizard.rb +6 -1
- data/sig/wizard/configuration.rbs +9 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: facf812ccc5f3049422d317eb80033fc5459ab22a94163c2ba036d125241479e
|
|
4
|
+
data.tar.gz: e6b30c1a557d7f1b4dd501f88ce430e272cdbdde39c16604ecef89381dac4f70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0b3ac2e8cd385451a93f148b22798fef289a01bba4fc3f5087a7bd360d28232e82cd4a55f41badb03eba5594e75efac5d5f5e35f415ebc1decbaf7d8765602b
|
|
7
|
+
data.tar.gz: cdf88074a891e6a8f6a55007f1d0d116d41c1e776acb33747ae29519c9032ac86cc96db8fa344f7b03d49ad3278044f5901c5ba858250c183d05eae4418cfef8
|
data/.idea/misc.xml
ADDED
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
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
|
-
$
|
|
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).
|
|
@@ -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,
|
|
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("/")
|
|
@@ -36,7 +40,8 @@ module Wizard
|
|
|
36
40
|
content["_MODEL_"] = model.camelize
|
|
37
41
|
content["::_CONTEXT_"] = context.nil? ? "" : "::#{context.camelize}"
|
|
38
42
|
content["_NAME_"] = name.camelize
|
|
39
|
-
content["_CONCEPT_"] =
|
|
43
|
+
content["_CONCEPT_"] = type_dirname.camelize
|
|
44
|
+
content["_CONCEPT_"] = true_type.camelize
|
|
40
45
|
|
|
41
46
|
content
|
|
42
47
|
end
|
data/lib/wizard/configuration.rb
CHANGED
data/lib/wizard/version.rb
CHANGED
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
|
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.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-
|
|
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
|
|
@@ -52,6 +53,7 @@ files:
|
|
|
52
53
|
- lib/wizard/file_helper.rb
|
|
53
54
|
- lib/wizard/version.rb
|
|
54
55
|
- sig/wizard.rbs
|
|
56
|
+
- sig/wizard/configuration.rbs
|
|
55
57
|
homepage: https://www.github.com/aredda/trailblazer-wizard
|
|
56
58
|
licenses:
|
|
57
59
|
- MIT
|