Skip to content

Instantly share code, notes, and snippets.

View lsegal's full-sized avatar

Loren Segal lsegal

View GitHub Profile
class Foo
# @overload foo
# @return [FooObject]
# @overload foo=(value)
# @param [String] value something with value
# @return [void]
attr_accessor :foo
# (don't document here)
def foo=(val)
class Foo
def apply(meth)
items.each do |v|
v.send(meth)
end
end
end
class String
# Splits text into tokens the way a shell would, handling quoted
# text as a single token. Use '\"' and "\'" to escape quotes and
# '\\' to escape a backslash.
#
# @return [Array] an array representing the tokens
def shell_split
out = [""]
state = :none
escape_next = false
require 'rake/gempackagetask'
class Gem::Specification
attribute :wiki
attribute :bugtracker
end
SPEC = Gem::Specification.new do |s|
s.name = "gemspec-test"
s.summary = "Testing a gemspec"
def MYCLASS(klass, &block)
eval "class #{klass}; end"
eval(klass).instance_eval(&block)
end
def MYDEFINE(meth, &proc)
define_method(meth, &proc)
end
#### Your new DSL: ####
--title "Refinery CMS"
lib/**/*.rb'
app/**/*.rb
db/seeds.rb
config/preinitializer.rb
vendor/plugins/images/**/*.rb
vendor/plugins/authentication/**/*.rb
vendor/plugins/dashboard/**/*.rb
vendor/plugins/inquiries/**/*.rb
vendor/plugins/news/**/*.rb
get '/docs/:project/*/?' do
setup_project
setup_page
opts = {
serialize: false,
serializer: serializer,
project: project,
project_path: project_path,
type: :layout
class Object
def self.method_added(name)
const_set(:InstanceMethods, Module.new) unless defined?(self::InstanceMethods)
meth = instance_method(name).bind(self.allocate)
self::InstanceMethods.send(:define_method, name, &meth)
remove_method(name)
include self::InstanceMethods
end
end
class Object
def self.method_added(name)
return if name == :initialize
const_set(:InstanceMethods, Module.new) unless defined?(self::InstanceMethods)
self::InstanceMethods.send(:define_method, name, &instance_method(name).bind(self.allocate))
remove_method(name)
include self::InstanceMethods
end
end
def uniq_min(list)
shortest, another = nil, nil
list.each do |obj|
another = obj if shortest && obj.length == shortest.length
shortest, another = obj, nil if !shortest || obj.length < shortest.length
end
another ? false : shortest
end