bcms_google_mini_search 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,9 @@ class SearchResult
31
31
  result.title = ele.elements["T"].text
32
32
  result.url = ele.elements["U"].text
33
33
  result.description = ele.elements["S"].text
34
- result.size = ele.elements["HAS/C"].attributes["SZ"]
34
+
35
+ doc_size_ele = ele.elements["HAS/C"]
36
+ result.size = doc_size_ele ? doc_size_ele.attributes["SZ"] : ""
35
37
 
36
38
  results << result
37
39
  end
@@ -52,8 +52,7 @@ EOF
52
52
  </GSP>
53
53
  EOF
54
54
  @large_xml_doc = REXML::Document.new(@large_results_set)
55
-
56
-
55
+
57
56
  end
58
57
 
59
58
  test "Parse result count from google mini results xml." do
@@ -425,4 +424,45 @@ XML
425
424
  assert_equal false, result.synonyms?
426
425
  assert_equal [], result.pages
427
426
  end
427
+
428
+ test "Search results for PDF's that have no size" do
429
+ pdf_results = <<EOF
430
+ <GSP>
431
+ <RES>
432
+ <M>35</M>
433
+ <R N="1">
434
+ <U>http://someurl.com</U>
435
+ <T>TITLE</T>
436
+ <S>BLURB</S>
437
+ <HAS>
438
+ <C SZ="1k" />
439
+ </HAS>
440
+ </R>
441
+ <R N="2">
442
+ <U>http://someurl2.com</U>
443
+ <T>TITLE 2</T>
444
+ <S>BLURB 2</S>
445
+ <HAS>
446
+ <L/>
447
+ </HAS>
448
+ </R>
449
+ </RES>
450
+ </GSP>
451
+ EOF
452
+ xml_doc = REXML::Document.new(pdf_results)
453
+ results = SearchResult.parse_xml xml_doc
454
+ assert_equal 2, results.size
455
+
456
+ assert_equal "1", results[0].number
457
+ assert_equal "http://someurl.com", results[0].url
458
+ assert_equal "TITLE", results[0].title
459
+ assert_equal "BLURB", results[0].description
460
+ assert_equal "1k", results[0].size
461
+
462
+ assert_equal "2", results[1].number
463
+ assert_equal "http://someurl2.com", results[1].url
464
+ assert_equal "TITLE 2", results[1].title
465
+ assert_equal "BLURB 2", results[1].description
466
+ assert_equal "", results[1].size
467
+ end
428
468
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcms_google_mini_search
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - BrowserMedia
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-18 00:00:00 -04:00
18
+ date: 2010-12-09 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21