class

class << self is good at keeping all of your class methods in the same block. If methods are being added in def self.method form then there’s no guarantee (other than convention and wishful thinking) that there won’t be an extra class method tucked away later in the file. def self.method is good at explicitly … Read more

How to run all tests with minitest?

Here’s a link to Rake::TestTask. There is an example in the page to get you started. I’ll post another one that I’m using right now for a gem: require ‘rake/testtask’ Rake::TestTask.new do |t| t.pattern = “spec/*_spec.rb” end As you can see, I assume that my files are all in /lib and that my specs are … Read more

How to hide password input from terminal in ruby script

One can also use core ruby. $ ri IO.noecho (from ruby core) —————————————————————————— io.noecho {|io| } —————————————————————————— Yields self with disabling echo back. STDIN.noecho(&:gets) will read and return a line without echo back. For 1.9.3 (and above), this requires you adding require ‘io/console’ to your code. require ‘io/console’ text = STDIN.noecho(&:gets)

Execute bash commands from a Rakefile

I think the way rake wants this to happen is with: http://rubydoc.info/gems/rake/FileUtils#sh-instance_method Example: task :test do sh “ls” end The built-in rake function sh takes care of the return value of the command (the task fails if the command has a return value other than 0) and in addition it also outputs the commands output.

How to install therubyracer gem on 10.10 Yosemite?

gem uninstall libv8 brew install v8 gem install therubyracer gem install libv8 -v ‘3.16.14.3’ — –with-system-v8 this is the only way it worked for me on 10.10 (ruby 2.1.2) Or try gem install libv8 -v ‘XX.XX.XX’ — –with-system-v8 adding the version of the gem 🙂 UPDATE for Mac OS Catalina: brew tap homebrew/versions brew install … Read more