Class: Inscriber::Database
- Inherits:
-
Object
- Object
- Inscriber::Database
- Defined in:
- lib/inscriber/database.rb
Constant Summary collapse
- DEFAULT_HOST =
'127.0.0.1'
- DEFAULT_PORT =
5432
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#database_name ⇒ Object
Returns the value of attribute database_name.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#host ⇒ Object
Returns the value of attribute host.
-
#input_dir ⇒ Object
Returns the value of attribute input_dir.
-
#locales ⇒ Object
Returns the value of attribute locales.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#source_lang ⇒ Object
Returns the value of attribute source_lang.
-
#tables ⇒ Object
Returns the value of attribute tables.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Database
constructor
A new instance of Database.
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(={}) @adapter = .fetch(:adapter, nil) @host = .fetch(:host, DEFAULT_HOST) @port = .fetch(:port, DEFAULT_PORT) @database_name = .fetch(:database_name, nil) @username = .fetch(:username, '') @password = .fetch(:password, '') @source_lang = .fetch(:source_lang, 'en') @output_dir = .fetch(:output_dir, 'tmp') @input_dir = .fetch(:input_dir, @output_dir) @file_name = .fetch(:file_name, 'translations') @tables = .fetch(:tables, nil) @locales = .fetch(:locales, nil) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def adapter @adapter end |
#database_name ⇒ Object
Returns the value of attribute database_name.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def database_name @database_name end |
#file_name ⇒ Object
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def file_name @file_name end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def host @host end |
#input_dir ⇒ Object
Returns the value of attribute input_dir.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def input_dir @input_dir end |
#locales ⇒ Object
Returns the value of attribute locales.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def locales @locales end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def output_dir @output_dir end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def port @port end |
#source_lang ⇒ Object
Returns the value of attribute source_lang.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def source_lang @source_lang end |
#tables ⇒ Object
Returns the value of attribute tables.
4 5 6 |
# File 'lib/inscriber/database.rb', line 4 def tables @tables end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/inscriber/database.rb', line 3 def username @username end |
Instance Method Details
#connection ⇒ Object
24 25 26 |
# File 'lib/inscriber/database.rb', line 24 def connection @connection ||= Sequel.connect(connection_string) end |