ralert 0.2.0 → 0.3.1
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 +4 -4
- data/lib/ralert.rb +5 -7
- data/lib/result.rb +19 -18
- data/lib/search-options.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6abc1ba48ebc8b6b36223b841f8d051fcb93739
|
4
|
+
data.tar.gz: 0644dda3c71b8c01f118c83b71ebd072d95b3dc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addfed28103ccf52fe4bb658c8592956e51d5c4e6cafa75b48ad746dfd6c66b32a020871b69f6e164063196052b6b0053ef1c2e9c1b88b4defb5c0e04981ad12
|
7
|
+
data.tar.gz: 7569fa732f2d541efc2fa5f2c4b8da54f9977d8728f8e1c36a7c6089d93bd7abb3b596a6a17f1919bc857e8fab26fe0d3065b43b67ae2838bd2e9b1e157d48e8
|
data/lib/ralert.rb
CHANGED
@@ -35,8 +35,8 @@ class Ralert
|
|
35
35
|
def construct_uri(query, options)
|
36
36
|
base_uri = "https://google.com/search?q="
|
37
37
|
|
38
|
-
if
|
39
|
-
query = "
|
38
|
+
if options.literal
|
39
|
+
query = "%22" + query + "%22"
|
40
40
|
end
|
41
41
|
|
42
42
|
if !options.date_range.nil?
|
@@ -45,19 +45,17 @@ class Ralert
|
|
45
45
|
query += "&tbs=qdr:w"
|
46
46
|
end
|
47
47
|
|
48
|
-
if options.sort_by
|
48
|
+
if options.sort_by == 'd'
|
49
49
|
query += ",sbd:1"
|
50
50
|
end
|
51
51
|
|
52
|
-
if
|
52
|
+
if options.safe == 'on'
|
53
53
|
query += "&safe=on"
|
54
54
|
else
|
55
55
|
query += "&safe=off"
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
query += "&tbm=nws"
|
60
|
-
end
|
58
|
+
query += "&tbm=#{options.mode}"
|
61
59
|
|
62
60
|
return base_uri + query
|
63
61
|
end
|
data/lib/result.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
class Result
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
attr_accessor :link, :title, :source, :date
|
3
|
+
|
4
|
+
def initialize(link='', title='', source = '', date = '')
|
5
|
+
@link = link
|
6
|
+
@title = title
|
7
|
+
@source = source
|
8
|
+
@date = date
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def ==(other)
|
12
|
+
self.class === other and
|
13
|
+
other.author == @link and
|
14
|
+
other.title == @title and
|
15
|
+
other.source = @source and
|
16
|
+
other.date == @date
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
alias eql? ==
|
20
|
+
def hash
|
21
|
+
@link.hash ^ @title.hash ^ @source.hash ^ @date.hash # XOR
|
22
|
+
end
|
22
23
|
end
|
data/lib/search-options.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class SearchOptions
|
2
2
|
attr_accessor :literal, :sort_by, :date_range, :safe, :mode
|
3
3
|
|
4
|
-
def initialize(literal =
|
4
|
+
def initialize(literal = false, sort_by = 'd', date_range = 'w', safe = 'off', mode = 'nws')
|
5
5
|
@literal = literal
|
6
6
|
@sort_by = sort_by
|
7
7
|
@date_range = date_range
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ralert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spyros Livathinos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Queries the Google search engine and returns an array of Result objects.
|
14
14
|
email: livathinos.spyros@gmail.com
|
@@ -19,7 +19,7 @@ files:
|
|
19
19
|
- lib/ralert.rb
|
20
20
|
- lib/result.rb
|
21
21
|
- lib/search-options.rb
|
22
|
-
homepage: http://
|
22
|
+
homepage: http://github.com/livathinos/ralert
|
23
23
|
licenses:
|
24
24
|
- MIT
|
25
25
|
metadata: {}
|
@@ -29,17 +29,17 @@ require_paths:
|
|
29
29
|
- lib
|
30
30
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project:
|
42
|
-
rubygems_version: 2.0
|
42
|
+
rubygems_version: 2.2.0
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: Ralert is a simple Ruby gem for parsing Google News search queries programmatically.
|