lukebayes-clix_flash_player 0.2.0 → 0.3.0

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{clix_flash_player}
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Luke Bayes"]
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'open4'
3
3
 
4
+ $CLIX_WRAPPER_TARGET = File.join(File.expand_path(File.dirname(__FILE__)), 'clix_wrapper.rb')
5
+
4
6
  $:.unshift(File.dirname(__FILE__)) unless
5
7
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
6
8
 
@@ -17,16 +19,30 @@ class CLIXFlashPlayer
17
19
 
18
20
  def execute(player, swf)
19
21
  cleanup
22
+ player = clean_path(player)
23
+ swf = clean_path(swf)
20
24
  validate(player, swf)
21
- player = File.expand_path(File.join(player, 'Contents', 'MacOS', 'Flash Player'))
22
- swf = File.expand_path(swf)
25
+
26
+ if(!player.match('Contents/MacOS'))
27
+ player = File.join(player, 'Contents', 'MacOS', 'Flash Player')
28
+ end
29
+
23
30
  setup_trap
31
+
24
32
  @thread = Thread.new {
25
33
  @player_pid = open4.popen4("#{player.split(' ').join('\ ')}")[0]
26
- wrapper = File.expand_path(File.dirname(__FILE__) + '/clix_wrapper.rb')
27
- command = "ruby #{wrapper} '#{player}' '#{swf}'"
28
- @activate_pid = open4.popen4(command)[0]
29
- Process.wait(@player_pid)
34
+ begin
35
+ raise "clix_wrapper.rb could not be found at: #{wrapper}" if !File.exists?($CLIX_WRAPPER_TARGET)
36
+ command = "ruby #{$CLIX_WRAPPER_TARGET} '#{player}' '#{swf}'"
37
+ @activate_pid, stdin, stdout, stderr = open4.popen4(command)
38
+ puts stdout.read
39
+ error = stderr.read
40
+ raise error if !error.nil? && error != ''
41
+ Process.wait(@player_pid)
42
+ rescue StandardError => e
43
+ kill
44
+ raise e
45
+ end
30
46
  }
31
47
  end
32
48
 
@@ -35,7 +51,9 @@ class CLIXFlashPlayer
35
51
  end
36
52
 
37
53
  def join
38
- @thread.join
54
+ if(@thread.alive?)
55
+ @thread.join
56
+ end
39
57
  end
40
58
 
41
59
  def alive?
@@ -44,6 +62,10 @@ class CLIXFlashPlayer
44
62
 
45
63
  private
46
64
 
65
+ def clean_path(path)
66
+ File.expand_path(path.gsub("'", '').gsub("\\", ''))
67
+ end
68
+
47
69
  def cleanup
48
70
  if(@thread && @thread.alive?)
49
71
  kill
data/lib/clix_wrapper.rb CHANGED
@@ -1,39 +1,22 @@
1
1
  #!/usr/bin/ruby
2
2
  require 'rubygems'
3
- require 'appscript'
4
-
5
- # player9 = "/Users/lbayes/Projects/CLIXFlashPlayer/exploration/fixtures/9.0.151/Flash Player.app/Contents/MacOS/Flash Player"
6
- # player10 = "/Users/lbayes/Projects/CLIXFlashPlayer/exploration/fixtures/10.0.22.87/Flash Player.app/Contents/MacOS/Flash Player"
7
-
8
- # player = player10
9
-
10
- # good_swf = '/Users/lbayes/Projects/CLIXFlashPlayer/exploration/fixtures/SomeProject.swf'
11
- # bad_swf = '/Users/lbayes/Projects/CLIXFlashPlayer/exploration/fixtures/InstantRuntimeException.swf'
12
-
13
- # swf = good_swf
14
3
 
15
4
  player = ARGV[0]
16
5
  swf = ARGV[1]
17
6
 
18
- puts "argv 0: #{player}"
19
- puts "argv 1: #{swf}"
7
+ raise "CLIXWrapper requires 'player' argument like:\nruby clix_wrapper [player] [swf]" if(player.nil?)
8
+ raise "CLIXWrapper could not find player at '#{player}'" if !File.exists?(player)
20
9
 
21
- if(player.nil?)
22
- raise "CLIXWrapper requires 'player' argument like:\nruby clix_wrapper [player] [swf]"
23
- end
10
+ raise "CLIXWrapper requires 'swf' argument like:\nruby clix_wrapper [player] [swf]" if(swf.nil?)
11
+ raise "CLIXWrapper could not find swf at '#{swf}'" if !File.exists?(swf)
24
12
 
25
- if(swf.nil?)
26
- raise "CLIXWrapper requires 'swf' argument like:\nruby clix_wrapper [player] [swf]"
13
+ begin
14
+ require 'appscript'
15
+ # Give the player focus:
16
+ Appscript.app(player).activate
17
+ # Open the SWF:
18
+ Appscript.app(player).open(MacTypes::Alias.path(swf))
19
+ rescue LoadError => e
20
+ raise "\n\n[ERROR] You must install the rb-appscript gem to use the desktop debug Flash Player, you do this by running:\n\nsudo gem install rb-appscript"
27
21
  end
28
22
 
29
- # player = File.expand_path(player).split(' ').join('\ ')
30
- # swf = File.expand_path(swf).split(' ').join('\ ')
31
-
32
-
33
- # Give the player focus:
34
- Appscript.app(player).activate
35
- puts "activate succeeded"
36
- # Open the SWF:
37
- Appscript.app(player).open(MacTypes::Alias.path(swf))
38
- puts "open succeeded"
39
-
data/rakefile.rb CHANGED
@@ -17,5 +17,31 @@ rescue LoadError
17
17
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
18
  end
19
19
 
20
+ # Ugly hack stolen from Hoe to execute test cases...
21
+ # need an internet connection to figure out how to
22
+ # get Jeweler to execute my tests.
23
+ def make_test_cmd multi = false # :nodoc:
24
+ test_globs = ['test/*_test.rb']
25
+ tests = ["rubygems", 'test/unit'] +
26
+ test_globs.map { |g| Dir.glob(g) }.flatten
27
+ tests.map! {|f| %(require "#{f}")}
28
+
29
+ filter = ENV['FILTER'] || ENV['TESTOPTS']
30
+ cmd = "-e '#{tests.join("; ")}' #{filter}"
31
+
32
+ if multi then
33
+ ENV['EXCLUDED_VERSIONS'] = multiruby_skip.join ":"
34
+ cmd = "-S multiruby #{cmd}"
35
+ end
36
+
37
+ cmd
38
+ end
39
+
40
+ desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'
41
+ task :test do
42
+ ruby make_test_cmd
43
+ end
44
+
45
+
20
46
  # require 'newgem/tasks' # load /tasks/*.rake
21
47
  # 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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Bayes