lukebayes-clix_flash_player 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.textile +113 -0
- data/VERSION +1 -0
- data/clix_flash_player.gemspec +55 -0
- data/rakefile.rb +16 -21
- metadata +16 -34
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/README.textile
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
h1. CLIX FlashPlayer
|
2
|
+
|
3
|
+
This is a Command Line interface to the Flash Player for OS X.
|
4
|
+
|
5
|
+
This project was created because unlike the modern distributions of the desktop debug Flash Player on Windows and Linux, the OS X distribution does not behave properly when executed by another process.
|
6
|
+
|
7
|
+
h1. The Problem(s)
|
8
|
+
|
9
|
+
We need to be able to execute and focus a specific instance of the Flash Player along with a specific SWF file. The Flash Player execution thread should block until the user selects File >> Quit (or hits CMD+Q), or until the parent application is interrupted (SIGINT) using CTRL+C.
|
10
|
+
|
11
|
+
The Flash Player should be focused and still terminate whether or not a runtime exception occurs in the first frame (or any frame) of the loaded SWF file.
|
12
|
+
|
13
|
+
Our solution should work each revision of the Flash Player, from 9.0.115 and greater.
|
14
|
+
|
15
|
+
h1. Attempts
|
16
|
+
|
17
|
+
h2. Open command
|
18
|
+
|
19
|
+
The first approach was to simply use the OS X <code>open</code> command. The problem with open, is that it expects a single application _or_ file argument, not an application _and_ file.
|
20
|
+
|
21
|
+
When <code>open</code> is sent a second argument, it appears to be the same as if open was called twice - this usually causes two instances of the Flash Player to be launched.
|
22
|
+
|
23
|
+
We can't call <code>open</code> with only the SWF file because then it launches an arbitrary Flash Player and not necessarily the specific version that we need.
|
24
|
+
|
25
|
+
Finally, <code>open</code> has the additional disadvantage in that when we send SIGINT to the parent process, the child Players are orphaned.
|
26
|
+
|
27
|
+
h2. Exec Flash Player.app with the SWF file as an argument
|
28
|
+
|
29
|
+
Of course, this doesn't work because Flash Player.app is a directory. Thanks Steve!
|
30
|
+
|
31
|
+
h2. Exec Flash Player.app/Contents/MacOS/Flash Player binary with the SWF file as an argument
|
32
|
+
|
33
|
+
This approach is the most promising yet in that it blocks the parent thread and returns when the Player is Quit and it kills the Player process when the parent is interrupted.
|
34
|
+
|
35
|
+
Unfortunately, this doesn't work for us because the Flash Player is never focused, and actually launches _behind_ all other applications.
|
36
|
+
|
37
|
+
h2. AppleScript Wrapper
|
38
|
+
|
39
|
+
We can try writing a terminal application using AppleScript that will launch the Flash Player, activate it, and _then_ open the requisite SWF file, which will presumably avoid breakage on runtime exceptions.
|
40
|
+
|
41
|
+
This worked great, except using the _osascript_ application to call the AppleScript, apparently breaks the SIGINT relationship from parent to child. So when the parent is aborted, the child is orphaned.
|
42
|
+
|
43
|
+
h2. AppleScript Application
|
44
|
+
|
45
|
+
Will the AppleScript behave differently as a full OS X _.app_?
|
46
|
+
|
47
|
+
This is awesome because the .app file actually throws a modal "Are you sure?" prompt - _behind_ all other applications. It also doesn't seem to accept command line parameters properly.
|
48
|
+
|
49
|
+
h2. Exec Flash Player.app/Contents/MacOS/Flash Player binary with the SWF file as an argument, and use AppleScript to focus the damn thing
|
50
|
+
|
51
|
+
At first blush, this appears to work great, then we encounter the uncaught (actually _uncatchable_) runtime exception...
|
52
|
+
|
53
|
+
If the SWF file we send the player has an uncaught runtime exception, the dialog appears behind all other applications, our AppleScript process becomes locked, and no longer responds to SIGINT (CTRL+C). The whole mess must instead be sent the SIGSTOP (CTRL+Z) and later killed with SIGKILL (kill -9 [pid]).
|
54
|
+
|
55
|
+
h2. Use rb-appscript to Launch Flash Player.app, Focus the app, and Open the SWF
|
56
|
+
|
57
|
+
This approach seems to work better than the exec and focus strategy because we are able to focus (activate) the player _before_ sending it a failing SWF file. This at least gives us the error dialog in front of other applications. We get the added benefit in that if we manually dismiss the dialog, our process works normally.
|
58
|
+
|
59
|
+
Unfortunately, if we interrupt the parent process (CTRL+C) before dismissing the dialog, our parent process becomes locked and must be killed brutally with SIGKILL.
|
60
|
+
|
61
|
+
h1. Solution
|
62
|
+
|
63
|
+
The only solution that I've been able to get consistently working, is to fork on the AppleScript features and use exec <code>kill -9 [process]</code> when we interrupt the application.
|
64
|
+
|
65
|
+
An example of this process can be seen in the <code>lib</code> and <code>test</code> packages of this project.
|
66
|
+
|
67
|
+
h1. Example
|
68
|
+
|
69
|
+
You can install the latest version of this project as a gem with:
|
70
|
+
|
71
|
+
<pre><code>
|
72
|
+
gem sources -a http://gems.github.com (you only have to do this once)
|
73
|
+
gem install lukebayes/clix_flash_player
|
74
|
+
</code></pre>
|
75
|
+
|
76
|
+
You can use the library in your Ruby code like this:
|
77
|
+
|
78
|
+
<pre><code>
|
79
|
+
require 'rubygems'
|
80
|
+
require 'clix_flash_player'
|
81
|
+
|
82
|
+
player = CLIXFlashPlayer.new
|
83
|
+
player.execute('bin/Flash Player.app', 'bin/MyProject.swf')
|
84
|
+
|
85
|
+
# Do something else here...
|
86
|
+
|
87
|
+
player.join
|
88
|
+
</code></pre>
|
89
|
+
|
90
|
+
h1. MIT License
|
91
|
+
|
92
|
+
<pre>
|
93
|
+
Copyright (c) 2009 Pattern Park
|
94
|
+
|
95
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
96
|
+
a copy of this software and associated documentation files (the
|
97
|
+
"Software"), to deal in the Software without restriction, including
|
98
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
99
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
100
|
+
permit persons to whom the Software is furnished to do so, subject to
|
101
|
+
the following conditions:
|
102
|
+
|
103
|
+
The above copyright notice and this permission notice shall be
|
104
|
+
included in all copies or substantial portions of the Software.
|
105
|
+
|
106
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
107
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
108
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
109
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
110
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
111
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
112
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
113
|
+
</pre>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{clix_flash_player}
|
5
|
+
s.version = "0.2.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Luke Bayes"]
|
9
|
+
s.date = %q{2009-05-17}
|
10
|
+
s.description = %q{The Flash Player on OS X does not appropriately allow the command line to control it.}
|
11
|
+
s.email = %q{josh@technicalpickles.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc",
|
14
|
+
"README.textile"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".gitignore",
|
18
|
+
"History.txt",
|
19
|
+
"Manifest.txt",
|
20
|
+
"README.rdoc",
|
21
|
+
"README.textile",
|
22
|
+
"VERSION",
|
23
|
+
"clix_flash_player.gemspec",
|
24
|
+
"lib/clix_flash_player.rb",
|
25
|
+
"lib/clix_wrapper.rb",
|
26
|
+
"rakefile.rb",
|
27
|
+
"script/console",
|
28
|
+
"script/destroy",
|
29
|
+
"script/generate",
|
30
|
+
"test/clix_flash_player_test.rb",
|
31
|
+
"test/test_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/technicalpickles/the-perfect-gem}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.3}
|
37
|
+
s.summary = %q{Command Line Interface wrapper for Flash Player on OS X}
|
38
|
+
s.test_files = [
|
39
|
+
"test/clix_flash_player_test.rb",
|
40
|
+
"test/test_helper.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<open4>, [">= 0.9.6"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
54
|
+
end
|
55
|
+
end
|
data/rakefile.rb
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
2
|
require File.dirname(__FILE__) + '/lib/clix_flash_player'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
19
|
-
p.rsync_args = '-av --delete --ignore-errors'
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "clix_flash_player"
|
8
|
+
gemspec.summary = "Command Line Interface wrapper for Flash Player on OS X"
|
9
|
+
gemspec.email = "josh@technicalpickles.com"
|
10
|
+
gemspec.homepage = "http://github.com/technicalpickles/the-perfect-gem"
|
11
|
+
gemspec.description = "The Flash Player on OS X does not appropriately allow the command line to control it."
|
12
|
+
gemspec.authors = ["Luke Bayes"]
|
13
|
+
gemspec.files.exclude('exploration/**/*')
|
14
|
+
gemspec.add_dependency('open4', '>= 0.9.6')
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
18
|
end
|
21
19
|
|
22
|
-
require 'newgem/tasks' # load /tasks/*.rake
|
23
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
24
|
-
|
25
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
26
|
-
# task :default => [:spec, :features]
|
20
|
+
# require 'newgem/tasks' # load /tasks/*.rake
|
21
|
+
# Dir['tasks/**/*.rake'].each { |t| load t }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lukebayes-clix_flash_player
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Bayes
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,55 +22,36 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.9.6
|
24
24
|
version:
|
25
|
-
|
26
|
-
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3.0
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: hoe
|
37
|
-
type: :development
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.8.0
|
44
|
-
version:
|
45
|
-
description: This is a Command Line interface to the Flash Player for OS X. This project was created because unlike the modern distributions of the desktop debug Flash Player on Windows and Linux, the OS X distribution does not behave properly when executed by another process.
|
46
|
-
email:
|
47
|
-
- lbayes@patternpark.com
|
25
|
+
description: The Flash Player on OS X does not appropriately allow the command line to control it.
|
26
|
+
email: josh@technicalpickles.com
|
48
27
|
executables: []
|
49
28
|
|
50
29
|
extensions: []
|
51
30
|
|
52
31
|
extra_rdoc_files:
|
53
|
-
- Manifest.txt
|
54
|
-
- History.txt
|
55
32
|
- README.rdoc
|
33
|
+
- README.textile
|
56
34
|
files:
|
57
|
-
-
|
35
|
+
- .gitignore
|
58
36
|
- History.txt
|
59
|
-
-
|
37
|
+
- Manifest.txt
|
60
38
|
- README.rdoc
|
39
|
+
- README.textile
|
40
|
+
- VERSION
|
41
|
+
- clix_flash_player.gemspec
|
61
42
|
- lib/clix_flash_player.rb
|
62
43
|
- lib/clix_wrapper.rb
|
44
|
+
- rakefile.rb
|
63
45
|
- script/console
|
64
46
|
- script/destroy
|
65
47
|
- script/generate
|
66
48
|
- test/clix_flash_player_test.rb
|
67
49
|
- test/test_helper.rb
|
68
50
|
has_rdoc: false
|
69
|
-
homepage:
|
51
|
+
homepage: http://github.com/technicalpickles/the-perfect-gem
|
70
52
|
post_install_message:
|
71
53
|
rdoc_options:
|
72
|
-
- --
|
73
|
-
- README.rdoc
|
54
|
+
- --charset=UTF-8
|
74
55
|
require_paths:
|
75
56
|
- lib
|
76
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -87,10 +68,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
68
|
version:
|
88
69
|
requirements: []
|
89
70
|
|
90
|
-
rubyforge_project:
|
71
|
+
rubyforge_project:
|
91
72
|
rubygems_version: 1.2.0
|
92
73
|
signing_key:
|
93
74
|
specification_version: 3
|
94
|
-
summary:
|
75
|
+
summary: Command Line Interface wrapper for Flash Player on OS X
|
95
76
|
test_files:
|
96
77
|
- test/clix_flash_player_test.rb
|
78
|
+
- test/test_helper.rb
|