kinopoisk_parser 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b39e141d40b1a6647bf706635e2bc87aca7e5049
4
- data.tar.gz: a5635ba2a8075bbcf424542f1d842270a9e83c75
3
+ metadata.gz: 24653cc8767111eb4cd54ceede08d3ab8dd9a5b4
4
+ data.tar.gz: 2f85849f90e4befe2b30f3580de2c68cba14f732
5
5
  SHA512:
6
- metadata.gz: f2861d2833565b793f7ee059a3d49557aff949269bcbfe4e7100222ec0c13186235ecbfc79871b6df8cb10af930c388d0173693441e764bb8ae4c31c79a77842
7
- data.tar.gz: fbf86669444bebbcc1fba9d56a2a1cdf821b4b70f6974c4434cd7dd5eff58f5e330dec6dc8910b7fdf344bf36e1391f03ff34bd7f2db067c96def8460ed253c8
6
+ metadata.gz: c3f3c5adc813675d9cea5a87f26c7f70dbb6e4546c31bd62832d39135463ca777a54e7864435e51cba1dae460f606868014ffebb6fc6b6d986e3cde6cd9310fc
7
+ data.tar.gz: fa98e16ff3b6d4960f6d92d43950abe799640d9ba324173410f4d51fa85d78b1755c8625e3576b2728f738917523765146a8b9c98bb7fe8f10868dba53b561a0
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'kinopoisk_parser'
3
- gem.version = '2.0.1'
3
+ gem.version = '2.1.0'
4
4
  gem.authors = ['RavWar']
5
5
  gem.email = ['rav_war@mail.ru']
6
6
  gem.homepage = 'https://github.com/RavWar/kinopoisk_parser'
@@ -112,7 +112,7 @@ module Kinopoisk
112
112
 
113
113
  # Returns an integer kinopoisk rating vote count
114
114
  def rating_count
115
- search_by_itemprop('ratingCount').to_i
115
+ search_by_itemprop('ratingCount').gsub(' ', '').to_i
116
116
  end
117
117
 
118
118
  # Returns an array of strings containing director names
@@ -179,8 +179,14 @@ module Kinopoisk
179
179
  # Kinopoisk has defined first=yes param to redirect to first result
180
180
  # Return its id from location header
181
181
  def find_by_title(title)
182
- url = SEARCH_URL+"#{URI.escape(title)}&first=yes"
183
- Kinopoisk.fetch(url).headers['Location'].to_s.match(/\/(\d*)\/$/)[1]
182
+ url = SEARCH_URL + "#{URI.escape(title)}&first=yes"
183
+ location = Kinopoisk.fetch(url).headers['Location'].to_s
184
+
185
+ if location.include?('error.kinopoisk.ru')
186
+ raise Denied, 'Request denied'
187
+ else
188
+ location.match(/\/(\d*)\/$/)[1]
189
+ end
184
190
  end
185
191
 
186
192
  def search_by_itemprop(name)
@@ -5,8 +5,10 @@ require 'kinopoisk/search'
5
5
  require 'kinopoisk/person'
6
6
 
7
7
  module Kinopoisk
8
- SEARCH_URL = "http://www.kinopoisk.ru/index.php?kp_query="
9
- NotFound = Class.new StandardError
8
+ SEARCH_URL = 'http://www.kinopoisk.ru/index.php?kp_query='
9
+
10
+ NotFound = Class.new StandardError
11
+ Denied = Class.new StandardError
10
12
 
11
13
  # Headers are needed to mimic proper request so kinopoisk won't block it
12
14
  def self.fetch(url)
@@ -15,7 +17,11 @@ module Kinopoisk
15
17
 
16
18
  # Returns a nokogiri document or an error if fetch response status is not 200
17
19
  def self.parse(url)
18
- p = fetch url
19
- p.status==200 ? Nokogiri::HTML(p.body.encode('utf-8')) : raise(NotFound)
20
+ page = fetch url
21
+ if page.status == 200
22
+ Nokogiri::HTML(page.body.encode('utf-8'))
23
+ else
24
+ raise NotFound, 'Page not found'
25
+ end
20
26
  end
21
27
  end
@@ -6,7 +6,7 @@ describe Kinopoisk::Movie, vcr: { cassette_name: 'movies' } do
6
6
  let(:avatar) { Kinopoisk::Movie.new 251733 }
7
7
 
8
8
  it { dexter.url.should eq('http://www.kinopoisk.ru/film/277537/') }
9
- it { dexter.title.should eq('Правосудие Декстера') }
9
+ it { dexter.title.should eq('Декстер') }
10
10
  it { dexter.title_en.should eq('Dexter') }
11
11
 
12
12
  it { dexter.poster.should eq('http://st.kp.yandex.net/images/film_iphone/iphone360_277537.jpg') }
@@ -21,7 +21,7 @@ describe Kinopoisk::Movie, vcr: { cassette_name: 'movies' } do
21
21
  it { dexter.operators.should eq(['Ромео Тироне','Джеф Джёр','Мартин Дж. Лэйтон']) }
22
22
  it { dexter.composers.should eq(['Дэниэл Лихт']) }
23
23
  it { dexter.art_directors.should eq(['Джессика Кендер','Энтони Коули','Эрик Уейлер']) }
24
- it { dexter.editors.should eq(['Луис Ф. Циоффи','Стюарт Шилл','Кит Хендерсон']) }
24
+ it { dexter.editors.should eq(['Луис Циоффи', 'Стюарт Шилл', 'Кит Хендерсон']) }
25
25
  it { dexter.genres.should eq(['триллер','драма','криминал', 'детектив']) }
26
26
  it { dexter.actors.should include('Майкл С. Холл', 'Дженнифер Карпентер') }
27
27
  it { dexter.description.should match('Декстер Морган.') }
@@ -17,8 +17,8 @@ describe Kinopoisk::Person, vcr: { cassette_name: 'people' } do
17
17
  it { person.name.should eq('Декстер Флетчер') }
18
18
  it { person.birthplace.should eq('Лондон') }
19
19
  it { person.first_movie.should eq('1976') }
20
- it { person.last_movie.should eq('2014') }
20
+ it { person.last_movie.should be_a(String) }
21
21
  it { person.birthdate.should be_a(Date) }
22
- it { person.total_movies.should eq(93) }
22
+ it { person.total_movies.should be_a(Integer) }
23
23
  it { person.height.should eq('1.68 м') }
24
24
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinopoisk_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RavWar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httpclient
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: vcr
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: |2
@@ -103,8 +103,8 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - .gitignore
107
- - .travis.yml
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
108
  - Gemfile
109
109
  - LICENSE.txt
110
110
  - README.md
@@ -127,17 +127,17 @@ require_paths:
127
127
  - lib
128
128
  required_ruby_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '>='
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.2.2
140
+ rubygems_version: 2.4.5
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Easily search and access information on kinopoisk.ru