srt 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +4 -2
- data/lib/srt/file.rb +3 -3
- data/lib/srt/line.rb +3 -1
- data/lib/srt/parser.rb +1 -1
- data/lib/srt/version.rb +1 -1
- data/spec/file_spec.rb +2 -2
- data/spec/line_spec.rb +16 -0
- data/spec/parser_spec.rb +4 -0
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NWIwZDk0MDFjOTVlM2ZhZjMxNDE2NTdmYTUxYzJmZTgwZTI5MDRjNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d968cae2699fc1dd691a20c0714412659feed184
|
4
|
+
data.tar.gz: 209e318fd211fb54b2a9792f3cf61b691327612a
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZjkwYzc4NmQ2NzJjOWE1OWIxODE0ZTE1ZGIxNmFmYTJkY2U4OGY4MjBjZmUz
|
11
|
-
ZTUwOWYzYTY3Yzc3NzYzNjQ4NjhhOTEzOGM0ZDE5N2U3N2M4MTQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzFiZDYxYWQwNzhkZjI4MzI2N2U0MjQ1NDU5NWY2YWI3ZGYyZjM0MzFiMGRk
|
14
|
-
NWVhMDA3YzY1OGU2ZGQ5MGFkY2ZiMjcxOTgwMDQxZTBiNDU5OTU5YTA0MWZk
|
15
|
-
ZTFlMzM3NmFkZGYzYTgyOTI5MDhlYTI1ZmI2MjA4YzA1MDc3NzQ=
|
6
|
+
metadata.gz: '095c33709a65f85f6e5eb1d05a2577f941b1f31d75399563dad423779fa66256caad3f9fc091db4e86ae57bc9cf51d161da7d2e896cd916222ba2717073e9518'
|
7
|
+
data.tar.gz: 9e5551a03c3380f0bbb322985ceea14670196c7815756f34c34a38a7971e027b859ccfbc1931e201513a97d06f21c2c88e97d192251a759cd6094c731ac47a2e
|
data/.travis.yml
CHANGED
data/lib/srt/file.rb
CHANGED
@@ -168,10 +168,10 @@ module SRT
|
|
168
168
|
line.end_time += seconds
|
169
169
|
end
|
170
170
|
elsif (original_framerate = Parser.framerate(options.keys[0])) && (target_framerate = Parser.framerate(options.values[0]))
|
171
|
-
|
171
|
+
time_ratio = original_framerate / target_framerate
|
172
172
|
lines.each do |line|
|
173
|
-
line.start_time *=
|
174
|
-
line.end_time *=
|
173
|
+
line.start_time *= time_ratio
|
174
|
+
line.end_time *= time_ratio
|
175
175
|
end
|
176
176
|
end
|
177
177
|
elsif options.length == 2
|
data/lib/srt/line.rb
CHANGED
@@ -41,7 +41,9 @@ module SRT
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def to_s(time_str_function=:time_str)
|
44
|
-
|
44
|
+
content = text.empty? ? [''] : text
|
45
|
+
coordinates = display_coordinates ? display_coordinates : ""
|
46
|
+
[sequence, send(time_str_function) + coordinates, content, ""].flatten.join("\n")
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/srt/parser.rb
CHANGED
@@ -12,7 +12,7 @@ module SRT
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def timecode(timecode_string)
|
15
|
-
mres = timecode_string.match(/(?<h>\d+):(?<m>\d+):(?<s>\d+)[,.](?<ms>\d+)
|
15
|
+
mres = timecode_string.match(/(?<h>\d+):(?<m>\d+):(?<s>\d+)[,.]?(?<ms>\d+)?/)
|
16
16
|
mres ? "#{mres["h"].to_i * 3600 + mres["m"].to_i * 60 + mres["s"].to_i}.#{mres["ms"]}".to_f : nil
|
17
17
|
end
|
18
18
|
|
data/lib/srt/version.rb
CHANGED
data/spec/file_spec.rb
CHANGED
@@ -333,11 +333,11 @@ describe SRT::File do
|
|
333
333
|
before { file.timeshift({ "25fps" => "23.976fps" }) }
|
334
334
|
|
335
335
|
it "should have correctly scaled timecodes for subtitle #24" do
|
336
|
-
expect(file.lines[23].time_str).to eq("00:01
|
336
|
+
expect(file.lines[23].time_str).to eq("00:02:01,779 --> 00:02:03,368")
|
337
337
|
end
|
338
338
|
|
339
339
|
it "should have correctly scaled timecodes for subtitle #43" do
|
340
|
-
expect(file.lines[42].time_str).to eq("00:03:
|
340
|
+
expect(file.lines[42].time_str).to eq("00:03:53,217 --> 00:03:54,746")
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
data/spec/line_spec.rb
CHANGED
@@ -22,4 +22,20 @@ describe SRT::Line do
|
|
22
22
|
expect(line.time_str).to eq("00:03:44,200 --> 00:04:04,578")
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe "#to_s" do
|
27
|
+
let(:line) { SRT::Line.new }
|
28
|
+
|
29
|
+
before do
|
30
|
+
line.sequence = "1"
|
31
|
+
line.start_time = 224.2
|
32
|
+
line.end_time = 244.578
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with empty content" do
|
36
|
+
it "creates a valid empty node" do
|
37
|
+
expect(line.to_s).to eq("1\n00:03:44,200 --> 00:04:04,578\n\n")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
25
41
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -14,6 +14,10 @@ describe SRT::Parser do
|
|
14
14
|
it "should convert the SRT timecode format to a float representing seconds" do
|
15
15
|
expect(subject.timecode("01:03:44,200")).to eq(3824.2)
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should handle timecodes with no milliseconds component" do
|
19
|
+
expect(subject.timecode("01:03:44")).to eq(3824.0)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
describe ".timespan" do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: srt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Petersen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Ruby gem for parsing srt (subtitle) files. SRT stands for SubRip text
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE
|
67
67
|
- README.md
|
@@ -92,17 +92,17 @@ require_paths:
|
|
92
92
|
- lib
|
93
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.2
|
105
|
+
rubygems_version: 2.5.2
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Ruby gem for parsing subtitle files.
|