module AmazonAthena::CLI
Public Class Methods
access_key()
click to toggle source
# File lib/amazon_athena/cli.rb, line 326 def self.access_key @access_key end
access_secret()
click to toggle source
# File lib/amazon_athena/cli.rb, line 330 def self.access_secret @access_secret end
athena()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/amazon_athena/cli.rb, line 362 def self.check_class_path unless self.class_path =~ /AthenaJDBC/ jar_path = File.expand_path(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()
click to toggle source
# File lib/amazon_athena/cli.rb, line 338 def self.class_path ENV['CLASSPATH'] end
details(data)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# File lib/amazon_athena/cli.rb, line 334 def self.staging_folder @staging_folder end