osaka 0.4.10 → 0.4.11
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 +4 -4
- data/lib/osaka/mailmergeflow.rb +4 -4
- data/lib/osaka/numbers.rb +13 -13
- data/lib/osaka/pages.rb +2 -2
- data/lib/osaka/remotecontrol.rb +12 -0
- data/lib/osaka/scriptrunner.rb +14 -14
- data/lib/osaka/typicalapplication.rb +47 -37
- data/lib/osaka/version.rb +1 -1
- data/spec/integration_numbers_spec.rb +5 -5
- data/spec/integration_pages_spec.rb +24 -0
- data/spec/launchservices_spec.rb +2 -2
- data/spec/numbers_spec.rb +15 -15
- data/spec/osakaexpectations_spec.rb +2 -2
- data/spec/pages_spec.rb +17 -17
- data/spec/typicalapplication_spec.rb +15 -5
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3c3111ee1c6b444321590382e2bca76f4341c674
|
|
4
|
+
data.tar.gz: ab4b79b6eb693de745f8b0d13014301217aba48e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6925989beb9445a8356c78d08adef696fdf63a98e9f6193e8803b48cf5ca6993328e876812a3d0f77f8b1c96a0995a6868e56a6f2382dadde21fffcfdb10e35c
|
|
7
|
+
data.tar.gz: 14554cb5bc06dbff9e95779a0f1651ce176582f0bbdc3c76b0765db757349239506311f09cc46835ef73a2b55155e71140ae9a7d643ac327127c70f2d3c40a4e
|
data/lib/osaka/mailmergeflow.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
module CommonFlows
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
def self.number_and_pages_mail_merge(numbers_file, pages_file, output_file)
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
if block_given?
|
|
7
7
|
Osaka::Numbers.create_document(numbers_file) { |numbers|
|
|
8
|
-
yield numbers
|
|
9
|
-
}
|
|
8
|
+
yield numbers
|
|
9
|
+
}
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
pages = Osaka::Pages.new
|
data/lib/osaka/numbers.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
module Osaka
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
class Location
|
|
5
5
|
def cell(name)
|
|
6
6
|
create_location_with_added_name("cell", name)
|
|
@@ -10,44 +10,44 @@ module Osaka
|
|
|
10
10
|
create_location_with_added_name("table", name)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
class Numbers < TypicalApplication
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def initialize
|
|
17
17
|
super "Numbers"
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def new_document
|
|
21
21
|
super
|
|
22
|
-
control.set_current_window(
|
|
22
|
+
control.set_current_window(do_and_wait_for_new_standard_window {
|
|
23
23
|
control.keystroke(:return)
|
|
24
24
|
})
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def self.create_document(filename, &block)
|
|
28
28
|
numbers = Osaka::Numbers.new
|
|
29
29
|
numbers.create_document(filename, &block)
|
|
30
30
|
end
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
def fill_cell(column, row, value)
|
|
33
33
|
if (column > column_count)
|
|
34
34
|
set_column_count(column)
|
|
35
35
|
end
|
|
36
36
|
control.tell("tell document 1; tell sheet 1; tell table 1; set value of cell #{column} of row #{row} to \"#{value}\"; end tell; end tell; end tell")
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
def column_count
|
|
40
40
|
control.tell("tell document 1; tell sheet 1; tell table 1; get column count; end tell; end tell; end tell").to_i
|
|
41
41
|
end
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
def set_column_count(amount)
|
|
44
44
|
control.tell("tell document 1; tell sheet 1; tell table 1; set column count to #{amount}; end tell; end tell; end tell")
|
|
45
|
-
end
|
|
46
|
-
|
|
45
|
+
end
|
|
46
|
+
|
|
47
47
|
def set_header_columns(column)
|
|
48
48
|
control.click_menu_bar(at.menu_item(column.to_s).menu(1).menu_item("Header Columns"), "Table")
|
|
49
49
|
end
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
|
|
51
|
+
|
|
52
52
|
end
|
|
53
53
|
end
|
data/lib/osaka/pages.rb
CHANGED
|
@@ -89,8 +89,8 @@ module Osaka
|
|
|
89
89
|
|
|
90
90
|
def new_document
|
|
91
91
|
super
|
|
92
|
-
if control.
|
|
93
|
-
control.set_current_window(
|
|
92
|
+
if control.window_list.include? "Template Chooser"
|
|
93
|
+
control.set_current_window(do_and_wait_for_new_standard_window {
|
|
94
94
|
control.click(at.button("Choose").window("Template Chooser"))
|
|
95
95
|
})
|
|
96
96
|
end
|
data/lib/osaka/remotecontrol.rb
CHANGED
|
@@ -11,6 +11,16 @@ module Osaka
|
|
|
11
11
|
attr_reader :name
|
|
12
12
|
attr_accessor :base_location
|
|
13
13
|
|
|
14
|
+
@@debug_info_enabled = false
|
|
15
|
+
|
|
16
|
+
def self.enable_debug_prints
|
|
17
|
+
@@debug_info_enabled = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def debug_print(message)
|
|
21
|
+
puts message if @@debug_info_enabled
|
|
22
|
+
end
|
|
23
|
+
|
|
14
24
|
def initialize(name, base_location = Location.new(""))
|
|
15
25
|
@name = name
|
|
16
26
|
@base_location = base_location
|
|
@@ -89,6 +99,7 @@ module Osaka
|
|
|
89
99
|
|
|
90
100
|
def wait_until_exists!(*locations, &action)
|
|
91
101
|
wait_until(locations, action) { |location|
|
|
102
|
+
debug_print "Waiting until exists: #{location.to_s} on remote #{current_window_name.to_s}"
|
|
92
103
|
exists?(location)
|
|
93
104
|
}
|
|
94
105
|
end
|
|
@@ -219,6 +230,7 @@ module Osaka
|
|
|
219
230
|
end
|
|
220
231
|
|
|
221
232
|
def set_current_window(window_name)
|
|
233
|
+
debug_print "Changing remote base location to: #{window_name}"
|
|
222
234
|
@base_location = at.window(window_name)
|
|
223
235
|
end
|
|
224
236
|
|
data/lib/osaka/scriptrunner.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Osaka
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
class ScriptRunnerError < RuntimeError
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
class TimeoutError < RuntimeError
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
class VersioningError < RuntimeError
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
module ScriptRunner
|
|
15
15
|
|
|
16
16
|
@@debug_info_enabled = false
|
|
@@ -40,36 +40,36 @@ module Osaka
|
|
|
40
40
|
File.open(@@debug_info_script_filename, File::WRONLY|File::APPEND|File::CREAT, 0755) { |file|
|
|
41
41
|
file.puts("osascript#{escaped_commands}")
|
|
42
42
|
}
|
|
43
|
-
end
|
|
43
|
+
end
|
|
44
44
|
puts debug_output
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
def self.print_debug_info_for_additional_output(output)
|
|
49
49
|
if (!output.empty? && debug_prints?)
|
|
50
50
|
if (@@debug_info_format == :plain_text)
|
|
51
51
|
debug_output = "Output was: #{output}"
|
|
52
52
|
elsif (@@debug_info_format == :short_html)
|
|
53
53
|
debug_output = "Output: <b>#{output}</b><br>"
|
|
54
|
-
end
|
|
54
|
+
end
|
|
55
55
|
puts debug_output
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
def self.execute(applescript)
|
|
60
60
|
script_commands = applescript.gsub("\"", "\\\"").split(';')
|
|
61
|
-
escaped_commands = ""
|
|
62
|
-
script_commands.each { |l|
|
|
61
|
+
escaped_commands = ""
|
|
62
|
+
script_commands.each { |l|
|
|
63
63
|
escaped_commands += " -e \"#{l.strip}\""
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
print_debug_info_for_escaped_commands(applescript, escaped_commands)
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
output = ""
|
|
69
69
|
begin
|
|
70
70
|
output = CommandRunner::run("osascript#{escaped_commands}")
|
|
71
71
|
rescue Osaka::SystemCommandFailed => ex
|
|
72
|
-
if ex.message =~ /assistive devices/
|
|
72
|
+
if ex.message =~ /assistive devices/
|
|
73
73
|
puts <<-eom
|
|
74
74
|
Osaka execution failed with the error: #{ex.message}
|
|
75
75
|
The reason for this is probably that you didn't enable the acess for assistive devices.
|
|
@@ -78,7 +78,7 @@ module Osaka
|
|
|
78
78
|
system preferences -> Accessibility -> Enable access for assistive devices
|
|
79
79
|
If you are under snow leopard, it is under:
|
|
80
80
|
system preferences -> Universal Access -> Enable access for assistive devices
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
Osaka will not continue as it won't work without this enabled. Please enable it and re-run.
|
|
83
83
|
eom
|
|
84
84
|
exit
|
|
@@ -88,8 +88,8 @@ module Osaka
|
|
|
88
88
|
end
|
|
89
89
|
print_debug_info_for_additional_output(output)
|
|
90
90
|
output
|
|
91
|
-
end
|
|
92
|
-
|
|
91
|
+
end
|
|
92
|
+
|
|
93
93
|
def self.execute_file(scriptName, parameters = "")
|
|
94
94
|
CommandRunner::run("osascript #{scriptName} #{parameters}".strip)
|
|
95
95
|
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module Osaka
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
class ApplicationInfo
|
|
5
5
|
|
|
6
6
|
attr_reader :name
|
|
7
7
|
|
|
8
8
|
def initialize(script_info)
|
|
9
9
|
@name = script_info.match(/name:(.+?), creation date/)[1]
|
|
10
|
-
end
|
|
10
|
+
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
class ApplicationWindowsMustBeClosed < StandardError
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
class TypicalApplication
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
attr_accessor :control
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def initialize(name)
|
|
21
21
|
@name = name
|
|
22
22
|
@control = RemoteControl.new(name)
|
|
23
23
|
end
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
def initialize_copy(other)
|
|
26
26
|
super
|
|
27
27
|
@control = other.control.clone
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def get_info
|
|
31
31
|
script_info = control.tell("get info for (path to application \"#{@name}\")")
|
|
32
32
|
ApplicationInfo.new(script_info)
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
def open (filename)
|
|
36
36
|
abolutePathFileName = File.absolute_path(filename)
|
|
37
|
-
new_window =
|
|
37
|
+
new_window = do_and_wait_for_new_standard_window {
|
|
38
38
|
control.tell("open \"#{abolutePathFileName}\"")
|
|
39
39
|
}
|
|
40
40
|
control.set_current_window(new_window)
|
|
@@ -55,13 +55,13 @@ module Osaka
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
def close_dialog_sheet_with_dont_save
|
|
60
60
|
if (control.exists?(at.sheet(1)))
|
|
61
61
|
control.click!(at.button("Don’t Save").sheet(1))
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
def quit(option = :user_chose)
|
|
66
66
|
if control.running?
|
|
67
67
|
control.quit
|
|
@@ -78,55 +78,65 @@ module Osaka
|
|
|
78
78
|
end
|
|
79
79
|
(latest_window_list - original_window_list)[0]
|
|
80
80
|
end
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
def do_and_wait_for_new_standard_window
|
|
83
|
+
control.activate
|
|
84
|
+
latest_window_list = original_window_list = control.standard_window_list
|
|
85
|
+
yield
|
|
86
|
+
while ((latest_window_list - original_window_list).size == 0)
|
|
87
|
+
latest_window_list = control.standard_window_list
|
|
88
|
+
end
|
|
89
|
+
(latest_window_list - original_window_list)[0]
|
|
90
|
+
end
|
|
91
|
+
|
|
82
92
|
def new_document
|
|
83
|
-
control.set_current_window(
|
|
93
|
+
control.set_current_window(do_and_wait_for_new_standard_window {
|
|
84
94
|
control.keystroke("n", :command)
|
|
85
95
|
})
|
|
86
96
|
control.focus
|
|
87
97
|
end
|
|
88
|
-
|
|
98
|
+
|
|
89
99
|
def create_document(filename)
|
|
90
100
|
new_document
|
|
91
101
|
yield self
|
|
92
102
|
save_as(filename)
|
|
93
103
|
close
|
|
94
104
|
end
|
|
95
|
-
|
|
105
|
+
|
|
96
106
|
def duplicate_available?
|
|
97
107
|
control.exists?(at.menu_item("Duplicate").menu(1).menu_bar_item("File").menu_bar(1))
|
|
98
108
|
end
|
|
99
|
-
|
|
109
|
+
|
|
100
110
|
def duplicate
|
|
101
111
|
unless duplicate_available?
|
|
102
112
|
raise(Osaka::VersioningError, "MacOS Versioning Error: Duplicate is not available on this Mac version")
|
|
103
113
|
end
|
|
104
|
-
|
|
114
|
+
do_and_wait_for_new_standard_window {
|
|
105
115
|
control.click_menu_bar(at.menu_item("Duplicate"), "File")
|
|
106
116
|
}
|
|
107
117
|
new_instance = clone
|
|
108
|
-
new_instance.control.set_current_window(
|
|
118
|
+
new_instance.control.set_current_window(do_and_wait_for_new_standard_window {
|
|
109
119
|
sleep(0.4) # This sleep is added because mountain lion keynote crashes without it!
|
|
110
120
|
control.keystroke!(:return)
|
|
111
121
|
}) unless control.mac_version == :lion
|
|
112
|
-
|
|
122
|
+
|
|
113
123
|
new_instance
|
|
114
124
|
end
|
|
115
|
-
|
|
125
|
+
|
|
116
126
|
def duplicate_and_close_original
|
|
117
|
-
new_instance = duplicate
|
|
118
|
-
close
|
|
127
|
+
new_instance = duplicate
|
|
128
|
+
close
|
|
119
129
|
@control = new_instance.control
|
|
120
130
|
end
|
|
121
|
-
|
|
131
|
+
|
|
122
132
|
def save
|
|
123
133
|
control.keystroke("s", :command)
|
|
124
134
|
end
|
|
125
|
-
|
|
135
|
+
|
|
126
136
|
def save_pops_up_dialog?
|
|
127
137
|
control.exists?(at.menu_item("Save…").menu(1).menu_bar_item("File").menu_bar(1))
|
|
128
138
|
end
|
|
129
|
-
|
|
139
|
+
|
|
130
140
|
def save_as(filename)
|
|
131
141
|
if save_pops_up_dialog?
|
|
132
142
|
save
|
|
@@ -138,37 +148,37 @@ module Osaka
|
|
|
138
148
|
control.keystroke("s", [:command, :shift])
|
|
139
149
|
end
|
|
140
150
|
end
|
|
141
|
-
|
|
142
|
-
wait_for_save_dialog_and_save_file(filename)
|
|
151
|
+
|
|
152
|
+
wait_for_save_dialog_and_save_file(filename)
|
|
143
153
|
end
|
|
144
|
-
|
|
154
|
+
|
|
145
155
|
def wait_for_save_dialog_and_save_file(filename)
|
|
146
156
|
control.wait_until_exists(at.sheet(1))
|
|
147
157
|
dialog = create_dialog(TypicalSaveDialog, at.sheet(1))
|
|
148
158
|
dialog.save(filename)
|
|
149
159
|
control.set_current_window(File.basename(filename))
|
|
150
160
|
end
|
|
151
|
-
|
|
161
|
+
|
|
152
162
|
def close(option = :user_chose)
|
|
153
163
|
control.keystroke("w", :command)
|
|
154
164
|
wait_for_window_and_dialogs_to_close(option)
|
|
155
165
|
end
|
|
156
|
-
|
|
166
|
+
|
|
157
167
|
def activate
|
|
158
168
|
if (control.mac_version == :lion)
|
|
159
|
-
control.launch unless control.running?
|
|
169
|
+
control.launch unless control.running?
|
|
160
170
|
end
|
|
161
171
|
control.activate
|
|
162
172
|
end
|
|
163
|
-
|
|
173
|
+
|
|
164
174
|
def focus
|
|
165
175
|
control.focus
|
|
166
176
|
end
|
|
167
|
-
|
|
177
|
+
|
|
168
178
|
def running?
|
|
169
179
|
control.running?
|
|
170
180
|
end
|
|
171
|
-
|
|
181
|
+
|
|
172
182
|
def copy
|
|
173
183
|
control.keystroke("c", :command)
|
|
174
184
|
end
|
|
@@ -184,22 +194,22 @@ module Osaka
|
|
|
184
194
|
def select_all
|
|
185
195
|
control.keystroke("a", :command)
|
|
186
196
|
end
|
|
187
|
-
|
|
197
|
+
|
|
188
198
|
def print_dialog
|
|
189
199
|
control.keystroke("p", :command).wait_until_exists(at.sheet(1))
|
|
190
200
|
create_dialog(TypicalPrintDialog, at.sheet(1))
|
|
191
201
|
end
|
|
192
|
-
|
|
202
|
+
|
|
193
203
|
def create_dialog(dialog_class, location)
|
|
194
204
|
dialog_class.new(control.name, location + (location.has_top_level_element? ? "" : control.base_location))
|
|
195
205
|
end
|
|
196
|
-
|
|
206
|
+
|
|
197
207
|
def select_file_from_open_dialog(filename, dialog_location)
|
|
198
208
|
dialog = create_dialog(TypicalOpenDialog, dialog_location)
|
|
199
209
|
dialog.set_folder(File.dirname(filename))
|
|
200
210
|
dialog.select_file(File.basename(filename))
|
|
201
211
|
end
|
|
202
|
-
|
|
212
|
+
|
|
203
213
|
def raise_error_on_open_standard_windows(error_message)
|
|
204
214
|
raise Osaka::ApplicationWindowsMustBeClosed, error_message if ! control.standard_window_list.empty?
|
|
205
215
|
end
|
data/lib/osaka/version.rb
CHANGED
|
@@ -2,16 +2,16 @@ require 'tmpdir'
|
|
|
2
2
|
require 'osaka'
|
|
3
3
|
|
|
4
4
|
describe "Integration tests for Numbers" do
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
it "Should be able to fill in large index cells", :integration => true do
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
Dir.mktmpdir { |dir|
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
Osaka::Numbers.create_document(File.join(dir, "temp.numbers")) { |doc|
|
|
11
11
|
doc.fill_cell(12, 1, "Data")
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
require 'tmpdir'
|
|
3
|
+
require 'osaka'
|
|
4
|
+
|
|
5
|
+
describe "Integration of mail merge flow with Pages and Numbers", :integration => true do
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
before (:each) do
|
|
9
|
+
@tempdir = Dir.mktmpdir
|
|
10
|
+
@pages_template_filename = File.join(@tempdir, "document.pages")
|
|
11
|
+
@pdf_output_file = File.join(@tempdir, "output.pdf")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
after (:each) do
|
|
15
|
+
FileUtils.remove_entry_secure @tempdir
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "Should be able to open a new document" do
|
|
19
|
+
|
|
20
|
+
Osaka::Pages.create_document(@pages_template_filename) { |doc|
|
|
21
|
+
doc.type("Hello World! This is pages. We're going to mail merge!\r\r")
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
end
|
data/spec/launchservices_spec.rb
CHANGED
|
@@ -56,8 +56,8 @@ END_OF_DUMP
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "Can retrieve a value based on the bundle name" do
|
|
59
|
-
Osaka::CommandRunner.
|
|
60
|
-
Osaka::LaunchServices.retrieve("TextMate")[:id].
|
|
59
|
+
expect(Osaka::CommandRunner).to receive(:run).and_return(@dumped_registry)
|
|
60
|
+
expect(Osaka::LaunchServices.retrieve("TextMate")[:id]).to eq "54064"
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
data/spec/numbers_spec.rb
CHANGED
|
@@ -5,53 +5,53 @@ describe "Osaka::Numbers" do
|
|
|
5
5
|
|
|
6
6
|
include(*Osaka::OsakaExpectations)
|
|
7
7
|
|
|
8
|
-
subject { Osaka::Numbers.new }
|
|
8
|
+
subject { Osaka::Numbers.new }
|
|
9
9
|
let(:control) { subject.control = double("RemoteControl").as_null_object}
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
it "Should be able to get the column count" do
|
|
12
12
|
expect_tell('tell document 1; tell sheet 1; tell table 1; get column count; end tell; end tell; end tell').and_return("10")
|
|
13
13
|
expect(subject.column_count).to eq 10
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
it "Should be able to set the column count to a certain value" do
|
|
17
17
|
expect_tell('tell document 1; tell sheet 1; tell table 1; set column count to 10; end tell; end tell; end tell')
|
|
18
18
|
subject.set_column_count(10)
|
|
19
19
|
end
|
|
20
|
-
|
|
21
|
-
it "Should be able to fill in data in cells" do
|
|
20
|
+
|
|
21
|
+
it "Should be able to fill in data in cells" do
|
|
22
22
|
expect(subject).to receive(:column_count).and_return(10)
|
|
23
23
|
expect_tell('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
|
|
24
24
|
subject.fill_cell(1, 2, "30")
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
it "Will change the column count when the cell is outside of the range of the current column count" do
|
|
28
28
|
expect(subject).to receive(:column_count).and_return(5)
|
|
29
29
|
expect(subject).to receive(:set_column_count).with(6)
|
|
30
30
|
expect_tell('tell document 1; tell sheet 1; tell table 1; set value of cell 6 of row 2 to "30"; end tell; end tell; end tell')
|
|
31
31
|
subject.fill_cell(6, 2, "30")
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
it "Should be able to select blank from the template choser" do
|
|
36
36
|
expect_set_current_window("Template Choser")
|
|
37
|
-
expect(subject).to receive(:
|
|
37
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_return("Template Choser")
|
|
38
38
|
expect_set_current_window("Untitled")
|
|
39
|
-
expect(subject).to receive(:
|
|
39
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("Untitled")
|
|
40
40
|
expect_keystroke(:return)
|
|
41
|
-
subject.new_document
|
|
41
|
+
subject.new_document
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
it "Should be able to change the header columns" do
|
|
45
45
|
expect_click_menu_bar(at.menu_item("0").menu(1).menu_item("Header Columns"), "Table")
|
|
46
46
|
subject.set_header_columns(0)
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
it "Should be able to use a class method for creating documents quickly" do
|
|
50
50
|
expect(Osaka::Numbers).to receive(:new).at_least(1).times.and_return(double("App"))
|
|
51
51
|
expect(subject).to receive(:create_document)
|
|
52
52
|
|
|
53
53
|
Osaka::Numbers.create_document("filename") { |doc|
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
end
|
|
@@ -7,7 +7,7 @@ describe "Osakas Ruby expectations" do
|
|
|
7
7
|
|
|
8
8
|
subject { double("RemoteControl") }
|
|
9
9
|
let(:control) { subject }
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
it "Wait until exists can be called without a code block" do
|
|
12
12
|
expect_wait_until_exists!(at.window(1))
|
|
13
13
|
subject.wait_until_exists!(at.window(1))
|
|
@@ -16,7 +16,7 @@ describe "Osakas Ruby expectations" do
|
|
|
16
16
|
it "Wait until exists can be called with a code block" do
|
|
17
17
|
code_block_been_called = false
|
|
18
18
|
expect_wait_until_exists!(at.window(1)).and_yield
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
subject.wait_until_exists!(at.window(1)) {
|
|
21
21
|
code_block_been_called = true
|
|
22
22
|
}
|
data/spec/pages_spec.rb
CHANGED
|
@@ -17,23 +17,23 @@ describe "Osaka::Pages" do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "Should be able to create a new document using template choser if there is one" do
|
|
20
|
-
expect(subject).to receive(:
|
|
20
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("Template Chooser")
|
|
21
21
|
expect_keystroke("n", :command)
|
|
22
22
|
expect_set_current_window("Template Chooser")
|
|
23
|
-
expect_focus
|
|
24
|
-
|
|
25
|
-
expect(subject).to receive(:
|
|
23
|
+
expect_focus
|
|
24
|
+
expect_window_list.and_return(["Template Chooser"])
|
|
25
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("New Document")
|
|
26
26
|
expect_click(at.button("Choose").window("Template Chooser"))
|
|
27
27
|
expect_set_current_window("New Document")
|
|
28
28
|
subject.new_document
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "Should be able to create a new document also when there is no template chooser" do
|
|
32
|
-
expect(subject).to receive(:
|
|
32
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("New Document")
|
|
33
33
|
expect_keystroke("n", :command)
|
|
34
34
|
expect_set_current_window("New Document")
|
|
35
35
|
expect_focus
|
|
36
|
-
|
|
36
|
+
expect_window_list.and_return(["New Document"])
|
|
37
37
|
subject.new_document
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -48,15 +48,15 @@ describe "Osaka::Pages" do
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "Should be able to do mail merge to a PDF flow" do
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
mail_merge_dialog = double("Pages Mail Merge Dialog")
|
|
53
53
|
print_dialog = double("Generic Print Dialog")
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
expect(subject).to receive(:mail_merge).and_return(mail_merge_dialog)
|
|
56
56
|
expect(mail_merge_dialog).to receive(:merge).and_return(print_dialog)
|
|
57
57
|
expect(mail_merge_dialog).to receive(:set_merge_to_printer)
|
|
58
58
|
expect(print_dialog).to receive(:save_as_pdf).with("filename")
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
subject.mail_merge_to_pdf("filename")
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -79,9 +79,9 @@ describe "Osaka::Pages" do
|
|
|
79
79
|
expect(subject).to receive(:do_and_wait_for_new_window).and_yield.and_return("Link")
|
|
80
80
|
expect_exists?(at.menu_item("Show Inspector").menu(1).menu_bar_item("View").menu_bar(1)).and_return(true)
|
|
81
81
|
expect_click_menu_bar(at.menu_item("Show Inspector"), "View")
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
inspector_mock = double("Inspector")
|
|
84
|
-
expect(Osaka::PagesInspector).to receive(:new).with(control.name, at.window("Link")).and_return(inspector_mock)
|
|
84
|
+
expect(Osaka::PagesInspector).to receive(:new).with(control.name, at.window("Link")).and_return(inspector_mock)
|
|
85
85
|
expect(subject.inspector).to eq(inspector_mock)
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -98,11 +98,11 @@ describe "Osaka::Pages" do
|
|
|
98
98
|
inspector_mock = double("Inspector")
|
|
99
99
|
expect(subject).to receive(:inspector).and_return(inspector_mock)
|
|
100
100
|
expect(inspector_mock).to receive(:change_mail_merge_source)
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
expect_wait_until_exists(at.sheet(1))
|
|
103
103
|
expect(subject).to receive(:do_and_wait_for_new_window).and_yield.and_return("dialog")
|
|
104
104
|
expect_click(at.radio_button("Numbers Document:").radio_group(1).sheet(1))
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
expect(subject).to receive(:select_file_from_open_dialog).with("/tmp/filename", at.window("dialog"))
|
|
107
107
|
expect_click(at.button("OK").sheet(1))
|
|
108
108
|
|
|
@@ -111,11 +111,11 @@ describe "Osaka::Pages" do
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it "Should be able to stop when an error happens due to mail merge. This is especially important since otherwise Pages goes nuts and crashes :)" do
|
|
114
|
-
expect(subject).to receive(:inspector).and_return(double("Inspector").as_null_object)
|
|
114
|
+
expect(subject).to receive(:inspector).and_return(double("Inspector").as_null_object)
|
|
115
115
|
expect_wait_until_exists(at.sheet(1))
|
|
116
116
|
expect(subject).to receive(:do_and_wait_for_new_window)
|
|
117
117
|
expect(subject).to receive(:select_file_from_open_dialog)
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
expect_exists?(at.sheet(1).sheet(1)).and_return(true)
|
|
120
120
|
|
|
121
121
|
expect {subject.set_mail_merge_document("/tmp/filename") }.to raise_error(Osaka::PagesError, "Setting Mail Merge numbers file failed")
|
|
@@ -134,7 +134,7 @@ describe "Osaka::Pages Inspector" do
|
|
|
134
134
|
|
|
135
135
|
subject {Osaka::PagesInspector.new("Pages", "Link")}
|
|
136
136
|
let(:control) {subject.control = double("RemoteControl")}
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
it "Can convert symbolic names to locations" do
|
|
139
139
|
# Nice... checking a map. Perhaps delete ?
|
|
140
140
|
expect(subject.get_location_from_symbol(:document)).to eq at.radio_button(1).radio_group(1)
|
|
@@ -173,7 +173,7 @@ describe "Osaka::Pages Mail Merge dialog" do
|
|
|
173
173
|
|
|
174
174
|
subject { Osaka::PagesMailMergeDialog.new("", nil) }
|
|
175
175
|
let(:control) {subject.control = double("RemoteControl").as_null_object}
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
it "Should be able to set the mail merge dialog to merge to new document" do
|
|
178
178
|
expect_click(at.pop_up_button(2).sheet(1))
|
|
179
179
|
expect_wait_until_exists!(at.menu_item(1).menu(1).pop_up_button(2).sheet(1))
|
|
@@ -27,6 +27,16 @@ describe "Osaka::TypicalApplication" do
|
|
|
27
27
|
expect(code_block_called).to eq true
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
it "Should be able to do something and wait until a new STANDARD window pops up" do
|
|
31
|
+
expect_standard_window_list.and_return(["original window"], ["original window"], ["original window"], ["new window", "original window"])
|
|
32
|
+
expect_activate
|
|
33
|
+
code_block_called = false
|
|
34
|
+
expect(subject.do_and_wait_for_new_standard_window {
|
|
35
|
+
code_block_called = true
|
|
36
|
+
}).to eq "new window"
|
|
37
|
+
expect(code_block_called).to eq true
|
|
38
|
+
end
|
|
39
|
+
|
|
30
40
|
context "Cloning and copying" do
|
|
31
41
|
|
|
32
42
|
it "Should be able to clone TypicalApplications" do
|
|
@@ -48,20 +58,20 @@ describe "Osaka::TypicalApplication" do
|
|
|
48
58
|
it "Should pass the right open string to the application osascript" do
|
|
49
59
|
filename = "filename.key"
|
|
50
60
|
expect_tell("open \"#{File.absolute_path(filename)}\"")
|
|
51
|
-
expect(subject).to receive(:
|
|
61
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return(filename)
|
|
52
62
|
expect_set_current_window(filename)
|
|
53
63
|
subject.open(filename)
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
it "Should only get the basename of the filename when it sets the window title." do
|
|
57
67
|
filename = "/root/dirname/filename.key"
|
|
58
|
-
expect(subject).to receive(:
|
|
68
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_return("filename")
|
|
59
69
|
expect_set_current_window("filename")
|
|
60
70
|
subject.open(filename)
|
|
61
71
|
end
|
|
62
72
|
|
|
63
73
|
it "Should be able to create a new document" do
|
|
64
|
-
expect(subject).to receive(:
|
|
74
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("new_window")
|
|
65
75
|
expect_keystroke("n", :command)
|
|
66
76
|
expect_set_current_window("new_window")
|
|
67
77
|
expect_focus
|
|
@@ -198,7 +208,7 @@ describe "Osaka::TypicalApplication" do
|
|
|
198
208
|
expect(subject).to receive(:duplicate_available?).and_return(true)
|
|
199
209
|
|
|
200
210
|
expect_click_menu_bar(at.menu_item("Duplicate"), "File")
|
|
201
|
-
expect(subject).to receive(:
|
|
211
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("duplicate window")
|
|
202
212
|
|
|
203
213
|
allow(subject).to receive_message_chain(:clone, :control).and_return(new_instance_control)
|
|
204
214
|
expect(subject.duplicate.control).to eq(new_instance_control)
|
|
@@ -208,7 +218,7 @@ describe "Osaka::TypicalApplication" do
|
|
|
208
218
|
expect(subject).to receive(:duplicate_available?).and_return(true)
|
|
209
219
|
|
|
210
220
|
expect_click_menu_bar(at.menu_item("Duplicate"), "File")
|
|
211
|
-
expect(subject).to receive(:
|
|
221
|
+
expect(subject).to receive(:do_and_wait_for_new_standard_window).and_yield.and_return("duplicate window", "New name duplicate window")
|
|
212
222
|
|
|
213
223
|
allow(subject).to receive_message_chain(:clone, :control).and_return(new_instance_control)
|
|
214
224
|
expect(subject).to receive(:sleep).with(0.4) # Avoiding Mountain Lion crash
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: osaka
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bas Vodde
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- spec/integration_keynote_spec.rb
|
|
82
82
|
- spec/integration_numbers_spec.rb
|
|
83
83
|
- spec/integration_pages_numbers_mail_merge_spec.rb
|
|
84
|
+
- spec/integration_pages_spec.rb
|
|
84
85
|
- spec/integration_preview_spec.rb
|
|
85
86
|
- spec/integration_textedit_spec.rb
|
|
86
87
|
- spec/keynote_flows_spec.rb
|