Easy to use ruby library for interacting with Confluence - confluence4r · 31 July 2009, 16:43
http://confluence.atlassian.com/display/CONFEXT/Confluence4r
I added a gemspec for the package to the bottom of the page if you want to build it as a gem in-house.
— Max Schubert
Getting ruby 1.8.7 and newer to compile with readline support on Red Hat Enterprise Linux (RHEL4 and RHEL5) · 4 April 2009, 10:20
Paraphrased from http://www.sanft.com/2008/12/01/upgrading-to-ruby-186-on-red-hat/
First, ensure you have the following packages installed:
- readline
- readline-devel
Then make sure you remove the system ruby and ruby-devel packages, otherwise gems and other extensions might find the wrong version of ruby when they look for compile flags etc:
- ruby
- ruby-devel
After unpacking the source for ruby, do the usual:
configure --prefix /usr/local make all sudo make install
Now do the following from the ruby source directory:
cd ext/readline /usr/local/bin/ruby extconf.rb make make install
To ensure that ruby now has readline support, run
/usr/local/bin/ruby -rreadline -e 1
If you get no output (which should be the result), voila, readline support is now active.
— Max Schubert
Getting ruby gem mysql native extension to install on RHEL5 / CentOS 5 · 2 April 2009, 12:04
From
http://www.wzzrd.com/2008_02_01_archive.html
If you are on a 32-bit platform:
gem install mysql -- --with-mysql-conf=/usr/bin/mysql_config --with-mysql-lib=/usr/lib/mysql
If you are on a 64-bit platform:
gem install mysql -- --with-mysql-conf=/usr/bin/mysql_config --with-mysql-lib=/usr/lib64/mysql
— Max Schubert
Comment [1]
Which rubies do not work with rubygems 1.3.x? · 2 April 2009, 11:28
Anything later than ruby 1.8.7. Spent a few hours learning that lesson:
- 1.9.x – no go
- 1.8.8 – latest snapshot or stable – no go
Thanks to my coworker, Ryan Richins, for pointing me to a version that does work!
— Max Schubert
Freezing Ruby Data Structures Recursively · 15 September 2008, 14:18
Flavorrific published a monkey patch that extends Object with a deep freeze method that freezes child arrays and hashes of a data structure so that they aren’t accidentally changed (for example, configuration data from YAML).
I have extended his work in the following ways:
- Attributes of child objects are frozen as well
- Accesses to non-existent hash and array keys throw an IndexError.
class Object # Define a deep_freeze method in Object (based on code posted by flavorrific # http://flavoriffic.blogspot.com/2008/08/freezing-deep-ruby-data-structures.html) # that will call freeze on the top-level object instance the method is # called on in as well as any child object instances contained in the # parent. This patch will also raise an IndexError if keys from # ‘deeply frozen’ Hashes or Arrays are accessed that do not exist.def deep_freeze
# String doesn’t support each if (self.class != String) && (self.respond_to? :each) each { |v| v.deep_freeze if v.respond_to?(:deep_freeze) } end # Deep freeze instance variable values if self.kind_of? Object self.instance_variables.each { |v| iv = self.instance_variable_get(v) iv.deep_freeze self.instance_variable_set(v, iv) } end if self.kind_of? Hash instance_eval(<<EOF) def default(key) raise IndexError, “Frozen hash: key ‘\#{key}’ does not exist!” end EOF end # Prevent user from accessing array elements that do not exist. if self.kind_of? Array instance_eval(<<EOF) def at(index) self.fetch(index) end def [](arg1, arg2 = nil) results = Array.new if ! arg2.nil? # Start index and end index given arg1.upto(arg1 + arg2) { |index| results << self.fetch(index) } else if arg1.kind_of? Range # Range passed in arg1.each { |index| results << self.fetch(index) } else results << self.fetch(arg1) end end results end EOF end # Freeze the current structure freeze endend
— Max Schubert
