ruby

Getting RSpec into RDoc

In Ioke doc, the ISpec tests are included in the documentation, see ioke.org/dok/index.html How can this be done with Ruby's RSpec and RDoc (or SDoc)? I can't find any commandline switches or external libs to do so. Any ideas (not including implementing it all by myself ;-) )? ...

Running gem server in passenger

I'm running a few rails/rake apps in Apache/passenger and I want to add the documentation app served by gem server to these apps, so I can easily give it a special (sub)domain, like docs.example.org, so it's easily available for all members of our team and nobody has to start the server himself or remember port numbers (like 8808, the de...

testing helpers with 'haml_tag'

module FooHelper def foo haml_tag(:div) do haml_content("bar") end end end When I test this I get: NoMethodError: undefined method `haml_tag' This code is perfectly valid and works in a development/production environment. It's something to do with having the haml helpers properly loaded in the test environment. Th...

Continuous Integration Advice?

I'm working on setting up a Continuous Integration server (using Integrity) for my Rails app, and I'd like advice: Do most folks set up CI to build and test their app on every push to their central SCM repository, or only when pushing to their staging branch? I'll use the CI server to automatically run flay, flog, reek, and rcov -- are...

$stdin compatibility with std::istream using swig, C++, and Ruby

I have a function in C++ that takes in an std::istream as the input: class Foo { Foo(std::istream &); } Using SWIG, I've bound it to Ruby, but Ruby's $stdin variable is fundamentally different from anything like the stream classes in C++, so I'm not sure how to either 1) expose the C++ class to Ruby in a way that I can use $stdin,...

named_scope is creating new objects if I use it with a :join

Disclaimer: My original exposure to Ruby on Rails was literally years ago, and a great many things are new to me now that I'm picking it back up. One of these things is named scopes. They seem great, but I'm not getting the result I expect. Here's a for-instance: class User has_many logs named_scope :logged_in, :joins => ['logs'...

How to get started with Ruby? How can I use Ruby? What is it famous for? How is a DSL going to be useful?

What are some great Learning resources? What kind of problems do I solve with Ruby? Is learning ruby on rails same as ruby? If my current background is visual studio and microsoft.net framework, is IronRuby the best way for me? Awful lot of questions, please suggest. ...

Java - Problems Rounding Numbers

I wrote some Java code to generate pseudo-random numbers but I'm running into what I think are rounding problems getting it to match up with the same code in Ruby. Here's what I have in Java: public class randTest { private final static Double A = Math.pow(5,13); private final static Integer S = 314159265; private final static Dou...

Bypassing validation with machinist

Hi, I am writing my specs on my model Thing which has a date field which should be after the date of creation, thus I use the *validate_timeliness* plugin like that validate_date :date, :after Time.now I want to be able to add some Things with an anterior date but validation fails. I want to bypass the validation when creating some T...

RadRails trial expired - any free options for Rails in Eclipse?

I installed RadRails a while back and uninstalled it after it said that my trial had expired. Is it correct that this is the only option for Rails development in Eclipse? And is there any other - free - option for Eclipse? (I tried "Ruby RDT" but it doesn't offer any Rails support, just basic Ruby editing.) ...

Filtering ActiveRecord queries in rails

I'm used to Django where you can run multiple filter methods on querysets, ie Item.all.filter(foo="bar").filter(something="else"). The however this is not so easy to do in Rails. Item.find(:all, :conditions => ["foo = :foo", { :foo = bar }]) returns an array meaning this will not work: Item.find(:all, :conditions => ["foo = :foo", { :...

how to set a header when serving a static file

I want to host an ical file, but when serving it, I need to set the Content-type header to calendar and stuff in php, I would just <?php header ("Content-type: text/calendar") ?> //calendar stuff proceeds Can I do the same using ruby? or can I somehow tell apache to set a different header when serving this file? ...

Your Language Regex match full name "last, first middle1 middle2 suffix"

Spent me 3 hours to get a good regex finished for parsing these 3 main possible situations. Redden, Taylor Captain Hasting Jr. Redden, Taylor Hasting Jr. Redden, Taylor Hasting full, l, f, m1, m2, s = /your_regex_here/.match("Redden, Taylor Captain Hasting Jr.").to_a I want to see what other possible answers there are beside min...

How can I find non ascii strings in an array of strings, in Rails 2.0/ruby 1.8.6?

I have an array full of user logins that was loaded from the database. What's the simplest and efficient way to keep only the logins that contain non-ascii characters? logins = Users.find(:all).map{|user|user.login} logins_with_non_ascii_characters = logins.select{ |login| ...??? } Thanks Edit: if you have a SQL solution (I use MySQ...

rbuic on windows

I've had no luck getting the rbuic UI compiler (from qt4-qtruby-1.4.10 release) to produce any output on windows. Even running rbuic -h does not work. I'm guessing the output is going somewhere other than stdout... Any suggestions? ...

What will change if i learn Ruby? (I know ASP.NET)

I wonder that, Ruby programming language is ...(easy/difficult) to learn. I can develop web application %x faster than asp.net. There are a lot of screen casts to learn Ruby.(http://xxxRubLearn.xxx, etc.) The principle(s) of Ruby is(are) only ...... You can increase work proccessor (like W3P on IIS) and make faster your web app. Futu...

Nokogiri: How can I add a child to a node at a specific position?

Hello all, I have a node which has two children: an XML text and an XML element. <h1 id="Installation-blahblah">Installation on server<a href="#Installation-blah" class="wiki-anchor">&para;</a> In this case the XML text is: Installation on server and the XML element: <a href="#Installation-blah" class="wiki-anchor">anchor;</...

Distributing Ruby/Python desktop apps

Is there any way besides Shoes to develop and distribute cross-platform GUI desktop applications written in Ruby? I come to believe that general bugginess of _why's applications is exceptionally crippling in case of Shoes, and anything more complex than a two-button form is a pain to maintain. RubyGTK, wxRuby, etc seem to be promising,...

How do you change headers in a CSV File with FasterCSV then save the new headers?

Hi, I'm having trouble understanding the :header_converters and :converters in FasterCSV. Basically, all I want to do is change column headers to their appropriate column names. something like: FasterCSV.foreach(csv_file, {:headers => true, :return_headers => false, :header_converters => :symbol, :converters => :all} ) do |row| put...

How do you create a configurable Ruby on Rails plugin?

i am trying to create my first rails plugin, and i want it to be configurable, that is to say, i want to be able to set a variable in the environment.rb file or something. UPDATE: i'm trying to do something like what's done here: http://soakedandsoaped.com/articles/read/exception-notifier-ruby-on-rails-plugin. i have tried mimicking th...