subrip 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/README.md +1 -1
  2. data/lib/shift.rb +10 -4
  3. data/lib/subrip/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Command-line utility to shift subtitles.
4
4
 
5
- My solution to RubyLearning.com's challenge # 1 https://github.com/npras/subrip
5
+ My solution to RubyLearning.com's challenge # 1 http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/
6
6
 
7
7
  ## Installation
8
8
 
@@ -11,10 +11,16 @@ module Subrip
11
11
 
12
12
  def shift_subtitle
13
13
  op_lines = File.readlines(@ip_file).map do |line|
14
- if line.match /(.*) --> (.*)/
15
- "#{transform_time($1)} --> #{transform_time($2)}\n"
16
- else
17
- line
14
+ begin
15
+ if line.match /(.*) --> (.*)/
16
+ "#{transform_time($1)} --> #{transform_time($2)}\n"
17
+ else
18
+ # in some files newline is interpretted as carriage return
19
+ line.chomp! + '\n'
20
+ end
21
+ rescue ArgumentError
22
+ # skipping non utf-8 chars
23
+ next
18
24
  end
19
25
  end
20
26
  File.open(@op_file, 'w') do |f|
@@ -1,3 +1,3 @@
1
1
  module Subrip
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subrip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: