Class: Inscriber::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/inscriber/database.rb

Constant Summary collapse

DEFAULT_HOST =
'127.0.0.1'
DEFAULT_PORT =
5432

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Database

Returns a new instance of Database.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/inscriber/database.rb', line 9

def initialize(options={})
  @adapter       = options.fetch(:adapter, nil)
  @host          = options.fetch(:host, DEFAULT_HOST)
  @port          = options.fetch(:port, DEFAULT_PORT)
  @database_name = options.fetch(:database_name, nil)
  @username      = options.fetch(:username, '')
  @password      = options.fetch(:password, '')
  @source_lang   = options.fetch(:source_lang, 'en')
  @output_dir    = options.fetch(:output_dir, 'tmp')
  @input_dir     = options.fetch(:input_dir, @output_dir)
  @file_name     = options.fetch(:file_name, 'translations')
  @tables        = options.fetch(:tables, nil)
  @locales       = options.fetch(:locales, nil)
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def adapter
  @adapter
end

#database_nameObject

Returns the value of attribute database_name.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def database_name
  @database_name
end

#file_nameObject

Returns the value of attribute file_name.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def file_name
  @file_name
end

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def host
  @host
end

#input_dirObject

Returns the value of attribute input_dir.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def input_dir
  @input_dir
end

#localesObject

Returns the value of attribute locales.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def locales
  @locales
end

#output_dirObject

Returns the value of attribute output_dir.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def output_dir
  @output_dir
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def password
  @password
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def port
  @port
end

#source_langObject

Returns the value of attribute source_lang.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def source_lang
  @source_lang
end

#tablesObject

Returns the value of attribute tables.



4
5
6
# File 'lib/inscriber/database.rb', line 4

def tables
  @tables
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/inscriber/database.rb', line 3

def username
  @username
end

Instance Method Details

#connectionObject



24
25
26
# File 'lib/inscriber/database.rb', line 24

def connection
  @connection ||= Sequel.connect(connection_string)
end