This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: ruby one_account_to_csv.rb < html_dump.html > transactions.csv | |
# First row has column titles. | |
$text = readlines.join | |
puts "Date,Type,Merchant,Debit,Credit" | |
$text.scan %r{<tr class="content">.*?</tr>}m do |line| | |
unless line =~ /colspan="5"/ | |
values = line.scan(%r{<td.*?>(?:<[^/].*?>)*(.*?)</}).map {|v| v.first} | |
values.each do |value| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n' | |
if (Rails.env.development? || Rails.env.test?) && ENV['DEBUG_TRANSLATION'] | |
module I18n | |
class << self | |
def translate_with_debug(*args) | |
puts "Translate: #{args.inspect}" | |
translate_without_debug(*args) | |
end | |
alias_method_chain :translate, :debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })} | |
RSpec::Matchers.define :accept_nested_attributes_for do |association| | |
match do |model| | |
@model = model | |
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym) | |
if @nested_att_present && @reject | |
model.send("#{association}_attributes=".to_sym,[@reject]) | |
@reject_success = model.send("#{association}").empty? | |
end | |
model.send("#{association}").clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: http://rubygems.org/ | |
specs: | |
RedCloth (4.2.3-java) | |
abstract (1.0.0) | |
actionmailer (3.0.0) | |
actionpack (= 3.0.0) | |
mail (~> 2.2.5) | |
actionpack (3.0.0) | |
activemodel (= 3.0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'rails', '3.0.0' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
if defined?(JRUBY_VERSION) | |
gem 'activerecord-jdbc-adapter' | |
gem 'jdbc-sqlite3', :require => false |