zimdb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,7 +15,9 @@ Now you can do things like this:
15
15
  movie.director # => "Todd Phillips"
16
16
  # and more...
17
17
 
18
+ Check out [this spec file](https://github.com/indrode/zimdb/blob/master/spec/movie_spec.rb) to see which movie attributes are currently available.
18
19
 
20
+ ##License
19
21
  Copyright (c) 2011 Indro De
20
22
 
21
23
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
data/lib/zimdb/hash.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  class Hash
2
+ # Transforms hash keys into symbols.
3
+ #
4
+ # @return [Hash] the transformed hash
2
5
  def symbolize_keys
3
6
  t = self.dup
4
7
  self.clear
data/lib/zimdb/movie.rb CHANGED
@@ -2,7 +2,8 @@ module Zimdb
2
2
  class Movie
3
3
 
4
4
  def initialize(params)
5
- @json = JSON.parse(HTTParty.get("http://www.imdbapi.com/?t=#{params[:title]}")).symbolize_keys
5
+ title = URI::encode(params[:title])
6
+ @json = JSON.parse(HTTParty.get("http://www.imdbapi.com/?t=#{title}")).symbolize_keys
6
7
  end
7
8
 
8
9
  def response
data/lib/zimdb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zimdb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/zimdb.rb CHANGED
@@ -1,4 +1,3 @@
1
- require "rubygems"
2
1
  require "httparty"
3
2
  require "json"
4
3
  require "zimdb/version"
@@ -1 +1 @@
1
- {"Title"=>"The Hangover", "Year"=>"2009", "Rated"=>"R", "Released"=>"5 Jun 2009", "Genre"=>"Comedy, Crime", "Director"=>"Todd Phillips", "Writer"=>"Jon Lucas, Scott Moore", "Actors"=>"Zach Galifianakis, Bradley Cooper, Justin Bartha, Ed Helms", "Plot"=>"A Las Vegas-set comedy centered around three groomsmen who lose their about-to-be-wed buddy during their drunken misadventures, then must retrace their steps in order to find him.", "Poster"=>"http://ia.media-imdb.com/images/M/MV5BMTU1MDA1MTYwMF5BMl5BanBnXkFtZTcwMDcxMzA1Mg@@._V1._SX320.jpg", "Runtime"=>"1 hr 40 mins", "Rating"=>"7.9", "Votes"=>"142757", "ID"=>"tt1119646", "Response"=>"True"}
1
+ {"Title":"The Hangover","Year":"2009","Rated":"R","Released":"5 Jun 2009","Genre":"Comedy, Crime","Director":"Todd Phillips","Writer":"Jon Lucas, Scott Moore","Actors":"Zach Galifianakis, Bradley Cooper, Justin Bartha, Ed Helms","Plot":"A Las Vegas-set comedy centered around three groomsmen who lose their about-to-be-wed buddy during their drunken misadventures, then must retrace their steps in order to find him.","Poster":"http://ia.media-imdb.com/images/M/MV5BMTU1MDA1MTYwMF5BMl5BanBnXkFtZTcwMDcxMzA1Mg@@._V1._SX320.jpg","Runtime":"1 hr 40 mins","Rating":"7.9","Votes":"142757","ID":"tt1119646","Response":"True"}
data/spec/movie_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe Zimdb::Movie do
4
4
  before(:each) do
5
5
  @movie = Zimdb::Movie.new(:title => "Hangover")
6
6
  @movie.response.should == true
7
- end
7
+ end
8
8
 
9
9
  it "should return a false response if not found" do
10
10
  movie2 = Zimdb::Movie.new(:title => "asdasd")
@@ -12,11 +12,18 @@ describe Zimdb::Movie do
12
12
  movie2.title.should be_nil
13
13
  end
14
14
 
15
+ it "should allow more than one word in movie title" do
16
+ movie3 = Zimdb::Movie.new(:title => "The Hangover")
17
+ movie3.response.should == true
18
+ movie3.title.should == "The Hangover"
19
+ movie3.year.should == 2009
20
+ end
21
+
15
22
  it "should return the title" do
16
23
  @movie.title.should == "The Hangover"
17
24
  end
18
25
 
19
- it "should return the title" do
26
+ it "should return the year" do
20
27
  @movie.year.should == 2009
21
28
  end
22
29
 
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,16 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
  require 'zimdb'
4
3
  require 'fakeweb'
5
4
 
5
+ FakeWeb.allow_net_connect = false
6
+
6
7
  RSpec.configure do |config|
7
8
  def fixture(filename)
8
9
  File.dirname(__FILE__) + '/fixtures/' + filename
9
10
  end
10
11
 
11
- FakeWeb.register_uri(:get, "http://www.imdbapi.com/?t=hangover", :body => open(fixture("hangover.json")).read)
12
- FakeWeb.register_uri(:get, "http://www.imdbapi.com/?t=hangover", :body => open(fixture("asdasd.json")).read)
12
+ FakeWeb.register_uri(:get, "http://www.imdbapi.com/?t=Hangover", :body => open(fixture("hangover.json")))
13
+ FakeWeb.register_uri(:get, "http://www.imdbapi.com/?t=The%20Hangover", :body => open(fixture("hangover.json")))
14
+ FakeWeb.register_uri(:get, "http://www.imdbapi.com/?t=asdasd", :body => open(fixture("asdasd.json")))
13
15
 
14
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zimdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2011-11-14 00:00:00.000000000 Z
12
+ date: 2011-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70158706211160 !ruby/object:Gem::Requirement
16
+ requirement: &70313887340500 !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: *70158706211160
24
+ version_requirements: *70313887340500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70158706210620 !ruby/object:Gem::Requirement
27
+ requirement: &70313887338240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70158706210620
35
+ version_requirements: *70313887338240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fakeweb
38
- requirement: &70158706187320 !ruby/object:Gem::Requirement
38
+ requirement: &70313887316060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '1.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70158706187320
46
+ version_requirements: *70313887316060
47
47
  description: Access movie information from IMDb via the API offered by http://www.imdbapi.com/
48
48
  email:
49
49
  - indro.de@gmail.com
@@ -95,3 +95,4 @@ test_files:
95
95
  - spec/movie_spec.rb
96
96
  - spec/spec_helper.rb
97
97
  - spec/zimdb_spec.rb
98
+ has_rdoc: