Class: Ath::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/ath/shell.rb

Constant Summary collapse

HISTORY_FILE =
File.join(ENV.fetch('HOME', '.'), '.ath_history')
HISTSIZE =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(athena: Aws::Athena::Client.new, s3: Aws::S3::Client.new, database: nil, options: {}) ⇒ Shell



10
11
12
13
14
15
# File 'lib/ath/shell.rb', line 10

def initialize(athena: Aws::Athena::Client.new, s3: Aws::S3::Client.new, database: nil, options: {})
  @driver = Ath::Driver.new(athena: athena, s3: s3)
  @options = options
  @database = database
  @scanner = Ath::Scanner.new(shell: self)
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



7
8
9
# File 'lib/ath/shell.rb', line 7

def database
  @database
end

#driverObject (readonly)

Returns the value of attribute driver.



5
6
7
# File 'lib/ath/shell.rb', line 5

def driver
  @driver
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/ath/shell.rb', line 6

def options
  @options
end

#pagerObject

Returns the value of attribute pager.



8
9
10
# File 'lib/ath/shell.rb', line 8

def pager
  @pager
end

Instance Method Details

#oneshot(query) ⇒ Object



27
28
29
# File 'lib/ath/shell.rb', line 27

def oneshot(query)
  execute_query(query)
end

#startObject



17
18
19
20
21
22
23
24
25
# File 'lib/ath/shell.rb', line 17

def start
  load_history

  while line = Readline.readline(prompt, true)
    execute_query(line)
  end

  save_history
end