Class: RdfProcess
Instance Attribute Summary collapse
Instance Method Summary
collapse
#addStep, #addVariable, #calculate_depends_on
Constructor Details
Returns a new instance of RdfProcess.
16
17
18
19
20
21
22
|
# File 'lib/rdf_process.rb', line 16
def initialize
@fresh_status = "old" @runtime_list = []
@monitor_file_list = []
@runtime_variable_list = {}
end
|
Instance Attribute Details
#fresh_status ⇒ Object
Returns the value of attribute fresh_status.
14
15
16
|
# File 'lib/rdf_process.rb', line 14
def fresh_status
@fresh_status
end
|
#komunikat ⇒ Object
Returns the value of attribute komunikat.
14
15
16
|
# File 'lib/rdf_process.rb', line 14
def komunikat
@komunikat
end
|
#monitor_file_list ⇒ Object
Returns the value of attribute monitor_file_list.
15
16
17
|
# File 'lib/rdf_process.rb', line 15
def monitor_file_list
@monitor_file_list
end
|
#progress ⇒ Object
Returns the value of attribute progress.
14
15
16
|
# File 'lib/rdf_process.rb', line 14
def progress
@progress
end
|
#runtime_list ⇒ Object
Returns the value of attribute runtime_list.
14
15
16
|
# File 'lib/rdf_process.rb', line 14
def runtime_list
@runtime_list
end
|
#runtime_variable_list ⇒ Object
Returns the value of attribute runtime_variable_list.
14
15
16
|
# File 'lib/rdf_process.rb', line 14
def runtime_variable_list
@runtime_variable_list
end
|
Instance Method Details
#eval_file(file) ⇒ Object
126
127
128
|
# File 'lib/rdf_process.rb', line 126
def eval_file(file)
instance_eval File.read(file), file
end
|
#get_dependent_step_from(step_id) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/rdf_process.rb', line 95
def get_dependent_step_from(step_id)
dependent_steps = []
@runtime_list.each do |step|
st = step[:depends_on]
if st != nil then
if st.include?(step_id) then
dependent_steps << step[:step_id]
end
end
end
dependent_steps
end
|
#log(komunikat, progress = nil) ⇒ Object
113
114
115
116
117
118
119
120
|
# File 'lib/rdf_process.rb', line 113
def log(komunikat, progress = nil)
@progress = progress
@komunikat = komunikat
puts komunikat
send_log
end
|
#processing ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/rdf_process.rb', line 36
def processing
s = 0
current_step = 1
size = @runtime_list.size
process_pass = 0.0
@runtime_list.each do |step|
if step[:fresh_status] == nil or step[:fresh_status] == "old" then
s1 = Time.now
step[:runtime_code].call
s2 = Time.now - s1
s += s2
log "#{step[:name]} - Elapse time: #{s2}s"
step[:fresh_status] = "fresh"
end
process_pass = current_step * 100 / size
log("#{step[:name]} - #{process_pass} - #{current_step} - #{size} %", process_pass.round)
current_step += 1
end
@fresh_status = "fresh"
log "Process - Elapse time: #{s}s, #{process_pass}"
end
|
#refresh_status(step_id) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/rdf_process.rb', line 74
def refresh_status(step_id)
@runtime_list.each do |step|
if step[:step_id] == step_id then
step[:fresh_status] = "old"
end
st = step[:depends_on]
if st
if st.include?(step_id) then
refresh_status(step[:step_id])
end
end
end
end
|
#reset ⇒ Object
24
25
26
27
28
29
|
# File 'lib/rdf_process.rb', line 24
def reset
@fresh_status = "old" @runtime_list = []
@monitor_file_list = []
@runtime_variable_list = {}
end
|
#save_variables(file) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/rdf_process.rb', line 130
def save_variables(file)
File.open(file, "w") do |aFile|
@runtime_variable_list.each do | name, value |
if value[:type] != "graph" then code = "addVariable '#{value[:type]}' do
name '#{name}'
value \"#{value[:value].gsub("\"",'\\"')}\"
step_id '#{value[:step_id]}'
end"
aFile.puts code
end
end
aFile.puts "# vieslav.pl "
end
end
|
#send_log ⇒ Object
122
123
124
|
# File 'lib/rdf_process.rb', line 122
def send_log
puts "send log"
end
|
#set_monitor_file(index, file) ⇒ Object
67
68
69
70
71
72
|
# File 'lib/rdf_process.rb', line 67
def set_monitor_file(index, file)
@monitor_file_list[index][:file] = file
refresh_status(@monitor_file_list[index][:step_id])
@fresh_status = "old"
end
|
#set_runtime_variable(name, value) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/rdf_process.rb', line 60
def set_runtime_variable(name, value)
@runtime_variable_list[name][:value] = value
refresh_status(@runtime_variable_list[name][:step_id])
@fresh_status = "old"
end
|