Top Level Namespace
- Includes:
- Filters, REXML
Defined Under Namespace
Modules: Filters Classes: ENML_Listener, ENML_utils, Enwrite, Evernote_utils, Hugo, Output
Instance Method Summary collapse
-
#config(key, defval = nil, store = config_store) ⇒ Object
Get a persistent config value.
-
#config_file ⇒ Object
Config file storage.
- #config_store ⇒ Object
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #msg(msg) ⇒ Object
-
#now ⇒ Object
Message output.
-
#setconfig(key, val, store = config_store) ⇒ Object
Set a persistent config value.
- #verbose(msg) ⇒ Object
- #warn(msg) ⇒ Object
Methods included from Filters
#filter_gist, #filter_youtube, #run_filters
Instance Method Details
#config(key, defval = nil, store = config_store) ⇒ Object
Get a persistent config value
41 42 43 |
# File 'lib/util.rb', line 41 def config(key, defval=nil, store=config_store) return store.transaction { store.fetch(key, defval) } end |
#config_file ⇒ Object
Config file storage
32 33 34 |
# File 'lib/util.rb', line 32 def config_file return "#{ENV['HOME']}/.enwrite.config" end |
#config_store ⇒ Object
36 37 38 |
# File 'lib/util.rb', line 36 def config_store return YAML::Store.new(config_file()) end |
#debug(msg) ⇒ Object
14 15 16 |
# File 'lib/util.rb', line 14 def debug(msg) puts ("#{now} Enwrite [DEBUG]: " + msg) if $enwrite_debug end |
#error(msg) ⇒ Object
18 19 20 |
# File 'lib/util.rb', line 18 def error(msg) $stderr.puts ("#{now} Enwrite [ERROR]: " + msg).red end |
#msg(msg) ⇒ Object
22 23 24 |
# File 'lib/util.rb', line 22 def msg(msg) puts ("#{now} Enwrite [INFO]: " + msg).green end |
#now ⇒ Object
Message output
6 7 8 |
# File 'lib/util.rb', line 6 def now Time.now.strftime "%Y-%m-%d %H:%M:%S %Z %Y" end |
#setconfig(key, val, store = config_store) ⇒ Object
Set a persistent config value
46 47 48 |
# File 'lib/util.rb', line 46 def setconfig(key, val, store=config_store) return store.transaction { store[key] = val } end |