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
#!/usr/bin/env ruby | |
require "fileutils" | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'tty-command' | |
end | |
def check!(project_root, git_root, force_exit = false, rubocop_format = 'fu') |
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
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'tty-prompt', '~> 0.18.1' | |
gem 'colorize', '~> 0.8.1' | |
gem 'time_ago_in_words', '~> 0.1' | |
gem 'git', '~> 1.5.0' | |
gem 'pry' |
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
#!/usr/bin/env ruby | |
require "./config/environment" | |
require "active_record/migration" | |
require "tty-prompt" | |
migration = TTY::Prompt.new(interrupt: :exit) | |
migration_version = migration.select("Select Migration", filter: true) do |menu| | |
ActiveRecord::Base.connection.migration_context.migrations_status.reverse.each do |status, version, name| | |
menu.choice "#{status.center(8)} #{version.ljust(14)} #{name}", version | |
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
require "reverse_parameters" | |
# Converts Object.new(<args>).call to Object.call(<args>) | |
# module must be extend after initialize method in order to transfer parameters | |
module CallObject | |
def create_callable | |
class_eval(<<-RUBY, __FILE__, __LINE__ + 1) | |
def self.call(#{ReverseParameters.new(instance_method(:initialize)).parameters}) | |
self.new(#{ReverseParameters.new(instance_method(:initialize)).arguments}).call | |
end | |
RUBY |
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
max_stack_frames = 500 | |
TooManyStackFrames = Class.new(StandardError) | |
TracePoint.new(:call) do |tp| | |
if caller.size >= max_stack_frames | |
raise TooManyStackFrames, "Stack has exceeded #{max_stack_frames} frames" | |
end | |
end.enable |
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
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" | |
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%}$(travis_status)$(git_prompt_info)' | |
function travis_status_dir { | |
GIT_ROOT=`git rev-parse --show-toplevel` | |
echo "${GIT_ROOT}/tmp/.travis" | |
} | |
function travis_status_file { | |
GIT_SHA=`git rev-parse HEAD` |
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 "thread" | |
class Thread | |
alias_method :_initialize, :initialize | |
def initialize(*args, &block) | |
inheritable_attributes = Thread.current.inheritable_attributes | |
_initialize(*args) do | |
Thread.current.inheritable_attributes = inheritable_attributes | |
block.call |
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
class MyClass | |
def initalize(arg1: arg2:, **additional_args) | |
post_initalize(**additional_args) | |
end | |
def post_initalize(*) | |
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
class Sharer | |
def initalizer(stuff_name) | |
@stuff_name = stuff_name | |
end | |
def stuff | |
@stuff_name | |
end | |
NewerOlder