Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

FS & Custom Ruby Installation

For general discussion related FlowStone

FS & Custom Ruby Installation

Postby Drnkhobo » Mon May 13, 2013 10:27 pm

. . .Oh Ruby, show me your delights. Do not obscure from me, for I am one with you. . .

Ahhh ok I want to start a thread here which goes into the topic of using custom Ruby source in FS apps.
Based on this thread: http://www.dsprobotics.com/support/viewtopic.php?f=2&t=941

So for my first endeavor I want to make a FS exe that connects to the net using Ruby's standard net/http libraries. Which will then, from inside the app, connect to a webpage & parse the html.

The second journey for us would be to use the EZCrypt gem & encrypt a string inside Ruby.



Let's start at no.1 shall we?

My understanding is that to get the net/http libraries included in Ruby, you need to compile your own Ruby source.

So I followed digitalwhitebyte's advice:


Get the source zip from the download page,

After downloaded unzip it locally to say c:\ruby-src
Open CMD prompt, but make sure you run it as administrator,
run vcvars32.bat, you can locate it in your MSV folder like <MSV path>\VC\bin
Make a folder for your build say c:\ruby-build. Move into it / change dir

c:\ruby-build> c:\ruby-1.9.3-p0\win32\configure.bat
c:\ruby-build> nmake
c:\ruby-build> nmake test
c:\ruby-build> nmake DESTDIR=c:/ruby-build install

To use them, then you can simply link them like
$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1"
$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"

All compiled 'n snug in a bug in a rug with a . . .you get the point :roll:

So I load up FS, make a Ruby module and type:

$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"
reuire 'net/http'


Grrrr. . .Ruby isnt playing nice here! Its saying the socket.so file isnt compatible. So I find the socket.so file in my compiled Ruby & place it in the FS lib folder.

Aw damn! Now Ruby is telling me: uninitialized constant Encoding::UTF_7
Google search returns some info but mostly side shoots rather than trunks :(

but ahah! something glistening in the wet dark google search . . . .

Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).

Solution: You've most likely referred to a class or module that doesn't exist. Most likely, you've forgotten to require a gem or library needed for the code to work, or you've made a typo. Another possibility is that the class you'd like to refer to is in another module. If that's the case, you'll have to refer to it with its full name as in the following code.


#!/usr/bin/env ruby

module MyModule
class MyClass; end
end

c = MyModule::MyClass.new


hmm so it seems that Encoding::UTF_7 is used in openssl. Ive checked my libs for that but its not in the compiled folder of Ruby.

Has anyone used this before?

Are there easier ways. . . gems???? :lol:
Drnkhobo
 
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: FS & Custom Ruby Installation

Postby digitalwhitebyte » Tue May 14, 2013 6:28 pm

what error you have when compiled the source?
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: FS & Custom Ruby Installation

Postby Drnkhobo » Tue May 14, 2013 8:00 pm

omg thank you Dwb!

Well i noticed that when I compiled
c:\ruby-build> nmake


When it came to installing openssl, it just said failed! I cant remember if it gave a reason. . .

Am I doing this correctly? To say that the "$LOAD_PATH. . . " line tells Ruby to look into that folder for files too?
Drnkhobo
 
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: FS & Custom Ruby Installation

Postby digitalwhitebyte » Tue May 14, 2013 11:02 pm

sorry but I did not understand, you were able to compile the source?
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: FS & Custom Ruby Installation

Postby Drnkhobo » Wed May 15, 2013 6:51 pm

Yeah it compiled fine, just not with the openssl libs.
Capture.PNG
Capture.PNG (6.43 KiB) Viewed 17519 times
Drnkhobo
 
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: FS & Custom Ruby Installation

Postby digitalwhitebyte » Wed May 15, 2013 11:03 pm

Ok, now to install rubygems there are still two libraries to compile, yaml and zlib from source,
a bit complex to do.
I try to tidy up the procedure and ready as soon as I add it to the original post.

however this is done,
every time you install a rubygem will always have to launch the file vcvars32.bat first before giving in the console, the command to install the gems.
and verify that the environment variables in the PATH variable there is the path of the ruby that you compiled.
this need because some gems is compiled from C code,
and ruby need to know the paths of the compiler in use on the system.

but keep in mind that they did all this, some gems will not be able to function,
because the code will turn off if a thread takes too long to finish its execution.
especially with executions of code to use web connections, they use a socket that is executed in a loop running,
it definitely will block the ruby code.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: FS & Custom Ruby Installation

Postby Drnkhobo » Thu May 16, 2013 8:35 pm

especially with executions of code to use web connections, they use a socket that is executed in a loop running,
it definitely will block the ruby code.

So basically network & Ruby is out the window?
Drnkhobo
 
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: FS & Custom Ruby Installation

Postby digitalwhitebyte » Thu May 16, 2013 11:10 pm

can not use anything that has a thread that does not end in a period of time imposed by Malc to judge that a ruby execution is blocked.
all this because at the end of ruby does not run in a multithreaded environment.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: FS & Custom Ruby Installation

Postby digitalwhitebyte » Fri May 17, 2013 12:35 am

Guide updated
How I built libyaml
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am


Return to General

Who is online

Users browsing this forum: No registered users and 67 guests