counting_stars 0.1.0 → 0.2.0
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/.travis.yml +8 -0
- data/README.md +28 -8
- data/Rakefile +4 -1
- data/counting_stars.gemspec +1 -0
- data/lib/counting_stars.rb +14 -0
- data/lib/counting_stars/version.rb +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d943addfa3e0c0639d3300791d432f8f1ed72c5
|
4
|
+
data.tar.gz: faef94eccc28d972bbe1a25c59838d9e48d9aaed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c927cbe86f650936810f691736486dd37bb7d814392035b9184eca0c43f439a0bfff271b6d6186fdc40f0468645d32d2b89c60112c05ee16c626ff0493ccaaa
|
7
|
+
data.tar.gz: 6480dd4c4b7cfc91be64d18947968a23203cede3b4d8b798956c1533c0395f696f84a049c0e5b40753ec2f96e1c89e6165523bbd56fd70b1133edd0333fba74f
|
data/.travis.yml
CHANGED
@@ -1,3 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.2.0
|
4
|
+
|
5
|
+
before_install:
|
6
|
+
- gem install bundler
|
7
|
+
|
8
|
+
addons:
|
9
|
+
code_climate:
|
10
|
+
repo_token:
|
11
|
+
secure: "JYgaUE2ngLH97PCXs4eJv0AXm5p/Xa830CwVylz6EeAU4DbYeD2SqIlUdaqtPdSEciK+ZJYcnG4Wv0i81RxfXg4x/ZXA4iZN/+L5uUmQ2+ADKrv5UbUOUK6tW0/WqjS273y01LEpAG0LM5jlMD2uFmbgSfC/yGWxvIonlQW510g="
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# Counting Stars
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/krmbzds/counting_stars)
|
4
|
+
[](https://codeclimate.com/github/krmbzds/counting_stars)
|
5
|
+
[](https://codeclimate.com/github/krmbzds/counting_stars)
|
6
|
+
[](http://badge.fury.io/rb/counting_stars)
|
7
|
+
[](https://gemnasium.com/krmbzds/counting_stars)
|
4
8
|
|
5
|
-
|
9
|
+
|
10
|
+
A simple ruby library for extracting rating and metadata information from Google Search.
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
@@ -22,17 +27,32 @@ Or install it yourself as:
|
|
22
27
|
|
23
28
|
## Usage
|
24
29
|
|
25
|
-
|
30
|
+
### As a Ruby Module
|
31
|
+
|
32
|
+
```rb
|
33
|
+
require 'counting_stars'
|
34
|
+
|
35
|
+
CountingStars::count("Marriott's Grande Ocean", "booking.com")
|
36
|
+
=> ["Rating: 9.4/10", "26 reviews"]
|
26
37
|
|
27
|
-
|
38
|
+
CountingStars::count("Marriott's Grande Ocean", "tripadvisor.com")
|
39
|
+
=> ["Rating: 4.5", "501 reviews", "Price range: $$$"]
|
40
|
+
|
41
|
+
# Now you can also use shorthand methods
|
42
|
+
CountingStars::booking("Marriott's Grande Ocean")
|
43
|
+
=> {:rating=>"9.4", :reviews=>"26"}
|
44
|
+
|
45
|
+
CountingStars::tripadvisor("Marriott's Grande Ocean")
|
46
|
+
=> {:rating=>"4", :reviews=>"506", :price_range=>"$$$"}
|
47
|
+
```
|
28
48
|
|
29
|
-
|
49
|
+
### Commmandline
|
30
50
|
|
31
|
-
|
51
|
+
:rocket: Coming soon.
|
32
52
|
|
33
53
|
## Contributing
|
34
54
|
|
35
|
-
1. Fork it ( https://github.com/
|
55
|
+
1. Fork it ( https://github.com/krmbzds/counting_stars/fork )
|
36
56
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
57
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
58
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
data/counting_stars.gemspec
CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
|
28
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4', '>=0.4.7'
|
28
29
|
end
|
data/lib/counting_stars.rb
CHANGED
@@ -6,6 +6,10 @@ require 'counting_stars/version'
|
|
6
6
|
|
7
7
|
module CountingStars
|
8
8
|
|
9
|
+
INTEGER = /\d+/
|
10
|
+
DECIMAL = /\d+\.\d+/
|
11
|
+
DOLLARS = /\$+/
|
12
|
+
|
9
13
|
def self.count(query, site)
|
10
14
|
request "#{query} site:#{site}"
|
11
15
|
end
|
@@ -22,4 +26,14 @@ module CountingStars
|
|
22
26
|
page.gsub(/[[:space:]]/, ' ').lstrip.split(' - ')
|
23
27
|
end
|
24
28
|
|
29
|
+
def self.booking(query)
|
30
|
+
response = count(query, 'booking.com')
|
31
|
+
{ rating: response[0][DECIMAL], reviews: response[1][INTEGER] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.tripadvisor(query)
|
35
|
+
response = count(query, 'tripadvisor.com')
|
36
|
+
{ rating: response[0][INTEGER], reviews: response[1][INTEGER], price_range: response[2][DOLLARS] }
|
37
|
+
end
|
38
|
+
|
25
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: counting_stars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kerem Bozdas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -98,6 +98,26 @@ dependencies:
|
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 3.2.0
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: codeclimate-test-reporter
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0.4'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.4.7
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.4'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.4.7
|
101
121
|
description: A simple tool for extracting rating and metadata information from Google
|
102
122
|
Search.
|
103
123
|
email:
|