Class: CLIXFlashPlayer
- Inherits:
-
Object
- Object
- CLIXFlashPlayer
- Defined in:
- lib/clix_flash_player.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #execute(player, swf) ⇒ Object
-
#initialize ⇒ CLIXFlashPlayer
constructor
A new instance of CLIXFlashPlayer.
- #join ⇒ Object
- #kill ⇒ Object
Constructor Details
#initialize ⇒ CLIXFlashPlayer
Returns a new instance of CLIXFlashPlayer.
14 15 16 17 18 |
# File 'lib/clix_flash_player.rb', line 14 def initialize @activate_pid = nil @player_pid = nil @thread = nil end |
Instance Method Details
#alive? ⇒ Boolean
60 61 62 |
# File 'lib/clix_flash_player.rb', line 60 def alive? return @thread.alive? end |
#execute(player, swf) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/clix_flash_player.rb', line 20 def execute(player, swf) cleanup player = clean_path(player) swf = clean_path(swf) validate(player, swf) if(!player.match('Contents/MacOS')) player = File.join(player, 'Contents', 'MacOS', 'Flash Player') end setup_trap @thread = Thread.new { @player_pid = open4.popen4("#{player.split(' ').join('\ ')}")[0] begin raise "clix_wrapper.rb could not be found at: #{wrapper}" if !File.exists?($CLIX_WRAPPER_TARGET) command = "ruby #{$CLIX_WRAPPER_TARGET} '#{player}' '#{swf}'" @activate_pid, stdin, stdout, stderr = open4.popen4(command) $stdout.puts stdout.read error = stderr.read raise error if !error.nil? && error != '' Process.wait(@player_pid) rescue StandardError => e $stdout.puts e.to_s kill raise e end } end |
#join ⇒ Object
54 55 56 57 58 |
# File 'lib/clix_flash_player.rb', line 54 def join if(@thread.alive?) @thread.join end end |
#kill ⇒ Object
50 51 52 |
# File 'lib/clix_flash_player.rb', line 50 def kill system("kill -9 #{@player_pid}") end |