Class: Hotdog::Commands::BaseCommand
- Inherits:
-
Object
- Object
- Hotdog::Commands::BaseCommand
show all
- Defined in:
- lib/hotdog/commands.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(application) ⇒ BaseCommand
Returns a new instance of BaseCommand.
9
10
11
12
13
14
15
16
|
# File 'lib/hotdog/commands.rb', line 9
def initialize(application)
@application = application
@source_provider = application.source_provider
@logger = application.logger
@options = application.options
@prepared_statements = {}
@persistent_db_path = File.join(@options.fetch(:confdir, "."), "hotdog.sqlite3")
end
|
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
17
18
19
|
# File 'lib/hotdog/commands.rb', line 17
def application
@application
end
|
#logger ⇒ Object
Returns the value of attribute logger.
18
19
20
|
# File 'lib/hotdog/commands.rb', line 18
def logger
@logger
end
|
#options ⇒ Object
Returns the value of attribute options.
19
20
21
|
# File 'lib/hotdog/commands.rb', line 19
def options
@options
end
|
#persistent_db_path ⇒ Object
Returns the value of attribute persistent_db_path.
20
21
22
|
# File 'lib/hotdog/commands.rb', line 20
def persistent_db_path
@persistent_db_path
end
|
Instance Method Details
#define_options(optparse, options = {}) ⇒ Object
48
49
50
|
# File 'lib/hotdog/commands.rb', line 48
def define_options(optparse, options={})
end
|
#execute(q, args = []) ⇒ Object
26
27
28
29
|
# File 'lib/hotdog/commands.rb', line 26
def execute(q, args=[])
update_db
execute_db(@db, q, args)
end
|
#fixed_string? ⇒ Boolean
31
32
33
|
# File 'lib/hotdog/commands.rb', line 31
def fixed_string?()
@options[:fixed_string]
end
|
#parse_options(optparse, args = []) ⇒ Object
52
53
54
|
# File 'lib/hotdog/commands.rb', line 52
def parse_options(optparse, args=[])
optparse.parse(args)
end
|
#reload(options = {}) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/hotdog/commands.rb', line 35
def reload(options={})
options = @options.merge(options)
if options[:offline]
logger.info("skip reloading on offline mode.")
else
if @db
close_db(@db)
@db = nil
end
update_db(options)
end
end
|
#run(args = [], options = {}) ⇒ Object
22
23
24
|
# File 'lib/hotdog/commands.rb', line 22
def run(args=[], options={})
raise(NotImplementedError)
end
|