Class: Softcover::BaseConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/softcover/config.rb

Direct Known Subclasses

BookConfig, Config

Constant Summary collapse

DEFAULTS =
{
  host: 'https://www.softcover.io'
}
PATH =
'.'

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



11
12
13
14
15
# File 'lib/softcover/config.rb', line 11

def [](key)
  store.transaction do
    store[key]
  end || DEFAULTS[key.to_sym]
end

.[]=(key, value) ⇒ Object



17
18
19
20
21
# File 'lib/softcover/config.rb', line 17

def []=(key, value)
  store.transaction do
    store[key] = value
  end
end

.exists?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/softcover/config.rb', line 31

def exists?
  File.exists?(file_path)
end

.readObject



23
24
25
# File 'lib/softcover/config.rb', line 23

def read
  puts `cat #{file_path}`
end

.removeObject



27
28
29
# File 'lib/softcover/config.rb', line 27

def remove
  File.delete(file_path) if exists?
end