FS & Custom Ruby Installation
Posted: 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:
All compiled 'n snug in a bug in a rug with a . . .you get the point
So I load up FS, make a Ruby module and type:
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 . . . .
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????
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
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????