Class: Igniter::Extensions::Contracts::Creator::Scope
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Creator::Scope
- Defined in:
- lib/igniter/extensions/contracts/creator/scope.rb
Constant Summary collapse
- PRESETS =
{ app_local: { root: "app/lib", spec_root: "spec/lib", example_root: "examples", readme_path: "docs/igniter-packs/README.md", packaging_hints: [ "keep the pack close to the host app while the API is still moving", "prefer app-local namespacing before extracting a shared gem" ] }, monorepo_package: { root: "lib", spec_root: "spec", example_root: "examples", readme_path: "README.md", packaging_hints: [ "add package-owned specs and a runnable example before promoting the pack", "keep the public entrypoint independent from igniter-core and contracts internals" ] }, standalone_gem: { root: "lib", spec_root: "spec", example_root: "examples", readme_path: "README.md", packaging_hints: [ "publish only after the pack has a stable public entrypoint and package-owned example", "treat the pack as a distributable gem with a small explicit surface" ] } }.freeze
Instance Attribute Summary collapse
-
#example_root ⇒ Object
readonly
Returns the value of attribute example_root.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#packaging_hints ⇒ Object
readonly
Returns the value of attribute packaging_hints.
-
#readme_path ⇒ Object
readonly
Returns the value of attribute readme_path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#spec_root ⇒ Object
readonly
Returns the value of attribute spec_root.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, root:, spec_root:, example_root:, readme_path:, packaging_hints:) ⇒ Scope
constructor
A new instance of Scope.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, root:, spec_root:, example_root:, readme_path:, packaging_hints:) ⇒ Scope
Returns a new instance of Scope.
55 56 57 58 59 60 61 62 63 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 55 def initialize(name:, root:, spec_root:, example_root:, readme_path:, packaging_hints:) @name = name.to_sym @root = root @spec_root = spec_root @example_root = example_root @readme_path = readme_path @packaging_hints = packaging_hints.dup.freeze freeze end |
Instance Attribute Details
#example_root ⇒ Object (readonly)
Returns the value of attribute example_root.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def example_root @example_root end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def name @name end |
#packaging_hints ⇒ Object (readonly)
Returns the value of attribute packaging_hints.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def packaging_hints @packaging_hints end |
#readme_path ⇒ Object (readonly)
Returns the value of attribute readme_path.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def readme_path @readme_path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def root @root end |
#spec_root ⇒ Object (readonly)
Returns the value of attribute spec_root.
41 42 43 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 41 def spec_root @spec_root end |
Class Method Details
.available ⇒ Object
43 44 45 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 43 def self.available PRESETS.keys end |
.build(scope) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 47 def self.build(scope) preset = PRESETS.fetch(scope.to_sym) do raise ArgumentError, "unknown creator scope #{scope.inspect}" end new(name: scope, **preset) end |
Instance Method Details
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/igniter/extensions/contracts/creator/scope.rb', line 65 def to_h { name: name, root: root, spec_root: spec_root, example_root: example_root, readme_path: readme_path, packaging_hints: packaging_hints } end |