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.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/grntest/execution-context.rb', line 27

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
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.



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

def base_directory
  @base_directory
end

#db_pathObject

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_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.



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

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

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

#temporary_directory_pathObject

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

#abortObject



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

def abort
  throw @abort_tag
end

#errorObject



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

def error
  case @on_error
  when :omit
    omit
  end
end

#executeObject



46
47
48
49
50
51
# File 'lib/grntest/execution-context.rb', line 46

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

#logObject



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

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

#log_pathObject



57
58
59
# File 'lib/grntest/execution-context.rb', line 57

def log_path
  @temporary_directory_path + "groonga.log"
end

#logging?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/grntest/execution-context.rb', line 42

def logging?
  @logging
end

#omitObject



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

def omit
  @omitted = true
  abort
end

#omitted?Boolean

Returns:

  • (Boolean)


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

def omitted?
  @omitted
end

#relative_db_pathObject



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

def relative_db_path
  @db_path.relative_path_from(@temporary_directory_path)
end

#top_level?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/grntest/execution-context.rb', line 53

def top_level?
  @n_nested == 1
end