Class: FlareUp::Command::Base
- Inherits:
-
Object
- Object
- FlareUp::Command::Base
- Defined in:
- lib/flare_up/command/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #execute(connection) ⇒ Object
-
#initialize(table_name, *args) ⇒ Base
constructor
A new instance of Base.
-
#name ⇒ Object
Split CamelCase and UPCASE it for error presentation.
Constructor Details
#initialize(table_name, *args) ⇒ Base
Returns a new instance of Base.
17 18 19 |
# File 'lib/flare_up/command/base.rb', line 17 def initialize(table_name, *args) @table_name = table_name end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
15 16 17 |
# File 'lib/flare_up/command/base.rb', line 15 def table_name @table_name end |
Instance Method Details
#execute(connection) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flare_up/command/base.rb', line 27 def execute(connection) begin connection.execute(get_command) [] rescue PG::InternalError => e case e. when /Check 'stl_load_errors' system table for details/ return STLLoadErrorFetcher.fetch_errors(connection) when /The specified S3 prefix '.+' does not exist/ raise DataSourceError, "A data source with prefix '#{@data_source}' does not exist." when /The bucket you are attempting to access must be addressed using the specified endpoint/ raise OtherZoneBucketError, "Your Redshift instance appears to be in a different zone than your S3 bucket. Specify the \"REGION 'bucket-region'\" option." when /PG::SyntaxError/ matches = /syntax error (.+) \(PG::SyntaxError\)/.match(e.) raise SyntaxError, "Syntax error in the #{name} command: [#{matches[1]}]." else raise e end end end |
#name ⇒ Object
Split CamelCase and UPCASE it for error presentation
22 23 24 25 |
# File 'lib/flare_up/command/base.rb', line 22 def name namespaces = self.class.to_s.split('::') namespaces.last.split(/(?=[A-Z])/).map { |w| w.upcase }.join(' ') end |