imdb-parser 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/imdb/parser.rb +1 -1
- data/lib/imdb/parser/version.rb +1 -1
- data/spec/parser_spec.rb +12 -5
- data/tools/next_edgecase.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 441dde337226bbb7a8fea631e575dfab6b68c17d
|
4
|
+
data.tar.gz: abdd01473df67f4c5c831cb4e7669b1b5f88c233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174766a5872edf0f0ccb07f0836df379aa4a9c02a6aa97a9596acfa352b8c5667eac5908b73de5226fb506e082992019daccaec219671ac08c54323c8731beb6
|
7
|
+
data.tar.gz: e43f7eeeea73a61348a476019150aaecd330fbd478e4a88b48d29fbe7abf8f49e63dbcd773dfeba3431f70f758e0da83d9f9ce789c865a57c1841ed90c1094e5
|
data/Gemfile.lock
CHANGED
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" ,'
|
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
|
data/lib/imdb/parser.rb
CHANGED
data/lib/imdb/parser/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -1,24 +1,31 @@
|
|
1
1
|
require 'imdb/parser'
|
2
2
|
|
3
3
|
|
4
|
-
describe IMDB::Parser::Parser
|
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(
|
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.
|
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.
|
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(
|
39
|
+
expect(parser.actors.count).to eq(2)
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
data/tools/next_edgecase.rb
CHANGED
@@ -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
|
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-
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|