gsa 0.5.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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/fixtures/cassette_library/delete_many_records.yml +44 -0
- data/fixtures/cassette_library/delete_single_record.yml +44 -0
- data/fixtures/cassette_library/many_records.yml +44 -0
- data/fixtures/cassette_library/many_results_no_filters.yml +90 -0
- data/fixtures/cassette_library/many_results_with_filters.yml +134 -0
- data/fixtures/cassette_library/no_result_no_filters.yml +55 -0
- data/fixtures/cassette_library/no_result_with_filters.yml +57 -0
- data/fixtures/cassette_library/single_record.yml +44 -0
- data/fixtures/cassette_library/single_result_no_filters.yml +483 -0
- data/fixtures/cassette_library/single_result_with_filters.yml +185 -0
- data/fixtures/facets/many.txt +1 -0
- data/fixtures/facets/single.txt +1 -0
- data/fixtures/feeds/15_records.txt +17 -0
- data/fixtures/feeds/1_records.txt +1 -0
- data/fixtures/queries/many.txt +1 -0
- data/fixtures/queries/none.txt +1 -0
- data/fixtures/queries/single.txt +1 -0
- data/fixtures/result_sets/many.txt +1 -0
- data/fixtures/result_sets/many_facets.txt +1 -0
- data/fixtures/result_sets/single.txt +1 -0
- data/fixtures/result_sets/single_facets.txt +1 -0
- data/fixtures/uids/many.txt +1 -0
- data/fixtures/uids/single.txt +1 -0
- data/gsa.gemspec +39 -0
- data/lib/defaults.rb +41 -0
- data/lib/facade.rb +48 -0
- data/lib/gsa.rb +27 -0
- data/lib/gsa/exceptions.rb +3 -0
- data/lib/gsa/faceter.rb +41 -0
- data/lib/gsa/feeder.rb +19 -0
- data/lib/gsa/modules/filer.rb +26 -0
- data/lib/gsa/modules/injector.rb +16 -0
- data/lib/gsa/modules/xmlizer.rb +24 -0
- data/lib/gsa/records_converter.rb +61 -0
- data/lib/gsa/search_converter.rb +41 -0
- data/lib/gsa/searcher.rb +32 -0
- data/lib/gsa/uid_extractor.rb +24 -0
- data/lib/gsa/version.rb +3 -0
- data/spec/fixtures.rb +73 -0
- data/spec/lib/gsa_spec.rb +318 -0
- data/spec/spec_helper.rb +15 -0
- metadata +209 -0
@@ -0,0 +1,185 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://dev-gsa.1000bulbs.com/search?filter=0&getfields=*&num=1000&output=xml_no_dtd&q=excellent%20blue%20bulb&requiredfields=brand:Philips.material:Fiberglass&sort=relevance
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 18 Sep 2013 13:42:33 GMT
|
23
|
+
Server:
|
24
|
+
- Google Search Appliance
|
25
|
+
X-Frame-Options:
|
26
|
+
- SAMEORIGIN
|
27
|
+
Cache-Control:
|
28
|
+
- private
|
29
|
+
Content-Type:
|
30
|
+
- text/xml; charset=ISO-8859-1
|
31
|
+
X-Xss-Protection:
|
32
|
+
- 1; mode=block
|
33
|
+
X-Content-Type-Options:
|
34
|
+
- nosniff
|
35
|
+
Content-Encoding:
|
36
|
+
- gzip
|
37
|
+
Vary:
|
38
|
+
- Accept-Encoding
|
39
|
+
Content-Length:
|
40
|
+
- '401'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
body:
|
44
|
+
encoding: ASCII-8BIT
|
45
|
+
string: !binary |-
|
46
|
+
H4sIAAAAAAAAAIWTz2+CMBTH7/4VTQ8eNALqSPwBGA9z2WGZitvVFHiyJqVg
|
47
|
+
W4x//iqb6FqTJRz6+r6f7yuvfcHiXDB0AiFpyUM8dDyMgKdlRnke4tf4fTCZ
|
48
|
+
+NPBECOpCM8IKzmEmJd4EXWCl3iNPp+3IR47I6zj3VvkOd7T1PNHgauDYBPB
|
49
|
+
OQXGgCuUsBpQUrMkcDdau15ul2+Ik0LbHTE6EZ0O8QM5RqWgOeWE7U1R/yLq
|
50
|
+
NyLXsDxQpkC0vp7t4llMDupAgWWyxXo21rMwWQrVEgIYnAhPwSZvKdOB10Vr
|
51
|
+
MPS8B4dtdk2srFVV30rri9zzcp+pzObvcqaLgGNNBWTGrydCX/ds/UUZraRT
|
52
|
+
EN1NSthsRRMQOSNS2kX+R8zaFNp6H7vVYGJ7/mybXM0Iz1vUpuxC1V2DnZH+
|
53
|
+
/LHjTx81+i5rupA0BXlrUWXjVcPElX6feoCiIK7zHKTSs4WOf183XJ/33Yh0
|
54
|
+
mZon3VzNLwt6WTS6S+TS677bKH4n6eYf6aAt6+rJjDrfZB3iY9wDAAA=
|
55
|
+
http_version:
|
56
|
+
recorded_at: Wed, 18 Sep 2013 13:41:27 GMT
|
57
|
+
- request:
|
58
|
+
method: get
|
59
|
+
uri: http://dev-gsa.1000bulbs.com/search?filter=0&getfields=*&num=1000&output=xml_no_dtd&q=excellent%20blue%20bulb&requiredfields=brand:Philips.material:Glass&sort=relevance
|
60
|
+
body:
|
61
|
+
encoding: US-ASCII
|
62
|
+
string: ''
|
63
|
+
headers:
|
64
|
+
Accept:
|
65
|
+
- '*/*; q=0.5, application/xml'
|
66
|
+
Accept-Encoding:
|
67
|
+
- gzip, deflate
|
68
|
+
User-Agent:
|
69
|
+
- Ruby
|
70
|
+
response:
|
71
|
+
status:
|
72
|
+
code: 200
|
73
|
+
message: OK
|
74
|
+
headers:
|
75
|
+
Date:
|
76
|
+
- Wed, 18 Sep 2013 13:43:03 GMT
|
77
|
+
Server:
|
78
|
+
- Google Search Appliance
|
79
|
+
X-Frame-Options:
|
80
|
+
- SAMEORIGIN
|
81
|
+
Cache-Control:
|
82
|
+
- private
|
83
|
+
Content-Type:
|
84
|
+
- text/xml; charset=ISO-8859-1
|
85
|
+
X-Xss-Protection:
|
86
|
+
- 1; mode=block
|
87
|
+
X-Content-Type-Options:
|
88
|
+
- nosniff
|
89
|
+
Content-Encoding:
|
90
|
+
- gzip
|
91
|
+
Vary:
|
92
|
+
- Accept-Encoding
|
93
|
+
Content-Length:
|
94
|
+
- '863'
|
95
|
+
Connection:
|
96
|
+
- close
|
97
|
+
body:
|
98
|
+
encoding: ASCII-8BIT
|
99
|
+
string: !binary |-
|
100
|
+
H4sIAAAAAAAAAM1WUXObOBB+76/Q6KEP7djCJrZTV1bHdYmbNE5TwO1dXzwY
|
101
|
+
FKI7RRAQae7f3wI2EHCb5Obm5sYZW9r9vtVqtZ8U+u7+RqI7nqQiUjM86BsY
|
102
|
+
ceVHgVDhDJ86n3vHx6M3vQFGqfZU4MlI8RlWEX7HXtClc4m+WvYMm/0hhrm7
|
103
|
+
YkbfME1jPKEEJvQL4/c+l5IrjbYy42ibyS0lXwB7ObfnK6S8Gwh3i9GdB+4Z
|
104
|
+
PgDHKEpEKJQnN23Q6xz0ugCRVsgrITVPqrhGN4rR4YRcXwkug7SiverSXnVo
|
105
|
+
aZToipFwye885fMus3a1I6jspgowMIwDyRbWNi3KdJzVS8NBblS0CXTQ5Td8
|
106
|
+
7SgJv81EwoPW1rcJHPf08lpIEaf9Gw+qKTw5XUovTbvxf4luryh4tcraPekd
|
107
|
+
d8OV5jYvk54KK2qX1V0obpS1P4S/kdkfvTlU3oa3HcXzfZ7WhYm79LjgODF0
|
108
|
+
JciGUScLQ55qUBS6fdjTfN/UDWG8lPrt9mWo3+YDkQ8KXD4jYm8nBWKnnzo+
|
109
|
+
g0m1rG05yLmA3WBkwU8hyRUbUrKCwW9unqONSv/qdGXNsOb3msTSEwozumbX
|
110
|
+
WsdTQkDC+WdqQs+ROImCzNcpGQ/GlKwBZj0FZzHqNrYIzYGuvUxpyLN5EbiQ
|
111
|
+
9Cc2ogS+6cKefzv/MHctNpggh8doaAxMSmoztS7cjfN5bS8s5h715mfjkX2+
|
112
|
+
PFp9P3NsShpOunLzfQoQwtcZhozgfHa2/EgLa5HFR7jPQq7Q7grZYQKe+omI
|
113
|
+
8/oW0Mf2UTPvIqm9sFxgMqrthTwK604itWuvlcK718ueBsE3+q+4DHiqfIgC
|
114
|
+
uUEmLYwfySiptlU740T4JXk4qa1+wmHRYOPp0gVl7hlwx4/RYDIdHk+PRmjt
|
115
|
+
Lmp8FgdPxDusauY8kUbj7itd+yFvVFW2gXxQ4wfhimI3kND7jJ7PL5aMK0qK
|
116
|
+
Af04z22QygI536HV/8Rocfphht9fyezi9x8n75dHZ7k8Fg8eN8CTgklsVmpk
|
117
|
+
+E80Ai/fkzRS4g5oJI25D73wn0sEEvqZRE5klCVl0z1LJp2tHFbJwDD+TzIx
|
118
|
+
nyMT85kyMR+XSbPaT5PKvs7/mlLczb3YfPtjmcx/PKYUAi8OPCoE/g9kL/4G
|
119
|
+
wwtrqkoKAAA=
|
120
|
+
http_version:
|
121
|
+
recorded_at: Wed, 18 Sep 2013 13:41:58 GMT
|
122
|
+
- request:
|
123
|
+
method: get
|
124
|
+
uri: http://dev-gsa.1000bulbs.com/search?filter=0&getfields=*&num=1000&output=xml_no_dtd&q=excellent%20blue%20bulb&requiredfields=brand:Philips.material:Brass&sort=relevance
|
125
|
+
body:
|
126
|
+
encoding: US-ASCII
|
127
|
+
string: ''
|
128
|
+
headers:
|
129
|
+
Accept:
|
130
|
+
- '*/*; q=0.5, application/xml'
|
131
|
+
Accept-Encoding:
|
132
|
+
- gzip, deflate
|
133
|
+
User-Agent:
|
134
|
+
- Ruby
|
135
|
+
response:
|
136
|
+
status:
|
137
|
+
code: 200
|
138
|
+
message: OK
|
139
|
+
headers:
|
140
|
+
Date:
|
141
|
+
- Wed, 18 Sep 2013 13:43:15 GMT
|
142
|
+
Server:
|
143
|
+
- Google Search Appliance
|
144
|
+
X-Frame-Options:
|
145
|
+
- SAMEORIGIN
|
146
|
+
Cache-Control:
|
147
|
+
- private
|
148
|
+
Content-Type:
|
149
|
+
- text/xml; charset=ISO-8859-1
|
150
|
+
X-Xss-Protection:
|
151
|
+
- 1; mode=block
|
152
|
+
X-Content-Type-Options:
|
153
|
+
- nosniff
|
154
|
+
Content-Encoding:
|
155
|
+
- gzip
|
156
|
+
Vary:
|
157
|
+
- Accept-Encoding
|
158
|
+
Content-Length:
|
159
|
+
- '769'
|
160
|
+
Connection:
|
161
|
+
- close
|
162
|
+
body:
|
163
|
+
encoding: ASCII-8BIT
|
164
|
+
string: !binary |-
|
165
|
+
H4sIAAAAAAAAAI1VXVOjMBR991dk8uCDThvoh9aa4nQrW3XFD6C640uHQsTM
|
166
|
+
pgEhuO6/3wttAcFxnLY0ufeck5ubewM9e18L9MaSlEdygvWuhhGTfhRwGU7w
|
167
|
+
pXPbGY2GJx0do1R5MvBEJNkEywifGXt07tyhB9Oe4H63h2HuWobW1YbH/UGf
|
168
|
+
EpjQe4O9+0wIJhVaiYyhVSZWlNwD9m5qTy0kvTXIvWL05oF7gj+BYxQlPOTS
|
169
|
+
E8sm6DAHHRYg0pB85kKxpNTV2ipaixMy9cyZCNKSdtCmHbRoaZSokpEwwd48
|
170
|
+
6bM2s3I1FWS2LgV0Tfsk2MLapEWZirNqaTjIpYyWgQra/JqvqZKw14wnLGhs
|
171
|
+
fZXAcY/vXrjgcdpde5BN7onxj8RL07b+l+jmipyVqyzcn51RW25jbvIy4cmw
|
172
|
+
pLZZ7YXiWlq7PfgO+93hyWfprXmbKp7vs7RKTNymxwXHiaEqoW0M6mRhyFIF
|
173
|
+
HYVeP9Y02xV1rTH2hTpd7YfqNB/wfFDg8hnhOzspENv+qfQNmJTL2qaDnBvY
|
174
|
+
DUZm8QdBWYZOiQWD324eo402fuvSMidYsXdFYuFxiQ26MF6UiseEQAvnn3Ef
|
175
|
+
ao7ESRRkvkrJ4HhIyQJg5ndwpkHd2hahOFAm+Wu+++oacCHkXwbA4Uln9vTx
|
176
|
+
+nzqmoZ+jBwWo56mwy1Smal54y6d24U9Mw130JleHQ3t6/nAerpybEpqTmq5
|
177
|
+
+S45tMHDBEM8cDpbW36ghbWI4gJus5BJtL1AtpiApX7C4zy7BfTrXVS8t0go
|
178
|
+
L9zI67pWOYreKMzb/qhcu0YpvLtm2dFAfan+xRvFS+mDCoQGgTQwfiSipNxV
|
179
|
+
5YwT7m/Ig1Fl9RMGiwZLTxWuPMsdDS74I6Qfj3uj8WCAFu6swmdx8E28Y5SV
|
180
|
+
nAdSq9pdois/xI3KxNaQtRR/ECtyXcNB2Rv0enozN5ikpBjQi2lug0BmyHmC
|
181
|
+
M/iD0ezyfIKtuZj7/cfz7OnvVd4Zsw/vNcCTgkns/Gc60CUEXmzG3n8321W+
|
182
|
+
GwcAAA==
|
183
|
+
http_version:
|
184
|
+
recorded_at: Wed, 18 Sep 2013 13:42:10 GMT
|
185
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1 @@
|
|
1
|
+
[:voltage, :brand, :material, :bulb_type, :bulb_color]
|
@@ -0,0 +1 @@
|
|
1
|
+
[:voltage]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
[
|
2
|
+
{"id"=>1, "name"=>"blue Incandescent bulb", "description"=>"excellent and masterful blue bulb", "voltage"=>"120", "brand"=>"Bulbrite", "material"=>"Plastic", "bulb_type"=>"Incandescent", "bulb_color"=>"blue", "price"=>71},
|
3
|
+
{"id"=>2, "name"=>"white Incandescent bulb", "description"=>"awe-inspiring and poignant white bulb", "voltage"=>"220", "brand"=>"Satco", "material"=>"Brass", "bulb_type"=>"Incandescent", "bulb_color"=>"white", "price"=>41},
|
4
|
+
{"id"=>3, "name"=>"blue Halogen bulb", "description"=>"super and masterful blue bulb", "voltage"=>"100", "brand"=>"Eiko", "material"=>"Plastic", "bulb_type"=>"LED", "bulb_color"=>"blue", "price"=>66},
|
5
|
+
{"id"=>4, "name"=>"yellow Incandescent bulb", "description"=>"awesome and tasteful yellow bulb", "voltage"=>"220", "brand"=>"Plusrite", "material"=>"Brass", "bulb_type"=>"Incandescent", "bulb_color"=>"yellow", "price"=>27},
|
6
|
+
{"id"=>5, "name"=>"green LED bulb", "description"=>"amazing and unique green bulb", "voltage"=>"135", "brand"=>"Sylvania", "material"=>"Fiberglass", "bulb_type"=>"LED", "bulb_color"=>"green", "price"=>95},
|
7
|
+
{"id"=>6, "name"=>"yellow LED bulb", "description"=>"awesome and unique yellow bulb", "voltage"=>"65", "brand"=>"Sylvania", "material"=>"Resin", "bulb_type"=>"LED", "bulb_color"=>"yellow", "price"=>4},
|
8
|
+
{"id"=>7, "name"=>"yellow LED bulb", "description"=>"cheery and interesting yellow bulb", "voltage"=>"135", "brand"=>"Satco", "material"=>"Fiberglass", "bulb_type"=>"Incandescent", "bulb_color"=>"yellow", "price"=>53},
|
9
|
+
{"id"=>8, "name"=>"yellow Incandescent bulb", "description"=>"excellent and masterful yellow bulb", "voltage"=>"45", "brand"=>"Eiko", "material"=>"Metal", "bulb_type"=>"Incandescent", "bulb_color"=>"yellow", "price"=>6},
|
10
|
+
{"id"=>9, "name"=>"white Incandescent bulb", "description"=>"super and haunting white bulb", "voltage"=>"140", "brand"=>"Plusrite", "material"=>"Wood", "bulb_type"=>"Incandescent", "bulb_color"=>"white", "price"=>94},
|
11
|
+
{"id"=>10, "name"=>"blue Incandescent bulb", "description"=>"awesome and warm blue bulb", "voltage"=>"45", "brand"=>"Eiko", "material"=>"Ceramic", "bulb_type"=>"Halogen", "bulb_color"=>"blue", "price"=>17},
|
12
|
+
{"id"=>11, "name"=>"black Incandescent bulb", "description"=>"amazing and haunting black bulb", "voltage"=>"45", "brand"=>"Bulbrite", "material"=>"Brass", "bulb_type"=>"Halogen", "bulb_color"=>"black", "price"=>63},
|
13
|
+
{"id"=>12, "name"=>"white Halogen bulb", "description"=>"awe-inspiring and heavenly white bulb", "voltage"=>"45", "brand"=>"Sylvania", "material"=>"Fabric", "bulb_type"=>"LED", "bulb_color"=>"white", "price"=>85},
|
14
|
+
{"id"=>13, "name"=>"blue Incandescent bulb", "description"=>"super and unique blue bulb", "voltage"=>"135", "brand"=>"Satco", "material"=>"Resin", "bulb_type"=>"Flourescent", "bulb_color"=>"blue", "price"=>19},
|
15
|
+
{"id"=>14, "name"=>"green Flourescent bulb", "description"=>"super and special green bulb", "voltage"=>"75", "brand"=>"Plusrite", "material"=>"Glass", "bulb_type"=>"Halogen", "bulb_color"=>"green", "price"=>59},
|
16
|
+
{"id"=>15, "name"=>"white Incandescent bulb", "description"=>"cool and unique white bulb", "voltage"=>"135", "brand"=>"Sylvania", "material"=>"Ceramic", "bulb_type"=>"Flourescent", "bulb_color"=>"white", "price"=>79}
|
17
|
+
]
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id"=>1, "name"=>"blue Incandescent bulb", "description"=>"excellent and masterful blue bulb", "voltage"=>"120", "brand"=>"Bulbrite", "material"=>"Plastic", "bulb_type"=>"Incandescent", "bulb_color"=>"blue", "price"=>71}
|
@@ -0,0 +1 @@
|
|
1
|
+
"excellent blue bulb"
|
@@ -0,0 +1 @@
|
|
1
|
+
"FooBar"
|
@@ -0,0 +1 @@
|
|
1
|
+
"amazing and heavenly red bulb"
|
@@ -0,0 +1 @@
|
|
1
|
+
[{:result_number=>"1", :url=>"http://0.0.0.0:3000/products/379", :title=>"excellent and haunting blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"379"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and haunting blue bulb"}, {:meta_name=>"voltage", :meta_value=>"220"}, {:meta_name=>"brand", :meta_value=>"Plusrite"}, {:meta_name=>"material", :meta_value=>"Fabric"}, {:meta_name=>"bulb_type", :meta_value=>"Flourescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"24"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and haunting <b>blue bulb</b> "}, {:result_number=>"2", :url=>"http://0.0.0.0:3000/products/665", :title=>"excellent and interesting blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"665"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and interesting blue bulb"}, {:meta_name=>"voltage", :meta_value=>"120"}, {:meta_name=>"brand", :meta_value=>"Tcp"}, {:meta_name=>"material", :meta_value=>"Fabric"}, {:meta_name=>"bulb_type", :meta_value=>"Halogen"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"14"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:45 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:45 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and interesting <b>blue bulb</b> "}, {:result_number=>"3", :url=>"http://0.0.0.0:3000/products/1", :title=>"excellent and masterful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"1"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and masterful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"120"}, {:meta_name=>"brand", :meta_value=>"Bulbrite"}, {:meta_name=>"material", :meta_value=>"Plastic"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"71"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and masterful <b>blue bulb</b> "}, {:result_number=>"4", :url=>"http://0.0.0.0:3000/products/511", :title=>"excellent and edifying blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"511"}, {:meta_name=>"name", :meta_value=>"blue Flourescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and edifying blue bulb"}, {:meta_name=>"voltage", :meta_value=>"65"}, {:meta_name=>"brand", :meta_value=>"Sylvania"}, {:meta_name=>"material", :meta_value=>"Fiberglass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"27"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>blue</b> Flourescent <b>bulb excellent</b> and edifying <b>blue bulb</b> "}, {:result_number=>"5", :url=>"http://0.0.0.0:3000/products/875", :title=>"excellent and warm blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"875"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and warm blue bulb"}, {:meta_name=>"voltage", :meta_value=>"135"}, {:meta_name=>"brand", :meta_value=>"Tcp"}, {:meta_name=>"material", :meta_value=>"Glass"}, {:meta_name=>"bulb_type", :meta_value=>"Flourescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"36"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:46 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:46 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and warm <b>blue bulb</b> "}, {:result_number=>"6", :url=>"http://0.0.0.0:3000/products/173", :title=>"excellent and masterful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"173"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and masterful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"120"}, {:meta_name=>"brand", :meta_value=>"Eiko"}, {:meta_name=>"material", :meta_value=>"Glass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"98"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:43 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:43 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and masterful <b>blue bulb</b> "}, {:result_number=>"7", :url=>"http://0.0.0.0:3000/products/688", :title=>"excellent and edifying blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"688"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and edifying blue bulb"}, {:meta_name=>"voltage", :meta_value=>"45"}, {:meta_name=>"brand", :meta_value=>"Tcp"}, {:meta_name=>"material", :meta_value=>"Resin"}, {:meta_name=>"bulb_type", :meta_value=>"LED"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"89"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:45 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:45 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and edifying <b>blue bulb</b> "}, {:result_number=>"8", :url=>"http://0.0.0.0:3000/products/67", :title=>"excellent and special blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"67"}, {:meta_name=>"name", :meta_value=>"blue Flourescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and special blue bulb"}, {:meta_name=>"voltage", :meta_value=>"140"}, {:meta_name=>"brand", :meta_value=>"Plusrite"}, {:meta_name=>"material", :meta_value=>"Metal"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"38"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:42 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:42 UTC"}], :search_result_snippet=>"<b>blue</b> Flourescent <b>bulb excellent</b> and special <b>blue bulb</b> "}, {:result_number=>"9", :url=>"http://0.0.0.0:3000/products/506", :title=>"excellent and tasteful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"506"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and tasteful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"115"}, {:meta_name=>"brand", :meta_value=>"Eiko"}, {:meta_name=>"material", :meta_value=>"Glass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"91"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and tasteful <b>blue bulb</b> "}, {:result_number=>"10", :url=>"http://0.0.0.0:3000/products/475", :title=>"excellent and unique blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"475"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and unique blue bulb"}, {:meta_name=>"voltage", :meta_value=>"110"}, {:meta_name=>"brand", :meta_value=>"Philips"}, {:meta_name=>"material", :meta_value=>"Brass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"48"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and unique <b>blue bulb</b> "}, {:result_number=>"11", :url=>"http://0.0.0.0:3000/products/206", :title=>"excellent and masterful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"206"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and masterful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"220"}, {:meta_name=>"brand", :meta_value=>"Eiko"}, {:meta_name=>"material", :meta_value=>"Ceramic"}, {:meta_name=>"bulb_type", :meta_value=>"LED"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"4"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:43 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:43 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and masterful <b>blue bulb</b> "}, {:result_number=>"12", :url=>"http://0.0.0.0:3000/products/57", :title=>"excellent and tasteful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"57"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and tasteful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"45"}, {:meta_name=>"brand", :meta_value=>"Bulbrite"}, {:meta_name=>"material", :meta_value=>"Wood"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"65"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:42 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:42 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and tasteful <b>blue bulb</b> "}, {:result_number=>"13", :url=>"http://0.0.0.0:3000/products/616", :title=>"excellent and haunting blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"616"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and haunting blue bulb"}, {:meta_name=>"voltage", :meta_value=>"75"}, {:meta_name=>"brand", :meta_value=>"Philips"}, {:meta_name=>"material", :meta_value=>"Glass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"27"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:45 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:45 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and haunting <b>blue bulb</b> "}, {:result_number=>"14", :url=>"http://0.0.0.0:3000/products/85", :title=>"excellent and unique blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"85"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and unique blue bulb"}, {:meta_name=>"voltage", :meta_value=>"45"}, {:meta_name=>"brand", :meta_value=>"Plusrite"}, {:meta_name=>"material", :meta_value=>"Metal"}, {:meta_name=>"bulb_type", :meta_value=>"LED"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"24"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:42 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:42 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and unique <b>blue bulb</b> "}, {:result_number=>"15", :url=>"http://0.0.0.0:3000/products/671", :title=>"excellent and warm blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"671"}, {:meta_name=>"name", :meta_value=>"blue Halogen bulb"}, {:meta_name=>"description", :meta_value=>"excellent and warm blue bulb"}, {:meta_name=>"voltage", :meta_value=>"135"}, {:meta_name=>"brand", :meta_value=>"Satco"}, {:meta_name=>"material", :meta_value=>"Wood"}, {:meta_name=>"bulb_type", :meta_value=>"Flourescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"77"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:45 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:45 UTC"}], :search_result_snippet=>"<b>blue</b> Halogen <b>bulb excellent</b> and warm <b>blue bulb</b> "}, {:result_number=>"16", :url=>"http://0.0.0.0:3000/products/765", :title=>"excellent and haunting blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"765"}, {:meta_name=>"name", :meta_value=>"blue LED bulb"}, {:meta_name=>"description", :meta_value=>"excellent and haunting blue bulb"}, {:meta_name=>"voltage", :meta_value=>"45"}, {:meta_name=>"brand", :meta_value=>"Plusrite"}, {:meta_name=>"material", :meta_value=>"Fabric"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"49"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:46 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:46 UTC"}], :search_result_snippet=>"<b>blue</b> LED <b>bulb excellent</b> and haunting <b>blue bulb</b> "}, {:result_number=>"17", :url=>"http://0.0.0.0:3000/products/330", :title=>"excellent and special blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"330"}, {:meta_name=>"name", :meta_value=>"blue Flourescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and special blue bulb"}, {:meta_name=>"voltage", :meta_value=>"100"}, {:meta_name=>"brand", :meta_value=>"Philips"}, {:meta_name=>"material", :meta_value=>"Glass"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"37"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:43 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:43 UTC"}], :search_result_snippet=>"<b>blue</b> Flourescent <b>bulb excellent</b> and special <b>blue bulb</b> "}, {:result_number=>"18", :url=>"http://0.0.0.0:3000/products/393", :title=>"excellent and masterful blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"393"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and masterful blue bulb"}, {:meta_name=>"voltage", :meta_value=>"65"}, {:meta_name=>"brand", :meta_value=>"Bulbrite"}, {:meta_name=>"material", :meta_value=>"Wood"}, {:meta_name=>"bulb_type", :meta_value=>"Flourescent"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"55"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and masterful <b>blue bulb</b> "}, {:result_number=>"19", :url=>"http://0.0.0.0:3000/products/934", :title=>"excellent and artsy blue bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"934"}, {:meta_name=>"name", :meta_value=>"blue Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"excellent and artsy blue bulb"}, {:meta_name=>"voltage", :meta_value=>"45"}, {:meta_name=>"brand", :meta_value=>"Philips"}, {:meta_name=>"material", :meta_value=>"Fabric"}, {:meta_name=>"bulb_type", :meta_value=>"Halogen"}, {:meta_name=>"bulb_color", :meta_value=>"blue"}, {:meta_name=>"price", :meta_value=>"18"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:47 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:47 UTC"}], :search_result_snippet=>"<b>blue</b> Incandescent <b>bulb excellent</b> and artsy <b>blue bulb</b> "}]
|
@@ -0,0 +1 @@
|
|
1
|
+
{:voltage=>[["220", 2], ["120", 3], ["65", 2], ["135", 2], ["45", 5], ["140", 1], ["115", 1], ["110", 1], ["75", 1], ["100", 1]], :brand=>[["Plusrite", 4], ["Tcp", 3], ["Bulbrite", 3], ["Sylvania", 1], ["Eiko", 3], ["Philips", 4], ["Satco", 1]], :material=>[["Fabric", 4], ["Plastic", 1], ["Fiberglass", 1], ["Glass", 5], ["Resin", 1], ["Metal", 2], ["Brass", 1], ["Ceramic", 1], ["Wood", 3]], :bulb_type=>[["Flourescent", 4], ["Halogen", 2], ["Incandescent", 10], ["Led", 3]], :bulb_color=>[["Blue", 19]]}
|
@@ -0,0 +1 @@
|
|
1
|
+
[{:result_number=>"1", :url=>"http://0.0.0.0:3000/products/480", :title=>"amazing and heavenly red bulb", :metatags=>[{:meta_name=>"id", :meta_value=>"480"}, {:meta_name=>"name", :meta_value=>"red Incandescent bulb"}, {:meta_name=>"description", :meta_value=>"amazing and heavenly red bulb"}, {:meta_name=>"voltage", :meta_value=>"75"}, {:meta_name=>"brand", :meta_value=>"Bulbrite"}, {:meta_name=>"material", :meta_value=>"Resin"}, {:meta_name=>"bulb_type", :meta_value=>"Incandescent"}, {:meta_name=>"bulb_color", :meta_value=>"red"}, {:meta_name=>"price", :meta_value=>"56"}, {:meta_name=>"created_at", :meta_value=>"2013-09-16 17:28:44 UTC"}, {:meta_name=>"updated_at", :meta_value=>"2013-09-16 17:28:44 UTC"}], :search_result_snippet=>"<b>red</b> Incandescent <b>bulb amazing</b> and <b>heavenly red bulb</b> "}]
|
@@ -0,0 +1 @@
|
|
1
|
+
{:voltage=>[["220", 2], ["120", 3], ["65", 2], ["135", 2], ["45", 5], ["140", 1], ["115", 1], ["110", 1], ["75", 1], ["100", 1]]}
|
@@ -0,0 +1 @@
|
|
1
|
+
["379", "665", "1", "511", "875", "173", "688", "67", "506", "475", "206", "57", "616", "85", "671", "765", "330", "393", "934"]
|
@@ -0,0 +1 @@
|
|
1
|
+
["480"]
|
data/gsa.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gsa/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'gsa'
|
8
|
+
spec.version = GSA::VERSION
|
9
|
+
spec.authors = ['Daniel J. Long', '1000Bulbs.com Dev Team']
|
10
|
+
spec.email = ['dlong@1000bulbs.com']
|
11
|
+
|
12
|
+
spec.summary = %q{
|
13
|
+
One-line feeding, searching and faceting for Google Search Appliance (GSA)'
|
14
|
+
}
|
15
|
+
|
16
|
+
spec.description = %q{
|
17
|
+
Harness GSA indexing power easily and immediately with one-line feeding,
|
18
|
+
searching, and faceting. This gem is tailored for the use in commerce
|
19
|
+
and other such uses outside the scope of the out-of-the-box GSA
|
20
|
+
"internal search".
|
21
|
+
}
|
22
|
+
|
23
|
+
spec.homepage = 'https://rubygems.org/gems/gsa'
|
24
|
+
spec.license = 'MIT'
|
25
|
+
|
26
|
+
spec.files = `git ls-files`.split($/)
|
27
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
31
|
+
spec.add_development_dependency 'rake'
|
32
|
+
spec.add_development_dependency 'webmock', '~> 1.13.0'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 2.5.0'
|
34
|
+
spec.add_development_dependency 'simplecov', '~> 0.7.1'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.6.7'
|
37
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.0.0'
|
38
|
+
spec.add_runtime_dependency 'json', '~> 1.8.0'
|
39
|
+
end
|
data/lib/defaults.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Defaults
|
2
|
+
# remember to set your base uri :)
|
3
|
+
NO_URI_TEXT = "base_uri not set"
|
4
|
+
|
5
|
+
# feed extension
|
6
|
+
FEED_EXTENSION = ":19900/xmlfeed"
|
7
|
+
|
8
|
+
# feed actions
|
9
|
+
ADD_ACTION = "add"
|
10
|
+
DELETE_ACTION = "delete"
|
11
|
+
|
12
|
+
# values for feeding
|
13
|
+
FEED_TYPE = "incremental" # OPTIONS: incremental, full
|
14
|
+
|
15
|
+
# values for searching
|
16
|
+
MAX_RESULTS = "1000" # GSA MAX: 1000
|
17
|
+
DEFAULT_NUM = MAX_RESULTS # OPTIONS: 1..1000
|
18
|
+
DEFAULT_FILTER = "0" # OPTIONS: 0, 1, s, p
|
19
|
+
DEFAULT_GETFIELDS = "*" # OPTIONS: * || names of specific metadatum. ie: price || name.price.description
|
20
|
+
DEFAULT_SORT = "relevance" # OPTIONS: relevance, date
|
21
|
+
DEFAULT_OUTPUT = "xml_no_dtd" # OPTIONS: xml_no_dtd, xml
|
22
|
+
NO_RESULTS = 0
|
23
|
+
|
24
|
+
# values for making xml files
|
25
|
+
DOC_TYPE = "<!DOCTYPE gsafeed PUBLIC '-//Google//DTD GSA Feeds//EN' ''>"
|
26
|
+
XML_TYPE = "<?xml version='1.0' encoding='UTF8'?>"
|
27
|
+
MIME_TYPE = "text/plain"
|
28
|
+
|
29
|
+
# values for parsing returned search results
|
30
|
+
GOOGLE_SEARCH_PROTOCOL = "GSP"
|
31
|
+
PARAMETERS = "PARAM"
|
32
|
+
RESULTS = "RES"
|
33
|
+
RESULT = "R"
|
34
|
+
RESULT_NUMBER = "N"
|
35
|
+
URL = "U"
|
36
|
+
TITLE = "T"
|
37
|
+
METATAGS = "MT"
|
38
|
+
META_NAME = "N"
|
39
|
+
META_VALUE = "V"
|
40
|
+
SEARCH_RESULT_SNIPPET = "S"
|
41
|
+
end
|
data/lib/facade.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Facade
|
2
|
+
def feed(args)
|
3
|
+
xml = records_to_xml(args)
|
4
|
+
feed_to_gsa(xml, args[:datasource_name])
|
5
|
+
end
|
6
|
+
|
7
|
+
def search(query, filters={})
|
8
|
+
raw_results = search_gsa_index(query, filters)
|
9
|
+
return raw_results if raw_results == GSA::NO_RESULTS
|
10
|
+
beautify_search_results(raw_results)
|
11
|
+
end
|
12
|
+
|
13
|
+
def facet(search_results, facetables)
|
14
|
+
GSA::Faceter.facet(search_results, facetables)
|
15
|
+
end
|
16
|
+
|
17
|
+
def uids(pretty_search_results, uid)
|
18
|
+
GSA::UIDExtractor.extract(pretty_search_results, uid)
|
19
|
+
end
|
20
|
+
|
21
|
+
#########
|
22
|
+
protected
|
23
|
+
#########
|
24
|
+
|
25
|
+
def feed_to_gsa(xml_file, datasource_name)
|
26
|
+
if GSA.base_uri
|
27
|
+
GSA::Feeder.feed(xml_file, datasource_name)
|
28
|
+
else
|
29
|
+
raise GSA::URINotSetError, GSA::NO_URI_TEXT
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_gsa_index(query, filters={})
|
34
|
+
if GSA.base_uri
|
35
|
+
GSA::Searcher.search(query, filters)
|
36
|
+
else
|
37
|
+
raise GSA::URINotSetError, GSA::NO_URI_TEXT
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def beautify_search_results(search_results)
|
42
|
+
GSA::SearchConverter.convert(search_results)
|
43
|
+
end
|
44
|
+
|
45
|
+
def records_to_xml(args)
|
46
|
+
GSA::RecordsConverter.convert(args)
|
47
|
+
end
|
48
|
+
end
|
data/lib/gsa.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require_relative 'gsa/version'
|
6
|
+
require_relative 'gsa/modules/injector'
|
7
|
+
require_relative 'gsa/modules/xmlizer'
|
8
|
+
require_relative 'gsa/modules/filer'
|
9
|
+
require_relative 'gsa/records_converter'
|
10
|
+
require_relative 'gsa/feeder'
|
11
|
+
require_relative 'gsa/searcher'
|
12
|
+
require_relative 'gsa/faceter'
|
13
|
+
require_relative 'gsa/search_converter'
|
14
|
+
require_relative 'gsa/uid_extractor'
|
15
|
+
require_relative 'gsa/exceptions'
|
16
|
+
|
17
|
+
require_relative 'defaults'
|
18
|
+
require_relative 'facade'
|
19
|
+
|
20
|
+
module GSA
|
21
|
+
class << self
|
22
|
+
attr_accessor :base_uri
|
23
|
+
end
|
24
|
+
|
25
|
+
include Defaults
|
26
|
+
extend Facade
|
27
|
+
end
|
data/lib/gsa/faceter.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module GSA
|
2
|
+
class Faceter
|
3
|
+
def self.facet(search_results, facetables=[])
|
4
|
+
faceted = build_faceted(facetables)
|
5
|
+
|
6
|
+
faceted = populate_faceted(search_results, facetables, faceted)
|
7
|
+
|
8
|
+
faceted = group_faceted(facetables, faceted)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build_faceted(facetables)
|
12
|
+
faceted = {}
|
13
|
+
facetables.each {|facetable| faceted[facetable] = []}
|
14
|
+
faceted
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.populate_faceted(search_results, facetables, faceted)
|
18
|
+
search_results.each {|result| handle_metatags(result, facetables, faceted)}
|
19
|
+
faceted
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.handle_metatags(result, facetables, faceted)
|
23
|
+
result[:metatags].each {|metatag| add_value_to_group(facetables, faceted, metatag)}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_value_to_group(facetables, faceted, metatag)
|
27
|
+
if facetables.include? metatag[:meta_name].to_sym
|
28
|
+
faceted[metatag[:meta_name].to_sym] << metatag[:meta_value]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.group_faceted(facetables, faceted)
|
33
|
+
facetables.each {|facetable| faceted[facetable] = sub_groups(faceted, facetable)}
|
34
|
+
faceted
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.sub_groups(faceted, facetable)
|
38
|
+
faceted[facetable].group_by(&:capitalize).map {|k,v| [k, v.length]} # change capitalize to something less invasive (don't alter the original form)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|