movie_show_times 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ A location is required to initialize the crawling. By default, it gets show times for the current date.
24
+
23
25
  movieShowTimes = MovieShowTimes::Crawler.new({ :location => 'Buenos Aires' })
24
26
 
25
27
  theater = movieShowTimes.theaters['Monumental']
@@ -35,13 +37,16 @@ Or install it yourself as:
35
37
  :times => ['13:30', '17:30', '21:30', '01:00']
36
38
  }
37
39
 
38
- ## TODO
39
40
 
40
- Improve API
41
+ You can retrieve movie show times for following days. There is no definition for how far in the future will this information be available, so use with caution as it may be the cause for retrieving no show times at all.
41
42
 
42
- Fix and extend movie info parsing (genres and languages)
43
+ movieShowTimes = MovieShowTimes::Crawler.new({ :location => 'Buenos Aires',
44
+ :days_ahead => 2
45
+ })
43
46
 
44
- Allow retrieving movie show times for following days
47
+ ## TODO
48
+
49
+ Improve API
45
50
 
46
51
  Include more movie info from other data sources
47
52
 
@@ -6,6 +6,7 @@ module MovieShowTimes
6
6
  class Crawler
7
7
 
8
8
  const_set("MissingLocationArgument", Class.new(StandardError))
9
+ const_set("WrongDaysAheadArgument", Class.new(StandardError))
9
10
 
10
11
  def initialize(options = {})
11
12
 
@@ -13,9 +14,13 @@ module MovieShowTimes
13
14
 
14
15
  language = options[:language] || 'en'
15
16
 
17
+ days_ahead = options[:days_ahead] || 0
18
+ raise WrongDaysAheadArgument unless days_ahead.kind_of? Integer and 0 >= days_ahead
19
+
16
20
  @parser = MovieShowTimes::Parser.new(language)
17
21
 
18
- search_url = "http://www.google.com/movies?hl=#{language}&near=#{CGI.escape(options[:location])}"
22
+ search_url = "http://www.google.com/movies?hl=#{language}" \
23
+ "&near=#{CGI.escape(options[:location])}&date=#{days_ahead}"
19
24
 
20
25
  @agent = Mechanize.new
21
26
  page = @agent.get(search_url)
@@ -1,3 +1,3 @@
1
1
  module MovieShowTimes
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -102,12 +102,25 @@ describe MovieShowTimes do
102
102
  end
103
103
  end
104
104
 
105
+ context 'when initialized with days ahead parameter' do
106
+ it "should raise an exception if value is not an integer" do
107
+ lambda { MovieShowTimes::Crawler.new( { :location => 'Buenos Aires', :days_ahead => 3.2 } )
108
+ }.should raise_error(MovieShowTimes::Crawler::WrongDaysAheadArgument)
109
+ end
110
+
111
+ it "should raise an exception if value is not greater or equal to zero" do
112
+ lambda { MovieShowTimes::Crawler.new( { :location => 'Buenos Aires', :days_ahead => 7 } )
113
+ }.should raise_error(MovieShowTimes::Crawler::WrongDaysAheadArgument)
114
+ end
115
+ end
116
+
105
117
  context 'when initialized with location' do
106
118
  before :all do
107
119
  FakeWeb.allow_net_connect = false
108
120
  (1..6).each do |i|
109
121
  uri = "http://www.google.com/movies?hl=en&near=Buenos+Aires"
110
122
  uri += "&start=#{10*(i - 1)}" if i > 1
123
+ uri += "&date=0" if i == 1
111
124
  FakeWeb.register_uri(:get, uri,
112
125
  :response => File.open("spec/fixtures/movies_bsas_#{i}.txt", 'r').read
113
126
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: movie_show_times
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-21 00:00:00.000000000Z
12
+ date: 2012-04-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
16
- requirement: &2156941580 !ruby/object:Gem::Requirement
16
+ requirement: &2161446200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156941580
24
+ version_requirements: *2161446200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2156941160 !ruby/object:Gem::Requirement
27
+ requirement: &2161445780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156941160
35
+ version_requirements: *2161445780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: chronic_duration
38
- requirement: &2156940740 !ruby/object:Gem::Requirement
38
+ requirement: &2161445360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156940740
46
+ version_requirements: *2161445360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2156940320 !ruby/object:Gem::Requirement
49
+ requirement: &2153296460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156940320
57
+ version_requirements: *2153296460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &2156939900 !ruby/object:Gem::Requirement
60
+ requirement: &2153296040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2156939900
68
+ version_requirements: *2153296040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakeweb
71
- requirement: &2156939480 !ruby/object:Gem::Requirement
71
+ requirement: &2153295620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2156939480
79
+ version_requirements: *2153295620
80
80
  description: Get Movie Show Times by Location
81
81
  email:
82
82
  - chrishein@gmail.com