Rubygems

For general discussion related FlowStone
sal
Posts: 42
Joined: Thu Aug 19, 2010 4:56 pm

Rubygems

Post by sal »

Hi,
any chances to add rubygems support?

Thank You

Sal
DSP
Posts: 150
Joined: Fri May 14, 2010 10:55 pm

Re: Rubygems

Post by DSP »

It already supports Ruby Gems!
sal
Posts: 42
Joined: Thu Aug 19, 2010 4:56 pm

Re: Rubygems

Post by sal »

how?
I tried the ruby way without success
sal
Posts: 42
Joined: Thu Aug 19, 2010 4:56 pm

Re: Rubygems

Post by sal »

Code: Select all

gem install mysql
gem install sqlite3-ruby
gem list


how do i accomplish this ?


mr DSP how do you install and use gems?
infuzion
Posts: 109
Joined: Tue Jul 13, 2010 11:55 am
Location: Kansas City, USA, Earth, Sol

Re: Rubygems

Post by infuzion »

sal wrote:

Code: Select all

gem install mysql
gem install sqlite3-ruby
gem list
How do I accomplish this ?
Have you tried to install the gems manually?
http://docs.rubygems.org/read/chapter/3
sal
Posts: 42
Joined: Thu Aug 19, 2010 4:56 pm

Re: Rubygems

Post by sal »

yes i tried that, but at the moment the use of gems is not allowed as confirmed by dsp robotics on pm due to bugs caused by gems on windows platform.
Hope they will find a solution at least for adding database connectivity and network usage.
infuzion
Posts: 109
Joined: Tue Jul 13, 2010 11:55 am
Location: Kansas City, USA, Earth, Sol

Re: Rubygems

Post by infuzion »

Oh, OK, cheers.
Embedded
Posts: 143
Joined: Sat Oct 30, 2010 1:42 pm

Re: Rubygems

Post by Embedded »

Sal - here's the workaround to get Gems working inside FS.
As said before many of the Gems will not work on Windows!

FOR ADVANCED PROGRAMMERS ONLY!!!

Step 1) Install Ruby on your PC

In order for this to work it needs to be a mswin32 compiled version of Ruby not a ming32 version.

Try this: http://www.dsprobotics.com/Files/Ruby192MSwin.zip

Just copy the folder to somewhere on your PC, you can also have the ming32 one installed in a different folder.

Check: Ruby -v

Should say something like: i386-mswin32

Step 2) Create a shortcut on your desktop

Right click - shortcut etc.

Use this string: C:\WINDOWS\system32\cmd.exe /E:ON /K D:\Ruby192MSwin\bin\setrbvars.bat

but remember to modify the path to match your ruby installation.

Step 3) download Install Gem on your system:

Put the downloaded gem in the gem folder: D:\Ruby192MSwin\lib\ruby\gems\1.9.1\gems (using your own path)

then in Ruby:

gem install gemname

You should see the gem install:

Gem Install.png
Gem Install.png (5.55 KiB) Viewed 41143 times


Step 4) Add the new path to FlowStone's ruby

Open FS2 and enter something like this into a Ruby edit module:

$LOAD_PATH << "D:/Ruby192MSwin/lib/ruby/gems/1.9.1/gems/myGemFolder"

Remembering to use / not \

This only has to be done once!

Step 4) Test Gem

Start with a new Ruby Edit module and test if it loads:

ie. require 'MyGemName'

Results: the first time it load you get a result of True, from then on False - both are good it has been loaded!

Ruby Gem Test clip-2.png
Ruby Gem Test clip-2.png (5.39 KiB) Viewed 41143 times


If the loaded gem causes a crash then it is the gem that doesn't work on Windows NOT FlowStone!

Thanks 'DSP' for you help on this..
DSP
Posts: 150
Joined: Fri May 14, 2010 10:55 pm

Re: Rubygems

Post by DSP »

Embedded - You're welcome, glad I could help...

Also worth mentioning is that gems are all the rage, but on Windows dll's have been doing these things for years.

dlls work perfectly with FlowStone V2 & Ruby on Windows, so if you have any specific need it's probably more reliable to just make a call to the dll.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Rubygems

Post by Tronic »

i have already tested this but for example this simple sock call

Code: Select all

require'socket'
#Socket.ip_address_list
Addrinfo.udp("192.168.0.2", 10001).bind {|s|
  p s.recv(10) #=> "hello"
}

stop the ruby code
""Execessive processing detected...etc.etc"

and even this

require 'Win32API'

Code: Select all

getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', 'V', 'L')
window_handle = getForegroundWindow.Call()
getWindowText = Win32API.new('user32', 'GetWindowText', 'LP', 'I')
title_buffer = ' ' * 512
getWindowText.Call(window_handle, title_buffer,512)
title_buffer


but the oddity is that, by removing the buffer size, working
getWindowText.Call(window_handle, title_buffer,512)
getWindowText.Call(window_handle, title_buffer)

Code: Select all

getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', 'V', 'L')
window_handle = getForegroundWindow.Call()
getWindowText = Win32API.new('user32', 'GetWindowText', 'LP', 'I')
title_buffer = ' ' * 512
getWindowText.Call(window_handle, title_buffer)
title_buffer
Post Reply