Class: Diecut::Mill
- Inherits:
-
Object
- Object
- Diecut::Mill
- Defined in:
- lib/diecut/mill.rb
Instance Attribute Summary collapse
-
#issue_handler ⇒ Object
writeonly
Sets the attribute issue_handler.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
- #mediator ⇒ Object
- #templates ⇒ Object
- #valise ⇒ Object
Instance Method Summary collapse
- #activate_plugins ⇒ Object
- #churn(ui) ⇒ Object
- #context_class ⇒ Object
-
#initialize(kind) ⇒ Mill
constructor
A new instance of Mill.
- #load_files ⇒ Object
- #ui_class ⇒ Object
- #user_interface ⇒ Object
Constructor Details
#initialize(kind) ⇒ Mill
Returns a new instance of Mill.
8 9 10 |
# File 'lib/diecut/mill.rb', line 8 def initialize(kind) @kind = kind end |
Instance Attribute Details
#issue_handler=(value) ⇒ Object (writeonly)
Sets the attribute issue_handler
12 13 14 |
# File 'lib/diecut/mill.rb', line 12 def issue_handler=(value) @issue_handler = value end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
11 12 13 |
# File 'lib/diecut/mill.rb', line 11 def kind @kind end |
#mediator ⇒ Object
14 15 16 |
# File 'lib/diecut/mill.rb', line 14 def mediator @mediator ||= Diecut.mediator(kind) end |
#templates ⇒ Object
18 19 20 |
# File 'lib/diecut/mill.rb', line 18 def templates @templates ||= TemplateSet.new end |
#valise ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/diecut/mill.rb', line 32 def valise @valise ||= begin stems = mediator.activated_plugins.map do |plugin| plugin.stem_for(kind) end Valise::Set.define do stems.each do |stem| ro stem.template_dir end end end end |
Instance Method Details
#activate_plugins ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/diecut/mill.rb', line 22 def activate_plugins mediator.plugins.map(&:name).each do |name| if yield(name) mediator.activate(name) else mediator.deactivate(name) end end end |
#churn(ui) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/diecut/mill.rb', line 67 def churn(ui) templates.context = mediator.apply_user_input(ui, templates.context_class) templates.results do |path, contents| yield(path, contents) end end |
#context_class ⇒ Object
52 53 54 |
# File 'lib/diecut/mill.rb', line 52 def context_class templates.context_class end |
#load_files ⇒ Object
46 47 48 49 50 |
# File 'lib/diecut/mill.rb', line 46 def load_files valise.filter('**', %i[extended dotmatch]).files do |file| templates.add(file.rel_path.to_s, file.contents) end end |
#ui_class ⇒ Object
56 57 58 |
# File 'lib/diecut/mill.rb', line 56 def ui_class mediator.build_ui_class(context_class) end |
#user_interface ⇒ Object
60 61 62 63 64 65 |
# File 'lib/diecut/mill.rb', line 60 def user_interface load_files templates.prepare ui_class.new end |