Class: DatoDump::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/dato_dump/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dato_dump/configuration.rb', line 7

def initialize(path)
  File.exist?(path) or
    raise RuntimeError, "config file #{path} is missing"

  data = YAML.load_file(path)

  data.is_a? Hash or
    raise RuntimeError, "config file #{path} must be a hash"

  @domain = data.fetch('domain')
  @token = data.fetch('token')
  @api_host = data.fetch('api_host', 'http://api.datocms.com')
  @destination_path = data.fetch('destination_path', '_data')
end

Instance Attribute Details

#api_hostObject (readonly)

Returns the value of attribute api_host.



5
6
7
# File 'lib/dato_dump/configuration.rb', line 5

def api_host
  @api_host
end

#destination_pathObject (readonly)

Returns the value of attribute destination_path.



5
6
7
# File 'lib/dato_dump/configuration.rb', line 5

def destination_path
  @destination_path
end

#domainObject (readonly)

Returns the value of attribute domain.



5
6
7
# File 'lib/dato_dump/configuration.rb', line 5

def domain
  @domain
end

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/dato_dump/configuration.rb', line 5

def token
  @token
end