bootleg 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,33 +28,35 @@ Load content for a certain zipcode:
28
28
 
29
29
  Example:
30
30
 
31
- Bootleg.load('21102')
31
+ $ Bootleg.load('21102')
32
32
 
33
33
  This will load all the movies for a 25 mile radius(including their showtimes
34
34
  and the theaters where they play).
35
35
 
36
36
  Examples:
37
37
 
38
- movie = BootlegMovie.where(name: 'Example').first
38
+ $ movie = BootlegMovie.where(name: 'Example').first
39
39
 
40
40
  Get all the theaters where the movie is played:
41
41
 
42
- theaters = movie.theaters
42
+ $ theaters = movie.theaters
43
43
 
44
44
  Get all the showtimes:
45
45
 
46
- showtimes = movie.showtimes
46
+ $ showtimes = movie.showtimes
47
47
 
48
48
  Get the theater of the showtimes:
49
49
 
50
- theater = showtimes.first.theater
50
+ $ theater = showtimes.first.theater
51
51
 
52
+ ## Other Details
52
53
 
53
54
  The content is stored in 3 Active Record models BootlegMovie,
54
55
  BootlegTheater and BootlegShowtime. After you load a zipcode just start
55
56
  a rails console and take a look at the models to see what information is
56
57
  stored inside.
57
58
 
59
+ The zipcode is stored under BootlegShowtime.:w
58
60
 
59
61
  ## Contributing
60
62
 
@@ -64,6 +66,6 @@ stored inside.
64
66
  4. Push to the branch (`git push origin my-new-feature`)
65
67
  5. Create new Pull Request
66
68
 
67
- If there is other content that you would like to pull it is relatively easy
68
- to build a new feature to extract it. If you would like to contribute
69
- and need help feel free to shoot me an email at marius@mlpinit.com .
69
+ It is relatively easy to pull other information from moviefone.com. If you
70
+ need an extra feature and you would like to contribute feel free to shoot
71
+ me an email at marius@mlpinit.com beforehand.
@@ -1,3 +1,3 @@
1
1
  module Bootleg
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -8,10 +8,11 @@ class Extractor
8
8
 
9
9
  attr_reader :page_theaters
10
10
 
11
- def initialize(page)
11
+ def initialize(page, zipcode)
12
12
  @page = (Nokogiri::HTML(open(page)))
13
13
  @page_theaters = []
14
14
  extract_movies
15
+ @zipcode ||= zipcode
15
16
  end
16
17
 
17
18
  def extract_movies
@@ -3,7 +3,6 @@ class CreateBootlegMovies < ActiveRecord::Migration
3
3
  create_table :bootleg_movies do |t|
4
4
  t.string :name
5
5
  t.string :href
6
- t.string :showtimes
7
6
 
8
7
  t.timestamps
9
8
  end
@@ -3,6 +3,7 @@ class CreateBootlegShowtimes < ActiveRecord::Migration
3
3
  create_table :bootleg_showtimes do |t|
4
4
  t.integer :bootleg_movie_id
5
5
  t.integer :bootleg_theater_id
6
+ t.string :zipcode
6
7
  t.string :showtimes
7
8
 
8
9
  t.timestamps
@@ -1,5 +1,5 @@
1
1
  class BootlegShowtime < ActiveRecord::Base
2
- attr_accessible :bootleg_movie_id, :bootleg_theater_id, :showtimes
2
+ attr_accessible :bootleg_movie_id, :bootleg_theater_id, :zipcode, :showtimes
3
3
 
4
4
  belongs_to :bootleg_movie
5
5
  belongs_to :bootleg_theater
@@ -2,10 +2,16 @@ require_relative 'finder'
2
2
  require_relative 'extractor'
3
3
 
4
4
  class Manager
5
+
6
+ class << self
7
+ attr_accessor :zipcode
8
+ end
9
+
5
10
  def initialize(zipcode)
6
11
  @zipcode = zipcode
7
12
  @pages ||= find_pages
8
13
  @all_theaters = []
14
+ Manager.zipcode = zipcode
9
15
  end
10
16
 
11
17
  def find_pages
@@ -14,7 +20,7 @@ class Manager
14
20
 
15
21
  def extract_theaters
16
22
  @pages.each do |page|
17
- @all_theaters << Extractor.new(page).page_theaters
23
+ @all_theaters << Extractor.new(page, @zipcode).page_theaters
18
24
  end
19
25
  @all_theaters.flatten
20
26
  end
@@ -38,6 +38,8 @@ module Theater
38
38
  end
39
39
  showtime = BootlegShowtime.last
40
40
  showtime.showtimes = movie.showtimes.to_s.gsub(/-/, '').gsub(/\n/,'').strip
41
+ showtime.zipcode = Manager.zipcode
42
+ showtime.date = Time.zone.now
41
43
  showtime.save
42
44
  end
43
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootleg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-21 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri