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
file=Pathname.new(Dir.pwd+'/lib') | |
if(file.exist?) | |
$:.unshift(file.to_s) | |
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
gemfile=File.read("Gemfile") | |
unversioned = gemfile.scan(/(?<!#)\s+(gem|custom_require) ['"]([\w-]+)['"](?!,.*(\d+\.\d+\.\d+))/) | |
lockfile = File.read("Gemfile.lock") | |
puts unversioned.inspect | |
unversioned.each do |lead, name| | |
version = lockfile.scan(/#{name} \(((\d+\.?)+)\)/).first.first | |
gemfile.gsub! /#{lead} ['"]#{name}['"]/, "\\0, '~> #{version}'" |
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
RSpec.describe YourModule do | |
let(:includer) { Class.new.include(described_class).new } | |
describe "#hello_world" do | |
it "returns Hello World" do | |
expect(includer.hello_world). | |
to eq("Hello World") | |
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
require 'spec_helper' | |
RSpec.describe YourRecord do | |
subject(:record) { create :your_record, *traits } | |
let(:traits) { [] } | |
its(:name) { is_expected.to be_nil } | |
its(:size) { is_expected.to eq(0) } | |
context "when name is bob" do |
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
find ./ -name rollout_ui | sed 's/\(.*\)/\1\/ \1/' | sed 's/rollout_ui$/lk_rollout_ui/' | xargs -n2 git mv |
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
#pseudo code | |
class Rollout | |
def auto_disable(feature, user, feature_block, old_block) | |
if active?(feature, user) | |
begin | |
yield feature_block | |
rescue => e | |
deactivate(feature) | |
raise e |
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 UserFinder | |
def self.find(id) | |
record = User.find(id) | |
"#{record.user_type}User".constantize.new(record) | |
end | |
end | |
class User < ActiveRecord::Base | |
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 SemiOpenStruct | |
def initialize(hash={}) | |
@hash = hash | |
end | |
def method_missing(method,*args,&block) | |
@hash[method] || | |
__try_hash_setter(method,*args,&block) || | |
super | |
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
@test "tmux is installed and in the path" { | |
which vim | |
which derp | |
} | |
Uploading /tmp/busser/suites/bats/vim_stuff.rb (mode=0644) | |
-----> Running bats test suite | |
0 tests, 0 failures | |
Finished verifying <default-ubuntu-1204> (0m1.05s). |
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
[4] pry(main)> mod = Module.new | |
=> #<Module:0x007fa1ac93c650> | |
[5] pry(main)> mod::Foo = Class.new | |
=> #<Class:0x007fa1ae5ad7f8> | |
[6] pry(main)> mod::Foo | |
=> #<Class:0x007fa1ae5ad7f8> | |
[7] pry(main)> mod::Foo.parent | |
=> Object |