typingpool 0.8.11 → 0.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tp-assign +5 -4
- data/bin/tp-collect +16 -6
- data/bin/tp-finish +5 -4
- data/bin/tp-make +5 -4
- data/bin/tp-review +52 -26
- data/lib/typingpool/test.rb +4 -126
- data/lib/typingpool/test/fixtures/tp_collect_id.txt +1 -1
- data/lib/typingpool/test/fixtures/tp_collect_sandbox-assignment.csv +7 -8
- data/lib/typingpool/test/fixtures/tp_review2a_id.txt +1 -0
- data/lib/typingpool/test/fixtures/tp_review2a_sandbox-assignment.csv +7 -0
- data/lib/typingpool/test/fixtures/tp_review2b_id.txt +1 -0
- data/lib/typingpool/test/fixtures/tp_review2b_sandbox-assignment.csv +7 -0
- data/lib/typingpool/test/fixtures/tp_review3_id.txt +1 -0
- data/lib/typingpool/test/fixtures/tp_review3_sandbox-assignment.csv +7 -0
- data/lib/typingpool/test/fixtures/tp_review_id.txt +1 -1
- data/lib/typingpool/test/fixtures/tp_review_sandbox-assignment.csv +7 -8
- data/lib/typingpool/test/fixtures/vcr/tp-collect-1.yml +3176 -1814
- data/lib/typingpool/test/fixtures/vcr/tp-collect-2.yml +116 -2641
- data/lib/typingpool/test/fixtures/vcr/tp-collect-3.yml +119 -2693
- data/lib/typingpool/test/fixtures/vcr/tp-review-1.yml +353 -355
- data/lib/typingpool/test/fixtures/vcr/tp-review-2.yml +161 -242
- data/lib/typingpool/test/fixtures/vcr/tp-review-3.yml +4716 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-4.yml +741 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-5.yml +248 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-6.yml +233 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-7.yml +4479 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-8.yml +188 -0
- data/lib/typingpool/test/fixtures/vcr/tp-review-9.yml +187 -0
- data/lib/typingpool/test/script.rb +13 -320
- data/lib/typingpool/utility/test.rb +175 -0
- data/lib/typingpool/utility/test/script.rb +342 -0
- data/lib/typingpool/version.rb +1 -1
- data/test/make_amazon_question_fixture.rb +1 -1
- data/test/make_tp_collect_fixture_1.rb +18 -19
- data/test/make_tp_collect_fixture_2.rb +16 -10
- data/test/make_tp_collect_fixture_3.rb +15 -9
- data/test/make_tp_collect_fixture_4.rb +19 -11
- data/test/make_tp_collect_fixture_5.rb +25 -0
- data/test/make_tp_collect_fixture_6.rb +22 -0
- data/test/make_tp_collect_fixture_7.rb +22 -0
- data/test/make_tp_collect_fixture_8.rb +26 -0
- data/test/make_tp_review_fixture_1.rb +18 -19
- data/test/make_tp_review_fixture_2.rb +43 -24
- data/test/make_tp_review_fixture_3.rb +35 -0
- data/test/make_tp_review_fixture_4.rb +56 -0
- data/test/test_integration_script_1_tp_config.rb +7 -7
- data/test/test_integration_script_2_tp_make.rb +12 -12
- data/test/test_integration_script_3_tp_assign.rb +23 -21
- data/test/test_integration_script_4_tp_review.rb +156 -23
- data/test/test_integration_script_5_tp_collect.rb +33 -24
- data/test/test_integration_script_6_tp_finish.rb +23 -20
- data/test/test_unit_amazon.rb +4 -2
- data/test/test_unit_filer.rb +6 -6
- data/test/test_unit_project.rb +2 -2
- data/test/test_unit_project_local.rb +2 -2
- data/test/test_unit_project_remote.rb +3 -1
- data/test/test_unit_template.rb +6 -6
- data/test/test_unit_test.rb +3 -3
- metadata +23 -3
- data/lib/typingpool/app/test.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7f1162da9010eea09066f72b78c40eacc342d34
|
4
|
+
data.tar.gz: 4243222ed91a427012291a3be392ca5de6d5bc70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982e426847cad2182163ab13d8832e70f64c84ee6f2ffe3bdcc712c346d8655cda67eb8c116fe22a761010f0e780f0c62c9fe9e76eacffe4d2abf8517ee50686
|
7
|
+
data.tar.gz: 063621305ccb40f636fd1f8234bf5f97d7584ff81d62220bc47c64ce30e259be8e6278ed773828c078f8980f9d88c8ef074adbe645c0e916eff34cdfb99d7d4d
|
data/bin/tp-assign
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'typingpool'
|
5
|
+
require 'typingpool/utility/test'
|
5
6
|
require 'highline/import'
|
6
7
|
include Typingpool::App::FriendlyExceptions
|
7
8
|
include Typingpool::App::CLI::Formatter
|
9
|
+
include Typingpool::Utility::Test
|
8
10
|
|
9
11
|
options = {
|
10
12
|
:keyword => [],
|
@@ -97,7 +99,6 @@ OptionParser.new do |opts|
|
|
97
99
|
opts.on('--testfixture=PATH',
|
98
100
|
'For testing purposes only. Ignore.',
|
99
101
|
'A VCR fixture for running with mock data.') do |fixture|
|
100
|
-
require 'typingpool/app/test'
|
101
102
|
options[:fixture] = fixture
|
102
103
|
end
|
103
104
|
|
@@ -214,11 +215,11 @@ STDERR.puts "#{needed_assignments.count} assignments to assign"
|
|
214
215
|
Typingpool::Amazon.setup(:sandbox => options[:sandbox], :config => config)
|
215
216
|
|
216
217
|
if options[:fixture]
|
217
|
-
|
218
|
+
vcr_load(options[:fixture], config, not(options[:fixturerecord]), {
|
218
219
|
:preserve_exact_body_bytes => true,
|
219
|
-
:match_requests_on => [:method,
|
220
|
+
:match_requests_on => [:method, vcr_core_host_matcher]
|
220
221
|
})
|
221
|
-
at_exit{
|
222
|
+
at_exit{ vcr_stop }
|
222
223
|
end
|
223
224
|
|
224
225
|
#Are there enough funds for this assignment?
|
data/bin/tp-collect
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'typingpool'
|
4
4
|
require 'optparse'
|
5
|
+
require 'typingpool/utility/test'
|
6
|
+
include Typingpool::Utility::Test
|
5
7
|
|
6
8
|
options = {}
|
7
9
|
OptionParser.new do |commands|
|
@@ -15,12 +17,19 @@ OptionParser.new do |commands|
|
|
15
17
|
"A config file") do |path|
|
16
18
|
options[:config] = path
|
17
19
|
end
|
18
|
-
commands.on('--
|
19
|
-
"
|
20
|
+
commands.on('--testfixture=PATH',
|
21
|
+
"For testing purposes only. Ignore.",
|
20
22
|
"A VCR ficture for running with mock data.") do |fixture|
|
21
|
-
require 'typingpool/app/test'
|
22
23
|
options[:fixture] = fixture
|
23
24
|
end
|
25
|
+
|
26
|
+
commands.on('--testfixturerecord',
|
27
|
+
'For testing purposes only. Ignore.',
|
28
|
+
'Allows recording of a new fixture',
|
29
|
+
'to --testfixture path.') do
|
30
|
+
options[:fixturerecord] = true
|
31
|
+
end
|
32
|
+
|
24
33
|
commands.on('--help',
|
25
34
|
"Display this screen") do
|
26
35
|
STDERR.puts commands
|
@@ -31,14 +40,15 @@ end.parse!
|
|
31
40
|
config = Typingpool::App::CLI.config_from_arg(options[:config]) or abort "No config file at '#{options[:config]}'"
|
32
41
|
|
33
42
|
if options[:fixture]
|
34
|
-
|
35
|
-
|
43
|
+
vcr_load(options[:fixture], config, not(options[:fixturerecord]), {
|
44
|
+
|
45
|
+
})
|
46
|
+
at_exit{ vcr_stop }
|
36
47
|
end
|
37
48
|
|
38
49
|
STDERR.puts "Collecting results from Amazon"
|
39
50
|
Typingpool::Amazon.setup(:sandbox => options[:sandbox], :config => config)
|
40
51
|
hits = Typingpool::Amazon::HIT.all_approved
|
41
|
-
|
42
52
|
STDERR.puts "Looking for local project folders to receive results" unless hits.empty?
|
43
53
|
Typingpool::App.find_projects_waiting_for_hits(hits, config) do |project, hits|
|
44
54
|
assignments_file = Typingpool::App.assignments_file_for_sandbox_status(options[:sandbox], project)
|
data/bin/tp-finish
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'typingpool'
|
5
5
|
require 'fileutils'
|
6
|
+
require 'typingpool/utility/test'
|
7
|
+
include Typingpool::Utility::Test
|
6
8
|
|
7
9
|
options = {}
|
8
10
|
OptionParser.new do |commands|
|
@@ -31,7 +33,6 @@ OptionParser.new do |commands|
|
|
31
33
|
commands.on('--testfixture=PATH',
|
32
34
|
'For testing purposes only. Ignore.',
|
33
35
|
'A VCR fixture for running with mock data.') do |fixture|
|
34
|
-
require 'typingpool/app/test'
|
35
36
|
options[:fixture] = fixture
|
36
37
|
end
|
37
38
|
|
@@ -65,11 +66,11 @@ end
|
|
65
66
|
|
66
67
|
Typingpool::Amazon.setup(:sandbox => options[:sandbox], :config => config)
|
67
68
|
if options[:fixture]
|
68
|
-
|
69
|
+
vcr_load(options[:fixture], config, not(options[:fixturerecord]), {
|
69
70
|
:preserve_exact_body_bytes => true,
|
70
|
-
:match_requests_on => [:method,
|
71
|
+
:match_requests_on => [:method, vcr_core_host_matcher]
|
71
72
|
})
|
72
|
-
at_exit{
|
73
|
+
at_exit{ vcr_stop }
|
73
74
|
end
|
74
75
|
STDERR.puts "Removing from Amazon"
|
75
76
|
STDERR.puts " Collecting all results"
|
data/bin/tp-make
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'typingpool'
|
5
|
+
require 'typingpool/utility/test'
|
5
6
|
require 'fileutils'
|
6
7
|
require 'tempfile'
|
7
8
|
require 'tmpdir'
|
8
9
|
include Typingpool::App::FriendlyExceptions
|
10
|
+
include Typingpool::Utility::Test
|
9
11
|
|
10
12
|
options = {
|
11
13
|
:files => [],
|
@@ -88,7 +90,6 @@ OptionParser.new do |opts|
|
|
88
90
|
opts.on('--testfixture=PATH',
|
89
91
|
'For testing purposes only. Ignore.',
|
90
92
|
'A VCR fixture for running with mock data.') do |fixture|
|
91
|
-
require 'typingpool/app/test'
|
92
93
|
options[:fixture] = fixture
|
93
94
|
end
|
94
95
|
|
@@ -194,14 +195,14 @@ else
|
|
194
195
|
end #if project.local
|
195
196
|
|
196
197
|
unless options[:noupload]
|
197
|
-
|
198
|
+
vcr_load(options[:fixture], config, not(options[:fixturerecord]), {
|
198
199
|
:preserve_exact_body_bytes => true,
|
199
|
-
:match_requests_on => [:method,
|
200
|
+
:match_requests_on => [:method, vcr_core_host_matcher]
|
200
201
|
}) if options[:fixture]
|
201
202
|
Typingpool::App.upload_audio_for_project(project) do |file, as|
|
202
203
|
STDERR.puts "Uploading #{File.basename(file)} to #{project.remote.host}/#{project.remote.path} as #{as}"
|
203
204
|
end
|
204
|
-
|
205
|
+
vcr_stop if options [:fixture]
|
205
206
|
end
|
206
207
|
|
207
208
|
if STDOUT.tty? && Typingpool::Utility.os_x?
|
data/bin/tp-review
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'typingpool'
|
4
|
+
require 'typingpool/utility/test'
|
4
5
|
require 'highline/import'
|
5
6
|
require 'optparse'
|
6
7
|
include Typingpool::App::CLI::Formatter
|
8
|
+
include Typingpool::Utility::Test
|
7
9
|
|
8
10
|
options = {}
|
9
11
|
OptionParser.new do |commands|
|
@@ -26,12 +28,19 @@ OptionParser.new do |commands|
|
|
26
28
|
'Test in Mechanical Turk\'s sandbox') do |sandbox|
|
27
29
|
options[:sandbox] = true
|
28
30
|
end
|
29
|
-
commands.on('--
|
30
|
-
"
|
31
|
-
"A VCR
|
32
|
-
|
31
|
+
commands.on('--testfixture=PATH',
|
32
|
+
"For testing purposes only. Ignore.",
|
33
|
+
"A VCR ficture for running with mock data.",
|
34
|
+
"Path should NOT include file extension, e.g. '.yml'") do |fixture|
|
33
35
|
options[:fixture] = fixture
|
34
36
|
end
|
37
|
+
|
38
|
+
commands.on('--testfixturerecord',
|
39
|
+
'For testing purposes only. Ignore.',
|
40
|
+
'Allows recording of a new fixture',
|
41
|
+
'to --testfixture path.') do
|
42
|
+
options[:fixturerecord] = true
|
43
|
+
end
|
35
44
|
commands.on('--help',
|
36
45
|
"Display this screen") do
|
37
46
|
STDERR.puts commands
|
@@ -55,8 +64,8 @@ if options[:project]
|
|
55
64
|
end
|
56
65
|
|
57
66
|
if options[:fixture]
|
58
|
-
|
59
|
-
at_exit{
|
67
|
+
vcr_load(options[:fixture], config, not(options[:fixturerecord]))
|
68
|
+
at_exit{ vcr_stop }
|
60
69
|
end
|
61
70
|
|
62
71
|
Typingpool::Amazon.setup(:sandbox => options[:sandbox], :config => config)
|
@@ -64,29 +73,47 @@ Typingpool::Amazon.setup(:sandbox => options[:sandbox], :config => config)
|
|
64
73
|
assignments = Typingpool::App.assignments_file_for_sandbox_status(options[:sandbox], options[:project]) if options[:project]
|
65
74
|
STDERR.puts "Gathering submissions from Amazon"
|
66
75
|
hits = if options[:project] && ((hit_ids = assignments.map{|assignment| assignment['hit_id'] }.select{|hit_id| hit_id }).count > 0)
|
67
|
-
Typingpool::Amazon::HIT.with_ids(hit_ids).select{|hit| hit.submitted? }
|
76
|
+
Typingpool::Amazon::HIT.with_ids(hit_ids).select{|hit| hit.submitted? || hit.approved? }
|
68
77
|
else
|
69
|
-
hits = Typingpool::Amazon::HIT.all_reviewable{|hit| hit.submitted? && hit.ours? }
|
78
|
+
hits = Typingpool::Amazon::HIT.all_reviewable{|hit| (hit.submitted? || hit.approved?) && hit.ours? }
|
70
79
|
if options[:project]
|
71
80
|
#code path for projects assigned through RUI
|
72
81
|
hits.select!{|hit| hit.project_id == options[:project].local.id }
|
73
82
|
end
|
74
83
|
hits
|
75
84
|
end
|
76
|
-
|
77
85
|
STDERR.puts "Matching submissions with local projects"
|
86
|
+
project_with_hits_needing_decision = []
|
87
|
+
hits_needing_decision_count = 0
|
88
|
+
Typingpool::App.find_projects_waiting_for_hits(hits, config).each do |project_with_hits|
|
89
|
+
hits = project_with_hits[:hits]
|
90
|
+
project = project_with_hits[:project]
|
91
|
+
assignments = Typingpool::App.assignments_file_for_sandbox_status(options[:sandbox], project)
|
92
|
+
hits.sort!{|a, b| a.url <=> b.url }
|
93
|
+
hits_needing_decision=[]
|
94
|
+
hits.each do |hit|
|
95
|
+
if hit.approved?
|
96
|
+
#collect auto-approved hits so people don't have to run tp-collect
|
97
|
+
Typingpool::App.record_approved_hits_in_assignments_file(assignments, [hit])
|
98
|
+
Typingpool::App.create_transcript(project, assignments)
|
99
|
+
else
|
100
|
+
hits_needing_decision.push(hit)
|
101
|
+
hits_needing_decision_count += 1
|
102
|
+
end
|
103
|
+
end #hits.each do...
|
104
|
+
if hits_needing_decision.count > 0
|
105
|
+
project_with_hits_needing_decision.push({project: project, hits: hits_needing_decision})
|
106
|
+
end
|
107
|
+
end #Typingpool::App::find_projects_waiting_for_hits.each do ...
|
78
108
|
choices = %w(approve reject quit skip)
|
109
|
+
hits_decided_count = 0
|
79
110
|
catch :quitting do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
project_hits.each do |hash|
|
84
|
-
hits = hash[:hits]
|
85
|
-
project = hash[:project]
|
111
|
+
project_with_hits_needing_decision.each do |project_with_hits|
|
112
|
+
hits = project_with_hits[:hits]
|
113
|
+
project = project_with_hits[:project]
|
86
114
|
assignments = Typingpool::App.assignments_file_for_sandbox_status(options[:sandbox], project)
|
87
|
-
hits.sort!{|a, b| a.url <=> b.url }
|
88
115
|
hits.each do |hit|
|
89
|
-
|
116
|
+
hits_decided_count += 1
|
90
117
|
say(cli_bold("\nTranscript for: ") + hit.url)
|
91
118
|
project_info = cli_bold("Project: ") + project.name
|
92
119
|
if project.local.subtitle
|
@@ -106,8 +133,8 @@ catch :quitting do
|
|
106
133
|
prompt << cli_reverse('[') + prompt.pop + cli_reverse(']')
|
107
134
|
prompt = prompt.join(cli_reverse(', '))
|
108
135
|
prompt += cli_reverse('? ')
|
109
|
-
prompt += cli_reverse("(#{
|
110
|
-
|
136
|
+
prompt += cli_reverse("(#{hits_decided_count}/#{hits_needing_decision_count}) ")
|
137
|
+
|
111
138
|
choice=nil
|
112
139
|
until choice
|
113
140
|
input = ask(prompt)
|
@@ -117,15 +144,15 @@ catch :quitting do
|
|
117
144
|
say("Invalid selection '#{input}'.")
|
118
145
|
end
|
119
146
|
end #until choice
|
120
|
-
|
147
|
+
|
121
148
|
case choice
|
122
149
|
when 'approve'
|
123
150
|
begin
|
124
151
|
hit.assignment.at_amazon.approve!
|
125
152
|
rescue RTurk::InvalidRequest => exception
|
126
|
-
|
127
|
-
|
128
|
-
|
153
|
+
#assignment may have passed its approval deadline since
|
154
|
+
#the session started and has been auto approved. In that
|
155
|
+
#case, add to the transcript; no need to tell the user.
|
129
156
|
unless exception.message.match(/AWS.MechanicalTurk.InvalidAssignmentState\b.+\bstatus of:\s*Submitted/i)
|
130
157
|
#different issue than auto approval; raise exception
|
131
158
|
raise exception
|
@@ -161,9 +188,8 @@ catch :quitting do
|
|
161
188
|
say(cli_bold("Skipping\n"))
|
162
189
|
next
|
163
190
|
end #case choice
|
164
|
-
end #hits.
|
165
|
-
|
166
|
-
end #find_projects_waiting_for(...) do
|
191
|
+
end #hits.each do....
|
192
|
+
end # project_with_hits_needing_decision.each do
|
167
193
|
end #catch :quitting do
|
168
194
|
|
169
195
|
#Put project path on STDOUT so script can be pipelined, e.g.
|
data/lib/typingpool/test.rb
CHANGED
@@ -1,71 +1,18 @@
|
|
1
1
|
module Typingpool
|
2
2
|
require 'minitest'
|
3
|
-
require 'typingpool/
|
4
|
-
|
3
|
+
require 'typingpool/utility/test'
|
4
|
+
|
5
5
|
class Test < Minitest::Test
|
6
|
+
include Utility::Test
|
7
|
+
|
6
8
|
class << self
|
7
9
|
attr_accessor :live
|
8
10
|
attr_accessor :record
|
9
|
-
|
10
|
-
def app_dir
|
11
|
-
Utility.app_dir
|
12
|
-
end
|
13
|
-
|
14
11
|
end #class << self
|
15
12
|
|
16
13
|
self.record = ARGV.delete('--record')
|
17
14
|
self.live = ARGV.delete('--live')
|
18
15
|
|
19
|
-
def fixtures_dir
|
20
|
-
File.join(Utility.lib_dir, 'test', 'fixtures')
|
21
|
-
end
|
22
|
-
|
23
|
-
def audio_dir
|
24
|
-
File.join(fixtures_dir, 'audio')
|
25
|
-
end
|
26
|
-
|
27
|
-
def vcr_dir
|
28
|
-
File.join(fixtures_dir, 'vcr')
|
29
|
-
end
|
30
|
-
|
31
|
-
def delete_vcr_fixture(fixture_name)
|
32
|
-
fixture_path = File.join(vcr_dir, [fixture_name, '.yml'].join)
|
33
|
-
File.delete(fixture_path) if File.exist? fixture_path
|
34
|
-
end
|
35
|
-
|
36
|
-
def cleared_vcr_fixture_path_for(fixture_name)
|
37
|
-
if Typingpool::Test.record
|
38
|
-
delete_vcr_fixture(fixture_name)
|
39
|
-
end
|
40
|
-
if (Typingpool::Test.record || not(Typingpool::Test.live))
|
41
|
-
File.join(vcr_dir, fixture_name)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def with_vcr(fixture_name, config, opts={})
|
46
|
-
if fixture = cleared_vcr_fixture_path_for(fixture_name)
|
47
|
-
read_only = not(Typingpool::Test.record)
|
48
|
-
Typingpool::App.vcr_load(fixture, config, read_only, opts)
|
49
|
-
end
|
50
|
-
begin
|
51
|
-
yield
|
52
|
-
ensure
|
53
|
-
Typingpool::App.vcr_stop
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def config
|
58
|
-
if File.exist?(File.expand_path(Config.default_file))
|
59
|
-
Config.file
|
60
|
-
else
|
61
|
-
Config.from_bundled_template
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def amazon_credentials?(config=self.config)
|
66
|
-
config.amazon && config.amazon.key && config.amazon.secret
|
67
|
-
end
|
68
|
-
|
69
16
|
def skip_with_message(reason, skipping_what='')
|
70
17
|
skipping_what = " #{skipping_what}" unless skipping_what.empty?
|
71
18
|
skip ("Skipping#{skipping_what}: #{reason}")
|
@@ -78,10 +25,6 @@ module Typingpool
|
|
78
25
|
end
|
79
26
|
end
|
80
27
|
|
81
|
-
def s3_credentials?(config)
|
82
|
-
amazon_credentials?(config) && config.amazon.bucket
|
83
|
-
end
|
84
|
-
|
85
28
|
def skip_if_no_s3_credentials(skipping_what='', config=self.config)
|
86
29
|
if not (skip_if_no_amazon_credentials(skipping_what, config))
|
87
30
|
if not(s3_credentials?(config))
|
@@ -90,10 +33,6 @@ module Typingpool
|
|
90
33
|
end #if not(skip_if_no_amazon_credentials...)
|
91
34
|
end
|
92
35
|
|
93
|
-
def sftp_credentials?(config)
|
94
|
-
config.sftp && config.sftp.user && config.sftp.host && config.sftp.url
|
95
|
-
end
|
96
|
-
|
97
36
|
def skip_if_no_sftp_credentials(skipping_what='', config=self.config)
|
98
37
|
if not(sftp_credentials?(config))
|
99
38
|
skip_with_message('No SFTP credentials', skipping_what)
|
@@ -110,67 +49,6 @@ module Typingpool
|
|
110
49
|
end #if not(s3_credentials?...
|
111
50
|
end
|
112
51
|
|
113
|
-
def add_goodbye_message(msg)
|
114
|
-
at_exit do
|
115
|
-
STDERR.puts msg
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def dummy_config(number=1)
|
120
|
-
Typingpool::Config.file(File.join(fixtures_dir, "config-#{number}"))
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
def project_default
|
125
|
-
Hash[
|
126
|
-
:config_filename => '.config',
|
127
|
-
:subtitle => "Typingpool's test interview transcription",
|
128
|
-
:title => "Typingpool's Test & Interview",
|
129
|
-
:chunks => '0:22',
|
130
|
-
:unusual => ['Hack Day', 'Sunnyvale', 'Chad D'],
|
131
|
-
:voice => ['Ryan', 'Havi, hacker'],
|
132
|
-
]
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
def in_temp_dir
|
137
|
-
Typingpool::Utility.in_temp_dir{|dir| yield(dir) }
|
138
|
-
end
|
139
|
-
|
140
|
-
def working_url?(*args)
|
141
|
-
Typingpool::Utility.working_url?(*args)
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
def works_eventually?(max_seconds=10, min_tries=2)
|
146
|
-
start = Time.now.to_i
|
147
|
-
tries = 0
|
148
|
-
wait = 0
|
149
|
-
until ((tries >= min_tries) && ((Time.now.to_i + wait - start) >= max_seconds)) do
|
150
|
-
sleep wait
|
151
|
-
return true if yield
|
152
|
-
wait = wait > 0 ? wait * 2 : 1
|
153
|
-
tries += 1
|
154
|
-
end
|
155
|
-
false
|
156
|
-
end
|
157
|
-
|
158
|
-
def working_url_eventually?(url, max_seconds=10, min_tries=2, max_redirects=6)
|
159
|
-
works_eventually?(max_seconds, min_tries) do
|
160
|
-
working_url?(url, max_redirects)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def broken_url_eventually?(url, max_seconds=10, min_tries=2, max_redirects=6)
|
165
|
-
works_eventually?(max_seconds, min_tries) do
|
166
|
-
not(working_url?(url, max_redirects))
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def fetch_url(*args)
|
171
|
-
Typingpool::Utility.fetch_url(*args)
|
172
|
-
end
|
173
|
-
|
174
52
|
require 'typingpool/test/script'
|
175
53
|
end #Test
|
176
54
|
end #Typingpool
|