Class: Grntest::ExecutionContext

Inherits:
Object
  • Object
show all
Defined in:
lib/grntest/execution-context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExecutionContext

Returns a new instance of ExecutionContext.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/grntest/execution-context.rb', line 35

def initialize
  @logging = true
  @base_directory = Pathname(".")
  @temporary_directory_path = Pathname("tmp")
  @db_path = Pathname("db")
  @plugins_directory = nil
  @plugin_extension = guess_plugin_extension
  @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
  @n_nested = 0
  @result = []
  @output_type = "json"
  @log = nil
  @query_log = nil
  @on_error = :default
  @abort_tag = nil
  @timeout = 0
  @read_timeout = 5
  @default_timeout = @timeout
  @default_read_timeout = @read_timeout
  @shutdown_wait_timeout = 5
  @omitted = false
  @suppress_backtrace = true
  @collect_query_log = false
  @debug = false
end

Instance Attribute Details

#abort_tagObject

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_directoryObject

Returns the value of attribute base_directory.



19
20
21
# File 'lib/grntest/execution-context.rb', line 19

def base_directory
  @base_directory
end

#collect_query_log=(value) ⇒ Object (writeonly)

Sets the attribute collect_query_log

Parameters:

  • value

    the value to set the attribute collect_query_log to.



33
34
35
# File 'lib/grntest/execution-context.rb', line 33

def collect_query_log=(value)
  @collect_query_log = value
end

#db_pathObject

Returns the value of attribute db_path.



19
20
21
# File 'lib/grntest/execution-context.rb', line 19

def db_path
  @db_path
end

#debug=(value) ⇒ Object (writeonly)

Sets the attribute debug

Parameters:

  • value

    the value to set the attribute debug to.



34
35
36
# File 'lib/grntest/execution-context.rb', line 34

def debug=(value)
  @debug = value
end

#default_read_timeoutObject

Returns the value of attribute default_read_timeout.



30
31
32
# File 'lib/grntest/execution-context.rb', line 30

def default_read_timeout
  @default_read_timeout
end

#default_timeoutObject

Returns the value of attribute default_timeout.



29
30
31
# File 'lib/grntest/execution-context.rb', line 29

def default_timeout
  @default_timeout
end

#groonga_suggest_create_datasetObject

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

Parameters:

  • value

    the value to set the attribute logging to.



18
19
20
# File 'lib/grntest/execution-context.rb', line 18

def logging=(value)
  @logging = value
end

#on_errorObject

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_typeObject

Returns the value of attribute output_type.



24
25
26
# File 'lib/grntest/execution-context.rb', line 24

def output_type
  @output_type
end

#plugin_extensionObject

Returns the value of attribute plugin_extension.



21
22
23
# File 'lib/grntest/execution-context.rb', line 21

def plugin_extension
  @plugin_extension
end

#plugins_directoryObject

Returns the value of attribute plugins_directory.



20
21
22
# File 'lib/grntest/execution-context.rb', line 20

def plugins_directory
  @plugins_directory
end

#read_timeoutObject

Returns the value of attribute read_timeout.



28
29
30
# File 'lib/grntest/execution-context.rb', line 28

def read_timeout
  @read_timeout
end

#resultObject

Returns the value of attribute result.



23
24
25
# File 'lib/grntest/execution-context.rb', line 23

def result
  @result
end

#shutdown_wait_timeoutObject

Returns the value of attribute shutdown_wait_timeout.



31
32
33
# File 'lib/grntest/execution-context.rb', line 31

def shutdown_wait_timeout
  @shutdown_wait_timeout
end

#suppress_backtrace=(value) ⇒ Object (writeonly)

Sets the attribute suppress_backtrace

Parameters:

  • value

    the value to set the attribute suppress_backtrace to.



32
33
34
# File 'lib/grntest/execution-context.rb', line 32

def suppress_backtrace=(value)
  @suppress_backtrace = value
end

#temporary_directory_pathObject

Returns the value of attribute temporary_directory_path.



19
20
21
# File 'lib/grntest/execution-context.rb', line 19

def temporary_directory_path
  @temporary_directory_path
end

#timeoutObject

Returns the value of attribute timeout.



27
28
29
# File 'lib/grntest/execution-context.rb', line 27

def timeout
  @timeout
end

Instance Method Details

#abortObject



133
134
135
# File 'lib/grntest/execution-context.rb', line 133

def abort
  throw @abort_tag
end

#close_logsObject



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/grntest/execution-context.rb', line 137

def close_logs
  if @log
    @log.close
    @log = nil
  end

  if @query_log
    @query_log.close
    @query_log = nil
  end
end

#collect_query_log?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/grntest/execution-context.rb', line 69

def collect_query_log?
  @collect_query_log
end

#debug?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/grntest/execution-context.rb', line 73

def debug?
  @debug
end

#errorObject



121
122
123
124
125
126
# File 'lib/grntest/execution-context.rb', line 121

def error
  case @on_error
  when :omit
    omit
  end
end

#executeObject



77
78
79
80
81
82
# File 'lib/grntest/execution-context.rb', line 77

def execute
  @n_nested += 1
  yield
ensure
  @n_nested -= 1
end

#libtool_directoryObject



108
109
110
111
112
113
114
115
# File 'lib/grntest/execution-context.rb', line 108

def libtool_directory
  @plugins_directory.find do |sub_path|
    if sub_path.directory? and sub_path.basename.to_s == ".libs"
      return ".libs/"
    end
  end
  ""
end

#logObject



92
93
94
# File 'lib/grntest/execution-context.rb', line 92

def log
  @log ||= File.open(log_path.to_s, "a+")
end

#log_pathObject



88
89
90
# File 'lib/grntest/execution-context.rb', line 88

def log_path
  @temporary_directory_path + "groonga.log"
end

#logging?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/grntest/execution-context.rb', line 61

def logging?
  @logging
end

#omitObject



128
129
130
131
# File 'lib/grntest/execution-context.rb', line 128

def omit
  @omitted = true
  abort
end

#omitted?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/grntest/execution-context.rb', line 117

def omitted?
  @omitted
end

#query_logObject



100
101
102
# File 'lib/grntest/execution-context.rb', line 100

def query_log
  @query_log ||= File.open(query_log_path.to_s, "a+")
end

#query_log_pathObject



96
97
98
# File 'lib/grntest/execution-context.rb', line 96

def query_log_path
  @temporary_directory_path + "groonga.query.log"
end

#relative_db_pathObject



104
105
106
# File 'lib/grntest/execution-context.rb', line 104

def relative_db_path
  @db_path.relative_path_from(@temporary_directory_path)
end

#suppress_backtrace?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/grntest/execution-context.rb', line 65

def suppress_backtrace?
  @suppress_backtrace or debug?
end

#top_level?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/grntest/execution-context.rb', line 84

def top_level?
  @n_nested == 1
end