Module: AmazonAthena::CLI
- Extended by:
- GLI::App
- Defined in:
- lib/amazon_athena/cli.rb
Class Method Summary collapse
- .access_key ⇒ Object
- .access_secret ⇒ Object
- .athena ⇒ Object
- .check_aws_settings ⇒ Object
- .check_class_path ⇒ Object
- .class_path ⇒ Object
- .details(data) ⇒ Object
- .render(output) ⇒ Object
- .staging_folder ⇒ Object
Class Method Details
.access_key ⇒ Object
326 327 328 |
# File 'lib/amazon_athena/cli.rb', line 326 def self.access_key @access_key end |
.access_secret ⇒ Object
330 331 332 |
# File 'lib/amazon_athena/cli.rb', line 330 def self.access_secret @access_secret end |
.athena ⇒ Object
9 10 11 12 13 14 |
# File 'lib/amazon_athena/cli.rb', line 9 def self.athena AmazonAthena::Client.new \ key: self.access_key, secret: self.access_secret, s3_staging_dir: self.staging_folder end |
.check_aws_settings ⇒ Object
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/amazon_athena/cli.rb', line 342 def self.check_aws_settings if self.access_key.nil? || self.access_secret.nil? msg = <<~MSG athena-cli needs your AWS credentials. You can pass them via the --key and --secret flags or set AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables. MSG exit_now! msg end if self.staging_folder.nil? msg = <<~MSG athena-cli requires an S3 location to use as a scratch folder. Please provide one via the --staging-dir flag or set the ATHENA_S3_STAGING_DIR environment variable. MSG exit_now! msg, 1 end end |
.check_class_path ⇒ Object
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/amazon_athena/cli.rb', line 362 def self.check_class_path unless self.class_path =~ /AthenaJDBC/ jar_path = File.(File.join([File.dirname(__FILE__),'..', 'jdbc','AthenaJDBC41-1.0.0.jar'])) msg = <<~MSG JRuby requires JDBC driver to be in your Java class path. For download instructions, see: http://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html After downloading, add /path/to/driver.jar to your CLASSPATH environment variable. Example: export CLASSPATH="$CLASSPATH:~/src/AthenaJDB41-1.0.0.jar" MSG exit_now! msg, 1 end end |
.class_path ⇒ Object
338 339 340 |
# File 'lib/amazon_athena/cli.rb', line 338 def self.class_path ENV['CLASSPATH'] end |
.details(data) ⇒ Object
381 382 383 384 385 386 |
# File 'lib/amazon_athena/cli.rb', line 381 def self.details(data) longest_key = data.keys.max_by(&:length) data.each do |key, value| printf "%##{longest_key.length}s %s\n", key, value end end |
.render(output) ⇒ Object
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/amazon_athena/cli.rb', line 388 def self.render(output) case output when Hash details(output) when String puts output when Array case output.first when Hash tp output else puts output end else return end end |
.staging_folder ⇒ Object
334 335 336 |
# File 'lib/amazon_athena/cli.rb', line 334 def self.staging_folder @staging_folder end |