haystack_worker 0.0.2 → 1.0.0
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/README.md +2 -2
- data/lib/haystack_worker/haystack_worker.bundle +0 -0
- data/lib/haystack_worker/jobs.rb +9 -13
- metadata +84 -73
data/README.md
CHANGED
@@ -9,10 +9,10 @@ A haystack worker's sole responsibility is to calculate surpluses of characters
|
|
9
9
|
It receives 'jobs' from a haystack server which come in the form:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
{ 'id' => 123, '
|
12
|
+
{ 'id' => 123, 'from' => [1, 3, 8, etc], 'to' => [10, 4, 14, etc] }
|
13
13
|
```
|
14
14
|
|
15
|
-
The
|
15
|
+
The 'from' and 'to' arrays represent the search space that this worker has been assigned to explore. The ID is used by the haystack worker to keep track of jobs.
|
16
16
|
|
17
17
|
It posts data back to the haystack at /job/:id in the form:
|
18
18
|
|
Binary file
|
data/lib/haystack_worker/jobs.rb
CHANGED
@@ -8,9 +8,9 @@ module HaystackWorker::Jobs
|
|
8
8
|
data = data_for(results)
|
9
9
|
|
10
10
|
json = Net::HTTP.post_form(path, data).body
|
11
|
-
hash =
|
11
|
+
hash = JSON.parse(json)
|
12
12
|
|
13
|
-
[hash['id'], hash
|
13
|
+
[hash['id'], ranges_for(hash)]
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -18,18 +18,14 @@ module HaystackWorker::Jobs
|
|
18
18
|
{ :results => results.to_json }
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def with_support_for_ranges(&block)
|
26
|
-
hash = yield
|
27
|
-
|
28
|
-
if hash['ranges']
|
29
|
-
ranges = hash['ranges'].map { |r| eval(r) }
|
30
|
-
hash.merge!('ranges' => ranges)
|
21
|
+
def ranges_for(hash)
|
22
|
+
if hash['from'] && hash['to']
|
23
|
+
pairs = hash['from'].zip(hash['to'])
|
24
|
+
pairs.inject([]) { |arr, (f, t)| arr << (f..t) }
|
31
25
|
end
|
26
|
+
end
|
32
27
|
|
33
|
-
|
28
|
+
def job_path(id = nil)
|
29
|
+
URI("http://#@haystack_domain/job/#{id}")
|
34
30
|
end
|
35
31
|
end
|
metadata
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: haystack_worker
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Christopher Patuzzo
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-11-16 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: json
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
31
35
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
36
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: fakeweb
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
49
38
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
54
46
|
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: fakeweb
|
55
50
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rack
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
65
52
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
70
60
|
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rack
|
71
64
|
prerelease: false
|
72
|
-
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
66
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
78
76
|
description: Works on behalf of a haystack server.
|
79
77
|
email: chris.patuzzo@gmail.com
|
80
|
-
executables:
|
78
|
+
executables:
|
81
79
|
- haystack
|
82
|
-
extensions:
|
80
|
+
extensions:
|
83
81
|
- ext/haystack_worker/extconf.rb
|
84
82
|
extra_rdoc_files: []
|
85
|
-
|
83
|
+
|
84
|
+
files:
|
86
85
|
- README.md
|
87
86
|
- lib/haystack_worker/base.rb
|
88
87
|
- lib/haystack_worker/benchmark.rb
|
88
|
+
- lib/haystack_worker/haystack_worker.bundle
|
89
89
|
- lib/haystack_worker/jobs.rb
|
90
90
|
- lib/haystack_worker/surpluses.rb
|
91
91
|
- lib/haystack_worker.rb
|
@@ -96,26 +96,37 @@ files:
|
|
96
96
|
- bin/haystack
|
97
97
|
homepage: https://github.com/cpatuzzo/haystack_worker
|
98
98
|
licenses: []
|
99
|
+
|
99
100
|
post_install_message:
|
100
101
|
rdoc_options: []
|
101
|
-
|
102
|
+
|
103
|
+
require_paths:
|
102
104
|
- lib
|
103
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
106
|
none: false
|
105
|
-
requirements:
|
106
|
-
- -
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
|
109
|
-
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
115
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
115
123
|
requirements: []
|
124
|
+
|
116
125
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.24
|
118
127
|
signing_key:
|
119
128
|
specification_version: 3
|
120
129
|
summary: Haystack Worker
|
121
130
|
test_files: []
|
131
|
+
|
132
|
+
has_rdoc:
|