Class: Memot::Config
- Inherits:
-
Object
- Object
- Memot::Config
- Defined in:
- lib/memot/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #auth ⇒ Object
-
#initialize(auth, notes) ⇒ Config
constructor
A new instance of Config.
- #notes ⇒ Object
Constructor Details
#initialize(auth, notes) ⇒ Config
Returns a new instance of Config.
60 61 62 63 |
# File 'lib/memot/config.rb', line 60 def initialize(auth, notes) @auth = auth @notes = notes end |
Class Method Details
.load_env ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/memot/config.rb', line 12 def load_env auth = { dropbox: { app_key: ENV["MEMOT_DROPBOX_APP_KEY"], app_secret: ENV["MEMOT_DROPBOX_APP_SECRET"], access_token: ENV["MEMOT_DROPBOX_ACCESS_TOKEN"], }, evernote: { token: ENV["MEMOT_EVERNOTE_TOKEN"], sandbox: ENV["MEMOT_EVERNOTE_SANDBOX"].downcase == "true", }, } if ENV["MEMOT_NOTES"] # # daily:/memo/daily,reading:/memo/reading # -> { daily: "/memo/daily", reading: "/memo/reading" } # notes = ENV["MEMOT_NOTES"].split(",").map { |pair| pair.split(":") }.inject({}) do |nts, kv| nts[kv[0]] = kv[1] nts end else notes = {} end self.new(auth, notes) end |
.load_yaml(yaml_path) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/memot/config.rb', line 4 def load_yaml(yaml_path) yaml = symbolize_keys(YAML.load_file(yaml_path)) auth = yaml[:auth] || {} notes = yaml[:notes] || {} self.new(auth, notes) end |
Instance Method Details
#auth ⇒ Object
65 66 67 |
# File 'lib/memot/config.rb', line 65 def auth @auth end |
#notes ⇒ Object
69 70 71 |
# File 'lib/memot/config.rb', line 69 def notes @notes end |