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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db68c2b3754d20707792ffde3ef60b33a18bbec3
4
- data.tar.gz: af6df9818eaa6513b5393becf25dd7a87d226324
3
+ metadata.gz: a6abc1ba48ebc8b6b36223b841f8d051fcb93739
4
+ data.tar.gz: 0644dda3c71b8c01f118c83b71ebd072d95b3dc8
5
5
  SHA512:
6
- metadata.gz: 06e3243385de2ced3f3051cf067a0fa47f4826abbd6dc182f30e95cb8b9747b866610304cd5747ea0effbb2294fb890def0f88332a2e7f0bbe455312ef1207e7
7
- data.tar.gz: 643b0b4d7efd401c33b94fd9cc36f374dc0fbf660cb0dd502114738bc315cc8c01b11c0e1b067e22eda334e5a03a34ff264e3af2ae426bb8bd25217fed0c663b
6
+ metadata.gz: addfed28103ccf52fe4bb658c8592956e51d5c4e6cafa75b48ad746dfd6c66b32a020871b69f6e164063196052b6b0053ef1c2e9c1b88b4defb5c0e04981ad12
7
+ data.tar.gz: 7569fa732f2d541efc2fa5f2c4b8da54f9977d8728f8e1c36a7c6089d93bd7abb3b596a6a17f1919bc857e8fab26fe0d3065b43b67ae2838bd2e9b1e157d48e8
@@ -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 !options.literal.nil?
39
- query = "\"" + 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.nil?
48
+ if options.sort_by == 'd'
49
49
  query += ",sbd:1"
50
50
  end
51
51
 
52
- if !options.safe.nil?
52
+ if options.safe == 'on'
53
53
  query += "&safe=on"
54
54
  else
55
55
  query += "&safe=off"
56
56
  end
57
57
 
58
- if options.mode.nil?
59
- query += "&tbm=nws"
60
- end
58
+ query += "&tbm=#{options.mode}"
61
59
 
62
60
  return base_uri + query
63
61
  end
@@ -1,22 +1,23 @@
1
1
  class Result
2
- attr_accessor :link, :title, :source, :date
3
- def initialize(link='', title='', source = '', date = '')
4
- @link = link
5
- @title = title
6
- @source = source
7
- @date = date
8
- end
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
- def ==(other)
11
- self.class === other and
12
- other.author == @link and
13
- other.title == @title and
14
- other.source = @source and
15
- other.date == @date
16
- end
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
- alias eql? ==
19
- def hash
20
- @link.hash ^ @title.hash ^ @source.hash ^ @date.hash # XOR
21
- end
19
+ alias eql? ==
20
+ def hash
21
+ @link.hash ^ @title.hash ^ @source.hash ^ @date.hash # XOR
22
+ end
22
23
  end
@@ -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 = nil, sort_by = nil, date_range = nil, safe = nil, mode = nil)
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.2.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-08-22 00:00:00.000000000 Z
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://thinkcactus.com
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.3
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.