cangrejo 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cangrejo/modes/local.rb +1 -1
- data/lib/cangrejo/net/socket_http.rb +2 -0
- data/lib/cangrejo/session.rb +39 -10
- data/lib/cangrejo/support/launcher.rb +1 -1
- data/lib/cangrejo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3ceddcc75aa3488d8b945009a725259487023d
|
4
|
+
data.tar.gz: 4f0fc0a1386cdf9af7f9eaa362d5e884255bea19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d5296989ab3ec15c8a190d46736fb518e16feac5caecfdedf06ccbbb71d2e7f5f9cf139dcd5269b500fb2074dbe9c9e42374bee53787100c108e4391a5d6d5c
|
7
|
+
data.tar.gz: 2d43b279a9c7a37b7fbc60e28c6c10979d219a54c661c7f8a97ccc364295fdfa36f6bbbdf7ef80ed706672a094e3235a6d96e24e22788fc195c62acae589e6ae
|
data/lib/cangrejo/modes/local.rb
CHANGED
data/lib/cangrejo/session.rb
CHANGED
@@ -3,7 +3,9 @@ require "ostruct"
|
|
3
3
|
module Cangrejo
|
4
4
|
class Session
|
5
5
|
|
6
|
-
|
6
|
+
WAIT_STEP = 45.0 # Ruby sockets automatically timeout after 60 secs
|
7
|
+
|
8
|
+
attr_reader :doc, :state_name, :state_params
|
7
9
|
|
8
10
|
def initialize(_name, _options={})
|
9
11
|
@name = _name
|
@@ -18,12 +20,8 @@ module Cangrejo
|
|
18
20
|
self
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
@rest.
|
23
|
-
end
|
24
|
-
|
25
|
-
def state_params
|
26
|
-
@rest.params
|
23
|
+
def elapsed
|
24
|
+
@rest.elapsed
|
27
25
|
end
|
28
26
|
|
29
27
|
def raw_doc
|
@@ -32,8 +30,16 @@ module Cangrejo
|
|
32
30
|
|
33
31
|
def crawl(_state, _params={})
|
34
32
|
raise ConfigurationError.new 'Session not started' if @rest.nil?
|
35
|
-
|
36
|
-
|
33
|
+
|
34
|
+
params = add_timestamp(_params)
|
35
|
+
|
36
|
+
while_times_out do
|
37
|
+
@rest.put(name: _state, params: params, wait: WAIT_STEP)
|
38
|
+
@state_name = _state
|
39
|
+
@state_params = _params
|
40
|
+
end
|
41
|
+
|
42
|
+
wrap_response_doc
|
37
43
|
self
|
38
44
|
end
|
39
45
|
|
@@ -44,8 +50,31 @@ module Cangrejo
|
|
44
50
|
|
45
51
|
private
|
46
52
|
|
53
|
+
def add_timestamp(_params)
|
54
|
+
_params.merge({
|
55
|
+
'_ts' => DateTime.now.strftime('%Q')
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
def while_times_out
|
60
|
+
loop do
|
61
|
+
begin
|
62
|
+
yield
|
63
|
+
break
|
64
|
+
rescue RestClient::RequestTimeout
|
65
|
+
# retry on timeout
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def wrap_response_doc
|
71
|
+
@doc = OpenStruct.new @rest.doc
|
72
|
+
end
|
73
|
+
|
47
74
|
def select_mode(_options)
|
48
|
-
@mode = if _options.has_key? :
|
75
|
+
@mode = if _options.has_key? :mode
|
76
|
+
_options[:mode]
|
77
|
+
elsif _options.has_key? :path
|
49
78
|
require "cangrejo/modes/local"
|
50
79
|
Modes::Local.new _options[:path]
|
51
80
|
elsif _options.has_key? :git_remote
|
@@ -14,7 +14,7 @@ module Cangrejo
|
|
14
14
|
def launch
|
15
15
|
gem_path = File.join(@path, 'Gemfile')
|
16
16
|
# TODO: for some reason, the gemfile path must be specified here, maybe because of rbenv?
|
17
|
-
@pid = Process.spawn({ 'BUNDLE_GEMFILE' => gem_path }, "bin/crabfarm s --host #{host}", chdir: @path)
|
17
|
+
@pid = Process.spawn({ 'BUNDLE_GEMFILE' => gem_path }, "bin/crabfarm s --host #{host} --no-reload", chdir: @path)
|
18
18
|
wait_for_socket
|
19
19
|
end
|
20
20
|
|
data/lib/cangrejo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cangrejo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|