substitute 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +10 -0
- data/be +0 -0
- data/bin/substitute +8 -0
- data/example/subtitles.txt +11 -0
- data/lib/substitute.rb +4 -0
- data/lib/substitute/line.rb +49 -0
- data/lib/substitute/version.rb +3 -0
- data/substitute.gemspec +26 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 69f53d4c0277e6884c3a958ffad2f68cb633d6e7
|
4
|
+
data.tar.gz: d09779d9f3f10f768f485aa4007c5a88f0f472eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6287c8a808289ee10bf76de0756d0f0515d7446b317124ea84f442be9d6d8fe416326445a05164bdbf1b30b31c5badd62f62da13d8414f1987ea563b99fbb57c
|
7
|
+
data.tar.gz: fe69a91dee98181f37bb7c479e34ebe38a9cb55a1f807afee53107b4ae0e4b445db529c1c6c1a795bb64a40fc8a9aa2bd63117e77296406b1f8f4d9606bc3ecb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ed Robinson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Substitute
|
2
|
+
|
3
|
+
Converts from Adobe Encore Text Scripts to [WebVTT](http://dev.w3.org/html5/webvtt/) format
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it with:
|
8
|
+
|
9
|
+
$ gem install substitute
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Substitute reads from standard in and writes to standard out.
|
14
|
+
|
15
|
+
For example:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ substitute < example/subtitles.txt
|
19
|
+
WEBVTT
|
20
|
+
|
21
|
+
2
|
22
|
+
00:02:47.080 --> 00:02:49.360
|
23
|
+
Open the pod bay doors, please, HAL.
|
24
|
+
Open the pod bay doors, please, HAL.
|
25
|
+
Hello, HAL. Do you read me?
|
26
|
+
Hello, HAL. Do you read me?
|
27
|
+
Do you read me, HAL?
|
28
|
+
|
29
|
+
3
|
30
|
+
00:02:49.840 --> 00:02:52.320
|
31
|
+
Affirmative, Dave. I read you.
|
32
|
+
|
33
|
+
4
|
34
|
+
00:03:17.480 --> 00:03:19.200
|
35
|
+
Open the pod bay doors, HAL.
|
36
|
+
|
37
|
+
5
|
38
|
+
00:03:19.600 --> 00:03:21.000
|
39
|
+
I'm sorry, Dave. I'm afraid I can't do that.
|
40
|
+
|
41
|
+
6
|
42
|
+
00:03:23.960 --> 00:03:25.240
|
43
|
+
What's the problem?
|
44
|
+
|
45
|
+
7
|
46
|
+
00:05:09.400 --> 00:05:10.400
|
47
|
+
I think you know what the problem is just as well as I do.
|
48
|
+
|
49
|
+
8
|
50
|
+
00:05:12.880 --> 00:05:13.880
|
51
|
+
What are you talking about, HAL?
|
52
|
+
```
|
53
|
+
|
54
|
+
Or write to a file
|
55
|
+
|
56
|
+
`$ substitute < subtitles.txt > subtitles.vtt`
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/[my-github-username]/substitute/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'reevoocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
ReevooCop::RakeTask.new(:reevoocop)
|
7
|
+
|
8
|
+
task default: [:spec, :reevoocop]
|
9
|
+
task build: [:spec, :reevoocop]
|
10
|
+
task release: [:spec, :reevoocop]
|
data/be
ADDED
File without changes
|
data/bin/substitute
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
2 00:02:47:02 00:02:49:09 Open the pod bay doors, please, HAL.
|
2
|
+
Open the pod bay doors, please, HAL.
|
3
|
+
Hello, HAL. Do you read me?
|
4
|
+
Hello, HAL. Do you read me?
|
5
|
+
Do you read me, HAL?
|
6
|
+
3 00:02:49:21 00:02:52:08 Affirmative, Dave. I read you.
|
7
|
+
4 00:03:17:12 00:03:19:05 Open the pod bay doors, HAL.
|
8
|
+
5 00:03:19:15 00:03:21:00 I'm sorry, Dave. I'm afraid I can't do that.
|
9
|
+
6 00:03:23:24 00:03:25:06 What's the problem?
|
10
|
+
7 00:05:09:10 00:05:10:10 I think you know what the problem is just as well as I do.
|
11
|
+
8 00:05:12:22 00:05:13:22 What are you talking about, HAL?
|
data/lib/substitute.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Substitute
|
2
|
+
class Line
|
3
|
+
def initialize(text)
|
4
|
+
self.text = text
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_accessor :text
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
if line_with_identifier?
|
11
|
+
"\n#{identifier}\n#{start} --> #{finish}\n#{remaining_text}"
|
12
|
+
else
|
13
|
+
text
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def parts
|
18
|
+
@_parts ||= text.split(' ')
|
19
|
+
end
|
20
|
+
|
21
|
+
def identifier
|
22
|
+
parts[0]
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
convert_timestamp(parts[1])
|
27
|
+
end
|
28
|
+
|
29
|
+
def finish
|
30
|
+
convert_timestamp(parts[2])
|
31
|
+
end
|
32
|
+
|
33
|
+
def convert_timestamp(timestamp)
|
34
|
+
times = timestamp.split(':')
|
35
|
+
frames = times[3].to_i
|
36
|
+
thous = (frames * 40).to_s.rjust(3, '0')
|
37
|
+
"#{times[0..2].join(':')}.#{thous}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def remaining_text
|
41
|
+
parts[3..-1].join(' ')
|
42
|
+
end
|
43
|
+
|
44
|
+
def line_with_identifier?
|
45
|
+
return unless parts[0]
|
46
|
+
parts[0].to_i.to_s == parts[0]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/substitute.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'substitute/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'substitute'
|
8
|
+
spec.version = Substitute::VERSION
|
9
|
+
spec.authors = ['Ed Robinson']
|
10
|
+
spec.email = ['ed.robinson@reevoo.com']
|
11
|
+
|
12
|
+
spec.summary = 'Convert Adobe Encore Text Scripts to WebVTT'
|
13
|
+
spec.homepage = 'https://github.com/errm/substitute'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
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
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: substitute
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Robinson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: reevoocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- ed.robinson@reevoo.com
|
86
|
+
executables:
|
87
|
+
- substitute
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- be
|
99
|
+
- bin/substitute
|
100
|
+
- example/subtitles.txt
|
101
|
+
- lib/substitute.rb
|
102
|
+
- lib/substitute/line.rb
|
103
|
+
- lib/substitute/version.rb
|
104
|
+
- substitute.gemspec
|
105
|
+
homepage: https://github.com/errm/substitute
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.5
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Convert Adobe Encore Text Scripts to WebVTT
|
129
|
+
test_files: []
|