srt 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +8 -0
- data/lib/srt.rb +3 -0
- data/lib/srt/file.rb +48 -0
- data/lib/srt/line.rb +22 -0
- data/lib/srt/version.rb +3 -0
- data/spec/bsg-s01e01.srt +2708 -0
- data/spec/srt_spec.rb +72 -0
- data/srt.gemspec +20 -0
- metadata +98 -0
data/spec/srt_spec.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'srt'
|
2
|
+
|
3
|
+
describe SRT do
|
4
|
+
context "A single line" do
|
5
|
+
it "should be empty" do
|
6
|
+
line = SRT::Line.new
|
7
|
+
line.should be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should not be empty" do
|
11
|
+
line = SRT::Line.new(:text => "This is a test")
|
12
|
+
line.should_not be_empty
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "A properly formatted SRT file" do
|
18
|
+
let(:file) { SRT::File.parse(File.open("./spec/bsg-s01e01.srt")) }
|
19
|
+
|
20
|
+
it "should parse" do
|
21
|
+
file.class.should == SRT::File
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have 600 lines" do
|
25
|
+
file.lines.size.should == 600
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not have errors" do
|
29
|
+
file.errors.should be_empty
|
30
|
+
end
|
31
|
+
|
32
|
+
context "the first line" do
|
33
|
+
let(:line) { file.lines.first }
|
34
|
+
|
35
|
+
it "should have the proper text" do
|
36
|
+
line.text.should == ["<i>(male narrator) Previously", "on Battlestar Galactica.</i>"]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have the proper sequence" do
|
40
|
+
line.sequence.should == 1
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have the proper start time" do
|
44
|
+
line.start_time.strftime("%H:%M:%S,%L").should == "00:00:02,110"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have the proper end time" do
|
48
|
+
line.end_time.strftime("%H:%M:%S,%L").should == "00:00:04,578"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "the last line" do
|
53
|
+
let(:line) { file.lines.last }
|
54
|
+
|
55
|
+
it "should have the proper text" do
|
56
|
+
line.text.should == ["Thank you."]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have the proper sequence" do
|
60
|
+
line.sequence.should == 600
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have the proper start time" do
|
64
|
+
line.start_time.strftime("%H:%M:%S,%L").should == "00:43:26,808"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have the proper end time" do
|
68
|
+
line.end_time.strftime("%H:%M:%S,%L").should == "00:43:28,139"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/srt.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/srt/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Christopher Petersen"]
|
6
|
+
gem.email = ["christopher.petersen@gmail.com"]
|
7
|
+
gem.description = %q{SRT stands for SubRip text file format, which is a file for storing subtitles. This is a Ruby library for manipulating SRT files.}
|
8
|
+
gem.summary = %q{Ruby gem for parsing subtitle files.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.add_development_dependency('rake')
|
12
|
+
gem.add_development_dependency('rspec')
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "srt"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Srt::VERSION
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: srt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christopher Petersen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: SRT stands for SubRip text file format, which is a file for storing subtitles.
|
47
|
+
This is a Ruby library for manipulating SRT files.
|
48
|
+
email:
|
49
|
+
- christopher.petersen@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/srt.rb
|
60
|
+
- lib/srt/file.rb
|
61
|
+
- lib/srt/line.rb
|
62
|
+
- lib/srt/version.rb
|
63
|
+
- spec/bsg-s01e01.srt
|
64
|
+
- spec/srt_spec.rb
|
65
|
+
- srt.gemspec
|
66
|
+
homepage: ''
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: -3640544855343307444
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: -3640544855343307444
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.24
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Ruby gem for parsing subtitle files.
|
96
|
+
test_files:
|
97
|
+
- spec/bsg-s01e01.srt
|
98
|
+
- spec/srt_spec.rb
|