substitute 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile +1 -1
- data/README.md +5 -0
- data/Rakefile +6 -6
- data/bin/substitute +8 -3
- data/lib/substitute.rb +1 -1
- data/lib/substitute/line.rb +18 -6
- data/lib/substitute/version.rb +1 -1
- data/substitute.gemspec +15 -15
- metadata +3 -4
- data/be +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0ecf05581938ae2fb68f98e0e51ac07b7bc3ec3
|
4
|
+
data.tar.gz: a8fcad80cfa236109a15273afd7de39431cf67de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b171266a40ee03a9d1969a7a92c07af20f04ba319b6fd9d2a5ebdfd88699dde8f08e6d85f5d7f0a877351a6de921f6363e3a31cfd21d76aa6ccbc099e8d674bb
|
7
|
+
data.tar.gz: 7296e6058cb201d969a8aaecfaa78959099478dd67589ff19445aea1ee6e8736ec14cfbcd9dd95e0194a718ccfd4eb2f1e6072845678b1ea70c6eb13b05316f3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Substitute
|
2
2
|
|
3
|
+
[](https://travis-ci.org/errm/substitute)
|
4
|
+
[](http://badge.fury.io/rb/substitute)
|
5
|
+
[](https://codeclimate.com/github/errm/substitute)
|
6
|
+
[](https://codeclimate.com/github/errm/substitute)
|
7
|
+
|
3
8
|
Converts from Adobe Encore Text Scripts to [WebVTT](http://dev.w3.org/html5/webvtt/) format
|
4
9
|
|
5
10
|
## Installation
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "reevoocop/rake_task"
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
ReevooCop::RakeTask.new(:reevoocop)
|
7
7
|
|
8
|
-
task default: [
|
9
|
-
task build: [
|
10
|
-
task release: [
|
8
|
+
task default: %i[spec reevoocop]
|
9
|
+
task build: %i[spec reevoocop]
|
10
|
+
task release: %i[spec reevoocop]
|
data/bin/substitute
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "substitute/line"
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
options[:srt] = true if ARGV[0] == "srt"
|
8
|
+
|
9
|
+
STDOUT.puts "WEBVTT" unless options[:srt]
|
4
10
|
|
5
|
-
STDOUT.puts 'WEBVTT'
|
6
11
|
while (line = STDIN.gets)
|
7
|
-
STDOUT.puts Substitute::Line.new(line)
|
12
|
+
STDOUT.puts Substitute::Line.new(line, options)
|
8
13
|
end
|
data/lib/substitute.rb
CHANGED
data/lib/substitute/line.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Substitute
|
2
2
|
class Line
|
3
|
-
def initialize(text)
|
3
|
+
def initialize(text, options = {})
|
4
4
|
self.text = text
|
5
|
+
@srt = options[:srt]
|
5
6
|
end
|
6
7
|
|
7
8
|
attr_accessor :text
|
@@ -15,7 +16,7 @@ module Substitute
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def parts
|
18
|
-
@_parts ||= text.split(
|
19
|
+
@_parts ||= text.split(" ")
|
19
20
|
end
|
20
21
|
|
21
22
|
def identifier
|
@@ -31,19 +32,30 @@ module Substitute
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def convert_timestamp(timestamp)
|
34
|
-
times = timestamp.split(
|
35
|
+
times = timestamp.split(":")
|
35
36
|
frames = times[3].to_i
|
36
|
-
thous = (frames * 40).to_s.rjust(3,
|
37
|
-
"#{times[0..2].join(
|
37
|
+
thous = (frames * 40).to_s.rjust(3, "0")
|
38
|
+
"#{times[0..2].join(":")}#{sep}#{thous}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def sep
|
42
|
+
return "," if srt?
|
43
|
+
"."
|
38
44
|
end
|
39
45
|
|
40
46
|
def remaining_text
|
41
|
-
parts[3..-1].join(
|
47
|
+
parts[3..-1].join(" ")
|
42
48
|
end
|
43
49
|
|
44
50
|
def line_with_identifier?
|
45
51
|
return unless parts[0]
|
46
52
|
parts[0].to_i.to_s == parts[0]
|
47
53
|
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def srt?
|
58
|
+
@srt
|
59
|
+
end
|
48
60
|
end
|
49
61
|
end
|
data/lib/substitute/version.rb
CHANGED
data/substitute.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "substitute/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = "substitute"
|
8
8
|
spec.version = Substitute::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ["Ed Robinson"]
|
10
|
+
spec.email = ["ed.robinson@reevoo.com"]
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
12
|
+
spec.summary = "Convert Adobe Encore Text Scripts to WebVTT"
|
13
|
+
spec.homepage = "https://github.com/errm/substitute"
|
14
|
+
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
|
17
|
-
spec.bindir =
|
17
|
+
spec.bindir = "bin"
|
18
18
|
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
24
|
+
spec.add_development_dependency "reevoocop"
|
25
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: substitute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
-
- be
|
99
98
|
- bin/substitute
|
100
99
|
- example/subtitles.txt
|
101
100
|
- lib/substitute.rb
|
@@ -122,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
121
|
version: '0'
|
123
122
|
requirements: []
|
124
123
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.13
|
126
125
|
signing_key:
|
127
126
|
specification_version: 4
|
128
127
|
summary: Convert Adobe Encore Text Scripts to WebVTT
|
data/be
DELETED
File without changes
|