whos_dated_who 0.3.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/Rakefile +4 -1
- data/lib/whos_dated_who/bing_client.rb +2 -2
- data/lib/whos_dated_who/biography.rb +3 -3
- data/lib/whos_dated_who/cli.rb +7 -6
- data/lib/whos_dated_who/client.rb +1 -0
- data/lib/whos_dated_who/importer.rb +1 -1
- data/lib/whos_dated_who/parser.rb +3 -2
- data/lib/whos_dated_who/version.rb +1 -1
- data/lib/whos_dated_who.rb +10 -10
- data/spec/acceptance/whos_dated_who_spec.rb +21 -0
- data/spec/whos_dated_who/client_spec.rb +0 -1
- data/spec/whos_dated_who/parser_spec.rb +13 -13
- data/whos_dated_who.gemspec +20 -20
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6926df4ea88a005695b59c0aeaf9ea31945c1cde
|
4
|
+
data.tar.gz: 9fc1d12d3d151d8d5499b9cae8df2ea01e0886dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d21d1383ba7f9a095f3909a9b18d5633b92ada3afa1eb867885b19e6069ca2eb97dfb6f86ab2a78dbabe968024824801d16ee8e4f1ff899850ca13504dc55b6f
|
7
|
+
data.tar.gz: 26d201634852dc932e49afd46866257fab9525c2493b02f4b91bc1ce4b32b90ff3cf0825476c8c96b0198d5491eace5c426907ed8b8d23d50bb103f61970f24b
|
data/Rakefile
CHANGED
@@ -2,9 +2,9 @@ require 'yaml'
|
|
2
2
|
module WhosDatedWho
|
3
3
|
class BingClient
|
4
4
|
API_KEY = ENV['BING_API_KEY'] ||
|
5
|
-
|
5
|
+
YAML.load_file(File.expand_path('~/.whos_dated_who.yml'))[:bing_api_key]
|
6
6
|
|
7
|
-
def initialize(type='Web', num_results=10, api_key=API_KEY)
|
7
|
+
def initialize(type = 'Web', num_results = 10, api_key = API_KEY)
|
8
8
|
@api_key = api_key
|
9
9
|
@client = Bing.new(@api_key, num_results, type)
|
10
10
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'date'
|
2
2
|
|
3
3
|
class Biography < Hashie::Trash
|
4
4
|
include Hashie::Extensions::IgnoreUndeclared
|
5
5
|
|
6
|
-
@split_on_comma = ->(i) { i.
|
6
|
+
@split_on_comma = ->(i) { i.is_a?(Array) ? i : i.split(', ') }
|
7
7
|
|
8
8
|
property :first_name
|
9
9
|
property :middle_name
|
@@ -35,7 +35,7 @@ class Biography < Hashie::Trash
|
|
35
35
|
property :measurements_inches
|
36
36
|
property :dress_size
|
37
37
|
property :shoe_size
|
38
|
-
property :websites, from: :official_website #array
|
38
|
+
property :websites, from: :official_website # array
|
39
39
|
property :father
|
40
40
|
property :mother
|
41
41
|
property :brothers # array
|
data/lib/whos_dated_who/cli.rb
CHANGED
@@ -3,19 +3,19 @@ require 'whos_dated_who'
|
|
3
3
|
|
4
4
|
module WhosDatedWho
|
5
5
|
class CLI < Thor
|
6
|
-
desc
|
6
|
+
desc 'version', 'Return the version of WhosDatedWho'
|
7
7
|
def version
|
8
8
|
puts WhosDatedWho::VERSION
|
9
9
|
end
|
10
10
|
|
11
|
-
desc
|
11
|
+
desc 'query', 'Return the relationship status of a celebrity'
|
12
12
|
def query(name)
|
13
13
|
result = Client.new.fetch(name)
|
14
14
|
puts "#{result[:relationship_status]}: #{result[:current_relationship][:human]}"
|
15
|
-
puts result[:current_relationship][:dates].join(
|
15
|
+
puts result[:current_relationship][:dates].join(', ')
|
16
16
|
end
|
17
17
|
|
18
|
-
desc
|
18
|
+
desc 'explore', 'Return the relationship status of everyone included in celebs.yml'
|
19
19
|
def explore
|
20
20
|
results = []
|
21
21
|
celebs = my_celebs
|
@@ -30,17 +30,18 @@ module WhosDatedWho
|
|
30
30
|
results
|
31
31
|
end
|
32
32
|
|
33
|
-
desc
|
33
|
+
desc 'import_mine', 'Import my favorites into RethinkDB'
|
34
34
|
def import_mine
|
35
35
|
Importer.new('celebs', 'mine').fetch_and_import(my_celebs)
|
36
36
|
end
|
37
37
|
|
38
|
-
desc
|
38
|
+
desc 'import_maxim', 'Import maxim hot 100'
|
39
39
|
def import_maxim
|
40
40
|
resp = Faraday.get('http://www.maxim.com/hot100/2014')
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
|
+
|
44
45
|
def my_celebs
|
45
46
|
YAML.load_file(File.expand_path('../../../celebs.yml', __FILE__))
|
46
47
|
end
|
@@ -18,7 +18,7 @@ module WhosDatedWho
|
|
18
18
|
import(result)
|
19
19
|
rescue
|
20
20
|
first_name, last_name = celeb.split
|
21
|
-
r.table("missing_#{table_name}").insert(
|
21
|
+
r.table("missing_#{table_name}").insert(first_name: first_name, last_name: last_name).run(conn)
|
22
22
|
logger.error("Error importing #{celeb}, added to missing")
|
23
23
|
end
|
24
24
|
end
|
@@ -15,6 +15,7 @@ module WhosDatedWho
|
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
+
|
18
19
|
def extract_bio
|
19
20
|
result = {}
|
20
21
|
result[:description] = @doc.css('#wikitext').text
|
@@ -66,11 +67,11 @@ module WhosDatedWho
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def parse_height(value)
|
69
|
-
(
|
70
|
+
(Regexp.last_match(1).to_i / 100.0) if value =~ /(\d+) cm.*$/
|
70
71
|
end
|
71
72
|
|
72
73
|
def parse_weight(value)
|
73
|
-
|
74
|
+
Regexp.last_match(1).to_f if value =~ /\((.+) kg/
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
data/lib/whos_dated_who.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'faraday'
|
2
|
+
require 'hashie'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
require 'searchbing'
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
7
|
+
require 'whos_dated_who/version'
|
8
|
+
require 'whos_dated_who/biography'
|
9
|
+
require 'whos_dated_who/parser'
|
10
|
+
require 'whos_dated_who/bing_client'
|
11
|
+
require 'whos_dated_who/client'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WhosDatedWho do
|
4
|
+
let(:client) { WhosDatedWho::Client.new }
|
5
|
+
|
6
|
+
context 'smoke test' do
|
7
|
+
it 'fetches and parses the correct results' do
|
8
|
+
result = client.fetch('Candice Swanepoel')
|
9
|
+
expect(result.status).to eq(:dating)
|
10
|
+
expect(result.biography.first_name).to eq('Candice')
|
11
|
+
expect(result.biography.last_name).to eq('Swanepoel')
|
12
|
+
expect(result.biography.age).to eq(26)
|
13
|
+
|
14
|
+
result = client.fetch('Katheryn Winnick')
|
15
|
+
expect(result.status).to eq(:unknown)
|
16
|
+
expect(result.biography.first_name).to eq('Katheryn')
|
17
|
+
expect(result.biography.last_name).to eq('Winnick')
|
18
|
+
expect(result.biography.age).to eq(37)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -9,36 +9,36 @@ module WhosDatedWho
|
|
9
9
|
@result = parser.result.biography
|
10
10
|
end
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
expect(@result.first_name).to eq(
|
15
|
-
expect(@result.last_name).to eq(
|
16
|
-
expect(@result.maiden_name).to eq(
|
12
|
+
context 'biography' do
|
13
|
+
it 'parses the HTML and returns a result hash' do
|
14
|
+
expect(@result.first_name).to eq('Scarlett')
|
15
|
+
expect(@result.last_name).to eq('Dauriac')
|
16
|
+
expect(@result.maiden_name).to eq('Johansson')
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'translates keys' do
|
20
20
|
expect(@result.born_at).to be_truthy
|
21
21
|
expect(@result.born_on).to be_truthy
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'coerces result values' do
|
25
25
|
expect(@result.age).to eq(30)
|
26
26
|
expect(@result.born_on).to be_kind_of(Date)
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
expect(@result).to_not have_key(
|
29
|
+
it 'ignores irrelevant keys' do
|
30
|
+
expect(@result).to_not have_key('snapshot')
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'parses height' do
|
34
34
|
expect(@result.height).to eq(1.60)
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it 'parses weight' do
|
38
38
|
expect(@result.weight).to eq(56.7)
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it 'populates arrays' do
|
42
42
|
[
|
43
43
|
:other_names, :brand_endorsements, :websites, :brothers, :sisters,
|
44
44
|
:friends, :pets, :favorite_movies, :favorite_places, :favorite_foods,
|
@@ -58,7 +58,7 @@ module WhosDatedWho
|
|
58
58
|
expect(@result.favorite_places).to include('London')
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it 'gets a description' do
|
62
62
|
expect(@result.description).to match(/American actress, model, and singer/)
|
63
63
|
end
|
64
64
|
end
|
data/whos_dated_who.gemspec
CHANGED
@@ -4,32 +4,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'whos_dated_who/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'whos_dated_who'
|
8
8
|
spec.version = WhosDatedWho::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
9
|
+
spec.authors = ['Adrian Perez']
|
10
|
+
spec.email = ['adrianperez.deb@gmail.com']
|
11
|
+
spec.summary = 'Unofficial API for whosdatedwho.com'
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/blackxored/whos_dated_who'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'faraday'
|
22
|
+
spec.add_dependency 'hashie'
|
23
|
+
spec.add_dependency 'nokogiri'
|
24
|
+
spec.add_dependency 'searchbing'
|
25
|
+
spec.add_dependency 'activesupport', '~> 4'
|
26
|
+
spec.add_dependency 'thor'
|
27
27
|
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'webmock'
|
32
|
+
spec.add_development_dependency 'pry-rescue'
|
33
|
+
spec.add_development_dependency 'coveralls'
|
34
|
+
spec.add_development_dependency 'rethinkdb'
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whos_dated_who
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Perez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/whos_dated_who/importer.rb
|
218
218
|
- lib/whos_dated_who/parser.rb
|
219
219
|
- lib/whos_dated_who/version.rb
|
220
|
+
- spec/acceptance/whos_dated_who_spec.rb
|
220
221
|
- spec/fixtures/scarlett-johansson.resp
|
221
222
|
- spec/spec_helper.rb
|
222
223
|
- spec/whos_dated_who/client_spec.rb
|
@@ -247,7 +248,9 @@ signing_key:
|
|
247
248
|
specification_version: 4
|
248
249
|
summary: Unofficial API for whosdatedwho.com
|
249
250
|
test_files:
|
251
|
+
- spec/acceptance/whos_dated_who_spec.rb
|
250
252
|
- spec/fixtures/scarlett-johansson.resp
|
251
253
|
- spec/spec_helper.rb
|
252
254
|
- spec/whos_dated_who/client_spec.rb
|
253
255
|
- spec/whos_dated_who/parser_spec.rb
|
256
|
+
has_rdoc:
|