<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/torrent.rb</filename>
    </added>
    <added>
      <filename>app/views/movies/_movie.erb</filename>
    </added>
    <added>
      <filename>app/views/movies/index.html.erb</filename>
    </added>
    <added>
      <filename>app/views/movies/index.rss.builder</filename>
    </added>
    <added>
      <filename>app/views/movies/show.erb</filename>
    </added>
    <added>
      <filename>app/views/movies/show2.html.haml</filename>
    </added>
    <added>
      <filename>db/migrate/20081211160533_create_torrents.rb</filename>
    </added>
    <added>
      <filename>lib/tasks/fetch.rake</filename>
    </added>
    <added>
      <filename>test/fixtures/torrents.yml</filename>
    </added>
    <added>
      <filename>test/unit/torrent_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -7,21 +7,5 @@ class MoviesController &lt; ApplicationController
   def show
     @movie = Movie.find(params[:id])
   end
-
-  def fetch
-    count = Movie.fetch_from_this_month
-    if count == 0
-      flash[:notice] = &quot;Nothing new, sorry!&quot;
-    else
-      flash[:notice] = &quot;I've got #{count} movies!&quot;
-    end
-    redirect_to movies_path
-  end
-
-  def rss
-    headers[&quot;Content-Type&quot;] = &quot;application/xml&quot;
-    @movies = Movie.all
-    render :layout =&gt; false
-  end
   
 end
\ No newline at end of file</diff>
      <filename>app/controllers/movies_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,32 +1,10 @@
-class Movie &lt; ActiveRecord::Base
-  named_scope :recent, lambda { {:conditions =&gt; ['created_at &gt; ?', 5.days.ago]}}
+class Movie &lt; ActiveRecord::Base 
 
-  belongs_to :genre
+  has_many :torrents
   
   validates_presence_of :title, :imdb_id
-  validates_uniqueness_of :imdb_id, :title
-
-  def self.fetch_from_this_month
-    movies = []
-    ids = Movie.latest_ids
-    # sciagamy pe&#322;ne informacje o filmach
-    imdb = IMDB::FullInformation.new
-    ids.each {|imdb_id| movies &lt;&lt; imdb.information(imdb_id)[:result] }
-    Movie.bulk_save(movies) # zapis w bazie
-  end
-
-  def self.latest_ids
-    # sciagamy idki imdb nowosci z tego miesiaca
-    IMDB::NowPlaying.new.movies(Time.now.year, Time.now.month)[:results].map{|movie| movie[:imdb_id]}
-  end
-
-  protected
-
-  def self.bulk_save(movies = nil)
-    count = 0
-    movies[0..100].each { |m| count +=1 if Movie.create(:title =&gt; m[:title], :imdb_id =&gt; m[:imdb_id]).valid? }
-    count
-  end
+  validates_uniqueness_of :imdb_id
+  validates_numericality_of [:votes,:rating, :year]
 
   def self.fake_movies
     {:query=&gt;{:month=&gt;6, :year=&gt;2008}, :results=&gt;[{:imdb_id=&gt;&quot;0960144&quot;, :title=&gt;&quot;You Don't Mess with the Zohan&quot;}, {:imdb_id=&gt;&quot;0416044&quot;, :title=&gt;&quot;Mongol&quot;},</diff>
      <filename>app/models/movie.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@
     %title Movie Pole
     = stylesheet_link_tag &quot;application&quot;
     = javascript_include_tag :defaults
+    = auto_discovery_link_tag(:rss, movies_path(:format =&gt; :rss))
   %body
     #doc
       #hd</diff>
      <filename>app/views/layouts/application.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@ module IMDB
       info[:release_date] = parse_release_date(main_div)
       info[:genres] = parse_genres(main_div)
       info[:tagline] = parse_tagline(main_div)
+      info[:imdb_id] = imdb_id
       result[:result] = info
       result
     end</diff>
      <filename>backends/imdb/lib/full_information.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,9 +2,9 @@ require &quot;rubygems&quot;
 require &quot;open-uri&quot;
 require &quot;hpricot&quot;
 
-require &quot;backends/imdb/lib/power_search&quot;
-require &quot;backends/imdb/lib/now_playing&quot;
-require &quot;backends/imdb/lib/full_information&quot;
+require File.expand_path(File.dirname(__FILE__) + &quot;/power_search&quot;)
+require File.expand_path(File.dirname(__FILE__) + &quot;/now_playing&quot;)
+require File.expand_path(File.dirname(__FILE__) + &quot;/full_information&quot;)
 
 module IMDB
   BASE_URI = &quot;http://www.imdb.com&quot;</diff>
      <filename>backends/imdb/lib/imdb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,21 @@
 require File.expand_path(File.dirname(__FILE__) + &quot;/../spec_helper&quot;)
 
 describe IMDB::NowPlaying, &quot;with 2009-07 fixture&quot; do
+
   before do
     @now_playing = IMDB::NowPlaying.new
     @now_playing.stub!(:open).and_return(open(File.dirname(__FILE__) + &quot;/../fixtures/2009-07.html&quot;))
   end
 
-  it &quot;should parse HTML and return hash&quot; do
+  it &quot;should parse HTML and return hash with query&quot; do
+    result = @now_playing.movies(2009, 07)
+    result.should include(:query)
+    result[:query].should include(:month)
+    result[:query].should include(:year)
+  end
+
+  it &quot;should parse HTML and return hash with results&quot; do
     result = @now_playing.movies(2009, 07)
-    result.should include(:query =&gt; { :month =&gt; 7, :year =&gt; 2009 })
     results = result[:results]
     results.should include(:imdb_id =&gt; &quot;0417741&quot;, :title =&gt; &quot;Harry Potter and the Half-Blood Prince&quot;)
     results.should include(:imdb_id =&gt; &quot;0775552&quot;, :title =&gt; &quot;They Came from Upstairs&quot;)</diff>
      <filename>backends/imdb/spec/lib/now_playing_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ class AddMoreAttrToMovies &lt; ActiveRecord::Migration
     add_column :movies, :rating, :integer
     add_column :movies, :votes, :integer    
     add_column :movies, :genre_id, :integer
-    add_column :movies, :imdb_id, :integer    
+    add_column :movies, :imdb_id, :integer  
   end
 
   def self.down</diff>
      <filename>db/migrate/20081208150509_add_more_attr_to_movies.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/models/genre.rb</filename>
    </removed>
    <removed>
      <filename>app/views/movies/index.html.haml</filename>
    </removed>
    <removed>
      <filename>app/views/movies/rss.rxml</filename>
    </removed>
    <removed>
      <filename>app/views/movies/show.html.haml</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>c94c9ef11622b22e6a734197f99ddfa6e141b59d</id>
    </parent>
  </parents>
  <author>
    <name>marek</name>
    <email>marek@.(none)</email>
  </author>
  <url>http://github.com/ncr/movie_pole/commit/2a24ad95ef1ae3efe8a7823d6c07ad2e48251c93</url>
  <id>2a24ad95ef1ae3efe8a7823d6c07ad2e48251c93</id>
  <committed-date>2008-12-11T10:30:11-08:00</committed-date>
  <authored-date>2008-12-11T10:30:11-08:00</authored-date>
  <message>added rake tasks for populating movies table from IMDB backend
added torrents table
added some erb views for education purposes :)</message>
  <tree>b364ae32988e503f4a7aba17bd5e73a8c2a6140d</tree>
  <committer>
    <name>marek</name>
    <email>marek@.(none)</email>
  </committer>
</commit>
