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
| factorygirl* | |
| new* | |
| Gemfile.lock |
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 TracJob | |
| def initialize action, repo, rev | |
| @action, @repo, @rev = action, repo, rev | |
| end | |
| attr :action, :repo, :rev, :failures | |
| def run trac_projs | |
| trac_projs.each do |project| | |
| success = trac_admin_success? project | |
| failures << tp unless success |
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 Assertions | |
| module_function | |
| def assert_close_enough value1, value2 | |
| assert_equal value1.round, value2.round | |
| 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
| # Create UNION qeuries between ActiveRecord 3.x Relation objects. | |
| # inspired by: https://coderwall.com/p/9hohaa | |
| module Union | |
| def union *relations | |
| opts = relations.extract_options! | |
| model = ((is_a?(ActiveRecord::Base) || is_a?(ActiveRecord::Relation)) && self) || relations.first.klass | |
| query = 'SELECT' | |
| query << ' DISTINCT' if opts[:distinct] |
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
| Bundler could not find compatible versions for gem "axiom": | |
| In snapshot (Gemfile.lock): | |
| axiom (0.2.0) | |
| In Gemfile: | |
| rom (>= 0.1.2) ruby depends on | |
| axiom (~> 0.1.1) ruby |
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
| # the simple stuff | |
| string = 'uninterpolated string' | |
| string = "interpolated\nstring" | |
| # if you have all kinds of quotes in your strings, these are available if you must | |
| string = %q{uninterpolated string} | |
| string = %Q{interpolated\nstring} | |
| #heredocs! | |
| string = <<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 Module | |
| # is there a given distinct method defined on the instance of a class? | |
| def distinct_method_defined? method_name | |
| distinct_instance_methods.include? method_name.to_sym | |
| end | |
| # display the methods - including inherited - that distinguish this class's instances | |
| def distinct_instance_methods | |
| exclude = self == Object ? Kernel.public_instance_methods : Object.public_instance_methods | |
| public_instance_methods - exclude |
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
| firstyear | |
| => "1885-1886" | |
| lastyear | |
| => "1884-1885" | |
| firstyear > lastyear | |
| => false | |
| firstyear.bytes | |
| => [49, 56, 56, 53, 45, 49, 56, 56, 54] |
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 Foo | |
| def bar= new_bar | |
| return "MEGAZOIDS" | |
| end | |
| end | |
| f = Foo.new | |
| p f.bar = "lolcats" #=> "lolcats" |
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 foo | |
| if false then | |
| x = 1 | |
| end | |
| x | |
| end | |
| foo #=> nil, where you'd think it would error |