Class: Grntest::ExecutionContext
- Inherits:
-
Object
- Object
- Grntest::ExecutionContext
- Defined in:
- lib/grntest/execution-context.rb
Instance Attribute Summary collapse
-
#abort_tag ⇒ Object
Returns the value of attribute abort_tag.
-
#base_directory ⇒ Object
Returns the value of attribute base_directory.
-
#collect_query_log ⇒ Object
writeonly
Sets the attribute collect_query_log.
-
#db_path ⇒ Object
Returns the value of attribute db_path.
-
#groonga_suggest_create_dataset ⇒ Object
Returns the value of attribute groonga_suggest_create_dataset.
-
#logging ⇒ Object
writeonly
Sets the attribute logging.
-
#on_error ⇒ Object
Returns the value of attribute on_error.
-
#output_type ⇒ Object
Returns the value of attribute output_type.
-
#result ⇒ Object
Returns the value of attribute result.
-
#temporary_directory_path ⇒ Object
Returns the value of attribute temporary_directory_path.
Instance Method Summary collapse
- #abort ⇒ Object
- #collect_query_log? ⇒ Boolean
- #error ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
- #log ⇒ Object
- #log_path ⇒ Object
- #logging? ⇒ Boolean
- #omit ⇒ Object
- #omitted? ⇒ Boolean
- #query_log ⇒ Object
- #query_log_path ⇒ Object
- #relative_db_path ⇒ Object
- #top_level? ⇒ Boolean
Constructor Details
#initialize ⇒ ExecutionContext
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/grntest/execution-context.rb', line 28 def initialize @logging = true @base_directory = Pathname(".") @temporary_directory_path = Pathname("tmp") @db_path = Pathname("db") @groonga_suggest_create_dataset = "groonga-suggest-create-dataset" @n_nested = 0 @result = [] @output_type = "json" @log = nil @on_error = :default @abort_tag = nil @omitted = false @collect_query_log = false end |
Instance Attribute Details
#abort_tag ⇒ Object
Returns the value of attribute abort_tag.
26 27 28 |
# File 'lib/grntest/execution-context.rb', line 26 def abort_tag @abort_tag end |
#base_directory ⇒ Object
Returns the value of attribute base_directory.
21 22 23 |
# File 'lib/grntest/execution-context.rb', line 21 def base_directory @base_directory end |
#collect_query_log=(value) ⇒ Object (writeonly)
Sets the attribute collect_query_log
27 28 29 |
# File 'lib/grntest/execution-context.rb', line 27 def collect_query_log=(value) @collect_query_log = value end |
#db_path ⇒ Object
Returns the value of attribute db_path.
21 22 23 |
# File 'lib/grntest/execution-context.rb', line 21 def db_path @db_path end |
#groonga_suggest_create_dataset ⇒ Object
Returns the value of attribute groonga_suggest_create_dataset.
22 23 24 |
# File 'lib/grntest/execution-context.rb', line 22 def groonga_suggest_create_dataset @groonga_suggest_create_dataset end |
#logging=(value) ⇒ Object (writeonly)
Sets the attribute logging
20 21 22 |
# File 'lib/grntest/execution-context.rb', line 20 def logging=(value) @logging = value end |
#on_error ⇒ Object
Returns the value of attribute on_error.
25 26 27 |
# File 'lib/grntest/execution-context.rb', line 25 def on_error @on_error end |
#output_type ⇒ Object
Returns the value of attribute output_type.
24 25 26 |
# File 'lib/grntest/execution-context.rb', line 24 def output_type @output_type end |
#result ⇒ Object
Returns the value of attribute result.
23 24 25 |
# File 'lib/grntest/execution-context.rb', line 23 def result @result end |
#temporary_directory_path ⇒ Object
Returns the value of attribute temporary_directory_path.
21 22 23 |
# File 'lib/grntest/execution-context.rb', line 21 def temporary_directory_path @temporary_directory_path end |
Instance Method Details
#abort ⇒ Object
99 100 101 |
# File 'lib/grntest/execution-context.rb', line 99 def abort throw @abort_tag end |
#collect_query_log? ⇒ Boolean
48 49 50 |
# File 'lib/grntest/execution-context.rb', line 48 def collect_query_log? @collect_query_log end |
#error ⇒ Object
87 88 89 90 91 92 |
# File 'lib/grntest/execution-context.rb', line 87 def error case @on_error when :omit omit end end |
#execute ⇒ Object
52 53 54 55 56 57 |
# File 'lib/grntest/execution-context.rb', line 52 def execute @n_nested += 1 yield ensure @n_nested -= 1 end |
#log ⇒ Object
67 68 69 |
# File 'lib/grntest/execution-context.rb', line 67 def log @log ||= File.open(log_path.to_s, "a+") end |
#log_path ⇒ Object
63 64 65 |
# File 'lib/grntest/execution-context.rb', line 63 def log_path @temporary_directory_path + "groonga.log" end |
#logging? ⇒ Boolean
44 45 46 |
# File 'lib/grntest/execution-context.rb', line 44 def logging? @logging end |
#omit ⇒ Object
94 95 96 97 |
# File 'lib/grntest/execution-context.rb', line 94 def omit @omitted = true abort end |
#omitted? ⇒ Boolean
83 84 85 |
# File 'lib/grntest/execution-context.rb', line 83 def omitted? @omitted end |
#query_log ⇒ Object
75 76 77 |
# File 'lib/grntest/execution-context.rb', line 75 def query_log @query_log ||= File.open(query_log_path.to_s, "a+") end |
#query_log_path ⇒ Object
71 72 73 |
# File 'lib/grntest/execution-context.rb', line 71 def query_log_path @temporary_directory_path + "groonga.query.log" end |
#relative_db_path ⇒ Object
79 80 81 |
# File 'lib/grntest/execution-context.rb', line 79 def relative_db_path @db_path.relative_path_from(@temporary_directory_path) end |
#top_level? ⇒ Boolean
59 60 61 |
# File 'lib/grntest/execution-context.rb', line 59 def top_level? @n_nested == 1 end |