imdb-parser 0.0.1 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 864a142a24c3d4a7f66b4602372f023af7da6222
4
- data.tar.gz: b7bdb4c6c32dd28fb354d52b11ea91ff0db85427
3
+ metadata.gz: 441dde337226bbb7a8fea631e575dfab6b68c17d
4
+ data.tar.gz: abdd01473df67f4c5c831cb4e7669b1b5f88c233
5
5
  SHA512:
6
- metadata.gz: e69636a6a33391e03ff5af875c53964f4e093a3da0c747ffee36d8ab3a14ba4ae0e043d361065880f5ac5fc2ebba388a3b2f4ee7f26220d096c2207715f399fe
7
- data.tar.gz: c44ff40e20eff3b4fa58f08ff89f40ccfdd3de1797f681d42946133717d96479b6d72cfe0fddf7c0ac60be1341f75021c314861d5866d306a2280a81fc194e70
6
+ metadata.gz: 174766a5872edf0f0ccb07f0836df379aa4a9c02a6aa97a9596acfa352b8c5667eac5908b73de5226fb506e082992019daccaec219671ac08c54323c8731beb6
7
+ data.tar.gz: e43f7eeeea73a61348a476019150aaecd330fbd478e4a88b48d29fbe7abf8f49e63dbcd773dfeba3431f70f758e0da83d9f9ce789c865a57c1841ed90c1094e5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imdb-parser (0.0.1)
4
+ imdb-parser (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -30,7 +30,7 @@ Here is a simple example of how to use the library. Run `rspec` to see a list of
30
30
  ```ruby
31
31
  require 'imdb/parser'
32
32
 
33
- parser = IMDB::Parser::Parser.new(File.open("actors.list" ,'rb'))
33
+ parser = IMDB::Parser::Parser.new(File.open("actors.list" ,'r:ISO-8859-1'))
34
34
  parser.each do |actor|
35
35
  puts actor.name
36
36
  puts "=" * actor.name.length
@@ -41,6 +41,10 @@ parser.each do |actor|
41
41
  end
42
42
  ```
43
43
 
44
+ ## File encoding
45
+
46
+ The files provided by IMDB are encoded as `ISO-8859-1`. Make sure you open the files as such or you will get encoding errors.
47
+
44
48
  ## Contributing
45
49
 
46
50
  1. Fork it
@@ -16,10 +16,10 @@ module IMDB
16
16
  else
17
17
  @input = StringIO.new(input.strip)
18
18
  end
19
+ strip_header
19
20
  end
20
21
 
21
22
  def each
22
- strip_header
23
23
  record = ""
24
24
  input.each do |line|
25
25
  if line.strip.empty?
@@ -1,5 +1,5 @@
1
1
  module IMDB
2
2
  module Parser
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,24 +1,31 @@
1
1
  require 'imdb/parser'
2
2
 
3
3
 
4
- describe IMDB::Parser::Parser, '#parse' do
4
+ describe IMDB::Parser::Parser do
5
5
  let(:contents) { %{
6
6
  Name\t\t\tTitles
7
7
  ----\t\t\t------
8
+ Suvari, Mena\tAmerican Pie (1999) [Heather] <11>
9
+
8
10
  Trachtenberg, Michelle\tEuroTrip (2004) [Jenny] <6>
9
11
  "Buffy the Vampire Slayer" (1997) {After Life (#6.3)} [Dawn Summers] <4>
10
12
  }}
11
13
 
12
14
  it "parses actors" do
13
15
  parser = IMDB::Parser::Parser.new(contents)
14
- expect(parser.actors.count).to eq(1)
16
+ expect(parser.actors.count).to eq(2)
17
+ end
18
+ it "can be resumed" do
19
+ parser = IMDB::Parser::Parser.new(contents)
20
+ parser.find { |a| a.name == "Suvari, Mena" }
21
+ expect(parser.to_enum.next.name).to eq("Trachtenberg, Michelle")
15
22
  end
16
23
  it "parses roles" do
17
24
  parser = IMDB::Parser::Parser.new(contents)
18
- expect(parser.actors.first.roles.count).to eq(2)
25
+ expect(parser.actors.last.roles.count).to eq(2)
19
26
  end
20
27
  describe "knows role type" do
21
- let(:roles) { IMDB::Parser::Parser.new(contents).actors.first.roles }
28
+ let(:roles) { IMDB::Parser::Parser.new(contents).actors.last.roles }
22
29
  it "parses movies" do
23
30
  expect(roles.first.type).to eq(:movie)
24
31
  end
@@ -29,7 +36,7 @@ describe IMDB::Parser::Parser, '#parse' do
29
36
  context "when passed an IO" do
30
37
  it "parses actors" do
31
38
  parser = IMDB::Parser::Parser.new(StringIO.new(contents.strip))
32
- expect(parser.actors.count).to eq(1)
39
+ expect(parser.actors.count).to eq(2)
33
40
  end
34
41
  end
35
42
 
@@ -1,13 +1,13 @@
1
1
  #! /usr/bin/env ruby
2
- require 'parser'
2
+ require 'imdb/parser'
3
3
 
4
4
  # USAGE: ruby -I lib tools/next_edgecase.rb /path/to/actors.list
5
5
 
6
6
  begin
7
- IMDB::Parser.new(File.open(ARGV[0], 'rb')).each do |a|
7
+ IMDB::Parser::Parser.new(File.open(ARGV[0], 'rb')).each do |a|
8
8
  a.roles
9
9
  end
10
- rescue IMDB::ParseError => e
10
+ rescue IMDB::Parser::ParseError => e
11
11
  puts %{
12
12
  it "handles " do
13
13
  expect { parse "#{e}" }.not_to raise_error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imdb-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Olive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler