run_loop 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
- json_token = "OUTPUT_JSON:\n"
158
+
156
159
  result = nil
157
160
  loop do
158
161
  unless File.exist?(log_file) && File.size?(log_file)
159
- sleep(1)
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(json_token)
166
- if ENV['DEBUG']=='1'
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 #{json_token}: #{index_if_found}"
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+json_token.size..output.length]
177
- index_of_json = rest.index("}\n\n")
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['DEBUG']=='1'
184
+ if ENV['DEBUG_READ']=='1'
182
185
  puts "Index #{index_if_found}, Size: #{size} Offset #{offset}"
183
186
 
184
187
  puts ("parse #{json}")
@@ -1,3 +1,3 @@
1
1
  module RunLoop
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
data/scripts/run_loop.js CHANGED
@@ -173,7 +173,7 @@ var Log = (function () {
173
173
 
174
174
  function log_json(object)
175
175
  {
176
- UIALogger.logMessage("OUTPUT_JSON:\n"+JSON.stringify(object)+"\n");
176
+ UIALogger.logMessage("OUTPUT_JSON:\n"+JSON.stringify(object)+"\nEND_OUTPUT");
177
177
  }
178
178
 
179
179
  return {
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.9
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-22 00:00:00.000000000 Z
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor