the_whos 0.0.1 → 0.0.2
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
- metadata +2 -3
- data/lib/the_whos.rb +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd95eec1c0a3845af7bcf884e9022693a701a9a97688205947c847c9f84cdeba
|
4
|
+
data.tar.gz: 6b8ae647c2f6c993a03b349a62e33eaf137c83b7850ae40bfdf9f964b834dad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbadc47b16fde1f47b6cb4a149069f553015d12e65cc6346c831d322555addfa7bfd94c12e313dc9625dd7a5579ee9acf9626a627495fb282e370b6bbfd390c9
|
7
|
+
data.tar.gz: 433e92edccc3f1a68e76089be90bfd7746c59a88c0a19b7610fe3a0124470bf77a19f0fbc1619a186261aed008ecae2b51e41b7d5fa4979dc17d439672ce5834
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_whos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramiro Eloisa
|
@@ -19,8 +19,7 @@ email: ram.eloisalg@egmail.com
|
|
19
19
|
executables: []
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
|
-
files:
|
23
|
-
- lib/the_whos.rb
|
22
|
+
files: []
|
24
23
|
homepage:
|
25
24
|
licenses:
|
26
25
|
- MIT
|
data/lib/the_whos.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require_relative 'title'
|
2
|
-
require_relative 'actor'
|
3
|
-
|
4
|
-
class TheWhos
|
5
|
-
@key_imdb = ARGV[0]
|
6
|
-
|
7
|
-
def self.create(id)
|
8
|
-
if id.chr == 't'
|
9
|
-
return Title.new(id)
|
10
|
-
elsif id.chr == 'n'
|
11
|
-
return Actor.new(id)
|
12
|
-
else
|
13
|
-
return 'Error'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.search_title(expression)
|
18
|
-
expression = expression.gsub(' ', '@')
|
19
|
-
url = "https://imdb-api.com/en/API/SearchTitle/#{@key_imdb}/#{expression}"
|
20
|
-
response = RestClient.get url
|
21
|
-
r_json = JSON.parse response.to_str
|
22
|
-
arr_search = r_json['results'].to_a
|
23
|
-
results = Array.new
|
24
|
-
arr_search.size.times do |i|
|
25
|
-
results << {id: "#{arr_search[i]['id']}", title: "#{arr_search[i]['title']}"}
|
26
|
-
end
|
27
|
-
return results
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.search_actor(expression)
|
31
|
-
expression = expression.gsub(' ', '@')
|
32
|
-
url = "https://imdb-api.com/en/API/SearchName/#{@key_imdb}/#{expression}"
|
33
|
-
response = RestClient.get url
|
34
|
-
r_json = JSON.parse response.to_str
|
35
|
-
arr_search = r_json['results'].to_a
|
36
|
-
results = Array.new
|
37
|
-
arr_search.size.times do |i|
|
38
|
-
results << {id: "#{arr_search[i]['id']}", title: "#{arr_search[i]['title']}"}
|
39
|
-
end
|
40
|
-
return results
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.match_title(title_a, title_b)
|
44
|
-
if title_a.class == String
|
45
|
-
title_a = Title.new(title_a)
|
46
|
-
end
|
47
|
-
if title_b.class == String
|
48
|
-
title_b = Title.new(title_b)
|
49
|
-
end
|
50
|
-
match = Array.new
|
51
|
-
title_a.fullcast.each do |actor_a|
|
52
|
-
title_b.fullcast.each do |actor_b|
|
53
|
-
if actor_a[:id] == actor_b[:id]
|
54
|
-
match << "#{actor_a[:actor].to_s} (#{actor_a[:id]})"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
if match.empty? == true
|
59
|
-
return 'Not Match'
|
60
|
-
else
|
61
|
-
return match
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.match_actor(actor_a, actor_b)
|
66
|
-
if actor_a.class == String
|
67
|
-
actor_a = Actor.new(actor_a)
|
68
|
-
end
|
69
|
-
if actor_b.class == String
|
70
|
-
actor_b = Actor.new(actor_b)
|
71
|
-
end
|
72
|
-
match = Array.new
|
73
|
-
actor_a.cast.each do |title_a|
|
74
|
-
actor_b.cast.each do |title_b|
|
75
|
-
if title_a[:id] == title_b[:id]
|
76
|
-
match << "#{title_a[:title]} (#{title_a[:id]})"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
if match.empty? == true
|
81
|
-
return 'Not Match'
|
82
|
-
else
|
83
|
-
return match
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.who(title, actor)
|
88
|
-
if title.class == String
|
89
|
-
title = Title.new(title)
|
90
|
-
end
|
91
|
-
if actor.class == String
|
92
|
-
actor = Actor.new(actor)
|
93
|
-
end
|
94
|
-
title.fullcast.each do |cast|
|
95
|
-
if cast[:id] == actor.id
|
96
|
-
return cast[:character]
|
97
|
-
end
|
98
|
-
end
|
99
|
-
return 'not appear'
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
end
|