Class: Terastream::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/terastream/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/terastream/cli.rb', line 16

def initialize
  @config    = nil
  @file      = nil
  @formatter = "json"
  @hostname  = nil
  @output    = nil
  @password  = nil
  @query     = nil
  @timeout   = 10000
  @username  = nil
  @output_options = {}
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def config
  @config
end

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def file
  @file
end

#formatterObject

Returns the value of attribute formatter.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def formatter
  @formatter
end

#hostnameObject

Returns the value of attribute hostname.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def hostname
  @hostname
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def output
  @output
end

#output_optionsObject

Returns the value of attribute output_options.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def output_options
  @output_options
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def password
  @password
end

#queryObject

Returns the value of attribute query.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def query
  @query
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def timeout
  @timeout
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/terastream/cli.rb', line 5

def username
  @username
end

Instance Method Details

#config_optionsObject



33
34
35
# File 'lib/terastream/cli.rb', line 33

def config_options
  @_config ||= read_config_file
end

#formatter_objectObject



45
46
47
# File 'lib/terastream/cli.rb', line 45

def formatter_object
  formatter == "csv" ? Terastream::CSVBuilder.new : Terastream::JsonBuilder.new
end

#missing_hostname?Boolean



41
42
43
# File 'lib/terastream/cli.rb', line 41

def missing_hostname?
  hostname.nil?
end

#missing_query?Boolean



37
38
39
# File 'lib/terastream/cli.rb', line 37

def missing_query?
  query_string.nil?
end

#output_objectObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/terastream/cli.rb', line 49

def output_object
  case (output || "").to_sym
  when :redis
    Terastream::Output::Redis.new(config_for("redis"))
  when :kinesis
  when :kafka
    Terastream::Output::Kakfa.new(config_for("kafka"))
  else
    nil
  end
end

#query_stringObject



29
30
31
# File 'lib/terastream/cli.rb', line 29

def query_string
  @_query_string ||= build_query_string
end