tscripter 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9027856dc86868bb991a34c30472780bd05f81f3
4
- data.tar.gz: 65c56d380abd7c08b9d976e0a5451a22f793d2b0
3
+ metadata.gz: 07b2b5f211bd76bacfce348ca69be7b641dd7163
4
+ data.tar.gz: 10456f0151e1d6e577628060c08ceb8901190039
5
5
  SHA512:
6
- metadata.gz: 3030aacac118dba2450245e2bb6c74df4534fe36d859ea7fcacce65962cf6275361e691bf662f17d72c776035de8be1fd7eb5abc15eb4e467784f929c806d132
7
- data.tar.gz: cb4d127d1ca7376c2c388fce81f9a940ca0db6d572ec563b8120151f38bf090df4c7430e64a60f767e7e88990eb77882893b870ecc2009ddfc9c31562335c602
6
+ metadata.gz: f1bd2a76d12c8a504fc198aa402efd5f7fdf768c377d73bc517b8752f8ab886cd6b5a34fa1542f68dd2d6d17587173836b86c69e224ad7758baa363a6c0d9bd2
7
+ data.tar.gz: b989478276db9c255961944df33f551f52a3c1ce17ec7b0d61f537bf6000ecf54de3d9c6563d7678b15bd7abe78785d76a1dcbd23d8fd710f38f0ff5c8a8a57e
data/README.md CHANGED
@@ -4,10 +4,12 @@ This gem edits transcript files, given that they are in the expected format.
4
4
 
5
5
  Current features:
6
6
  - Prepends alternating IDs to spoken lines
7
-
8
- Planned features:
9
7
  - Detect spoken lines that start with stage directions
10
8
  - Implement notation for consecutive lines by the same speaker
9
+ - If a line starts with `^`, then the speaker is the same as the previous line
10
+ - The pattern `*i 00:00` (where 00:00 is any timestamp) is replaced with `inaudible [00:00]
11
+
12
+ Planned features:
11
13
  - Accept multiple filenames
12
14
  - Accept wildcard filenames
13
15
 
@@ -1,3 +1,3 @@
1
1
  module Tscripter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/tscripter.rb CHANGED
@@ -4,10 +4,10 @@ require "tscripter/version"
4
4
  module Tscripter
5
5
  class Runner
6
6
  def go
7
- puts(go_with_args(ARGV))
7
+ puts(go_with_args(*ARGV))
8
8
  end
9
9
 
10
- def go_with_args(args)
10
+ def go_with_args(*args)
11
11
  if filename = args[0]
12
12
  file_basename = File.basename(filename, File.extname(filename))
13
13
  id1 = args[1]
@@ -33,25 +33,58 @@ module Tscripter
33
33
 
34
34
  def generate_edited_text(text, id1, id2)
35
35
  edited_text = ""
36
- use_id1 = true
36
+ ids = [id1, id2]
37
+ count = 0
37
38
 
38
- text.split("\n").each do |line, i|
39
- if line[0] == "[" || line.strip == ""
40
- edited_text << "#{line}\n"
41
- next
42
- end
39
+ text.split("\n").each do |line|
40
+ curr_id = ids[count % ids.length]
43
41
 
44
- if use_id1
45
- edited_text << "#{id1}: #{line}\n"
42
+ if line[0] == "["
43
+ if /^\[.*\].*\w+/ =~ line
44
+ edited_text << process_line(curr_id, line)
45
+ count += 1
46
+ else
47
+ edited_text << "#{line}\n"
48
+ end
49
+ elsif line.strip == ""
50
+ edited_text << "#{line}\n"
51
+ elsif line[0] == "^"
52
+ curr_id = ids[(count % ids.length) - 1]
53
+ edited_text << process_line(curr_id, line)
46
54
  else
47
- edited_text << "#{id2}: #{line}\n"
55
+ edited_text << process_line(curr_id, line)
56
+ count += 1
48
57
  end
49
58
 
50
- use_id1 = !use_id1
59
+ # edited_text << "\n"
51
60
  end
52
61
 
53
62
  edited_text
54
63
  end
55
64
 
65
+ private
66
+
67
+ def process_line(id, line)
68
+ line = remove_markup(line)
69
+ line = add_inaudible_notation(line)
70
+ "#{id}: #{line}\n"
71
+ end
72
+
73
+ def remove_markup(line)
74
+ if line[0] == '^'
75
+ line = line.slice(/\^\s(.*)/, 1)
76
+ else
77
+ line
78
+ end
79
+ end
80
+
81
+ def add_inaudible_notation(line)
82
+ line.scan(/\*[iI]\s\d{1,2}\:\d{1,2}/) do |inaud_markup|
83
+ timestamp = inaud_markup.match(/(\d{1,2}\:\d{1,2})/)[1]
84
+ inaudible_notation = "[inaudible #{timestamp}]"
85
+ line = line.gsub(inaud_markup, inaudible_notation)
86
+ end
87
+ line
88
+ end
56
89
  end
57
90
  end
data/test_input.txt CHANGED
@@ -7,5 +7,7 @@ Oh look, another line!
7
7
  This is fun!
8
8
  I agree!
9
9
  I mean right?
10
- Yup!
10
+ ^ Yup!
11
+ But what if *i 45:09
12
+ [turns away] You can't really mean that!
11
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tscripter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - A. M.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-06 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler