I use irb for composing and debugging scripts. Following is what you might need to do inorder to run Sikuli in IRB:
- Install JRuby or via rvm
- Copy sikuli-script.jar to jruby lib
- cp /Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar $JRUBY_HOME/lib
- For RVM:
- rvm list (to list currently installed rubies)
- rvm use jruby-1.x.x (to use jruby as the ruby implementation)
- rvm info (to print information about the ruby currently being used)
- cp /Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar $MY_RUBY_HOME/lib ($MY_RUBY_HOME points to the current ruby home, in this case jruby)
- run irb (the irb prompt should list jruby as the ruby implementation, something like jruby-1.x.x :001 > )
- jruby-1.x.x :001 > require 'java'
- => true
- jruby-1.x.x :002 > java_import 'org.sikuli.script.Screen'
- => Java::OrgSikuliScript::Screen
- jruby-1.x.x :003 > screen = Screen.new
- => #<Java::OrgSikuliScript::Screen:0x1dc2dad7>
- jruby-1.6.0 :004 > image_path='/Users/mubbashir/Desktop'
- => "/Users/mubbashir/Desktop"
- screen.hover("#{image_path}/apple.png")
- [info] Sikuli vision engine loaded.
- => 1
With Auto Completion IRB is just a blessing, specially when you want to try some new library or need to run some snippets:
Similarly in script it would be something like:
to run the script ruby script_file_name.rb Just be sure that you are using JRuby ;)
No comments:
Post a Comment