typingpool 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +23 -0
- data/bin/tp-assign +240 -0
- data/bin/tp-collect +50 -0
- data/bin/tp-config +114 -0
- data/bin/tp-finish +101 -0
- data/bin/tp-make +169 -0
- data/bin/tp-review +175 -0
- data/lib/typingpool/amazon.rb +732 -0
- data/lib/typingpool/app.rb +634 -0
- data/lib/typingpool/config.rb +344 -0
- data/lib/typingpool/error.rb +22 -0
- data/lib/typingpool/filer.rb +396 -0
- data/lib/typingpool/project.rb +593 -0
- data/lib/typingpool/template.rb +175 -0
- data/lib/typingpool/templates/assignment/amazon-init.js +38 -0
- data/lib/typingpool/templates/assignment/interview/nameless.html.erb +13 -0
- data/lib/typingpool/templates/assignment/interview/noisy.html.erb +12 -0
- data/lib/typingpool/templates/assignment/interview/partials/voices.html.erb +10 -0
- data/lib/typingpool/templates/assignment/interview/phone.html.erb +12 -0
- data/lib/typingpool/templates/assignment/interview.html.erb +11 -0
- data/lib/typingpool/templates/assignment/main.css +20 -0
- data/lib/typingpool/templates/assignment/partials/entry.html.erb +19 -0
- data/lib/typingpool/templates/assignment/partials/footer.html.erb +3 -0
- data/lib/typingpool/templates/assignment/partials/header.html.erb +11 -0
- data/lib/typingpool/templates/assignment/partials/labeling-example.html.erb +4 -0
- data/lib/typingpool/templates/assignment/partials/labeling.html.erb +5 -0
- data/lib/typingpool/templates/assignment/partials/length-description.html.erb +6 -0
- data/lib/typingpool/templates/assignment/partials/voices.html.erb +10 -0
- data/lib/typingpool/templates/assignment/speech.html.erb +11 -0
- data/lib/typingpool/templates/config.yml +21 -0
- data/lib/typingpool/templates/project/audio/chunks/.empty_directory +0 -0
- data/lib/typingpool/templates/project/audio/originals/.empty_directory +0 -0
- data/lib/typingpool/templates/project/data/.empty_directory +0 -0
- data/lib/typingpool/templates/project/etc/ About these files - read me.txt +8 -0
- data/lib/typingpool/templates/project/etc/audio-compat.js +25 -0
- data/lib/typingpool/templates/project/etc/player/audio-player.js +4 -0
- data/lib/typingpool/templates/project/etc/player/license.txt +19 -0
- data/lib/typingpool/templates/project/etc/player/player.swf +0 -0
- data/lib/typingpool/templates/project/etc/transcript.css +49 -0
- data/lib/typingpool/templates/transcript.html.erb +23 -0
- data/lib/typingpool/test/fixtures/amazon-question-html.html +95 -0
- data/lib/typingpool/test/fixtures/amazon-question-url.txt +1 -0
- data/lib/typingpool/test/fixtures/audio/mp3/interview.1.mp3 +0 -0
- data/lib/typingpool/test/fixtures/audio/mp3/interview.2.mp3 +0 -0
- data/lib/typingpool/test/fixtures/audio/wma/VN620007.WMA +0 -0
- data/lib/typingpool/test/fixtures/audio/wma/VN620052.WMA +0 -0
- data/lib/typingpool/test/fixtures/config-1 +20 -0
- data/lib/typingpool/test/fixtures/config-2 +25 -0
- data/lib/typingpool/test/fixtures/not_yaml.txt +4 -0
- data/lib/typingpool/test/fixtures/template-2.html.erb +10 -0
- data/lib/typingpool/test/fixtures/template-3.html.erb +22 -0
- data/lib/typingpool/test/fixtures/template.html.erb +10 -0
- data/lib/typingpool/test/fixtures/tp_collect_id.txt +1 -0
- data/lib/typingpool/test/fixtures/tp_collect_sandbox-assignment.csv +8 -0
- data/lib/typingpool/test/fixtures/tp_review_id.txt +1 -0
- data/lib/typingpool/test/fixtures/tp_review_sandbox-assignment.csv +8 -0
- data/lib/typingpool/test/fixtures/transcript-chunks.csv +226 -0
- data/lib/typingpool/test/fixtures/utf8_transcript.txt +7 -0
- data/lib/typingpool/test/fixtures/vcr/tp-collect-1.yml +2712 -0
- data/lib/typingpool/test/fixtures/vcr/tp-collect-2.yml +2718 -0
- data/lib/typingpool/test/fixtures/vcr/tp-collect-3.yml +2768 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-1.yml +570 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-2.yml +351 -0
- data/lib/typingpool/test.rb +418 -0
- data/lib/typingpool/transcript.rb +181 -0
- data/lib/typingpool/utility.rb +272 -0
- data/lib/typingpool.rb +500 -0
- data/test/make_amazon_question_fixture.rb +24 -0
- data/test/make_tp_collect_fixture_1.rb +26 -0
- data/test/make_tp_collect_fixture_2.rb +16 -0
- data/test/make_tp_collect_fixture_3.rb +15 -0
- data/test/make_tp_collect_fixture_4.rb +17 -0
- data/test/make_tp_review_fixture_1.rb +26 -0
- data/test/make_tp_review_fixture_2.rb +30 -0
- data/test/make_transcript_chunks_fixture.rb +53 -0
- data/test/test_integration_script_1_tp_config.rb +108 -0
- data/test/test_integration_script_2_tp_make.rb +119 -0
- data/test/test_integration_script_3_tp_assign.rb +152 -0
- data/test/test_integration_script_4_tp_review.rb +72 -0
- data/test/test_integration_script_5_tp_collect.rb +44 -0
- data/test/test_integration_script_6_tp_finish.rb +123 -0
- data/test/test_unit_amazon.rb +153 -0
- data/test/test_unit_config.rb +94 -0
- data/test/test_unit_filer.rb +202 -0
- data/test/test_unit_project.rb +168 -0
- data/test/test_unit_project_local.rb +68 -0
- data/test/test_unit_project_remote.rb +157 -0
- data/test/test_unit_template.rb +111 -0
- data/test/test_unit_transcript.rb +77 -0
- metadata +234 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
|
4
|
+
|
5
|
+
require 'typingpool'
|
6
|
+
require 'typingpool/test'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
class TestProjectRemote < Typingpool::Test
|
10
|
+
def test_project_remote_from_config
|
11
|
+
assert(remote = Typingpool::Project::Remote.from_config(project_default[:title], dummy_config(1)))
|
12
|
+
assert_instance_of(Typingpool::Project::Remote::S3, remote)
|
13
|
+
assert(remote = Typingpool::Project::Remote.from_config(project_default[:title], dummy_config(2)))
|
14
|
+
assert_instance_of(Typingpool::Project::Remote::SFTP, remote)
|
15
|
+
config = dummy_config(2)
|
16
|
+
config.to_hash.delete('sftp')
|
17
|
+
assert_raises(Typingpool::Error) do
|
18
|
+
Typingpool::Project::Remote.from_config(project_default[:title], config)
|
19
|
+
end #assert_raises
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_project_remote_s3_base
|
23
|
+
config = dummy_config(1)
|
24
|
+
assert(remote = Typingpool::Project::Remote::S3.new(project_default[:title], config.amazon))
|
25
|
+
%w(key secret bucket).each do |param|
|
26
|
+
refute_nil(remote.send(param.to_sym))
|
27
|
+
assert_equal(config.amazon.send(param.to_sym), remote.send(param.to_sym))
|
28
|
+
end #%w().each do...
|
29
|
+
assert_nil(config.amazon.url)
|
30
|
+
assert_includes(remote.url, config.amazon.bucket)
|
31
|
+
custom_url = 'http://tp.example.com/tp-test/1/2/3'
|
32
|
+
config.amazon.url = custom_url
|
33
|
+
assert(remote = Typingpool::Project::Remote::S3.new(project_default[:title], config.amazon))
|
34
|
+
refute_nil(remote.url)
|
35
|
+
refute_includes(remote.url, config.amazon.bucket)
|
36
|
+
assert_includes(remote.url, custom_url)
|
37
|
+
assert_equal('tp.example.com', remote.host)
|
38
|
+
assert_equal('/tp-test/1/2/3', remote.path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_project_remote_s3_networked
|
42
|
+
assert(config = self.config)
|
43
|
+
skip_if_no_s3_credentials('Project::Remote::S3 upload and delete tests', config)
|
44
|
+
config.to_hash.delete('sftp')
|
45
|
+
assert(project = Typingpool::Project.new(project_default[:title], config))
|
46
|
+
assert_instance_of(Typingpool::Project::Remote::S3, remote = project.remote)
|
47
|
+
standard_put_remove_tests(remote)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_project_remote_sftp_base
|
51
|
+
config = dummy_config(2)
|
52
|
+
assert(remote = Typingpool::Project::Remote::SFTP.new(project_default[:title], config.sftp))
|
53
|
+
%w(host path user url).each do |param|
|
54
|
+
refute_nil(remote.send(param.to_sym))
|
55
|
+
assert_equal(config.sftp.send(param.to_sym), remote.send(param.to_sym))
|
56
|
+
end #%w().each do...
|
57
|
+
assert_equal('example.com', remote.host)
|
58
|
+
assert_equal('public_html/transfer', remote.path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_project_remote_sftp_networked
|
62
|
+
assert(config = self.config)
|
63
|
+
skip_if_no_sftp_credentials('Project::Remote::SFTP upload and delete tests', config)
|
64
|
+
assert(project = Typingpool::Project.new(project_default[:title], config))
|
65
|
+
assert_instance_of(Typingpool::Project::Remote::SFTP, remote = project.remote)
|
66
|
+
standard_put_remove_tests(remote)
|
67
|
+
end
|
68
|
+
|
69
|
+
def standard_put_remove_tests(remote)
|
70
|
+
basenames = ['amazon-question-html.html', 'amazon-question-url.txt']
|
71
|
+
local_files = basenames.map{|basename| File.join(fixtures_dir, basename) }
|
72
|
+
local_files.each{|path| assert(File.exists? path) }
|
73
|
+
strings = local_files.map{|path| File.read(path) }
|
74
|
+
strings.each{|string| refute_empty(string) }
|
75
|
+
|
76
|
+
#with default basenames
|
77
|
+
put_remove_test(
|
78
|
+
:remote => remote,
|
79
|
+
:streams => local_files.map{|path| File.new(path) },
|
80
|
+
:test_with => lambda{|urls| urls.each_with_index{|url, i| assert_includes(url, basenames[i]) } }
|
81
|
+
)
|
82
|
+
|
83
|
+
#now with different basenames
|
84
|
+
remote_basenames = basenames.map{|name| [File.basename(name, '.*'), pseudo_random_chars, File.extname(name)].join }
|
85
|
+
base_args = {
|
86
|
+
:remote => remote,
|
87
|
+
:as => remote_basenames,
|
88
|
+
:test_with => lambda{|urls| urls.each_with_index{|url, i| assert_includes(url, remote_basenames[i]) }}
|
89
|
+
}
|
90
|
+
|
91
|
+
put_remove_test(
|
92
|
+
base_args.merge(
|
93
|
+
:streams => local_files.map{|path| File.new(path) },
|
94
|
+
)
|
95
|
+
)
|
96
|
+
|
97
|
+
#now using remove_urls for removal
|
98
|
+
put_remove_test(
|
99
|
+
base_args.merge(
|
100
|
+
:streams => local_files.map{|path| File.new(path) },
|
101
|
+
:remove_with => lambda{|urls| base_args[:remote].remove_urls(urls) }
|
102
|
+
)
|
103
|
+
)
|
104
|
+
|
105
|
+
#now with stringio streams
|
106
|
+
put_remove_test(
|
107
|
+
base_args.merge(
|
108
|
+
:streams => strings.map{|string| StringIO.new(string) },
|
109
|
+
)
|
110
|
+
)
|
111
|
+
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
#Uploads and then deletes streams to a remote server, running some
|
116
|
+
#basic tests along the way, along with some optional lambdas.
|
117
|
+
# ==== Params
|
118
|
+
# args[:remote] Required. A Project::Remote instance to use for
|
119
|
+
# putting and removing.
|
120
|
+
# args[:streams] Required. An enumerable collection of IO streams to
|
121
|
+
# put and remove.
|
122
|
+
# args[:as] Optional. An array of basenames to use to name the
|
123
|
+
# streams remotely. Default is to call
|
124
|
+
# Project::Remote#put with no 'as' param.
|
125
|
+
# args[:test_with] Optional. Lambda to call after putting the
|
126
|
+
# streams and after running the standard tests.
|
127
|
+
# args[:remove_with] Optional. Lambda to call to remove the remote
|
128
|
+
# files. Default lambda calls
|
129
|
+
# args[:remote].remove(args[:as])
|
130
|
+
# ==== Returns
|
131
|
+
#URLs of the former remote files (non functioning/404)
|
132
|
+
def put_remove_test(args)
|
133
|
+
args[:remote] or raise Error::Argument, "Must supply a Project::Remote instance as :remote"
|
134
|
+
args[:streams] or raise Error::Argument, "Must supply an array of IO streams as :streams"
|
135
|
+
args[:remove_with] ||= lambda do |urls|
|
136
|
+
args[:remote].remove(urls.map{|url| Typingpool::Utility.url_basename(url) })
|
137
|
+
end #lambda do...
|
138
|
+
put_args = [args[:streams]]
|
139
|
+
put_args.push(args[:as]) if args[:as]
|
140
|
+
assert(urls = args[:remote].put(*put_args))
|
141
|
+
begin
|
142
|
+
assert_equal(args[:streams].count, urls.count)
|
143
|
+
urls.each{|url| assert(working_url?(url)) }
|
144
|
+
args[:test_with].call(urls) if args[:test_with]
|
145
|
+
ensure
|
146
|
+
args[:remove_with].call(urls)
|
147
|
+
end #begin
|
148
|
+
urls.each{|url| refute(working_url?(url)) }
|
149
|
+
urls
|
150
|
+
end
|
151
|
+
|
152
|
+
#Copy-pasted from Project::Remote so we don't have to make that a public method
|
153
|
+
def pseudo_random_chars(length=6)
|
154
|
+
(0...length).map{(65 + rand(25)).chr}.join
|
155
|
+
end
|
156
|
+
|
157
|
+
end #TestProjectRemote
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
|
4
|
+
|
5
|
+
require 'typingpool'
|
6
|
+
require 'typingpool/test'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
class TestTemplate < Typingpool::Test
|
10
|
+
def test_template_base
|
11
|
+
assert(template1 = Typingpool::Template.new('template', [fixtures_dir]))
|
12
|
+
has_template_in_fixtures_dir_test(template1)
|
13
|
+
assert(template2 = Typingpool::Template.new('template.html.erb', [fixtures_dir]))
|
14
|
+
has_template_in_fixtures_dir_test(template2)
|
15
|
+
signature = 'ffffffffff'
|
16
|
+
assert_match(template1.render({:title => signature}), /#{signature}/)
|
17
|
+
refute_match(template1.read, /#{signature}/)
|
18
|
+
assert_match(template1.read, /<h1><%= title/i)
|
19
|
+
in_temp_dir do |dir1|
|
20
|
+
assert(template = Typingpool::Template.new('template', [dir1, fixtures_dir]))
|
21
|
+
assert(template.look_in.detect{|path| path == dir1})
|
22
|
+
has_template_in_fixtures_dir_test(template)
|
23
|
+
in_temp_dir do |dir2|
|
24
|
+
copy_template_fixture_into(dir2, '-2') do |path|
|
25
|
+
assert(template = Typingpool::Template.new('template', [dir1, dir2, fixtures_dir]))
|
26
|
+
assert_equal(path, template.full_path)
|
27
|
+
assert_match(template.render({:title => signature}), /#{signature}/)
|
28
|
+
refute_match(template.read, /#{signature}/)
|
29
|
+
assert_match(template.read, /<h2><%= title/i)
|
30
|
+
end #copy_template_fixture_into do...
|
31
|
+
end #in_temp_dir do |dir2|
|
32
|
+
end #in_temp_dir do |dir1|
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_template_from_config
|
36
|
+
in_temp_dir do |dir1|
|
37
|
+
in_temp_dir do |dir2|
|
38
|
+
copy_template_fixture_into(dir2, '-2') do |path|
|
39
|
+
config = dummy_config
|
40
|
+
config.templates = dir2
|
41
|
+
assert(template = Typingpool::Template.from_config('template', config))
|
42
|
+
assert_equal(path, template.full_path)
|
43
|
+
assert_match(template.read, /<h2><%= title/i)
|
44
|
+
config.templates = dir1
|
45
|
+
exception = assert_raise(Typingpool::Error) do
|
46
|
+
template = Typingpool::Template.from_config('template', config)
|
47
|
+
end #assert_raises() do...
|
48
|
+
assert_match(exception.message, /could not find/i)
|
49
|
+
end #copy_template_into do...
|
50
|
+
end #in_temp_dir do |dir2|
|
51
|
+
end #in_temp_dir do |dir1|
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_template_assignment
|
55
|
+
in_temp_dir do |dir|
|
56
|
+
copy_template_fixture_into(dir) do |path|
|
57
|
+
assignment_subdir = File.join(dir, 'assignment')
|
58
|
+
FileUtils.mkdir(assignment_subdir)
|
59
|
+
copy_template_fixture_into(assignment_subdir, '-2') do |assignment_path|
|
60
|
+
config = dummy_config
|
61
|
+
config.templates = dir
|
62
|
+
assert(template = Typingpool::Template::Assignment.from_config('template', config))
|
63
|
+
assert_equal(assignment_path, template.full_path)
|
64
|
+
assert_match(template.read, /<h2><%= title/i)
|
65
|
+
end #copy_template_fixture_into(assignment_subdir) do...
|
66
|
+
end #copy_template_fixture_into(dir, '') do...
|
67
|
+
end #in_temp_dir do...
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_template_env
|
71
|
+
assert(template = Typingpool::Template.new('template-3', [fixtures_dir]))
|
72
|
+
signatures = [('g' * 9), ('h' * 11)]
|
73
|
+
assert(rendered = template.render(:title => signatures[0], :new_title => signatures[1]))
|
74
|
+
assert_match(rendered, /<h1><%= title/i)
|
75
|
+
assert_match(rendered, /<h1>#{signatures[0]}/i)
|
76
|
+
assert_match(rendered, /<h1>#{signatures[1]}/i)
|
77
|
+
in_temp_dir do |dir|
|
78
|
+
copy_template_fixture_into(dir) do |template_path|
|
79
|
+
subdir = File.join(dir, 'closer')
|
80
|
+
FileUtils.mkdir(subdir)
|
81
|
+
copy_template_fixture_into(subdir, '-2') do |closer_template_oath|
|
82
|
+
FileUtils.cp(File.join(fixtures_dir, 'template-3.html.erb'), subdir)
|
83
|
+
FileUtils.cp(File.join(fixtures_dir, 'template-2.html.erb'), subdir)
|
84
|
+
look_in = [dir, subdir]
|
85
|
+
assert(template = Typingpool::Template.new('template', look_in))
|
86
|
+
assert_match(template.read, /<h1><%= title/i)
|
87
|
+
refute_match(template.read, /<h2><%= title/i)
|
88
|
+
assert(calling_template = Typingpool::Template.new('template-3', look_in))
|
89
|
+
assert(rendered = calling_template.render(:title => signatures[0], :new_title => signatures[1]))
|
90
|
+
assert_match(rendered, /<h2>/)
|
91
|
+
refute_match(rendered, /<h1>/)
|
92
|
+
end #copy_template_fixture_into do...
|
93
|
+
end #copy_template_fixture_into do...
|
94
|
+
end #in_temp_dir do...
|
95
|
+
end
|
96
|
+
|
97
|
+
def copy_template_fixture_into(dir, which_fixture='')
|
98
|
+
dest = File.join(dir, 'template.html.erb')
|
99
|
+
FileUtils.cp(File.join(fixtures_dir, "template#{which_fixture}.html.erb"), dest)
|
100
|
+
begin
|
101
|
+
yield(dest)
|
102
|
+
ensure
|
103
|
+
File.delete(dest)
|
104
|
+
end #begin
|
105
|
+
end
|
106
|
+
|
107
|
+
def has_template_in_fixtures_dir_test(template)
|
108
|
+
assert_equal(File.join(fixtures_dir, 'template.html.erb'), template.full_path)
|
109
|
+
end
|
110
|
+
|
111
|
+
end #TestTemplate
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
|
4
|
+
|
5
|
+
require 'typingpool'
|
6
|
+
require 'typingpool/test'
|
7
|
+
|
8
|
+
class TestTranscript < Typingpool::Test
|
9
|
+
|
10
|
+
def test_transcript_base
|
11
|
+
assert(transcript = Typingpool::Transcript.new(project_default[:title]))
|
12
|
+
assert_equal(project_default[:title], transcript.title)
|
13
|
+
assert_equal(0, transcript.count)
|
14
|
+
dummy_chunks = self.dummy_chunks
|
15
|
+
assert(transcript = Typingpool::Transcript.new(project_default[:title], dummy_chunks))
|
16
|
+
assert_equal(dummy_chunks.count, transcript.count)
|
17
|
+
assert_respond_to(transcript, :each)
|
18
|
+
transcript.each_with_index do |chunk, i|
|
19
|
+
assert_respond_to(chunk, :body)
|
20
|
+
assert_equal(dummy_chunks[i].body, chunk.body)
|
21
|
+
assert_equal(chunk.body, transcript[i].body)
|
22
|
+
end #transcript.each_with_index do...
|
23
|
+
assert(transcript = Typingpool::Transcript.new(project_default[:title]))
|
24
|
+
assert_equal(0, transcript.count)
|
25
|
+
assert_respond_to(transcript, :add_chunk)
|
26
|
+
dummy_chunks.each{|chunk| transcript.add_chunk(chunk) }
|
27
|
+
assert_equal(dummy_chunks.count, transcript.count)
|
28
|
+
random_index = rand(dummy_chunks.count)
|
29
|
+
assert_equal(dummy_chunks[random_index].body, transcript[random_index].body)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_transcript_chunks
|
33
|
+
dummy_assignments.each do |assignment|
|
34
|
+
assert(chunk = Typingpool::Transcript::Chunk.new(assignment['transcript']))
|
35
|
+
assert_equal(assignment['transcript'], chunk.body)
|
36
|
+
chunk.worker = assignment['worker']
|
37
|
+
assert_equal(assignment['worker'], chunk.worker)
|
38
|
+
chunk.project = assignment['project_id']
|
39
|
+
assert_equal(assignment['project_id'], chunk.project)
|
40
|
+
chunk.hit = assignment['hit_id']
|
41
|
+
assert_equal(assignment['hit_id'], chunk.hit)
|
42
|
+
url_populated = %w(offset offset_seconds filename filename_local)
|
43
|
+
url_populated.each{|attr| assert_nil(chunk.send(attr.to_sym)) }
|
44
|
+
chunk.url = assignment['audio_url']
|
45
|
+
assert_equal(assignment['audio_url'], chunk.url)
|
46
|
+
url_populated.each{|attr| refute_nil(chunk.send(attr.to_sym)) }
|
47
|
+
matches = chunk.offset.match(/^(\d+):(\d+)$/)
|
48
|
+
assert_equal(((matches[1].to_i * 60) + matches[2].to_i), chunk.offset_seconds)
|
49
|
+
refute_equal(chunk.filename, chunk.filename_local)
|
50
|
+
original_newline_count = chunk.body_as_text.scan(/\n/).count
|
51
|
+
chunk.body = chunk.body + "\n\r\f" + ('foo bar baz' * 100)
|
52
|
+
refute_match(chunk.body_as_text, /\r/) unless $/.match(/\r/)
|
53
|
+
assert_equal(original_newline_count + 2, chunk.body_as_text.scan(/\n/).count)
|
54
|
+
original_p_count = chunk.body_as_html.scan(/<p>/i).count
|
55
|
+
chunk.body = chunk.body + "One & two\n\n...and 3 < 4."
|
56
|
+
refute_match(chunk.body_as_html, /\s&\s/)
|
57
|
+
refute_match(chunk.body_as_html, /\s<\s/)
|
58
|
+
assert_equal(original_p_count + 1, chunk.body_as_html.scan(/<p>/i).count)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def dummy_chunks
|
63
|
+
dummy_assignments.map do |assignment|
|
64
|
+
chunk = Typingpool::Transcript::Chunk.new(assignment['transcript'])
|
65
|
+
chunk.worker = assignment['worker']
|
66
|
+
chunk.project = assignment['project_id']
|
67
|
+
chunk.hit = assignment['hit_id']
|
68
|
+
chunk.url = assignment['audio_url']
|
69
|
+
chunk
|
70
|
+
end #dummy_assignments.map do...
|
71
|
+
end
|
72
|
+
|
73
|
+
def dummy_assignments
|
74
|
+
Typingpool::Filer::CSV.new(File.join(fixtures_dir, 'transcript-chunks.csv')).read
|
75
|
+
end
|
76
|
+
|
77
|
+
end #TestTranscript
|
metadata
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: typingpool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.7.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Tate
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-09-09 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rturk
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "2.9"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "1.6"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: nokogiri
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "1.5"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: aws-s3
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0.6"
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: net-sftp
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.5
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: vcr
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: webmock
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
type: :runtime
|
92
|
+
version_requirements: *id007
|
93
|
+
description: An app for transcribing audio using Mechanical Turk
|
94
|
+
email: ryantate@ryantate.com
|
95
|
+
executables:
|
96
|
+
- tp-config
|
97
|
+
- tp-make
|
98
|
+
- tp-assign
|
99
|
+
- tp-review
|
100
|
+
- tp-collect
|
101
|
+
- tp-finish
|
102
|
+
extensions: []
|
103
|
+
|
104
|
+
extra_rdoc_files: []
|
105
|
+
|
106
|
+
files:
|
107
|
+
- Rakefile
|
108
|
+
- bin/tp-config
|
109
|
+
- bin/tp-make
|
110
|
+
- bin/tp-assign
|
111
|
+
- bin/tp-review
|
112
|
+
- bin/tp-collect
|
113
|
+
- bin/tp-finish
|
114
|
+
- lib/typingpool.rb
|
115
|
+
- lib/typingpool/amazon.rb
|
116
|
+
- lib/typingpool/app.rb
|
117
|
+
- lib/typingpool/config.rb
|
118
|
+
- lib/typingpool/error.rb
|
119
|
+
- lib/typingpool/filer.rb
|
120
|
+
- lib/typingpool/project.rb
|
121
|
+
- lib/typingpool/template.rb
|
122
|
+
- lib/typingpool/test.rb
|
123
|
+
- lib/typingpool/transcript.rb
|
124
|
+
- lib/typingpool/utility.rb
|
125
|
+
- lib/typingpool/templates/assignment/amazon-init.js
|
126
|
+
- lib/typingpool/templates/assignment/interview.html.erb
|
127
|
+
- lib/typingpool/templates/assignment/interview/nameless.html.erb
|
128
|
+
- lib/typingpool/templates/assignment/interview/noisy.html.erb
|
129
|
+
- lib/typingpool/templates/assignment/interview/partials/voices.html.erb
|
130
|
+
- lib/typingpool/templates/assignment/interview/phone.html.erb
|
131
|
+
- lib/typingpool/templates/assignment/main.css
|
132
|
+
- lib/typingpool/templates/assignment/partials/entry.html.erb
|
133
|
+
- lib/typingpool/templates/assignment/partials/footer.html.erb
|
134
|
+
- lib/typingpool/templates/assignment/partials/header.html.erb
|
135
|
+
- lib/typingpool/templates/assignment/partials/labeling-example.html.erb
|
136
|
+
- lib/typingpool/templates/assignment/partials/labeling.html.erb
|
137
|
+
- lib/typingpool/templates/assignment/partials/length-description.html.erb
|
138
|
+
- lib/typingpool/templates/assignment/partials/voices.html.erb
|
139
|
+
- lib/typingpool/templates/assignment/speech.html.erb
|
140
|
+
- lib/typingpool/templates/config.yml
|
141
|
+
- lib/typingpool/templates/project/audio/chunks/.empty_directory
|
142
|
+
- lib/typingpool/templates/project/audio/originals/.empty_directory
|
143
|
+
- lib/typingpool/templates/project/data/.empty_directory
|
144
|
+
- lib/typingpool/templates/project/etc/ About these files - read me.txt
|
145
|
+
- lib/typingpool/templates/project/etc/audio-compat.js
|
146
|
+
- lib/typingpool/templates/project/etc/player/audio-player.js
|
147
|
+
- lib/typingpool/templates/project/etc/player/license.txt
|
148
|
+
- lib/typingpool/templates/project/etc/player/player.swf
|
149
|
+
- lib/typingpool/templates/project/etc/transcript.css
|
150
|
+
- lib/typingpool/templates/transcript.html.erb
|
151
|
+
- lib/typingpool/test/fixtures/amazon-question-html.html
|
152
|
+
- lib/typingpool/test/fixtures/amazon-question-url.txt
|
153
|
+
- lib/typingpool/test/fixtures/audio/mp3/interview.1.mp3
|
154
|
+
- lib/typingpool/test/fixtures/audio/mp3/interview.2.mp3
|
155
|
+
- lib/typingpool/test/fixtures/audio/wma/VN620007.WMA
|
156
|
+
- lib/typingpool/test/fixtures/audio/wma/VN620052.WMA
|
157
|
+
- lib/typingpool/test/fixtures/config-1
|
158
|
+
- lib/typingpool/test/fixtures/config-2
|
159
|
+
- lib/typingpool/test/fixtures/not_yaml.txt
|
160
|
+
- lib/typingpool/test/fixtures/template-2.html.erb
|
161
|
+
- lib/typingpool/test/fixtures/template-3.html.erb
|
162
|
+
- lib/typingpool/test/fixtures/template.html.erb
|
163
|
+
- lib/typingpool/test/fixtures/tp_collect_id.txt
|
164
|
+
- lib/typingpool/test/fixtures/tp_collect_sandbox-assignment.csv
|
165
|
+
- lib/typingpool/test/fixtures/tp_review_id.txt
|
166
|
+
- lib/typingpool/test/fixtures/tp_review_sandbox-assignment.csv
|
167
|
+
- lib/typingpool/test/fixtures/transcript-chunks.csv
|
168
|
+
- lib/typingpool/test/fixtures/utf8_transcript.txt
|
169
|
+
- lib/typingpool/test/fixtures/vcr/tp-collect-1.yml
|
170
|
+
- lib/typingpool/test/fixtures/vcr/tp-collect-2.yml
|
171
|
+
- lib/typingpool/test/fixtures/vcr/tp-collect-3.yml
|
172
|
+
- lib/typingpool/test/fixtures/vcr/tp-review-1.yml
|
173
|
+
- lib/typingpool/test/fixtures/vcr/tp-review-2.yml
|
174
|
+
- test/make_amazon_question_fixture.rb
|
175
|
+
- test/make_tp_collect_fixture_1.rb
|
176
|
+
- test/make_tp_collect_fixture_2.rb
|
177
|
+
- test/make_tp_collect_fixture_3.rb
|
178
|
+
- test/make_tp_collect_fixture_4.rb
|
179
|
+
- test/make_tp_review_fixture_1.rb
|
180
|
+
- test/make_tp_review_fixture_2.rb
|
181
|
+
- test/make_transcript_chunks_fixture.rb
|
182
|
+
- test/test_integration_script_1_tp_config.rb
|
183
|
+
- test/test_integration_script_2_tp_make.rb
|
184
|
+
- test/test_integration_script_3_tp_assign.rb
|
185
|
+
- test/test_integration_script_4_tp_review.rb
|
186
|
+
- test/test_integration_script_5_tp_collect.rb
|
187
|
+
- test/test_integration_script_6_tp_finish.rb
|
188
|
+
- test/test_unit_amazon.rb
|
189
|
+
- test/test_unit_config.rb
|
190
|
+
- test/test_unit_filer.rb
|
191
|
+
- test/test_unit_project.rb
|
192
|
+
- test/test_unit_project_local.rb
|
193
|
+
- test/test_unit_project_remote.rb
|
194
|
+
- test/test_unit_template.rb
|
195
|
+
- test/test_unit_transcript.rb
|
196
|
+
has_rdoc: true
|
197
|
+
homepage: http://github.com/ryantate/typingpool
|
198
|
+
licenses: []
|
199
|
+
|
200
|
+
post_install_message:
|
201
|
+
rdoc_options: []
|
202
|
+
|
203
|
+
require_paths:
|
204
|
+
- lib
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
+
none: false
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 1.9.2
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: "0"
|
217
|
+
requirements:
|
218
|
+
- ffmpeg
|
219
|
+
- mp3splt
|
220
|
+
- mp3wrap
|
221
|
+
rubyforge_project:
|
222
|
+
rubygems_version: 1.5.0
|
223
|
+
signing_key:
|
224
|
+
specification_version: 3
|
225
|
+
summary: An app for transcribing audio using Mechanical Turk
|
226
|
+
test_files:
|
227
|
+
- test/test_unit_amazon.rb
|
228
|
+
- test/test_unit_config.rb
|
229
|
+
- test/test_unit_filer.rb
|
230
|
+
- test/test_unit_project.rb
|
231
|
+
- test/test_unit_project_local.rb
|
232
|
+
- test/test_unit_project_remote.rb
|
233
|
+
- test/test_unit_template.rb
|
234
|
+
- test/test_unit_transcript.rb
|