This file contains hidden or 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
| Array::partition = (callback) -> | |
| [positive, negative] = [[], []] | |
| for item, index in @ | |
| (if callback item, index then positive else negative).push item | |
| [positive, negative] |
This file contains hidden or 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
| ENV['RACK_ENV'] = 'test' | |
| require 'bundler/setup' | |
| require 'simplecov' | |
| SimpleCov.start do | |
| add_filter "/test/" | |
| end | |
| require 'test/unit' |
This file contains hidden or 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
| namespace :db do | |
| require 'sequel' | |
| Sequel.extension :migration | |
| DB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite://db/development.db') | |
| desc 'Migrate the database to latest version' | |
| task :migrate do | |
| Sequel::Migrator.run(DB, 'db/migrate') | |
| puts '<= db:migrate executed' |
This file contains hidden or 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
| namespace :assets do | |
| require 'sprockets' | |
| require 'uglifier' | |
| require 'yui/compressor' | |
| sprockets = Sprockets::Environment.new { |env| env.logger = Logger.new(STDOUT) } | |
| sprockets.css_compressor = YUI::CssCompressor.new | |
| sprockets.js_compressor = :uglifier | |
| sprockets.append_path File.expand_path('../lib/web/assets', __FILE__) | |
| output_path = File.expand_path('../lib/web/public', __FILE__) |
This file contains hidden or 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 "sprockets" | |
| require "sinatra/base" | |
| class SprocketsMiddleware | |
| attr_reader :app, :prefix, :sprockets | |
| def initialize(app, prefix) | |
| @app = app | |
| @prefix = prefix | |
| @sprockets = Sprockets::Environment.new |
This file contains hidden or 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
| class EmployeeTest < Test::Unit::TestCase | |
| let(:email) { Employee.new('jdoe@example.com') } | |
| def employee_has_an_email_test | |
| assert_equal('jdoe@example.com', employee.email) | |
| end | |
| end |
This file contains hidden or 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
| --- | |
| title: Welcome to Middleman | |
| --- | |
| %h1 Dashboard | |
| %h2 Net Income | |
| %table | |
| %caption Net Income Over Time | |
| %thead | |
| %th Month Ending |
This file contains hidden or 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
| class CallbackList | |
| NOOP_BLOCK = ->(*) { :ok } | |
| def self.[](block) | |
| block ||= NOOP_BLOCK | |
| new.tap { |proxy| block.call(proxy) } | |
| end | |
| def respond_with(callback, *args) | |
| callbacks.fetch(callback, NOOP_BLOCK).call(*args) | |
| end |
This file contains hidden or 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 'validus' | |
| class PersonValidator | |
| include Validus | |
| def initialize(attributes) | |
| @attributes = attributes | |
| end | |
| def validate |