Class: Architecture::DSL
- Inherits:
-
Object
- Object
- Architecture::DSL
- Defined in:
- lib/architecture/dsl.rb
Instance Method Summary collapse
- #append(file: nil, content:, context: {}) ⇒ Object
- #copy(name:, as: name, context: {}) ⇒ Object
- #create(directory: nil, file: nil, content: nil, context: {}) ⇒ Object
- #delete(directory: nil, file: nil) ⇒ Object
- #destination(path) ⇒ Object
-
#initialize(source:, destination:) {|_self| ... } ⇒ DSL
constructor
A new instance of DSL.
- #move(name:, as:) ⇒ Object
- #overwrite(file: nil, content:, context: {}) ⇒ Object
- #prepend(file: nil, content:, context: {}) ⇒ Object
- #replace(file: nil, search:, content:) ⇒ Object
- #source(path) ⇒ Object
- #within(source: nil, destination: nil, &block) ⇒ Object
Constructor Details
#initialize(source:, destination:) {|_self| ... } ⇒ DSL
Returns a new instance of DSL.
5 6 7 8 9 10 |
# File 'lib/architecture/dsl.rb', line 5 def initialize(source:, destination:) @source = source @destination = destination yield(self) end |
Instance Method Details
#append(file: nil, content:, context: {}) ⇒ Object
36 37 38 |
# File 'lib/architecture/dsl.rb', line 36 def append(file: nil, content:, context: {}) ::Architecture::Append.new(source: file, content: content, context: context).call end |
#copy(name:, as: name, context: {}) ⇒ Object
12 13 14 |
# File 'lib/architecture/dsl.rb', line 12 def copy(name:, as: name, context: {}) ::Architecture::Copy.new(source: source(name), destination: destination(as), context: context).call end |
#create(directory: nil, file: nil, content: nil, context: {}) ⇒ Object
20 21 22 |
# File 'lib/architecture/dsl.rb', line 20 def create(directory: nil, file: nil, content: nil, context: {}) ::Architecture::Create.new(source: directory || file, content: content, context: context).call end |
#delete(directory: nil, file: nil) ⇒ Object
24 25 26 |
# File 'lib/architecture/dsl.rb', line 24 def delete(directory: nil, file: nil) ::Architecture::Delete.new(source: directory || file).call end |
#destination(path) ⇒ Object
52 53 54 |
# File 'lib/architecture/dsl.rb', line 52 def destination(path) join(@destination, path) end |
#move(name:, as:) ⇒ Object
16 17 18 |
# File 'lib/architecture/dsl.rb', line 16 def move(name:, as:) ::Architecture::Move.new(source: path, destination: as).call end |
#overwrite(file: nil, content:, context: {}) ⇒ Object
40 41 42 |
# File 'lib/architecture/dsl.rb', line 40 def overwrite(file: nil, content:, context: {}) ::Architecture::Overwrite.new(source: file, content: content, context: context).call end |
#prepend(file: nil, content:, context: {}) ⇒ Object
32 33 34 |
# File 'lib/architecture/dsl.rb', line 32 def prepend(file: nil, content:, context: {}) ::Architecture::Prepend.new(source: file, content: content, context: context).call end |
#replace(file: nil, search:, content:) ⇒ Object
28 29 30 |
# File 'lib/architecture/dsl.rb', line 28 def replace(file: nil, search:, content:) ::Architecture::Replace.new(source: file, search: search, content: content).call end |
#source(path) ⇒ Object
48 49 50 |
# File 'lib/architecture/dsl.rb', line 48 def source(path) join(@source, path) end |
#within(source: nil, destination: nil, &block) ⇒ Object
44 45 46 |
# File 'lib/architecture/dsl.rb', line 44 def within(source: nil, destination: nil, &block) ::Architecture::DSL.new(source: source(path), destination: destination(path), &block).call end |