Class: Nanoc::Spec::HelperContext Private
- Inherits:
-
Object
- Object
- Nanoc::Spec::HelperContext
- Defined in:
- lib/nanoc/spec.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #dependency_tracker ⇒ Nanoc::Int::DependencyTracker readonly private
- #erbout ⇒ Object readonly private
Instance Method Summary collapse
- #config ⇒ Nanoc::MutableConfigView private
-
#create_item(content, attributes, identifier) ⇒ Nanoc::ItemWithRepsView
private
Creates a new item and adds it to the site’s collection of items.
-
#create_layout(content, attributes, identifier) ⇒ Object
private
TODO: document.
-
#create_rep(item, path) ⇒ Object
private
Creates a new representation for the given item.
-
#helper ⇒ Object
private
An object that includes the helper functions.
-
#initialize(mod) ⇒ HelperContext
constructor
private
A new instance of HelperContext.
- #item ⇒ Nanoc::ItemWithRepsView? private
- #item=(item) ⇒ Object private
- #item_rep ⇒ Nanoc::ItemRepView? private
- #item_rep=(item_rep) ⇒ Object private
- #items ⇒ Nanoc::ItemCollectionWithRepsView private
- #layouts ⇒ Nanoc::LayoutCollectionView private
- #rule_memory_for(obj) ⇒ Object private
- #update_rule_memory(obj, memory) ⇒ Object private
Constructor Details
#initialize(mod) ⇒ HelperContext
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HelperContext.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nanoc/spec.rb', line 11 def initialize(mod) @mod = mod @erbout = '' @rule_memory = {} @config = Nanoc::Int::Configuration.new.with_defaults @reps = Nanoc::Int::ItemRepRepo.new @items = Nanoc::Int::IdentifiableCollection.new(@config) @layouts = Nanoc::Int::IdentifiableCollection.new(@config) @dependency_tracker = Nanoc::Int::DependencyTracker.new(Object.new) end |
Instance Attribute Details
#dependency_tracker ⇒ Nanoc::Int::DependencyTracker (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/nanoc/spec.rb', line 6 def dependency_tracker @dependency_tracker end |
#erbout ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/nanoc/spec.rb', line 8 def erbout @erbout end |
Instance Method Details
#config ⇒ Nanoc::MutableConfigView
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/nanoc/spec.rb', line 73 def config assigns[:config] end |
#create_item(content, attributes, identifier) ⇒ Nanoc::ItemWithRepsView
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new item and adds it to the site’s collection of items.
32 33 34 35 36 |
# File 'lib/nanoc/spec.rb', line 32 def create_item(content, attributes, identifier) item = Nanoc::Int::Item.new(content, attributes, identifier) @items << item Nanoc::ItemWithRepsView.new(item, view_context) end |
#create_layout(content, attributes, identifier) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: document
39 40 41 42 43 |
# File 'lib/nanoc/spec.rb', line 39 def create_layout(content, attributes, identifier) layout = Nanoc::Int::Layout.new(content, attributes, identifier) @layouts << layout Nanoc::LayoutView.new(layout, view_context) end |
#create_rep(item, path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new representation for the given item.
50 51 52 53 54 55 |
# File 'lib/nanoc/spec.rb', line 50 def create_rep(item, path) rep = Nanoc::Int::ItemRep.new(item.unwrap, :default) rep.paths[:last] = path @reps << rep Nanoc::ItemRepView.new(rep, view_context) end |
#helper ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns An object that includes the helper functions.
58 59 60 61 62 |
# File 'lib/nanoc/spec.rb', line 58 def helper mod = @mod klass = Class.new(Nanoc::Int::Context) { include mod } klass.new(assigns) end |
#item ⇒ Nanoc::ItemWithRepsView?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 |
# File 'lib/nanoc/spec.rb', line 78 def item assigns[:item] end |
#item=(item) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/nanoc/spec.rb', line 64 def item=(item) @item = item ? item.unwrap : nil end |
#item_rep ⇒ Nanoc::ItemRepView?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 |
# File 'lib/nanoc/spec.rb', line 83 def item_rep assigns[:item_rep] end |
#item_rep=(item_rep) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/nanoc/spec.rb', line 68 def item_rep=(item_rep) @item_rep = item_rep ? item_rep.unwrap : nil end |
#items ⇒ Nanoc::ItemCollectionWithRepsView
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 |
# File 'lib/nanoc/spec.rb', line 88 def items assigns[:items] end |
#layouts ⇒ Nanoc::LayoutCollectionView
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/nanoc/spec.rb', line 93 def layouts assigns[:layouts] end |
#rule_memory_for(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 |
# File 'lib/nanoc/spec.rb', line 97 def rule_memory_for(obj) @rule_memory.fetch(obj, []) end |
#update_rule_memory(obj, memory) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/nanoc/spec.rb', line 101 def update_rule_memory(obj, memory) @rule_memory[obj] = memory end |