Skip to content

Instantly share code, notes, and snippets.

View tomas-stefano's full-sized avatar

Tomas D'Stefano tomas-stefano

  • Ministry of Justice
  • London
View GitHub Profile
@tomas-stefano
tomas-stefano / Grab the Path Executable of any gem.rb
Created May 31, 2010 01:18
Grab the Path Executable for a gem
require 'rubygems'
Gem.bin_path('rspec-core', 'rspec')
@tomas-stefano
tomas-stefano / process.rb
Created June 4, 2010 17:36
Studying process with many versions of ruby
# Obs.: I'm running with ruby 1.8.7
ruby_1_9_1 = "/Users/tomas/.rvm/rubies/ruby-1.9.1-p378/bin/ruby"
file = File.expand_path('rspec_bin.rb')
system("rvm 1.9.1 && #{ruby_1_9_1} -rrubygems #{file}")
## RESULT ##
HOME_DIR = "/home/nelson"
versions = Dir[File.join('#{HOME_DIR}/.rvm/rubies', "ruby*")]
versions.each do |version|
version.match(/-([\d\.]\+)-/)
ruby_version_string = version.split('/').last
ruby_version = $1
@tomas-stefano
tomas-stefano / Morpheus DSL Estrategy.rb
Created August 24, 2010 01:39
Pensando na forma de registrar minha DSL para o Morpheus
# Imagina que eu tenho uma gem chama infinity_test
# Eu quero criar a Dsl para o Morpheus em uma syntax Rack-Like:
# O que queremos:
tasks :require => %w(infinity_test) # will require infinity_test.tasks
class Tasks < Morpheus::Base
infinity_test :test, :test_framework => :rspec, :cucumber => true, :test_pattern => 'spec/spec_*.rb'
Ruby 1.8.7
rvm '1.8.7' 'ruby' '/Users/tomas/.rvm/gems/ruby-1.8.7-p302/gems/rspec-core-2.0.0.beta.20/bin/rspec spec/factories/buzz/spec/buzz_spec.rb spec/factories/slinky/spec/slinky/slinky_spec.rb spec/factories/wood/spec/wood_spec.rb spec/infinity_test/application_spec.rb spec/infinity_test/command_spec.rb spec/infinity_test/configuration_spec.rb spec/infinity_test/continuous_testing_spec.rb spec/infinity_test/cucumber_spec.rb spec/infinity_test/notifications/growl_spec.rb spec/infinity_test/options_spec.rb spec/infinity_test/rspec_spec.rb spec/infinity_test/runner_spec.rb spec/infinity_test/test_unit_spec.rb spec/infinity_test_spec.rb'
Ruby 1.9.2
rvm '1.9.2' 'ruby' '/Users/tomas/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/bin/rspec spec/factories/buzz/spec/buzz_spec.rb spec/factories/slinky/spec/slinky/slinky_spec.rb spec/factories/wood/spec/wood_spec.rb spec/infinity_test/application_spec.rb spec/infinity_test/command_spec.rb spec/infinity_test/configuration_spec.rb spec/infinity_test/conti
ruby /Users/tomas/.rvm/gems/ree-1.8.7-2010.02@infinity_test/bin/rspec spec/factories/buzz/spec/buzz_spec.rb spec/factories/slinky/spec/slinky/slinky_spec.rb spec/factories/wood/spec/wood_spec.rb spec/infinity_test/application_spec.rb spec/infinity_test/command_spec.rb
OUTPUT:
......................
Finished in 0.01747 seconds
22 examples, 0 failures

World famous FFFFFFFFUUUUUUUUU autotest-growl icon set

fucons

Passed: EWBTE

Failed: problem?

Vim #ftw but manage vim plugins is not a task that I like.
Let's change that:
A Fake bash commands:
$ vim-apt list
$ vim-apt update # Update and see new versions of that package (like apt-get update)
@tomas-stefano
tomas-stefano / before_changes.rb
Created October 21, 2010 19:18
before_changes
module BeforeChanges
def before_changes
before_change_object = self.clone
changes.each do |changed_field, change|
before_change_object.send("#{changed_field}=", change[0])
end
before_change_object
end
end
class Color
def self.green
ansi_color(31)
end
def self.red
ansi_color(32)
end
def yellow