run_loop 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/run_loop/core.rb +11 -8
- data/lib/run_loop/version.rb +1 -1
- data/scripts/run_loop.js +1 -1
- metadata +2 -2
data/lib/run_loop/core.rb
CHANGED
@@ -10,6 +10,9 @@ module RunLoop
|
|
10
10
|
|
11
11
|
module Core
|
12
12
|
|
13
|
+
START_DELIMITER = "OUTPUT_JSON:\n"
|
14
|
+
END_DELIMITER="\nEND_OUTPUT"
|
15
|
+
|
13
16
|
SCRIPTS_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'scripts'))
|
14
17
|
SCRIPTS = {
|
15
18
|
:dismiss => "run_dismiss_location.js",
|
@@ -152,33 +155,33 @@ module RunLoop
|
|
152
155
|
log_file = run_loop[:log_file]
|
153
156
|
initial_offset = run_loop[:initial_offset] || 0
|
154
157
|
offset = initial_offset
|
155
|
-
|
158
|
+
|
156
159
|
result = nil
|
157
160
|
loop do
|
158
161
|
unless File.exist?(log_file) && File.size?(log_file)
|
159
|
-
sleep(
|
162
|
+
sleep(0.5)
|
160
163
|
next
|
161
164
|
end
|
162
165
|
|
163
166
|
size = File.size(log_file)
|
164
167
|
output = File.read(log_file, size-offset, offset)
|
165
|
-
index_if_found = output.index(
|
166
|
-
if ENV['
|
168
|
+
index_if_found = output.index(START_DELIMITER)
|
169
|
+
if ENV['DEBUG_READ']=='1'
|
167
170
|
puts output.gsub("*", '')
|
168
171
|
puts "Size #{size}"
|
169
172
|
puts "offset #{offset}"
|
170
|
-
puts "index_of #{
|
173
|
+
puts "index_of #{START_DELIMITER}: #{index_if_found}"
|
171
174
|
end
|
172
175
|
|
173
176
|
if index_if_found
|
174
177
|
|
175
178
|
offset = offset + index_if_found
|
176
|
-
rest = output[index_if_found+
|
177
|
-
index_of_json = rest.index("}
|
179
|
+
rest = output[index_if_found+START_DELIMITER.size..output.length]
|
180
|
+
index_of_json = rest.index("}#{END_DELIMITER}")
|
178
181
|
|
179
182
|
json = rest[0..index_of_json]
|
180
183
|
|
181
|
-
if ENV['
|
184
|
+
if ENV['DEBUG_READ']=='1'
|
182
185
|
puts "Index #{index_if_found}, Size: #{size} Offset #{offset}"
|
183
186
|
|
184
187
|
puts ("parse #{json}")
|
data/lib/run_loop/version.rb
CHANGED
data/scripts/run_loop.js
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: run_loop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|