Thu Jan 03 01:00:00 UTC 2008
Codegear Turbo C++ and Ruby
Embedding Ruby into a Turbo C++ (Borland C++ Builder) Application
I’m currently looking at bringing together two of my favourite pieces of desktop software – Ruby and Codegear Turbo C++. I’m still sorting my thoughts out, but here are the main links that will help in getting started. I will write up more details about this once I’ve figured it all out.
The ongoing thread in Ruby-talk that is discussing this issue
Link: http://www.ruby-forum.com/topic/137241
Specific to Borland Builder
Old threads that seem to have a few good pointers and gotchas. These are: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/73326 and very importantly: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/73397
About generally embedding Ruby
A thread that covers the idea and also links to the PickAxe online for this: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/71319
Ruby Embedded into C++
A great tutorial that goes into a lot of detail about the whole process. Link: http://metaeditor.sourceforge.net/embed/
SWIG
You could also use SWIG to connect up between a C/C++ program and Ruby. Link: http://www.swig.org/
As soon as I have the whole procedure worked out, I shall put up a post about the full procedure for integrating between the two of them.
Sat Oct 27 12:22:00 UTC 2007
Online books about Ruby/ Rails
Here’s a small list of online/ free books about Ruby/ Rails. This is just to keep the references in one place. Hope this helps someone else – it certainly helps me!
The PickAxe Edition 1 (Programming Ruby)
http://www.rubycentral.com/pickaxe/
Why’s Poignant Guide about Ruby
http://poignantguide.net/ruby/
Mr. Neighborly’s Humble Little Ruby Book
http://www.humblelittlerubybook.com/
A Little Ruby, A Lot of Objects
Mon Mar 26 14:17:00 UTC 2007
Sending Email with Ruby
I know that there are a number of guides online that provide the basic source for sending email using Ruby but I found that the basic sample code was lacking in one major respect – it did not set the date on the outgoing email. That meant that there was no specific “sent time” for the email and its treatment would depend on the email client. For example, Thunderbird would mark it with the date/ time at which it was downloaded.
The solution to this problem is really quite simple – you just need to format and print the date into the message as shown below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'net/smtp'
#Senders and Recipients
from_name = 'My Name'
from_mail = 'me@mydomain.com'
to_name = 'My Friend'
to_mail = 'them@theirdomain.com'
#Servers and Authentication
smtp_host = 'mail.mydomain.com'
smtp_port = 25
smtp_domain = 'mydomain.com'
smtp_user = 'user@mydomain.com'
smtp_pwd = 'secure_password'
#The subject and the message
t = Time.now
subj = 'Sending Email with Ruby'
msg_body = "Check out the instructions on how to send mail using Ruby.\n"
#The date/time should look something like: Thu, 03 Jan 2006 12:33:22 -0700
msg_date = t.strftime("%a, %d %b %Y %H:%M:%S +0800")
#Compose the message for the email
msg = <<END_OF_MESSAGE
Date: #{msg_date}
From: #{from_name} <#{from_mail}>
To: #{to_name} <#{to_mail}>
Subject: #{subj}
#{msg_body}
END_OF_MESSAGE
Net::SMTP.start(smtp_host, smtp_port, smtp_domain, smtp_user, smtp_pwd, :plain) do |smtp|
smtp.send_message msg, smtp_user, to_mail
end
And that’s all there is to it!
TODO: Need to make the time printing more generic – right now, it’s kinda hard-coded to my time zone.