Created
September 2, 2012 17:27
-
-
Save alainravet/3601889 to your computer and use it in GitHub Desktop.
cowsay video notes
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
| brew install cowsay | |
| x = (<<'END') | |
| don't escape the backslash, f.ex /\:/\ | |
| END | |
| IO.popen(['cowsay', message]) do |process| | |
| process.read | |
| end | |
| $ bundle init | |
| group :development, :test do | |
| gem 'guard' | |
| gem 'guard-bundler' | |
| gem 'guard-rspec' | |
| end | |
| $ bundle install --binstubs | |
| $ guard init | |
| TIV : rvm option to add local binstubs to path.. | |
| cowsay is also available as a perl program -> embed it in the app. | |
| $ which perl -> /usr/bin/perl | |
| $ which cowsay | |
| $ cp /usr/games/cowsay -> <project>/bin | |
| time : 30:00 | |
| require 'pathname' | |
| cowsay_path = Pathname(__FILE__).dir + "../bin/cowsay" | |
| perl_path = '/usr/bin/perl' | |
| IO.popen([perl_path, cowsay_path.to_s, message]) do |process| | |
| process.read | |
| end | |
| note: on a remote host, it will lack the cowsay files => we must embed them too in the project | |
| $ ls /usr/share/cowsay | |
| $ ls /usr/share/cowsay/cows | |
| $ cp -r /usr/share/cowsay/cows -> <>/lib/cowsay//cows | |
| ? how to make the (remote) program find the cows files? | |
| ? how to tell popen .. | |
| a: via a hash -> look into spawn.. | |
| $ man spawn | |
| cows_path = cowsay_path = Pathname(__FILE__).dir + "../lib/cowsay/cows".to_s | |
| env = {'COWPATH' => cows_path} | |
| IO.popen([env, perl_path, cowsay_path.to_s, message]) do |process| | |
| a short spike : | |
| lib/cow.rb | |
| require 'sinatra' | |
| require_relative 'cowsay' | |
| get '/' do | |
| content_type :txt | |
| Cowsay.new_cow.say('Hoo') | |
| end | |
| $ sinatra lib/cow | |
| $ open localhost:4567 | |
| ? how to test this ? | |
| time : 49:30 | |
| google : test sinatra with rack/test | |
| file: spec/cowsay_integration_spec.rb | |
| require 'rack/test' | |
| set :environment, :test | |
| .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment