Class: Diecut::Mill
- Inherits:
-
Object
- Object
- Diecut::Mill
- Defined in:
- lib/diecut/mill.rb
Instance Attribute Summary collapse
-
#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.
7 8 9 |
# File 'lib/diecut/mill.rb', line 7 def initialize(kind) @kind = kind end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
10 11 12 |
# File 'lib/diecut/mill.rb', line 10 def kind @kind end |
#mediator ⇒ Object
13 14 15 |
# File 'lib/diecut/mill.rb', line 13 def mediator @mediator ||= Diecut.mediator(kind) end |
#templates ⇒ Object
17 18 19 |
# File 'lib/diecut/mill.rb', line 17 def templates @templates ||= TemplateSet.new end |
#valise ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/diecut/mill.rb', line 31 def valise @valise ||= mediator.activated_plugins.map do |plugin| stem = plugin.stem_for(kind) Valise::Set.define do ro stem.template_dir end.stemmed(stem.stem) end.reduce{|left, right| left + right}.sub_set(kind) end |
Instance Method Details
#activate_plugins ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/diecut/mill.rb', line 21 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
61 62 63 64 65 66 |
# File 'lib/diecut/mill.rb', line 61 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
46 47 48 |
# File 'lib/diecut/mill.rb', line 46 def context_class templates.context_class end |
#load_files ⇒ Object
40 41 42 43 44 |
# File 'lib/diecut/mill.rb', line 40 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
50 51 52 |
# File 'lib/diecut/mill.rb', line 50 def ui_class mediator.build_ui_class(context_class) end |
#user_interface ⇒ Object
54 55 56 57 58 59 |
# File 'lib/diecut/mill.rb', line 54 def user_interface load_files templates.prepare ui_class.new end |