I can't seem to get the button to open the url in a browser. The script runs in Shoes, however the button does not do anything. What am I doing wrong?
Shoes.setup do
gem 'launchy'
end
require 'launchy'
Shoes.app do
background "#EFC"
border("#BE8",
strokewidth: 6)
stack(margin: 12) do
para "Enter ID"
flow do
@e = edit_line
id = @e.text
fburl = "http://www.facebook.com/profile.php?id="
#alert fburl+id
button "OK" do
Launchy.open("#{fburl}+#{id}")
end
end
end
end
After making the suggested changes and using "shoes.setup do", I get the following error:
undefined method 'dir for Gem:Module :344:in 'method_missing' C:/Program Files (x86)/Common Files/Shoes/O.r1514/ruby/lib/rubygems/installer.rb:97:in 'initialize' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes/setup.rb:265:in 'new' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes/setup.rb:265:in 'install_sources' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes/setup.rb:27:in 'init C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes/setup.rb:329:in '' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:105:in 'require' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:105:in 'setup' Shoes Gem Loader.rb:1:in '' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:428:in 'eval' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:428:in 'visit' C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:118:in 'show_selector C:/Program Files (x86)/Common Files/Shoes/O.r1514/lib/shoes.rb:151:in 'block (4 levels in splash' (null):0:in 'call'
Am I to assume that launchy is not a usable gem in Shoes?
The "original" Shoes doesn't play well with gems. The newest version of Shoes (Shoes 4) lets you require gems normally. It's pre-alpha, but almost feature-complete. Here's your code modified to run in Shoes 4. Note that the id
assignment has to be moved into the button block (but this would be necessary for any version of Shoes)
require 'launchy'
Shoes.app do
background "#EFC"
border("#BE8", strokewidth: 6)
stack(margin: 12) do
para "Enter ID"
flow do
@e = edit_line
fburl = "http://www.facebook.com/profile.php?id="
button "OK" do
id = @e.text
alert fburl+id
Launchy.open("#{fburl}+#{id}")
end
end
end
end
To install Shoes 4, follow the instructions on GitHub, and make sure you gem install launchy
. Then you should be able to run your app.