captions 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/console +14 -14
- data/captions.gemspec +27 -27
- data/lib/captions/cue.rb +93 -93
- data/lib/captions/formats/srt.rb +30 -24
- data/lib/captions/formats/vtt.rb +122 -121
- data/lib/captions/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4094a14f9195032fc4167f3f490250597b23383dbfe60797b1099615a022bc1b
|
4
|
+
data.tar.gz: e7c75ad0480e1c383e70db1fa00e993af44aa3814e0fd1c29992aa854625dd69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 076728a26fee8ec9227ffb59bc483f8f819a556e97343e89e68223bb720a8424721066ba372b22a8c91e8da539141a934217064d2627ab7bba4c4e4fa2ae2df8
|
7
|
+
data.tar.gz: eb3daa1f1796cacb11f7ee476213e296d2fdfbda69bbf022b0876afae1c74d0fee1fbf889a370b60583d7b4661eb5819620e594fcbb7e32585df83d08db92632
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "captions"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "captions"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/captions.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'captions/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "captions"
|
8
|
-
spec.version = Captions::VERSION
|
9
|
-
spec.authors = ["navin"]
|
10
|
-
spec.email = ["navin@amagi.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Subtitle Editor and Converter written in Ruby}
|
13
|
-
spec.description = %q{Subtitle Editor and Converter written in Ruby. Captions can read/modify/export subtitles from one format to another }
|
14
|
-
spec.homepage = "https://github.com/navinre/captions"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
-
end
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.13"
|
26
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'captions/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "captions"
|
8
|
+
spec.version = Captions::VERSION
|
9
|
+
spec.authors = ["navin"]
|
10
|
+
spec.email = ["navin@amagi.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Subtitle Editor and Converter written in Ruby}
|
13
|
+
spec.description = %q{Subtitle Editor and Converter written in Ruby. Captions can read/modify/export subtitles from one format to another }
|
14
|
+
spec.homepage = "https://github.com/navinre/captions"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
data/lib/captions/cue.rb
CHANGED
@@ -1,93 +1,93 @@
|
|
1
|
-
module Captions
|
2
|
-
class Cue
|
3
|
-
include Util
|
4
|
-
|
5
|
-
# Text Properties supported
|
6
|
-
ALIGNMENT = "alignment"
|
7
|
-
COLOR = "color"
|
8
|
-
POSITION = "position"
|
9
|
-
|
10
|
-
# List of Text Properties
|
11
|
-
TEXT_PROPERTIES = [ALIGNMENT, COLOR, POSITION]
|
12
|
-
|
13
|
-
attr_accessor :number, :start_time, :end_time, :duration, :text, :properties
|
14
|
-
|
15
|
-
# Creates a new Cue class
|
16
|
-
# Each cue denotes a subtitle.
|
17
|
-
def initialize
|
18
|
-
self.text = nil
|
19
|
-
self.start_time = nil
|
20
|
-
self.end_time = nil
|
21
|
-
self.duration = nil
|
22
|
-
self.number =
|
23
|
-
self.properties = {}
|
24
|
-
end
|
25
|
-
|
26
|
-
# Sets the time for the cue. Both start-time and
|
27
|
-
# end-time can be passed together. This just assigns
|
28
|
-
# the value passed.
|
29
|
-
def set_time(start_time, end_time, duration = nil)
|
30
|
-
self.start_time = start_time
|
31
|
-
self.end_time = end_time
|
32
|
-
self.duration = duration
|
33
|
-
end
|
34
|
-
|
35
|
-
# Getter and Setter methods for Text Properties
|
36
|
-
# These are pre-defined properties. This is just to assign
|
37
|
-
# or access the properties of that text.
|
38
|
-
TEXT_PROPERTIES.each do |setting|
|
39
|
-
define_method :"#{setting}" do
|
40
|
-
if self.properties[setting].present?
|
41
|
-
return self.properties[setting]
|
42
|
-
end
|
43
|
-
return nil
|
44
|
-
end
|
45
|
-
|
46
|
-
define_method :"#{setting}=" do |value|
|
47
|
-
self.properties[setting] = value
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Serializes the values set for the cue.
|
52
|
-
# Converts start-time, end-time and duration to milliseconds
|
53
|
-
# If duration is not found, it will be calculated based on
|
54
|
-
# start-time and end-time.
|
55
|
-
def serialize(fps)
|
56
|
-
raise InvalidSubtitle, "Subtitle should have start time" if self.start_time.nil?
|
57
|
-
raise InvalidSubtitle, "Subtitle shold have end time" if self.end_time.nil?
|
58
|
-
|
59
|
-
begin
|
60
|
-
ms_per_frame = (1000.0 / fps)
|
61
|
-
self.start_time = convert_to_msec(self.start_time, ms_per_frame)
|
62
|
-
self.end_time = convert_to_msec(self.end_time, ms_per_frame)
|
63
|
-
if duration.nil?
|
64
|
-
self.duration = self.end_time - self.start_time
|
65
|
-
else
|
66
|
-
self.duration = convert_to_msec(self.duration, ms_per_frame)
|
67
|
-
end
|
68
|
-
rescue
|
69
|
-
raise InvalidSubtitle, "Cannot calculate start-time or end-time"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Changes start-time, end-time and duration based on new frame-rate
|
74
|
-
def change_frame_rate(old_rate, new_rate)
|
75
|
-
self.start_time = convert_frame_rate(self.start_time, old_rate, new_rate)
|
76
|
-
self.end_time = convert_frame_rate(self.end_time, old_rate, new_rate)
|
77
|
-
self.duration = convert_frame_rate(self.duration, old_rate, new_rate)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Adds text. If text is already found, new-line is appended.
|
81
|
-
def add_text(text)
|
82
|
-
if self.text.nil?
|
83
|
-
self.text = text
|
84
|
-
else
|
85
|
-
self.text += "\n" + text
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def <=>(other_cue)
|
90
|
-
self.start_time <=> other_cue.start_time
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
1
|
+
module Captions
|
2
|
+
class Cue
|
3
|
+
include Util
|
4
|
+
|
5
|
+
# Text Properties supported
|
6
|
+
ALIGNMENT = "alignment"
|
7
|
+
COLOR = "color"
|
8
|
+
POSITION = "position"
|
9
|
+
|
10
|
+
# List of Text Properties
|
11
|
+
TEXT_PROPERTIES = [ALIGNMENT, COLOR, POSITION]
|
12
|
+
|
13
|
+
attr_accessor :number, :start_time, :end_time, :duration, :text, :properties
|
14
|
+
|
15
|
+
# Creates a new Cue class
|
16
|
+
# Each cue denotes a subtitle.
|
17
|
+
def initialize(cue_number = nil)
|
18
|
+
self.text = nil
|
19
|
+
self.start_time = nil
|
20
|
+
self.end_time = nil
|
21
|
+
self.duration = nil
|
22
|
+
self.number = cue_number
|
23
|
+
self.properties = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Sets the time for the cue. Both start-time and
|
27
|
+
# end-time can be passed together. This just assigns
|
28
|
+
# the value passed.
|
29
|
+
def set_time(start_time, end_time, duration = nil)
|
30
|
+
self.start_time = start_time
|
31
|
+
self.end_time = end_time
|
32
|
+
self.duration = duration
|
33
|
+
end
|
34
|
+
|
35
|
+
# Getter and Setter methods for Text Properties
|
36
|
+
# These are pre-defined properties. This is just to assign
|
37
|
+
# or access the properties of that text.
|
38
|
+
TEXT_PROPERTIES.each do |setting|
|
39
|
+
define_method :"#{setting}" do
|
40
|
+
if self.properties[setting].present?
|
41
|
+
return self.properties[setting]
|
42
|
+
end
|
43
|
+
return nil
|
44
|
+
end
|
45
|
+
|
46
|
+
define_method :"#{setting}=" do |value|
|
47
|
+
self.properties[setting] = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Serializes the values set for the cue.
|
52
|
+
# Converts start-time, end-time and duration to milliseconds
|
53
|
+
# If duration is not found, it will be calculated based on
|
54
|
+
# start-time and end-time.
|
55
|
+
def serialize(fps)
|
56
|
+
raise InvalidSubtitle, "Subtitle should have start time" if self.start_time.nil?
|
57
|
+
raise InvalidSubtitle, "Subtitle shold have end time" if self.end_time.nil?
|
58
|
+
|
59
|
+
begin
|
60
|
+
ms_per_frame = (1000.0 / fps)
|
61
|
+
self.start_time = convert_to_msec(self.start_time, ms_per_frame)
|
62
|
+
self.end_time = convert_to_msec(self.end_time, ms_per_frame)
|
63
|
+
if duration.nil?
|
64
|
+
self.duration = self.end_time - self.start_time
|
65
|
+
else
|
66
|
+
self.duration = convert_to_msec(self.duration, ms_per_frame)
|
67
|
+
end
|
68
|
+
rescue
|
69
|
+
raise InvalidSubtitle, "Cannot calculate start-time or end-time"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Changes start-time, end-time and duration based on new frame-rate
|
74
|
+
def change_frame_rate(old_rate, new_rate)
|
75
|
+
self.start_time = convert_frame_rate(self.start_time, old_rate, new_rate)
|
76
|
+
self.end_time = convert_frame_rate(self.end_time, old_rate, new_rate)
|
77
|
+
self.duration = convert_frame_rate(self.duration, old_rate, new_rate)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Adds text. If text is already found, new-line is appended.
|
81
|
+
def add_text(text)
|
82
|
+
if self.text.nil?
|
83
|
+
self.text = text
|
84
|
+
else
|
85
|
+
self.text += "\n" + text
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def <=>(other_cue)
|
90
|
+
self.start_time <=> other_cue.start_time
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/captions/formats/srt.rb
CHANGED
@@ -3,34 +3,40 @@ module Captions
|
|
3
3
|
|
4
4
|
def parse
|
5
5
|
base_parser do
|
6
|
-
count =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
line =
|
12
|
-
if line.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
count = 0
|
7
|
+
state = :new_cue
|
8
|
+
cue = nil
|
9
|
+
loop do
|
10
|
+
count += 1
|
11
|
+
line = @file.gets
|
12
|
+
break if line.nil? ## End of file
|
13
|
+
line.strip!
|
14
|
+
case state
|
15
|
+
when :new_cue
|
16
|
+
next if line.empty? ## just another blank line, remain in new_cue state
|
17
|
+
begin
|
18
|
+
cue = Cue.new(Integer(line))
|
19
|
+
rescue ArgumentError
|
20
|
+
raise InvalidSubtitle, "Invalid Cue Number at line #{count}"
|
21
|
+
end
|
22
|
+
state = :time
|
23
|
+
when :time
|
24
|
+
raise InvalidSubtitle, "Invalid Time Format at line #{count}" unless is_time?(line)
|
25
|
+
start_time, end_time = get_time(line)
|
26
|
+
cue.set_time(start_time, end_time)
|
27
|
+
state = :text
|
28
|
+
when :text
|
29
|
+
if line.empty?
|
30
|
+
## end of previous cue
|
31
|
+
@cue_list.append(cue) if cue && cue.start_time
|
21
32
|
cue = nil
|
33
|
+
state = :new_cue
|
34
|
+
else
|
35
|
+
cue.add_text(line)
|
22
36
|
end
|
23
|
-
elsif is_time?(line)
|
24
|
-
s , e = get_time(line)
|
25
|
-
cue.set_time(s, e)
|
26
|
-
elsif is_text?(line)
|
27
|
-
cue.add_text(line)
|
28
|
-
elsif !line.empty?
|
29
|
-
raise MalformedString, "Invalid format at line #{count}"
|
30
37
|
end
|
31
|
-
count += 1
|
32
38
|
end
|
33
|
-
@cue_list.append(cue) if cue
|
39
|
+
@cue_list.append(cue) if cue && cue.start_time
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
data/lib/captions/formats/vtt.rb
CHANGED
@@ -1,121 +1,122 @@
|
|
1
|
-
module Captions
|
2
|
-
class VTT < Base
|
3
|
-
|
4
|
-
# Header used for all VTT files
|
5
|
-
VTT_HEADER = "WEBVTT"
|
6
|
-
|
7
|
-
# VTT file comments/style section
|
8
|
-
VTT_METADATA = /^NOTE|^STYLE/
|
9
|
-
|
10
|
-
# Auto Keyword used in Alignment
|
11
|
-
AUTO_KEYWORD = "auto"
|
12
|
-
|
13
|
-
# Alignment Data
|
14
|
-
ALIGNMENT_VALUES = {
|
15
|
-
"middle" => "middle",
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
cue
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
file.write(
|
59
|
-
file.write(
|
60
|
-
file.write(
|
61
|
-
file.write(
|
62
|
-
file.write(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
value.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
raise InvalidSubtitle, "VTT Position should be a number
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
1
|
+
module Captions
|
2
|
+
class VTT < Base
|
3
|
+
|
4
|
+
# Header used for all VTT files
|
5
|
+
VTT_HEADER = "WEBVTT"
|
6
|
+
|
7
|
+
# VTT file comments/style section
|
8
|
+
VTT_METADATA = /^NOTE|^STYLE/
|
9
|
+
|
10
|
+
# Auto Keyword used in Alignment
|
11
|
+
AUTO_KEYWORD = "auto"
|
12
|
+
|
13
|
+
# Alignment Data
|
14
|
+
ALIGNMENT_VALUES = {
|
15
|
+
"middle" => "middle",
|
16
|
+
"center" => "middle",
|
17
|
+
"left" => "left",
|
18
|
+
"right" => "right",
|
19
|
+
"start" => "start",
|
20
|
+
"end" => "end",
|
21
|
+
}
|
22
|
+
|
23
|
+
# Parse VTT file and update CueList
|
24
|
+
def parse
|
25
|
+
base_parser do
|
26
|
+
count = 1
|
27
|
+
cue_count = 0
|
28
|
+
meta_data_section = false
|
29
|
+
cue = nil
|
30
|
+
raise InvalidSubtitle, "Invalid VTT Signature" unless validate_header(@file.gets)
|
31
|
+
while(line = @file.gets) do
|
32
|
+
line = line.strip
|
33
|
+
if line.empty?
|
34
|
+
meta_data_section = false
|
35
|
+
elsif is_meta_data?(line)
|
36
|
+
meta_data_section = true
|
37
|
+
elsif is_time?(line)
|
38
|
+
@cue_list.append(cue) if cue
|
39
|
+
cue_count += 1
|
40
|
+
cue = Cue.new
|
41
|
+
cue.number = cue_count
|
42
|
+
line = line.split
|
43
|
+
cue.set_time(line[0], line[2])
|
44
|
+
set_properties(cue, line[3..-1])
|
45
|
+
elsif !meta_data_section and is_text?(line)
|
46
|
+
cue.add_text(line)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
@cue_list.append(cue) if cue
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Export CueList to VTT file
|
54
|
+
def dump(file)
|
55
|
+
base_dump(file) do |file|
|
56
|
+
file.write(VTT_HEADER)
|
57
|
+
@cue_list.each do |cue|
|
58
|
+
file.write("\n\n")
|
59
|
+
file.write(msec_to_timecode(cue.start_time))
|
60
|
+
file.write(" --> ")
|
61
|
+
file.write(msec_to_timecode(cue.end_time))
|
62
|
+
file.write("\n")
|
63
|
+
file.write(cue.text)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check whether its a VTT_HEADER or not
|
69
|
+
def validate_header(line)
|
70
|
+
!!line.strip.match(/^#{VTT_HEADER}/)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check whether its a meta-data or not
|
74
|
+
def is_meta_data?(text)
|
75
|
+
!!text.match(VTT_METADATA)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Timecode format used in VTT file
|
79
|
+
def is_time?(text)
|
80
|
+
!!text.match(/^(\d{2}:)?\d{2}:\d{2}.\d{3}.*(\d{2}:)?\d{2}:\d{2}.\d{3}/)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Check whether if its subtilte text or not
|
84
|
+
def is_text?(text)
|
85
|
+
!text.empty? and text.is_a?(String) and text != VTT_HEADER
|
86
|
+
end
|
87
|
+
|
88
|
+
def set_properties(cue, properties)
|
89
|
+
properties.each do |prop|
|
90
|
+
prop, value = prop.split(":")
|
91
|
+
value.gsub!("%","")
|
92
|
+
case prop
|
93
|
+
when "align"
|
94
|
+
cue.alignment = get_alignment(value)
|
95
|
+
when "line"
|
96
|
+
value = value.split(",")[0]
|
97
|
+
cue.position = get_line(value)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_alignment(value)
|
103
|
+
raise InvalidSubtitle, "Invalid VTT Alignment Property" unless ALIGNMENT_VALUES[value]
|
104
|
+
return ALIGNMENT_VALUES[value]
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_line(value)
|
108
|
+
raise InvalidSubtitle, "VTT Line property should be a valid number" if !is_integer?(value) and value != AUTO_KEYWORD
|
109
|
+
return value.to_i
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_position(value)
|
113
|
+
raise InvalidSubtitle, "VTT Position should be a valid number" if !is_integer?(value)
|
114
|
+
raise InvalidSubtitle, "VTT Position should be a number between 0 to 100" if (value.to_i < 0) or (value.to_i > 100)
|
115
|
+
return value.to_i
|
116
|
+
end
|
117
|
+
|
118
|
+
def is_integer?(val)
|
119
|
+
val.to_i.to_s == val
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/captions/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: captions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- navin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.7.9
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Subtitle Editor and Converter written in Ruby
|