Class: Mysqlexport::Config
- Inherits:
-
Object
- Object
- Mysqlexport::Config
- Defined in:
- lib/mysqlexport/config.rb
Instance Attribute Summary collapse
-
#user_specified_options ⇒ Object
readonly
Returns the value of attribute user_specified_options.
Instance Method Summary collapse
-
#client ⇒ Object
client options.
- #col_sep ⇒ Object
- #csv_heading ⇒ Object
- #database ⇒ Object
- #execute ⇒ Object
-
#force_quotes ⇒ Object
csv options.
-
#host ⇒ Object
database options.
-
#initialize(user_specified_options = {}) ⇒ Config
constructor
A new instance of Config.
- #output_path ⇒ Object
- #password ⇒ Object
- #port ⇒ Object
-
#pretty ⇒ Object
json options.
- #row_sep ⇒ Object
- #socket ⇒ Object
- #table ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(user_specified_options = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 |
# File 'lib/mysqlexport/config.rb', line 5 def initialize( = {}) @user_specified_options = .symbolize_keys end |
Instance Attribute Details
#user_specified_options ⇒ Object (readonly)
Returns the value of attribute user_specified_options.
3 4 5 |
# File 'lib/mysqlexport/config.rb', line 3 def @user_specified_options end |
Instance Method Details
#client ⇒ Object
client options
69 70 71 72 73 74 |
# File 'lib/mysqlexport/config.rb', line 69 def client return @client if @client.is_a? ::Mysql2::Client @client = ::Mysql2::Client.new(host: host, port: port, username: username, password: password, database: database, socket: socket) end |
#col_sep ⇒ Object
51 52 53 |
# File 'lib/mysqlexport/config.rb', line 51 def col_sep [:col_sep] end |
#csv_heading ⇒ Object
59 60 61 |
# File 'lib/mysqlexport/config.rb', line 59 def csv_heading [:csv_heading].to_s.downcase != "false" end |
#database ⇒ Object
26 27 28 |
# File 'lib/mysqlexport/config.rb', line 26 def database [:database] || active_record_connection.try(:current_database) end |
#execute ⇒ Object
34 35 36 |
# File 'lib/mysqlexport/config.rb', line 34 def execute [:execute] || "select * from #{table}" end |
#force_quotes ⇒ Object
csv options
47 48 49 |
# File 'lib/mysqlexport/config.rb', line 47 def force_quotes [:force_quotes].to_s.downcase == "true" || nil end |
#host ⇒ Object
database options
10 11 12 |
# File 'lib/mysqlexport/config.rb', line 10 def host [:host] || active_record_config.try(:[], :host) end |
#output_path ⇒ Object
42 43 44 |
# File 'lib/mysqlexport/config.rb', line 42 def output_path [:output_path] end |
#password ⇒ Object
22 23 24 |
# File 'lib/mysqlexport/config.rb', line 22 def password [:password] || active_record_config.try(:[], :password) end |
#port ⇒ Object
14 15 16 |
# File 'lib/mysqlexport/config.rb', line 14 def port [:port] || active_record_config.try(:[], :port) end |
#pretty ⇒ Object
json options
64 65 66 |
# File 'lib/mysqlexport/config.rb', line 64 def pretty [:pretty].to_s.downcase == "true" || nil end |
#row_sep ⇒ Object
55 56 57 |
# File 'lib/mysqlexport/config.rb', line 55 def row_sep [:row_sep] end |
#socket ⇒ Object
30 31 32 |
# File 'lib/mysqlexport/config.rb', line 30 def socket [:socket] || active_record_config.try(:[], :socket) end |
#table ⇒ Object
38 39 40 |
# File 'lib/mysqlexport/config.rb', line 38 def table [:table] end |
#username ⇒ Object
18 19 20 |
# File 'lib/mysqlexport/config.rb', line 18 def username [:username] || active_record_config.try(:[], :username) end |