lib/tap/support/class_configuration.rb in bahuvrihi-tap-0.10.0 vs lib/tap/support/class_configuration.rb in bahuvrihi-tap-0.10.1
- old
+ new
@@ -14,12 +14,11 @@
attr_reader :receiver
# Tracks the assignment of the config keys to receivers
attr_reader :assignments
- # A map of config keys and instance methods used to set a
- # config (ie the reader and writer for a config)
+ # A map of (key, config) pairs.
attr_reader :map
def initialize(receiver, parent=nil)
@receiver = receiver
@@ -109,21 +108,22 @@
end
end
# Initializes and returns a new InstanceConfiguration set to self
# and bound to the receiver, if specified.
- def instance_config(receiver=nil)
- InstanceConfiguration.new(self, receiver)
+ def instance_config(receiver=nil, store={})
+ InstanceConfiguration.new(self, receiver, store)
end
# Returns a hash of the (key, config.default) values in self.
def to_hash
hash = {}
each_pair {|key, config| hash[key] = config.default }
hash
end
+ # An array of config descriptions that are Comment objects.
def code_comments
code_comments = []
values.each do |config|
code_comments << config.desc if config.desc.kind_of?(Comment)
end
@@ -146,11 +146,10 @@
# format_str initializes a Templater which formats each [receiver, configurations]
# pair in turn, and puts the output to the target using <tt><<</tt>. The
# templater is assigned the following attributes for use in formatting:
#
# receiver:: The receiver
- # class_doc:: The TDoc for the receiver, from Tap::Support::TDoc[receiver]
# configurations:: An array of configurations and associated comments
#
# In the template these can be accessed as any ERB locals, for example:
#
# <%= receiver.to_s %>
@@ -159,10 +158,10 @@
# <% end %>
#
# The input template may be a String or an ERB; either may be used to
# initialize the templater.
def format_str(template=:doc, target="")
- Lazydoc.resolve(code_comments)
+ Lazydoc.resolve_comments(code_comments)
template = case template
when :doc then File.read(DOC_TEMPLATE_PATH)
when :nodoc then File.read(NODOC_TEMPLATE_PATH)
else template