Class: Igniter::Extensions::Contracts::Creator::Scaffold
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Creator::Scaffold
- Defined in:
- lib/igniter/extensions/contracts/creator/scaffold.rb
Constant Summary collapse
- SUPPORTED_KINDS =
%i[feature operational bundle].freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #example_file_path ⇒ Object
- #files ⇒ Object
-
#initialize(name:, kind:, namespace:, profile:, scope:) ⇒ Scaffold
constructor
A new instance of Scaffold.
- #namespace_path ⇒ Object
- #pack_class_name ⇒ Object
- #pack_constant ⇒ Object
- #pack_file_path ⇒ Object
- #readme_file_path ⇒ Object
- #spec_file_path ⇒ Object
- #summary ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, kind:, namespace:, profile:, scope:) ⇒ Scaffold
Returns a new instance of Scaffold.
12 13 14 15 16 17 18 19 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 12 def initialize(name:, kind:, namespace:, profile:, scope:) @name = normalize_name(name) @kind = normalize_kind(kind) @namespace = normalize_namespace(namespace) @profile = profile @scope = scope freeze end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
10 11 12 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 10 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 10 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 10 def namespace @namespace end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
10 11 12 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 10 def profile @profile end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
10 11 12 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 10 def scope @scope end |
Instance Method Details
#example_file_path ⇒ Object
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 41 def example_file_path "#{scope.example_root}/#{name}_pack.rb" end |
#files ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 49 def files { pack_file_path => pack_template, spec_file_path => spec_template, example_file_path => example_template, readme_file_path => readme_template } end |
#namespace_path ⇒ Object
29 30 31 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 29 def namespace_path namespace.split("::").map { |part| underscore(part) }.join("/") end |
#pack_class_name ⇒ Object
21 22 23 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 21 def pack_class_name "#{camelize(name)}Pack" end |
#pack_constant ⇒ Object
25 26 27 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 25 def pack_constant "#{namespace}::#{pack_class_name}" end |
#pack_file_path ⇒ Object
33 34 35 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 33 def pack_file_path "#{scope.root}/#{namespace_path}/#{name}_pack.rb" end |
#readme_file_path ⇒ Object
45 46 47 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 45 def readme_file_path scope.readme_path end |
#spec_file_path ⇒ Object
37 38 39 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 37 def spec_file_path "#{scope.spec_root}/#{namespace_path}/#{name}_pack_spec.rb" end |
#summary ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 58 def summary { name: name, kind: kind, namespace: namespace, profile: profile.to_h, scope: scope.to_h, pack_constant: pack_constant, files: files.keys } end |
#to_h ⇒ Object
70 71 72 |
# File 'lib/igniter/extensions/contracts/creator/scaffold.rb', line 70 def to_h summary.merge(files: files) end |