kinopoisk 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.
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe :Kinopoisk do
4
+ it 'should report the correct version' do
5
+ version = File.open(File.join(File.dirname(__FILE__), '..', '..', 'VERSION'), 'r') do |f|
6
+ f.read.strip
7
+ end
8
+ Kinopoisk::VERSION.should == version
9
+ end
10
+ end
@@ -0,0 +1,66 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'Kinopoisk::Movie' do
4
+ before(:each) do
5
+ @movie = Kinopoisk::Movie.new '273302'
6
+ end
7
+
8
+ it 'should return the right url for movie' do
9
+ @movie.url.should == 'http://www.kinopoisk.ru/level/1/film/273302/'
10
+ end
11
+
12
+ it 'should find the movie year' do
13
+ @movie.year.should == 2007
14
+ end
15
+
16
+ it 'should find the country' do
17
+ @movie.country.should == 'США'
18
+ end
19
+
20
+ it 'should find the directors' do
21
+ @movie.director.should be_a(Array)
22
+ @movie.director.should == ['Фрэнк Дарабонт']
23
+ end
24
+
25
+ it 'should find the authors' do
26
+ @movie.author.should be_a(Array)
27
+ @movie.author.should == ['Фрэнк Дарабонт', 'Стивен Кинг']
28
+ end
29
+
30
+ it 'should find the producer' do
31
+ @movie.producer.should be_a(Array)
32
+ @movie.producer.should == ['Фрэнк Дарабонт', 'Анна Гардуно', 'Лиз Глоцер', '...']
33
+ end
34
+
35
+ it 'should find genres' do
36
+ @movie.genres.should be_a(Array)
37
+ @movie.genres.should == ['ужасы', 'фантастика', 'триллер', 'драма']
38
+ end
39
+
40
+ it 'should find the movie length in minutes' do
41
+ @movie.length.should == 120
42
+ end
43
+
44
+ it 'should find the description' do
45
+ @movie.description.should == 'Маленький городок накрывает сверхъестественный туман, отрезая людей от внешнего мира. Группе героев, оказавшихся в этот момент в супермаркете, приходится вступить в неравный бой с обитающими в тумане монстрами.'
46
+ end
47
+
48
+ it '#plot is alias for #description' do
49
+ @movie.plot.should == 'Маленький городок накрывает сверхъестественный туман, отрезая людей от внешнего мира. Группе героев, оказавшихся в этот момент в супермаркете, приходится вступить в неравный бой с обитающими в тумане монстрами.'
50
+ end
51
+
52
+ it 'should find the poster' do
53
+ @movie.poster.should == 'http://www.kinopoisk.ru/images/film/273302.jpg'
54
+ end
55
+
56
+ it 'should find the rating' do
57
+ @movie.rating.should == '7.651'
58
+ end
59
+
60
+ it 'should find all cast members' do
61
+ @movie.cast_members.should == ['Томас Джейн', 'Марша Гэй Харден', 'Лори Холден',
62
+ 'Андре Брогер', 'Тоби Джонс', 'Уильям Сэдлер',
63
+ 'Джеффри ДеМун', 'Фрэнсис Стернхаген', 'Натан Гэмбл',
64
+ 'Алекса Давалос']
65
+ end
66
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'Kinopoisk::Search' do
4
+ before(:each) do
5
+ @search = Kinopoisk::Search.new 'Туман (2010)'
6
+ end
7
+
8
+ it 'should remember the query' do
9
+ @search.query.should == 'Туман (2010)'
10
+ end
11
+
12
+ it 'should find 6 results' do
13
+ @search.movies.size.should == 6
14
+ end
15
+
16
+ it 'should return only Kinopoisk::Movie objects' do
17
+ @search.movies.each{ |item| item.should be_a(Kinopoisk::Movie) }
18
+ end
19
+
20
+ it 'should not return items without title' do
21
+ @search.movies.each{ |item| item.title.should_not be_empty }
22
+ end
23
+ end
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format=specdoc
@@ -0,0 +1,37 @@
1
+ begin
2
+ require "spec"
3
+ rescue LoadError
4
+ require "rubygems"
5
+ gem 'rspec'
6
+ require "spec"
7
+ end
8
+
9
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
10
+ require 'kinopoisk'
11
+ require "pp"
12
+
13
+ def read_fixtures(path)
14
+ File.read File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', path))
15
+ end
16
+
17
+ KINOPOISK_SAMPLES = {
18
+ 'http://www.kinopoisk.ru/level/1/film/273302/' => '273302',
19
+ 'http://www.kinopoisk.ru/level/1/film/84991/' => '84991',
20
+ 'http://www.kinopoisk.ru/index.php?first=no&kp_query=%D0%A2%D1%83%D0%BC%D0%B0%D0%BD%20(2010)' => 'search_tuman_2010'
21
+ }
22
+
23
+ unless ENV['LIVE_TEST']
24
+ begin
25
+ require "rubygems"
26
+ require "fakeweb"
27
+
28
+ FakeWeb.allow_net_connect = false
29
+ KINOPOISK_SAMPLES.each do |url, response|
30
+ FakeWeb.register_uri :get, url, :response => read_fixtures(response)
31
+ end
32
+
33
+ rescue LoadError
34
+ puts 'Could not load FakeWeb, this test will hit Kinopoisk.ru'
35
+ puts 'You can run `gem install fakeweb` to stub out the responses.'
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ namespace :fixtures do
2
+ desc 'Refresh spec fixtures with fresh data from Kinopoisk.ru'
3
+ task :refresh do
4
+ require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper')
5
+
6
+ KINOPOISK_SAMPLES.each do |url, response|
7
+ output = File.expand_path File.dirname(__FILE__) + "/../spec/fixtures/#{response}"
8
+ `wget --referer="http://www.kinopoisk.ru/" --output-document="#{output}" --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8" --save-headers "#{url}"`
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kinopoisk
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Pavel Musolin
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-30 00:00:00 +03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hpricot
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 8
30
+ - 1
31
+ version: 0.8.1
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Easely access the publicly available information on Kinopoisk.ru
35
+ email: pavel@harizma.lv
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README
42
+ - lib/extendings.rb
43
+ - lib/kinopoisk.rb
44
+ - lib/kinopoisk/movie.rb
45
+ - lib/kinopoisk/search.rb
46
+ - tasks/fixtures.rake
47
+ files:
48
+ - Manifest
49
+ - README
50
+ - Rakefile
51
+ - VERSION
52
+ - kinopoisk.gemspec
53
+ - lib/extendings.rb
54
+ - lib/kinopoisk.rb
55
+ - lib/kinopoisk/movie.rb
56
+ - lib/kinopoisk/search.rb
57
+ - spec/fixtures/273302
58
+ - spec/fixtures/84991
59
+ - spec/fixtures/search_tuman_2010
60
+ - spec/kinopoisk/kinopoisk_spec.rb
61
+ - spec/kinopoisk/movie_spec.rb
62
+ - spec/kinopoisk/search_spec.rb
63
+ - spec/spec.opts
64
+ - spec/spec_helper.rb
65
+ - tasks/fixtures.rake
66
+ has_rdoc: true
67
+ homepage: http://github.com/pmisters/Kinopoisk
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --line-numbers
73
+ - --inline-source
74
+ - --title
75
+ - Kinopoisk
76
+ - --main
77
+ - README
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 1
93
+ - 2
94
+ version: "1.2"
95
+ requirements: []
96
+
97
+ rubyforge_project: kinopoisk
98
+ rubygems_version: 1.3.6
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Easely access the publicly available information on Kinopoisk.ru
102
+ test_files: []
103
+