Archive for 'Ruby'

I hardly ever use the local RDoc documentation of my installed Ruby gems. Typing in –no-rdoc –no-ri every time I install a gem is cumbersome. The gem takes longer to install and it uses up unnecessary disk space. That annoyance goes doubly when installing gems on a server.

Luckily, RubyGems allows to set default options in a file called .gemrc which should be placed in your home directory. The syntax is in YAML format, therefore straightforward for a Ruby programmer. Just add this line to .gemrc and you are golden.

    gem: --no-rdoc --no-ri
  

A list of all options can be found here.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Having a convenient way to store an applications configuration is something I want in every Ruby project. There are plenty of solutions for Ruby on Rails but none of them did really match my taste, because they did way too much. I wanted something simple that does not depend on Ruby on Rails and does not try to be too clever.

Here are my requirements for a configuration lib:

  • Nesting and namespaces
  • Simple string interpolation
  • Support for environments e.g testing, production, debug
  • Defaults for each environment

And this is what I came up with:

  • Use YAML (defaults, namespaces, scopes)
  • Parse the YAML file with ERB
  • Return an OpenStruct object for easy method accessors

The code and and information on how to install and use the lib can be found here: http://github.com/phuesler/simple_app_config

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

This is a short post about a small ruby gem I have written awhile ago. It’s a simple interface to Payone’s HTTP API. Payone is a payment service provider in Germany that offers several different payment methods like credit card, direct debit and so on and so forth.

The gem is still a little bit rough around the edges and doesn’t do much more than sending http post requests. So you still have to know the payone API. There is a lot of room for improvement, I am thinking about an API similar to ActiveMerchant or even an integration.

For the impatient here is how you install it:

gem install gemcutter
gem tumble

gem install payone_connect

And here is how you use it:

require 'payone_connect'
payone = PayoneConnect.new(api_key,params_hash)
puts payone.request[:status]

Enough said, here you can find the code: http://github.com/phuesler/payone_connect

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]