kinopoisk_parser 1.0.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 +15 -0
- data/.gitignore +18 -0
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +5 -0
- data/kinopoisk.gemspec +23 -0
- data/lib/kinopoisk/movie.rb +142 -0
- data/lib/kinopoisk/person.rb +74 -0
- data/lib/kinopoisk/search.rb +41 -0
- data/lib/kinopoisk.rb +19 -0
- data/spec/kinopoisk/movie_spec.rb +59 -0
- data/spec/kinopoisk/person_spec.rb +24 -0
- data/spec/kinopoisk/search_spec.rb +23 -0
- data/spec/spec_helper.rb +10 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWRkMWZkNGM4MmQ2MGQxNzE0Y2YwZTM0YTYwY2NkODQ2MmMxY2VkYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGQ5YzYyMjE2ZGEzNTNkMDIxOTYyMzNlNDNlNGEzNDYyNjM2YWM0Yw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTA5ZGRkMGIzYTBkY2VmYTAwMDQ0ZWNlZThhNjMwNTIwYmZkMTE5ZTE5OGJl
|
10
|
+
NWU0YzNhZjkxN2RmYjYxZmZkYTI4YjJmZWQ5NGUwMWJmZWYyOTQwZjZmOTg2
|
11
|
+
Y2UzZGVmYTZhY2FmNWQwYmRlNWVlNzNmMzQyNzBiZTg0NTA1YmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTdiMDExYzczMDc0ZTYzODIxM2JkYmI2ZjFjMGJjNTY1OWQyY2E5NDg4ZjFh
|
14
|
+
ZDhlNWVjMDE0NWM3NTYzZWEyMTQ4YTNlMWZlMGFmZWJiZDMwZTM2ZDlhNjA0
|
15
|
+
ODlkN2ExZWFjOTZkZDE1ZDQzOTU2YzkxY2RmNTYxY2ZkOTI3YTI=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 RavWar
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Kinopoisk Parser
|
2
|
+
|
3
|
+
Easily search and access information on kinopoisk.ru
|
4
|
+
|
5
|
+
[](http://travis-ci.org/RavWar/kinopoisk_parser)
|
6
|
+
[](https://codeclimate.com/github/RavWar/kinopoisk_parser)
|
7
|
+
[](https://gemnasium.com/RavWar/kinopoisk_parser)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'kinopoisk_parser'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install kinopoisk_parser
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Movie
|
26
|
+
|
27
|
+
Initialize with
|
28
|
+
|
29
|
+
m = Kinopoisk::Movie.new 277537
|
30
|
+
|
31
|
+
or
|
32
|
+
|
33
|
+
m = Kinopoisk::Movie.new 'Dexter'
|
34
|
+
|
35
|
+
Access information
|
36
|
+
|
37
|
+
m.title
|
38
|
+
#=> "Правосудие Декстера"
|
39
|
+
|
40
|
+
m.countries
|
41
|
+
#=> ["США"]
|
42
|
+
|
43
|
+
m.slogan
|
44
|
+
#=> "«Takes life. Seriously.»"
|
45
|
+
|
46
|
+
### Search
|
47
|
+
|
48
|
+
s = Kinopoisk::Search.new 'Life of Pi'
|
49
|
+
|
50
|
+
s.movies.count
|
51
|
+
#=> 6
|
52
|
+
|
53
|
+
s.people.count
|
54
|
+
#=> 5
|
55
|
+
|
56
|
+
### Person
|
57
|
+
|
58
|
+
p = Kinopoisk::Person.new 25584
|
59
|
+
|
60
|
+
p.name
|
61
|
+
#=> "Брэд Питт"
|
62
|
+
|
63
|
+
p.career
|
64
|
+
#=> ["Актер", "Продюсер"]
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/kinopoisk.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'kinopoisk_parser'
|
3
|
+
gem.version = '1.0.1'
|
4
|
+
gem.authors = ['RavWar']
|
5
|
+
gem.email = ['rav_war@mail.ru']
|
6
|
+
gem.homepage = 'https://github.com/RavWar/kinopoisk_parser'
|
7
|
+
gem.summary = 'Easily search and access information on kinopoisk.ru'
|
8
|
+
gem.description = <<-DESCRIPTION
|
9
|
+
This gem allows you to easily search and access publicly available
|
10
|
+
information about movies and actors on kinopoisk.ru
|
11
|
+
DESCRIPTION
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($/)
|
14
|
+
gem.test_files = gem.files.grep %r{^spec/}
|
15
|
+
gem.require_paths = %w(lib)
|
16
|
+
|
17
|
+
gem.add_runtime_dependency 'nokogiri'
|
18
|
+
gem.add_runtime_dependency 'httpclient'
|
19
|
+
gem.add_development_dependency 'vcr'
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'webmock'
|
23
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#coding: UTF-8
|
2
|
+
module Kinopoisk
|
3
|
+
class Movie
|
4
|
+
attr_accessor :id, :url, :title
|
5
|
+
|
6
|
+
# New object can be initialized with id(integer) or title(string).
|
7
|
+
#
|
8
|
+
# Kinopoisk::Movie.new 277537
|
9
|
+
# Kinopoisk::Movie.new 'Dexter'
|
10
|
+
#
|
11
|
+
# Initializing by title would send a search request and return first match.
|
12
|
+
# Movie page request is made once and on the first access to a remote data.
|
13
|
+
#
|
14
|
+
def initialize(input, title=nil)
|
15
|
+
@id = input.is_a?(String) ? find_by_title(input) : input
|
16
|
+
@url = "http://www.kinopoisk.ru/film/#{id}/"
|
17
|
+
@title = title
|
18
|
+
end
|
19
|
+
|
20
|
+
def actors
|
21
|
+
doc.search('td.actor_list div a').map{|n| n.text.gsub("\n",'').strip}
|
22
|
+
.delete_if{|text| text=='...'}
|
23
|
+
end
|
24
|
+
|
25
|
+
def title
|
26
|
+
@title ||= doc.search('.moviename-big').xpath('text()').text.strip
|
27
|
+
end
|
28
|
+
|
29
|
+
def imdb_rating_count
|
30
|
+
doc.search('div.block_2 div:last').text.gsub(/[ ()]/, '').to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
def imdb_rating
|
34
|
+
doc.search('div.block_2 div:last').text[/\d.\d\d/].to_f
|
35
|
+
end
|
36
|
+
|
37
|
+
def year
|
38
|
+
doc.search("table.info a[href*='/m_act%5Byear%5D/']").text.to_i
|
39
|
+
end
|
40
|
+
|
41
|
+
def countries
|
42
|
+
doc.search("table.info a[href*='/m_act%5Bcountry%5D/']").map(&:text)
|
43
|
+
end
|
44
|
+
|
45
|
+
def poster
|
46
|
+
doc.search("img[itemprop='image']").first.attr 'src'
|
47
|
+
end
|
48
|
+
|
49
|
+
def world_premiere
|
50
|
+
doc.search('td#div_world_prem_td2 a:first').text
|
51
|
+
end
|
52
|
+
|
53
|
+
def ru_premiere
|
54
|
+
doc.search('td#div_rus_prem_td2 a:first').text
|
55
|
+
end
|
56
|
+
|
57
|
+
def rating
|
58
|
+
doc.search('span.rating_ball').text.to_f
|
59
|
+
end
|
60
|
+
|
61
|
+
def poster_big
|
62
|
+
poster.gsub 'film', 'film_big'
|
63
|
+
end
|
64
|
+
|
65
|
+
def length
|
66
|
+
doc.search('td#runtime').text
|
67
|
+
end
|
68
|
+
|
69
|
+
def directors
|
70
|
+
to_array search_by_itemprop 'director'
|
71
|
+
end
|
72
|
+
|
73
|
+
def producers
|
74
|
+
to_array search_by_itemprop 'producer'
|
75
|
+
end
|
76
|
+
|
77
|
+
def composers
|
78
|
+
to_array search_by_itemprop 'musicBy'
|
79
|
+
end
|
80
|
+
|
81
|
+
def genres
|
82
|
+
to_array search_by_itemprop 'genre'
|
83
|
+
end
|
84
|
+
|
85
|
+
def title_en
|
86
|
+
search_by_itemprop 'alternativeHeadline'
|
87
|
+
end
|
88
|
+
|
89
|
+
def description
|
90
|
+
search_by_itemprop 'description'
|
91
|
+
end
|
92
|
+
|
93
|
+
def rating_count
|
94
|
+
search_by_itemprop('ratingCount').to_i
|
95
|
+
end
|
96
|
+
|
97
|
+
def writers
|
98
|
+
to_array search_by_text 'сценарий'
|
99
|
+
end
|
100
|
+
|
101
|
+
def operators
|
102
|
+
to_array search_by_text 'оператор'
|
103
|
+
end
|
104
|
+
|
105
|
+
def art_directors
|
106
|
+
to_array search_by_text 'художник'
|
107
|
+
end
|
108
|
+
|
109
|
+
def editors
|
110
|
+
to_array search_by_text 'монтаж'
|
111
|
+
end
|
112
|
+
|
113
|
+
def slogan
|
114
|
+
search_by_text 'слоган'
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def doc
|
120
|
+
@doc ||= Kinopoisk.parse url
|
121
|
+
end
|
122
|
+
|
123
|
+
# Kinopoisk has defined first=yes param to redirect to first result
|
124
|
+
# Return its id from location header
|
125
|
+
def find_by_title(title)
|
126
|
+
url = SEARCH_URL+"#{title}&first=yes"
|
127
|
+
Kinopoisk.fetch(url).headers['Location'].to_s.match(/\/(\d*)\/$/)[1]
|
128
|
+
end
|
129
|
+
|
130
|
+
def search_by_itemprop(name)
|
131
|
+
doc.search("[itemprop=#{name}]").text
|
132
|
+
end
|
133
|
+
|
134
|
+
def search_by_text(name)
|
135
|
+
doc.search("//td[text()='#{name}']").first.next.text
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_array(string)
|
139
|
+
string.gsub('...', '').split(', ')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#coding: UTF-8
|
2
|
+
module Kinopoisk
|
3
|
+
class Person
|
4
|
+
attr_accessor :id, :url, :name
|
5
|
+
|
6
|
+
def initialize(id, name=nil)
|
7
|
+
@id = id
|
8
|
+
@url = "http://www.kinopoisk.ru/name/#{id}/"
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def poster
|
13
|
+
doc.search('img.people_thumbnail').first.attr 'src'
|
14
|
+
end
|
15
|
+
|
16
|
+
def name
|
17
|
+
@name ||= doc.search('.moviename-big').text
|
18
|
+
end
|
19
|
+
|
20
|
+
def name_en
|
21
|
+
doc.search("//tr[./td/h1[@class='moviename-big']]/following-sibling::tr//span").text
|
22
|
+
end
|
23
|
+
|
24
|
+
def partner
|
25
|
+
doc.search("//td[@class='type'][contains(text(),'супруг')]").first.next.text
|
26
|
+
end
|
27
|
+
|
28
|
+
def birthdate
|
29
|
+
Date.strptime doc.search("td.birth").first.attr 'birthdate'
|
30
|
+
end
|
31
|
+
|
32
|
+
def birthplace
|
33
|
+
search_by_text('место рождения').split(', ').first
|
34
|
+
end
|
35
|
+
|
36
|
+
def genres
|
37
|
+
search_by_text('жанры').split(', ')
|
38
|
+
end
|
39
|
+
|
40
|
+
def career
|
41
|
+
search_by_text('карьера').split(', ')
|
42
|
+
end
|
43
|
+
|
44
|
+
def total_movies
|
45
|
+
search_by_text('всего фильмов').to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
def best_movies
|
49
|
+
doc.search('td.actor_list a').map(&:text)
|
50
|
+
end
|
51
|
+
|
52
|
+
def first_movie
|
53
|
+
search_by_text 'первый фильм'
|
54
|
+
end
|
55
|
+
|
56
|
+
def last_movie
|
57
|
+
search_by_text 'последний фильм'
|
58
|
+
end
|
59
|
+
|
60
|
+
def height
|
61
|
+
search_by_text 'рост'
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def doc
|
67
|
+
@doc ||= Kinopoisk.parse url
|
68
|
+
end
|
69
|
+
|
70
|
+
def search_by_text(name)
|
71
|
+
doc.search("//td[@class='type'][text()='#{name}']").first.next.text
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#coding: UTF-8
|
2
|
+
module Kinopoisk
|
3
|
+
class Search
|
4
|
+
attr_accessor :query, :url
|
5
|
+
|
6
|
+
def initialize(query)
|
7
|
+
@query = query
|
8
|
+
@url = SEARCH_URL + query.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def movies
|
12
|
+
find_nodes('film').map{|n| new_movie n }
|
13
|
+
end
|
14
|
+
|
15
|
+
def people
|
16
|
+
find_nodes('people').map{|n| new_person n }
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def doc
|
22
|
+
@doc ||= Kinopoisk.parse url
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_nodes(type)
|
26
|
+
doc.search ".info .name a[href*='/#{type}/']"
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse_id(node, type)
|
30
|
+
node.attr('href').match(/\/#{type}\/(\d*)\//)[1].to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
def new_movie(node)
|
34
|
+
Movie.new parse_id(node, 'film'), node.text.gsub(' (сериал)', '')
|
35
|
+
end
|
36
|
+
|
37
|
+
def new_person(node)
|
38
|
+
Person.new parse_id(node, 'people'), node.text
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/kinopoisk.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'httpclient'
|
3
|
+
require 'kinopoisk/movie'
|
4
|
+
require 'kinopoisk/search'
|
5
|
+
require 'kinopoisk/person'
|
6
|
+
|
7
|
+
module Kinopoisk
|
8
|
+
SEARCH_URL = "http://www.kinopoisk.ru/index.php?kp_query="
|
9
|
+
|
10
|
+
# Headers are needed to mimic proper request so kinopoisk won't block it
|
11
|
+
def self.fetch(url)
|
12
|
+
HTTPClient.new.get url, nil, { 'User-Agent'=>'a', 'Accept-Encoding'=>'a' }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse(url)
|
16
|
+
page = fetch url
|
17
|
+
page.status == 200 ? Nokogiri::HTML(page.body.encode('utf-8')) : raise
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#coding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Kinopoisk::Movie, vcr: { cassette_name: 'movie' } do
|
5
|
+
let(:movie) { Kinopoisk::Movie.new 277537 }
|
6
|
+
|
7
|
+
it { movie.url.should eq('http://www.kinopoisk.ru/film/277537/') }
|
8
|
+
it { movie.title.should eq('Правосудие Декстера') }
|
9
|
+
it { movie.title_en.should eq('Dexter') }
|
10
|
+
it { movie.countries.should eq(['США']) }
|
11
|
+
it { movie.year.should eq(2006) }
|
12
|
+
it { movie.poster.should eq('http://st.kinopoisk.ru/images/film/277537.jpg') }
|
13
|
+
it { movie.poster_big.should eq('http://st.kinopoisk.ru/images/film_big/277537.jpg') }
|
14
|
+
it { movie.producers.should eq(['Сара Коллетон','Джон Голдвин','Роберт Ллойд Льюис']) }
|
15
|
+
it { movie.art_directors.should eq(['Джессика Кендер','Энтони Коули','Эрик Уейлер']) }
|
16
|
+
it { movie.operators.should eq(['Ромео Тироне','Джеф Джёр','Мартин Дж. Лэйтон']) }
|
17
|
+
it { movie.editors.should eq(['Луис Ф. Циоффи','Стюарт Шилл','Мэттью Колонна']) }
|
18
|
+
it { movie.writers.should eq(['Джефф Линдсэй','Джеймс Манос мл.','Скотт Бак']) }
|
19
|
+
it { movie.actors.should include('Майкл С. Холл', 'Дженнифер Карпентер') }
|
20
|
+
it { movie.genres.should eq(['триллер','драма','криминал', 'детектив']) }
|
21
|
+
it { movie.directors.should eq(['Джон Дал','Стив Шилл','Кит Гордон']) }
|
22
|
+
it { movie.slogan.should eq('«Takes life. Seriously.»') }
|
23
|
+
it { movie.description.should match('Декстер Морган.') }
|
24
|
+
it { movie.world_premiere.should eq('1 октября 2006') }
|
25
|
+
it { movie.ru_premiere.should eq('3 ноября 2008') }
|
26
|
+
it { movie.composers.should eq(['Дэниэл Лихт']) }
|
27
|
+
it { movie.imdb_rating_count.should be_a(Integer) }
|
28
|
+
it { movie.imdb_rating.should be_a(Float) }
|
29
|
+
it { movie.rating_count.should be_a(Integer) }
|
30
|
+
it { movie.rating.should be_a(Float) }
|
31
|
+
it { movie.length.should eq('55 мин.') }
|
32
|
+
|
33
|
+
it 'should make only one request' do
|
34
|
+
movie.title
|
35
|
+
movie.countries
|
36
|
+
a_request(:get, movie.url).should have_been_made.once
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise error if nothing found' do
|
40
|
+
expect { Kinopoisk::Movie.new(111111111).title }.to raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'by title' do
|
44
|
+
let(:movie_by_title) { Kinopoisk::Movie.new 'Dexter' }
|
45
|
+
|
46
|
+
it { movie.url.should eq(movie_by_title.url) }
|
47
|
+
|
48
|
+
it 'should make only one request to initialize' do
|
49
|
+
movie_by_title
|
50
|
+
a_request(:get, /.*/).should have_been_made.once
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should make max two requests' do
|
54
|
+
movie_by_title.title
|
55
|
+
movie_by_title.countries
|
56
|
+
a_request(:get, /.*/).should have_been_made.twice
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#coding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Kinopoisk::Person, vcr: { cassette_name: 'person' } do
|
5
|
+
let(:person) { Kinopoisk::Person.new 13180 }
|
6
|
+
|
7
|
+
it 'should return right url' do
|
8
|
+
person.url.should eq('http://www.kinopoisk.ru/name/13180/')
|
9
|
+
end
|
10
|
+
|
11
|
+
it { person.best_movies.should include('Карты, деньги, два ствола', 'Братья по оружию') }
|
12
|
+
it { person.poster.should eq('http://st.kinopoisk.ru/images/actor/13180.jpg') }
|
13
|
+
it { person.career.should eq(['Актер', 'Режиссер', 'Сценарист', 'Продюсер']) }
|
14
|
+
it { person.genres.should eq(['драма', 'комедия', 'криминал']) }
|
15
|
+
it { person.partner.should eq('Далия Ибельхауптайте') }
|
16
|
+
it { person.name_en.should eq('Dexter Fletcher') }
|
17
|
+
it { person.name.should eq('Декстер Флетчер') }
|
18
|
+
it { person.birthplace.should eq('Лондон') }
|
19
|
+
it { person.first_movie.should eq('1976') }
|
20
|
+
it { person.last_movie.should eq('2014') }
|
21
|
+
it { person.birthdate.should be_a(Date) }
|
22
|
+
it { person.total_movies.should eq(87) }
|
23
|
+
it { person.height.should eq('1.68 м') }
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kinopoisk::Search, vcr: { cassette_name: 'search' } do
|
4
|
+
let(:search) { Kinopoisk::Search.new 'Dexter' }
|
5
|
+
|
6
|
+
it 'should return right url' do
|
7
|
+
search.url.should eq(Kinopoisk::SEARCH_URL+'Dexter')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should make only one request' do
|
11
|
+
search.movies
|
12
|
+
search.people
|
13
|
+
a_request(:get, search.url).should have_been_made.once
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return movie objects' do
|
17
|
+
search.movies.first.should be_a(Kinopoisk::Movie)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return person objects' do
|
21
|
+
search.people.first.should be_a(Kinopoisk::Person)
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kinopoisk_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- RavWar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httpclient
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vcr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: ! " This gem allows you to easily search and access publicly available\n
|
98
|
+
\ information about movies and actors on kinopoisk.ru\n"
|
99
|
+
email:
|
100
|
+
- rav_war@mail.ru
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- kinopoisk.gemspec
|
112
|
+
- lib/kinopoisk.rb
|
113
|
+
- lib/kinopoisk/movie.rb
|
114
|
+
- lib/kinopoisk/person.rb
|
115
|
+
- lib/kinopoisk/search.rb
|
116
|
+
- spec/kinopoisk/movie_spec.rb
|
117
|
+
- spec/kinopoisk/person_spec.rb
|
118
|
+
- spec/kinopoisk/search_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: https://github.com/RavWar/kinopoisk_parser
|
121
|
+
licenses: []
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.0.3
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Easily search and access information on kinopoisk.ru
|
143
|
+
test_files:
|
144
|
+
- spec/kinopoisk/movie_spec.rb
|
145
|
+
- spec/kinopoisk/person_spec.rb
|
146
|
+
- spec/kinopoisk/search_spec.rb
|
147
|
+
- spec/spec_helper.rb
|