Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/webvtt.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8
# frozen_string_literal: true

if defined?(Encoding)
Encoding.default_internal = Encoding.default_external = "UTF-8"
Expand Down
4 changes: 3 additions & 1 deletion lib/webvtt/parser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module WebVTT

def self.read(file)
Expand Down Expand Up @@ -118,7 +120,7 @@ def self.parse(cue)
end

def to_webvtt
res = ""
res = String.new
if @identifier
res << "#{@identifier}\n"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/webvtt/segmenter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'fileutils'

module WebVTT
Expand Down
4 changes: 3 additions & 1 deletion tests/parser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH << "lib/"
require "minitest/autorun"
require "webvtt"
Expand Down Expand Up @@ -257,7 +259,7 @@ def test_build_cue
cue.start = WebVTT::Timestamp.new 0
cue.end = WebVTT::Timestamp.new 12
cue.text = "Built from scratch"
output = ""
output = String.new
output << "00:00:00.000 --> 00:00:12.000\n"
output << "Built from scratch"
assert_equal output, cue.to_webvtt
Expand Down
6 changes: 5 additions & 1 deletion tests/segmenter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH << "lib/"
require "minitest/autorun"
require "webvtt"
Expand Down Expand Up @@ -53,9 +55,11 @@ def test_shortcut_method
res = WebVTT.segment("tests/subtitles/test.vtt")
assert_instance_of Array, res
assert_equal 2, res.size
assert_equal 35, res[1].size
subs = res[1]
assert_equal 35, subs.size

# clean up
subs.each {|f| FileUtils.rm(f.filename)}
FileUtils.rm("prog_index.m3u8")
end

Expand Down