lib/pinpress.rb in pinpress-1.1.1 vs lib/pinpress.rb in pinpress-1.1.2
- old
+ new
@@ -14,10 +14,16 @@
# Stores whether verbose output is turned on.
# @return [Boolean]
attr_accessor :verbose
end
+ # Establishes the template to use and yields a block with that
+ # template an a Pinboard client.
+ # @param [Fixnum] template_type Either a Pin or Tag template
+ # @param [String] template_name The neame of the template to use
+ # @yield
+ # @return [void]
def self.execute_template(template_type, template_name)
template_hash = PinPress.get_template_by_name(template_type, template_name)
if !template_hash.nil?
template = PinPress::TagTemplate.new(template_hash)
client = Pinboard::Client.new(token: configuration.pinpress[:api_token])
@@ -60,34 +66,31 @@
configuration.reset
configuration.add_section(:pinpress)
configuration.add_section(:pin_templates)
configuration.add_section(:tag_templates)
+ configuration.pinpress.merge!(
+ config_location: configuration.config_path,
+ default_pin_template: 'pinpress_default',
+ default_tag_template: 'pinpress_default',
+ log_level: 'WARN',
+ version: PinPress::VERSION
+ )
+
default_pin_template = {
name: 'pinpress_default',
- opener: "<ul>\n",
- item: %q(<li>
-<b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
-<%= extended %>
-</li>) + "\n",
+ opener: '<ul>',
+ item: '<li><b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b><%= extended %></li>',
closer: '</ul>'
}
default_tag_template = {
name: 'pinpress_default',
item: '<%= tag %> (<%= count %>),'
}
configuration.data['pin_templates'] = [default_pin_template]
configuration.data['tag_templates'] = [default_tag_template]
-
- configuration.pinpress.merge!(
- config_location: configuration.config_path,
- default_pin_template: 'pinpress_default',
- default_tag_template: 'pinpress_default',
- log_level: 'WARN',
- version: PinPress::VERSION
- )
end
pm = CLIUtils::Prefs.new(PinPress::PREF_FILES['INIT'], configuration)
pm.ask
configuration.ingest_prefs(pm)