I am looking for a Ruby markup parser (or helper) to convert a custom markup language to HTML.
Something like Decoda does in the PHP world (see $code->addMarkup() function). Is there a good tool in the Ruby world?
...
Hello, I'm learning Ruby (using the Pickaxe book) and I've encountered a little confusion with a block operation that goes a little like this:
class CsvReader
def initialize
@book_in_stock = []
end
def read_in_csv_data(csv_file_name)
CSV.foreach(csv_file_name, headers: true) do |row| # 1.
@book_in_stock << BookinSto...
I would like to know ice cream preferences of all my cats in an array.
So the output would be just the :ice_cream out of all the cat's :
[ "vanilla", "chocolate", "mint chocolate", "mice" ]
While the cat objects are :
cat => {:ice_cream => "chocolate", :paws => "4", :wants_to_kill_humans => "yes" }
Yikes this is such an easy answe...
What is the best way to run cron jobs on rails, when different machines have different jobs to do?
For example, server 1 runs cron job A, while server 2 runs cron job B
Is there a way to deploy the cron files along when we do a regular cap deploy?
...
I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7.
I installed MacPorts and ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7.
Could anyone hel...
How do I require external libraries when running Amazon EMR streaming jobs written in Ruby?
I've defined my mapper, and am getting this output in my logs:
/mnt/var/lib/hadoop/mapred/taskTracker/jobcache/job_201008110139_0001/attempt_201008110139_0001_m_000000_0/work/./mapper_stage1.rb:
line 1: require: command not found
My ...
Given the following snippet:
hash = { # 1
(line = __LINE__) => # 2
lambda { x } # 3
}
Doing some inspection on jruby:
puts line # >> 2
puts hash[line].inspect >> #<Proc:0x560932fe@/tmp/test.rb:2>
Seems to differ from the standard mri:
puts line # >> 2
puts hash[line].inspect >> #<Proc:0x00007fa59...
I've installed the newer version of SQLite3 (3.7.0.1) on my macbook (OS X 10.5) but 'sqlite3 --version' gives me the older version I had on my system:
$ sqlite3 --version
3.4.0
I suppose I was expecting this version to be overwritten but that doesn't seem to be the case. Can anyone clue me in? I'd really appreciate it, right now I'm t...
I am reading Metaprogramming in Ruby book. In that book, when I was reading about scopegates, the following code was shown
my_var = "Success"
MyClass = Class.new do
puts "#{my_var} in the class definition"
define_method :my_method do
puts "#{my_var} in the method"
end
end
MyClass.new.my_method
=>Success in the class defini...
I saw a ruby code snippet today.
[1,2,3,4,5,6,7].inject(:+)
=> 28
[1,2,3,4,5,6,7].inject(:*)
=> 5040
The injection here is quite different from those I've seen before, like
[1,2,3,4,5,6,7].inject {|sum, x| sum + x}
Please explain how does it work?
...
Hello, i have Ruby class:
class Migrator
def self.migrate_old_categories
ActiveRecord::Base.establish_connection(:data_center_v2)
ActiveRecord::Base.table_name = "categories"
end
end
I need use it, as i used it always. For example: Category.find(:all)
So, how i can it, when i'm write: Migrator.migrate_ol...
Am using Ruby version 1.9.1 on windows vista. Am getting the rake aborted error for any rake commands am using. This does not happen in all my app folder. Its happening only on a specific app folder.
C:\rails_project\stunetwork>rake db:reset
(in C:/rails_project/stunetwork)
rake aborted!
stack level too deep
C:/Ruby191/lib/ruby/gems/1....
class UbacParser
def initialize(str)
@str= str
@valid= true
base_parse
end
private
def base_parse
@protocol_code = Integer(@str[0..2]) rescue nil
begin
@data = @str[@str.index('<')[email protected]('>')-1]
str_mod = @str[@str.index('>##')+1..-1]
arr_mod=str_...
Hello, I've a Ruby regexp question.
if string == /(^\d{1,3})/ # this matches both "24" and "24 gravida ut aliquam"
# code...
end
I want the regexp to match only "24".
How should I do to only allow digits?
...
Take the following class:
class Automator
def fill_specific_form(fields)
fields.each_pair do |key, value|
puts "Setting '#{key}' to '#{value}'"
end
end
end
a = Automator.new
a.fill_specific_form :first_name => "Mads", :last_name => "Mobæk"
# => Setting 'first_name' to 'Mads'
# => Setting 'last_name' to 'Mobæk'
Is i...
I have a 'strange' problem, the following code converts the location lat value into a string (With a + sign for each iteration) leading to an eventual exception when comparing values. I've tried the code with values for another location and it works fine. The only difference is that the other numbers were negatives.
location= {:lng => ...
Given an array of strings
["the" "cat" "sat" "on" "the" "mat"]
I'm looking to get all combinations of items in sequence, from any starting position, e.g.
["the"]
["the" "cat"]
["the" "cat" "sat"]
...
["cat" "sat" "on" "the" "mat"]
["sat" "on" "the" "mat"]
["on" "the" "mat"]
...
["sat" "on"]
["sat" "on" "the"]
Combinations out of t...
Hi, I want to display few active records in rails console, I have Hirb enabled. The table is narrow enough to be displayed (so Hirb uses standard, horizontal table) but columns are so narrow that content is completely unreadable. Do you have any idea what I could do about it?
Displaying only few columns would be great (I have records in...
I have the following error during sqlite3-ruby install:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sql...
Hi! I have a model that I am attempting to apply optimistic locking to. If the user has a stale record I need the system to display what they entered and ask them to try again. I have attempted to use the changes method, which works. My issue is that the model has many different levels of related models, that are all submitted within the...