wreckster 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/Manifest.txt +1 -0
- data/lib/wreckster.rb +1 -1
- data/lib/wreckster/traversal.rb +3 -1
- data/test/helper.rb +19 -1
- data/test/test_object.rb +1 -1
- data/test/test_traversal.rb +30 -0
- data/test/test_wreckster.rb +1 -28
- metadata +19 -4
data/CHANGELOG.rdoc
CHANGED
data/Manifest.txt
CHANGED
data/lib/wreckster.rb
CHANGED
data/lib/wreckster/traversal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module Wreckster
|
2
4
|
class Traversal
|
3
5
|
attr_reader :name
|
@@ -8,7 +10,7 @@ module Wreckster
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def find options = {}
|
11
|
-
params = options.map { |k,v| "#{k}=#{v}" }.join("&")
|
13
|
+
params = options.map { |k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&")
|
12
14
|
map = JSON.parse(
|
13
15
|
Wreckster.connection.request(URI.parse(url + "?#{params}")).body
|
14
16
|
)
|
data/test/helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'minitest/autorun'
|
2
2
|
require "wreckster"
|
3
3
|
|
4
4
|
module Wreckster
|
@@ -18,4 +18,22 @@ module Wreckster
|
|
18
18
|
end
|
19
19
|
Response = Struct.new(:body)
|
20
20
|
Wreckster.connection = FakeConnector.new
|
21
|
+
|
22
|
+
class TestCase < MiniTest::Unit::TestCase
|
23
|
+
def conn
|
24
|
+
Wreckster.connection
|
25
|
+
end
|
26
|
+
|
27
|
+
def traversal_response
|
28
|
+
<<-eojson
|
29
|
+
{"query_time":0,"name":"Wreckster: A Graph-Based Ranking Engine","up_time":"0[d]:00[h]:54[m]:43[s]","traversals":["grateful\/singer-writer-rank","grateful\/follows-score","grateful\/co-follows-rank","gremlin","grateful\/artist-rank"]}
|
30
|
+
eojson
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_response
|
34
|
+
<<-eojson
|
35
|
+
{"ranks":[{"grateful\/co-follows-rank":5.0,"_id":"35","name":"WAY TO GO HOME","song_type":"original","performances":92,"type":"song"},{"grateful\/co-follows-rank":8.0,"_id":"36","name":"SAINT OF CIRCUMSTANCE","song_type":"original","performances":222,"type":"song"}],"query_time":1,"success":true,"size":2,"total_rank":2777.0}
|
36
|
+
eojson
|
37
|
+
end
|
38
|
+
end
|
21
39
|
end
|
data/test/test_object.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Wreckster
|
4
|
+
class TestTraversal < Wreckster::TestCase
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
conn.responses << Response.new(find_response)
|
8
|
+
|
9
|
+
@url = 'http://localhost:8182/'
|
10
|
+
@name = 'grateful/co-follows-rank'
|
11
|
+
@t = Wreckster::Traversal.new @url, @name
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_traversal
|
15
|
+
objs = @t.find('song.name' => 'SUGAREE', 'offset.end' => 2)
|
16
|
+
|
17
|
+
assert_equal 2, objs.length
|
18
|
+
assert_equal %w{ song song }, objs.map { |o| o.type }
|
19
|
+
assert_equal [5.0, 8.0], objs.map { |o| o.rank }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_cgi_escape
|
23
|
+
objs = @t.find('song.name' => 'Aaron Patterson', 'offset.end' => 2)
|
24
|
+
|
25
|
+
assert_equal 2, objs.length
|
26
|
+
assert_equal %w{ song song }, objs.map { |o| o.type }
|
27
|
+
assert_equal [5.0, 8.0], objs.map { |o| o.rank }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/test/test_wreckster.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
module Wreckster
|
4
|
-
class TestWreckster <
|
4
|
+
class TestWreckster < Wreckster::TestCase
|
5
5
|
def setup
|
6
6
|
@url = 'http://localhost:8182/'
|
7
7
|
end
|
@@ -17,32 +17,5 @@ module Wreckster
|
|
17
17
|
response = JSON.parse traversal_response
|
18
18
|
assert_equal response['traversals'].sort, traversals.map { |t| t.name }.sort
|
19
19
|
end
|
20
|
-
|
21
|
-
def test_traversal
|
22
|
-
conn.responses << Response.new(find_response)
|
23
|
-
|
24
|
-
t = Wreckster::Traversal.new @url, 'grateful/co-follows-rank'
|
25
|
-
objs = t.find('song.name' => 'SUGAREE', 'offset.end' => 2)
|
26
|
-
|
27
|
-
assert_equal 2, objs.length
|
28
|
-
assert_equal %w{ song song }, objs.map { |o| o.type }
|
29
|
-
assert_equal [5.0, 8.0], objs.map { |o| o.rank }
|
30
|
-
end
|
31
|
-
|
32
|
-
def conn
|
33
|
-
Wreckster.connection
|
34
|
-
end
|
35
|
-
|
36
|
-
def traversal_response
|
37
|
-
<<-eojson
|
38
|
-
{"query_time":0,"name":"Wreckster: A Graph-Based Ranking Engine","up_time":"0[d]:00[h]:54[m]:43[s]","traversals":["grateful\/singer-writer-rank","grateful\/follows-score","grateful\/co-follows-rank","gremlin","grateful\/artist-rank"]}
|
39
|
-
eojson
|
40
|
-
end
|
41
|
-
|
42
|
-
def find_response
|
43
|
-
<<-eojson
|
44
|
-
{"ranks":[{"grateful\/co-follows-rank":5.0,"_id":"35","name":"WAY TO GO HOME","song_type":"original","performances":92,"type":"song"},{"grateful\/co-follows-rank":8.0,"_id":"36","name":"SAINT OF CIRCUMSTANCE","song_type":"original","performances":222,"type":"song"}],"query_time":1,"success":true,"size":2,"total_rank":2777.0}
|
45
|
-
eojson
|
46
|
-
end
|
47
20
|
end
|
48
21
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wreckster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Aaron Patterson
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-02 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: net-http-persistent
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ~>
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 29
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: json
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
version: "0"
|
@@ -47,9 +52,11 @@ dependencies:
|
|
47
52
|
name: rubyforge
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 7
|
53
60
|
segments:
|
54
61
|
- 2
|
55
62
|
- 0
|
@@ -61,9 +68,11 @@ dependencies:
|
|
61
68
|
name: hoe
|
62
69
|
prerelease: false
|
63
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
64
72
|
requirements:
|
65
73
|
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
67
76
|
segments:
|
68
77
|
- 2
|
69
78
|
- 6
|
@@ -96,6 +105,7 @@ files:
|
|
96
105
|
- lib/wreckster/traversal.rb
|
97
106
|
- test/helper.rb
|
98
107
|
- test/test_object.rb
|
108
|
+
- test/test_traversal.rb
|
99
109
|
- test/test_wreckster.rb
|
100
110
|
has_rdoc: true
|
101
111
|
homepage: http://github.com/tenderlove/wreckster
|
@@ -108,26 +118,31 @@ rdoc_options:
|
|
108
118
|
require_paths:
|
109
119
|
- lib
|
110
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
111
122
|
requirements:
|
112
123
|
- - ">="
|
113
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
114
126
|
segments:
|
115
127
|
- 0
|
116
128
|
version: "0"
|
117
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
118
131
|
requirements:
|
119
132
|
- - ">="
|
120
133
|
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
121
135
|
segments:
|
122
136
|
- 0
|
123
137
|
version: "0"
|
124
138
|
requirements: []
|
125
139
|
|
126
140
|
rubyforge_project: wreckster
|
127
|
-
rubygems_version: 1.3.
|
141
|
+
rubygems_version: 1.3.7
|
128
142
|
signing_key:
|
129
143
|
specification_version: 3
|
130
144
|
summary: Wreckster is an API for accessing Rexster[http://wiki.github.com/tinkerpop/rexster/].
|
131
145
|
test_files:
|
132
146
|
- test/test_object.rb
|
147
|
+
- test/test_traversal.rb
|
133
148
|
- test/test_wreckster.rb
|