siteseeker_normalizer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +58 -8
- data/lib/siteseeker_normalizer/client.rb +2 -1
- data/lib/siteseeker_normalizer/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NjcyNjZjZDBkMjA1NDBkM2Y0MTQzMjg4MjE3YWFlNGNiOTljOGI1NQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 211d91fe539ec4e33ddebe8336c73252ab3b67a0
|
4
|
+
data.tar.gz: 5dba9516fdc952c5e9b9e1f4a850d0e6db4cb641
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MTQ1YWEzNjY3ZWE1ODA0OTJiYjI5YTk2MWE0NWIzYTNlM2M3ODA4MGEyOTI1
|
11
|
-
ZWUzYzIwMzZhZDEzNzczN2JkOWRlZjBkYjdjZTMxYTk5YzNiNzA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODk5Yjc3MTEyZDJlNmVhNzM4ZWVmMmE3NTQwYTg4ZmEyNjVjZmQ3NDRjYmQ2
|
14
|
-
OTE2MjQyMDA1OGE5YjAwM2U1YjA5OTM5OWQwNmQ2ZTI3MTUyMDBjMTc1ZTZl
|
15
|
-
MmU1NWI5NjhhYjA0YTUxOWUyZjM0ZjI2YzdhMjE4N2JjZGU4MTM=
|
6
|
+
metadata.gz: 4189fa5ad8c6245bf92bf4fc8a1beb24bb93da650bbf3326905c43c771d853892f8c56c680ebd876a819e70860c4531b66ba5b3cf626a46a545c88bb9a877c78
|
7
|
+
data.tar.gz: 7b7d752a74009fb6e38640ad05a2b48444b48d1f81d64d78ab6ea249f2043d32928da246d524d6822d2d0594efebe9d87b3ddf3788523d7a76dbc731bdcf8e48
|
data/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/malmostad/siteseeker_normalizer.png)](https://travis-ci.org/malmostad/siteseeker_normalizer) [![Dependency Status](https://gemnasium.com/malmostad/siteseeker_normalizer.png)](https://gemnasium.com/malmostad/siteseeker_normalizer) [![Gem Version](https://badge.fury.io/rb/siteseeker_normalizer.png)](http://badge.fury.io/rb/siteseeker_normalizer)
|
4
4
|
|
5
|
-
Ruby gem for Siteseeker integration. Performs requests and parses the response from Siteseeker. Search results is available as a structured object
|
5
|
+
Ruby gem for Siteseeker integration. Performs requests and parses the response from Siteseeker. Search results is available as a structured object.
|
6
6
|
|
7
7
|
## Requirements
|
8
|
-
* Ruby 1.9.3 or 2.0.
|
8
|
+
* Ruby 1.9.3, 2.0.0 or 2.1.0.
|
9
9
|
* A [Siteseeker](http://www.siteseeker.se/) account.
|
10
10
|
|
11
11
|
## Installation
|
@@ -22,13 +22,62 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install siteseeker_normalizer
|
24
24
|
|
25
|
-
If you get an error message about Nokogiri, install it with `sudo` first:
|
26
|
-
|
27
|
-
$ sudo gem install nokogiri
|
28
|
-
|
29
25
|
## Usage
|
30
|
-
|
31
|
-
|
26
|
+
Check out the the Rails app [Intranet Dashboard](https://github.com/malmostad/intranet-dashboard) in the `site_search` controller and views or the standalone Sinatra search app [Sitesearch](https://github.com/malmostad/sitesearch). Both are using memcached wrappers for the fetched search results.
|
27
|
+
|
28
|
+
```Ruby
|
29
|
+
require 'siteseeker_normalizer'
|
30
|
+
|
31
|
+
# Initialize a search client with your account name and a search index name.
|
32
|
+
client = SiteseekerNormalizer::Client.new("account_name", "index_name")
|
33
|
+
|
34
|
+
# Search query with a search string.
|
35
|
+
results = client.search("parkering")
|
36
|
+
|
37
|
+
# Search query with a Hash of parameters
|
38
|
+
# Used for category filtering, load more results etc. where the query comes from a previous result.
|
39
|
+
results = client.search(params)
|
40
|
+
|
41
|
+
# Fetch the results first and then parse. Useful for caching the response before parsing.
|
42
|
+
raw_results = client.fetch("parkering")
|
43
|
+
raw_results = client.fetch(params)
|
44
|
+
results = SiteseekerNormalizer::Parse.new(raw_results)
|
45
|
+
|
46
|
+
# Parsed response
|
47
|
+
results.total # => 1008
|
48
|
+
results.entries # => Array with result entries
|
49
|
+
|
50
|
+
# First entry in results
|
51
|
+
entry = results.entries.first
|
52
|
+
entry.title # => "Boendeparkering"
|
53
|
+
entry.summary # => "Boendeparkering finns snart i 19 ..."
|
54
|
+
entry.date # => "2013-12-17"
|
55
|
+
entry.breadcrumbs.first.text # => "malmo.se"
|
56
|
+
entry.breadcrumbs.first.url # => "http://www.malmo.se/Medborgare.html"
|
57
|
+
entry.category # => "Ämnessidor: Stadsplanering & trafik"
|
58
|
+
|
59
|
+
# Sorting, Array with sorting alternatives
|
60
|
+
results.sorting.first.text # => "Relevans"
|
61
|
+
results.sorting.first.query # => "q=parkering&t=simple&ls=2&d=0&d1=01&d2 ..."
|
62
|
+
results.sorting.first.current # => false
|
63
|
+
|
64
|
+
# Query for loading more results
|
65
|
+
results.more_query # => "q=parkering&t=simple&ls=2&d=0&d1=01&d2 ..."
|
66
|
+
|
67
|
+
# Array with categories for the results, used for filtering
|
68
|
+
category_group = results.category_groups.first
|
69
|
+
category_group.title # => "Ämnessidor"
|
70
|
+
category = category_group.categories.first
|
71
|
+
category.current? # => false
|
72
|
+
category.hits # => "12"
|
73
|
+
category.title # => "Biblioteken"
|
74
|
+
category.query # => "q=parkering&t=simple&ls=2&d=0&d1=01&d2 ..."
|
75
|
+
|
76
|
+
# Spelling suggestions
|
77
|
+
results = client.search("parkkering")
|
78
|
+
results.suggestions.first.text # => "parkering"
|
79
|
+
results.suggestions.first.url # => "q=parkering&t=simple&ls=2&d=0&d1=01& ..."
|
80
|
+
```
|
32
81
|
|
33
82
|
## Testing
|
34
83
|
Run:
|
@@ -46,3 +95,4 @@ Run:
|
|
46
95
|
|
47
96
|
## License
|
48
97
|
Released under AGPL version 3.
|
98
|
+
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
3
4
|
require 'uri'
|
4
5
|
|
5
6
|
module SiteseekerNormalizer
|
@@ -18,7 +19,7 @@ module SiteseekerNormalizer
|
|
18
19
|
if query.is_a? Hash
|
19
20
|
query = URI.encode_www_form(query)
|
20
21
|
else
|
21
|
-
query = "q=#{query}"
|
22
|
+
query = "q=#{URI.encode_www_form_component(query)}"
|
22
23
|
end
|
23
24
|
open("#{@base_search_url}&#{query}", read_timeout: @options[:read_timeout]).read
|
24
25
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siteseeker_normalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- martent
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Siteseeker integration library
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
79
|
- COPYING
|
80
80
|
- Gemfile
|
81
81
|
- README.md
|
@@ -101,12 +101,12 @@ require_paths:
|
|
101
101
|
- lib
|
102
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|