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
| Running 683 tests...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................OK! | |
| bin/mspec ci --background --agent | |
| rubinius 2.0.0dev (1.8.7 68a5acb5 yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0] | |
| ................................................................................................................................................................................................................ |
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 Address | |
| # :street, String | |
| # :city, String | |
| # :state, String | |
| # :country, String | |
| scope :local, lambda { |query| search_by_street_or_city(query, query) } | |
| scope :national, lambda {|query| search_by_state_or_country(query, query) } | |
| 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 'texticle/searchable' | |
| class Book | |
| # :title, String | |
| # :author, String | |
| extend Searchable(:title) | |
| end | |
| Book.create :title => "Poignant Guide to Ruby", :author => "_why" |
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
| def method_missing(name, *terms) | |
| if match = name.to_s.match(/search_by_(?<columns>[_a-zA-Z]\w*)/) | |
| string_columns = self.columns.select {|column| column.type == :string }.map(&:name) | |
| columns = match[:columns].split('_and_') | |
| super unless columns.all? {|column| string_columns.include?(column) } | |
| query = columns.inject({}) do |query, column| | |
| query.merge column => terms.shift | |
| end | |
| search(query) | |
| 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
| module Reader | |
| def read(lines_per_problem = 1) | |
| Enumerator.new do |yielder| | |
| gets.chomp.to_i.times do | |
| yielder.yield *[Array.new(lines_per_problem) { gets.chomp }] | |
| end | |
| end | |
| 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
| <html> | |
| <head> | |
| <title>My First Webpage</title> | |
| <style> | |
| h1.insetType { | |
| font-family: Rockwell, Georgia, "Times New Roman", Times, serif; | |
| font-size: 50px; | |
| color: #0D4383; | |
| text-shadow: rgba(0,0,0,0.5) -1px 0, rgba(0,0,0,0.3) 0 -1px, rgba(255,255,255,0.5) 0 1px, rgba(0,0,0,0.3) -1px -2px; | |
| } |
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
| #!/usr/bin/env ruby | |
| require 'yaml' | |
| top_dir = `git rev-parse --show-toplevel`.chomp | |
| changes = `git diff --cached --name-only`.chomp.split | |
| assets = YAML.load_file "#{top_dir}/config/assets.yml" | |
| assets = assets['javascripts'].values + assets['stylesheets'].values | |
| assets.flatten! |
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
| #!/usr/bin/env ruby | |
| commit_msg = File.open(ARGV[0]).read | |
| exit(0) if commit_msg[/f:\d+/] | |
| warn "Missing Freckle time duration in commit message! Aborting commit..." | |
| exit(1) |
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 Search < ActiveRecord::Base | |
| belongs_to :searchable, :polymorphic => true | |
| # This will actually work now, no more | |
| # n + 1 query problems, yay! | |
| default_scope :include => :searchable | |
| def hash | |
| searchable_id.hash + searchable_type.hash | |
| 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
| class CreateSearches < ActiveRecord::Migration | |
| def self.up | |
| ActiveRecord::Base.connection.execute <<-SQL | |
| CREATE VIEW searches AS | |
| SELECT authors.id AS searchable_id, authors.name AS term, | |
| CAST ('Author' AS varchar) AS searchable_type | |
| FROM authors | |
| UNION | |
| SELECT books.id AS searchable_id, books.title AS term, | |
| CAST ('Book' AS varchar) AS searchable_type |