example_plugin.rb in doing-2.1.30 vs example_plugin.rb in doing-2.1.31pre
- old
+ new
@@ -52,22 +52,22 @@
##
## If a template is included, a config key will
## automatically be added for the user to override
## The config key will be available at:
##
- ## wwid.config['export_templates'][PLUGIN_NAME]
+ ## Doing.config.settings['export_templates'][PLUGIN_NAME]
##
## config: (optional) A Hash which will be
## added to the main configuration in the plugins section.
## Options defined here are included when config file is
## created or updated with `config --update`. Use this to
## add new configuration keys, not to override existing
## ones.
##
## The configuration keys will be available at:
##
- ## wwid.config['plugins'][PLUGIN_NAME][KEY]
+ ## Doing.config.settings['plugins'][PLUGIN_NAME][KEY]
##
## Method to return plugin settings (required)
##
## @return Hash of settings for this plugin
##
@@ -123,10 +123,12 @@
## @return [String] Rendered output
##
def self.render(wwid, items, variables: {})
return unless items.good?
+ config = Doing.config.settings
+
# the :options key includes the flags passed to the
# command that called the plugin use `puts
# variables.inspect` to see properties and methods
# when run
opt = variables[:options]
@@ -160,12 +162,12 @@
date = i.date.strftime('%A %B %e at %I:%M%p')
title = i.title.gsub(/@/, 'hashtag ')
tpl = template('say')
- if wwid.config['export_templates'].key?('say')
- cfg_tpl = wwid.config['export_templates']['say']
+ if config['export_templates'].key?('say')
+ cfg_tpl = config['export_templates']['say']
tpl = cfg_tpl if cfg_tpl.good?
end
output = tpl.dup
output.gsub!(/%date/, date)
output.gsub!(/%title/, title)
@@ -186,10 +188,10 @@
# provided on STDERR unless doing is run with
# `--stdout` or non-interactively.
Doing.logger.info('Spoke the last entry. Did you hear it?')
# This export runs a command for fun, most plugins won't
- voice = wwid.config['plugins']['say']['say_voice'] || 'Alex'
+ voice = config['plugins']['say']['say_voice'] || 'Alex'
`say -v "#{voice}" "#{output}"`
# Return the result (don't output to terminal with puts or print)
output
end