mediawiki-keiki 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b786adda5c9f95e248abe9435bc3dbcd8a354460
4
- data.tar.gz: 306adbb72d9dded52f103fbe802bb82d2d7fbd39
3
+ metadata.gz: c397300e4298a75ba04c0097e2e0d3377835bee5
4
+ data.tar.gz: 6f7cebf1f1c272ce55c0b63ba88f09f731de0f57
5
5
  SHA512:
6
- metadata.gz: 8a42136d3437afe3b46814552ad7e0a1437d918bc8f4c2b8761c9aaa1daf50698347ce08cdc4ebcfe80a2faebdaa7bf19e4ce276d240c340b4debc5cbb401997
7
- data.tar.gz: 3c1ea82e75025f37d47c2ec17664aca48dc0892d291b27298e429bae0072fe8eca07c2825685ebe5540a81e79c41865dc66ad5ac7a9e052b69633bd6700fa976
6
+ metadata.gz: 1544b70dd0451e5889d8f9e5f0536e1817698296abc711378d4d51b09324c92680dd37f3d1ad44783eab6d1e0adc33424c69dd4176ee1a3cbfcb183290b50441
7
+ data.tar.gz: 634b85441fd001cd922de31b25924ccb3980126c6041f6d3e937c3fe14fde3ef6446d2c77d0a6566cfaaf70301b313ab729d84e8a6abe9fca3a1df2d348e445e
@@ -111,7 +111,7 @@ module MediaWiki
111
111
  def get_redirects_for(result_map, redirects)
112
112
  result_map.each do |rm|
113
113
  redirects.each do |r|
114
- rm[:redirected] = r["to"] if r["from"] == rm[:search_term] || rm[:normalized]
114
+ rm[:redirected] = r["to"] if r["from"] == rm[:search_term] || r["from"] == rm[:normalized]
115
115
  end
116
116
  end
117
117
  result_map
@@ -122,15 +122,6 @@ module MediaWiki
122
122
  query_result["query"][map_type] # if query_result["query"][map_type]
123
123
  end
124
124
 
125
- # # Use the query maps to update the values of the result map
126
- # def map_from_to(result_map, query_map)
127
- # result_map.each do |key, value|
128
- # query_map.each { |hash| value = hash["to"] if hash["from"] == value }
129
- # end
130
- # result_map
131
- # end
132
-
133
-
134
125
  private
135
126
 
136
127
  # Private method that gets called if the query_result has not been retrieved yet; gets query and parses as a hash.
@@ -63,7 +63,6 @@ describe MediaWiki::Query do
63
63
  describe "dynamic attributes" do
64
64
 
65
65
  before do
66
- # wiki_query.query_result
67
66
  @initialized_result_map = [{:search_term => "foo"}]
68
67
  @normalized_hash_array = [{"from"=>"foo", "to" =>"Foo"}]
69
68
  @redirected_hash_array = [{"from" => "Foo", "to" => "Foobar"}]
@@ -91,14 +90,6 @@ describe MediaWiki::Query do
91
90
  wiki_query.get_redirects_for(@normalized_map, @redirected_hash_array).must_equal @redirected_map
92
91
  end
93
92
 
94
- # it "must apply the noramalization map to the results map" do
95
- # wiki_query.map_from_to({"foo"=>"foo"}, @normalized_hash_array).must_equal @normalized_map
96
- # end
97
-
98
- # it "must apply the redirects map to the normalized result map" do
99
- # wiki_query.map_from_to(@normalized_map,@redirected_hash_array).must_equal @redirected_map
100
- # end
101
-
102
93
  it "must map the original query to the normalized, redirected title" do
103
94
  wiki_query.map_query_to_results.must_equal @redirected_map
104
95
  end
@@ -172,26 +163,193 @@ describe MediaWiki::Query do
172
163
 
173
164
  describe "multiple pages" do
174
165
 
175
- let(:wiki_query) { MediaWiki::Query.new('Partners In Health|ThoughtWorks|Accion International') }
166
+ let(:wiki_query) { MediaWiki::Query.new('foo|bar|a|b|c|Jimmy Fallon|Seth Rogan|Mesopotamia') }
167
+
168
+ before do
169
+ @expected_keys = ['foo','bar','a','b','c','Jimmy Fallon','Seth Rogan','Mesopotamia']
170
+ @initialized_map = [
171
+ {
172
+ :search_term => 'foo'
173
+ },
174
+ {
175
+ :search_term => 'bar'
176
+ },
177
+ {
178
+ :search_term => 'a'
179
+ },
180
+ {
181
+ :search_term => 'b'
182
+ },
183
+ {
184
+ :search_term => 'c'
185
+ },
186
+ {
187
+ :search_term => 'Jimmy Fallon'
188
+ },
189
+ {
190
+ :search_term => 'Seth Rogan'
191
+ },
192
+ {
193
+ :search_term => 'Mesopotamia'
194
+ }
195
+ ]
196
+ @normalizations = [
197
+ {
198
+ 'from' => 'foo',
199
+ 'to' => 'Foo'
200
+ },
201
+ {
202
+ 'from' => 'bar',
203
+ 'to' => 'Bar'
204
+ },
205
+ {
206
+ 'from' => 'a',
207
+ 'to' => 'A'
208
+ },
209
+ {
210
+ 'from' => 'b',
211
+ 'to' => 'B'
212
+ },
213
+ {
214
+ 'from' => 'c',
215
+ 'to' => 'C'
216
+ }
217
+ ]
218
+ @expected_normalized_map = [
219
+ {
220
+ :search_term => 'foo',
221
+ :normalized => 'Foo'
222
+ },
223
+ {
224
+ :search_term => 'bar',
225
+ :normalized => 'Bar'
226
+ },
227
+ {
228
+ :search_term => 'a',
229
+ :normalized => 'A'
230
+ },
231
+ {
232
+ :search_term => 'b',
233
+ :normalized => 'B'
234
+ },
235
+ {
236
+ :search_term => 'c',
237
+ :normalized => 'C'
238
+ },
239
+ {
240
+ :search_term => 'Jimmy Fallon'
241
+ },
242
+ {
243
+ :search_term => 'Seth Rogan'
244
+ },
245
+ {
246
+ :search_term => 'Mesopotamia'
247
+ }
248
+ ]
249
+ @expected_results_map = [
250
+ {
251
+ :search_term => 'foo',
252
+ :normalized => 'Foo',
253
+ :redirected => 'Foobar'
254
+ },
255
+ {
256
+ :search_term => 'bar',
257
+ :normalized => 'Bar'
258
+ },
259
+ {
260
+ :search_term => 'a',
261
+ :normalized => 'A'
262
+ },
263
+ {
264
+ :search_term => 'b',
265
+ :normalized => 'B'
266
+ },
267
+ {
268
+ :search_term => 'c',
269
+ :normalized => 'C'
270
+ },
271
+ {
272
+ :search_term => 'Jimmy Fallon'
273
+ },
274
+ {
275
+ :search_term => 'Seth Rogan',
276
+ :redirected => 'Seth Rogen'
277
+ },
278
+ {
279
+ :search_term => 'Mesopotamia'
280
+ }
281
+ ]
282
+ @redirects = [
283
+ {
284
+ 'from' => 'Foo',
285
+ 'to' => 'Foobar'
286
+ },
287
+ {
288
+ 'from' => 'Seth Rogan',
289
+ 'to' => 'Seth Rogen'
290
+ }
291
+ ]
292
+ @expected_keys_with_titles = {
293
+ 'foo'=>'Foobar',
294
+ 'bar'=> 'Bar',
295
+ 'a' => 'A',
296
+ 'b' => 'B',
297
+ 'c' => 'C',
298
+ 'Jimmy Fallon' => 'Jimmy Fallon',
299
+ 'Seth Rogan' => 'Seth Rogen',
300
+ 'Mesopotamia' => 'Mesopotamia'
301
+ }
302
+ end
303
+
304
+ it "must split the search string on the bar and return individual search terms" do
305
+ wiki_query.query.split('|').must_equal @expected_keys
306
+ end
307
+
308
+ it "must initialize a results map as an array with hashses containing the :search_term" do
309
+ wiki_query.initialize_map.must_equal @initialized_map
310
+ end
311
+
312
+ it "must get the normalizations from the query result" do
313
+ wiki_query.get_query_map("normalized").must_equal @normalizations
314
+ end
315
+
316
+ it "must get the redirects from the query result" do
317
+ wiki_query.get_query_map("redirects").must_equal @redirects
318
+ end
319
+
320
+ it "must store the normalizations in the results map" do
321
+ wiki_query.get_normalizations_for(@initialized_map, @normalizations).must_equal @expected_normalized_map
322
+ end
323
+
324
+ it "must store the redirects in the results map" do
325
+ wiki_query.get_redirects_for(@expected_normalized_map, @redirects).must_equal @expected_results_map
326
+ end
176
327
 
177
328
  it "must get a result map for each page" do
178
- wiki_query.map_query_to_results.length.must_equal 3
329
+ wiki_query.map_query_to_results.length.must_equal 8
179
330
  end
180
331
 
181
- it "must return all of the sites" do
182
- wiki_query.pages.length.must_equal 3
332
+ it "must get the complete results map" do
333
+ wiki_query.map_query_to_results.must_equal @expected_results_map
183
334
  end
184
335
 
185
- it "must tag the first page with the right query term" do
186
- wiki_query.pages['Partners In Health'].title.must_equal 'Partners In Health'
336
+ it "must return all of the sites" do
337
+ wiki_query.pages.length.must_equal 8
187
338
  end
188
339
 
189
- it "must tag the second page with the right query term" do
190
- wiki_query.pages['ThoughtWorks'].title.must_equal 'ThoughtWorks'
340
+ it "must have keys for all of the sites that match the original search terms" do
341
+ wiki_query.pages.keys.sort.must_equal @expected_keys.sort
191
342
  end
192
343
 
193
- it "must tag the last page with the right query term" do
194
- wiki_query.pages['Accion International'].title.must_equal 'ACCION International'
344
+ it "must have all of the keys pointing to the right title" do
345
+ pages_and_titles = Hash.new
346
+
347
+ #Populates a hash with all of the keys and their corresponding page titles
348
+ wiki_query.pages.each do |key, value|
349
+ pages_and_titles[key] = value.title
350
+ end
351
+
352
+ pages_and_titles.must_equal @expected_keys_with_titles
195
353
  end
196
354
 
197
355
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-keiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Waters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  requirements: []
230
230
  rubyforge_project:
231
- rubygems_version: 2.4.5
231
+ rubygems_version: 2.2.2
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: MediaWiki Keiki