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

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_fileObject

Config file storage



32
33
34
# File 'lib/util.rb', line 32

def config_file
  return "#{ENV['HOME']}/.enwrite.config"
end

#config_storeObject



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

#nowObject

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

#verbose(msg) ⇒ Object



10
11
12
# File 'lib/util.rb', line 10

def verbose(msg)
  puts ("#{now} Enwrite [VERBOSE]: " + msg).blue if $enwrite_verbose
end

#warn(msg) ⇒ Object



26
27
28
# File 'lib/util.rb', line 26

def warn(msg)
  $stderr.puts ("#{now} Enwrite [WARN]: " + msg).light_yellow
end