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
* Schedule | |
* Who's speaking now? | |
* Who's speaking next? | |
* When's lunch? | |
* What's the Google map URL? | |
* Current Speaker's SpeakerRate URL? | |
* Last Speaker's SpeakerRate URL? | |
* Relay non-commands to convore (just an idea) |
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
describe ".import" do | |
context "with no mapping block" do | |
context "given a single record" do | |
it "returns an empty collection" do | |
CsvMapper.import(nil).should be_empty | |
end | |
end | |
context "given a collection with only one record" do | |
it "returns an empty collection" do | |
CsvMapper.import([['John', 'Doe']]).should be_empty |
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
# Import with CSV Mapper | |
CsvMapper.import('path') do | |
start_at_row 1 # Skip the first row (probably a header row) | |
stop_at_row 10 # Stop parsing on the 10th row | |
map_to Business do | |
business_name # Parse to String by default | |
net_worth :type => Float # Parse column value Float | |
net_worth.to_f # Parse column value Float |
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
# Given a CSV record format like: | |
# john,doe,blonde,26 | |
CsvMapper.import('blah') do | |
map_to Person | |
first_name # maps to string by default | |
last_name # maps to string by default | |
_SKIP_ # skip the 'hair color' column |
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 'rubygems' | |
require 'active_support' | |
module CustomName | |
def self.included(base) | |
base.alias_method_chain :name, :update | |
end | |
def name_with_update | |
['custom', name_without_update].join(' ') |
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
jQuery('#label-switch').change(function(){ | |
var showLabels = (jQuery(this).is(':checked') ? 1 : 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
def possessify(word) | |
result = word.to_s.dup | |
if word.empty? | |
result | |
else | |
result.ends_with?('s') ? result << "'" : result << "'s" | |
end | |
end |
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
function rvm_require_ruby | |
{ | |
if ! rvm list strings | grep -q "^$1" ; then | |
echo "ERROR: Requires Ruby Version: '$1'" | |
return 1 | |
fi | |
return 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
function rvm_require_ruby { | |
if [ "`rvm list | grep $1`" = "" ] | |
then | |
echo "ERROR: Requires Ruby Version: $1" | |
exit | |
fi | |
} | |
function rvm_use { | |
rvm_require_ruby $1 | |
rvm use $1 |
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
# Given | |
class Business | |
attr_accessor :name, :net_worth | |
attr_accessor :line_1, :line_2, :city, :state, :zip | |
end | |
# Import with CSV Mapper | |
CsvMapper.import('path_to_file.csv') do | |
map_to Business | |
start_at_row 1 # Skip the first row (probably a header row) |
NewerOlder