Last active
August 29, 2015 13:56
-
-
Save thash/a86b9799ae60eb1deec6 to your computer and use it in GitHub Desktop.
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
task :goodbye, [:name, :alias] do |t, args| | |
puts "Goodbye, #{args.name} the #{args.alias}!" | |
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
task :default => :hello |
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
task :default => :hello | |
desc '挨拶をします' | |
task :hello do | |
puts "Hello!" | |
end | |
desc '名前とニックネームを引数にとり、別れの挨拶をします' | |
task :goodbye, [:name, :nickname] do |t, args| | |
puts "Goodbye, #{args.name} the #{args.nickname}!" | |
end | |
namespace :math do | |
desc '二乗を計算します' | |
task :square, [:n] do |t, args| | |
n = args.n.to_i | |
puts n * n | |
end | |
desc '三乗を計算します' | |
task :cube, [:n] do |t, args| | |
n = args.n.to_i | |
puts n * n * n | |
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
directory 'hoge/fuga/piyo' |
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
$ rake "goodbye[Rake, greeter]" | |
Goodbye, Rake the greeter! |
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
$ rake | |
Hello! |
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
$ rake -T | |
rake goodbye[name,nickname] # 名前とニックネームを引数にとり、別れの挨拶をします | |
rake hello # 挨拶をします | |
rake math:cube[n] # 三乗を計算します | |
rake math:square[n] # 二乗を計算します |
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
$ rake hoge/fuga/piyo | |
mkdir -p hoge/fuga/piyo |
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
$ ls | |
Rakefile | |
$ rake hoge.txt | |
writing hoge.txt | |
$ ls | |
Rakefile hoge.txt | |
$ cat hoge.txt | |
texttext | |
$ rake hoge.txt # 何も起こらない |
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
$ rake hello | |
Hello! |
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
$ rake "math:square[2]" | |
4 | |
$ rake "math:cube[2]" | |
8 |
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
file 'hoge.txt' do | |
puts 'writing hoge.txt' | |
open('./hoge.txt', 'w'){|f| f.write 'texttext' } | |
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
task :hello do | |
puts 'Hello!' | |
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
$ gem install rake | |
rake's executable "rake" conflicts with /Users/hash/.rbenv/versions/2.0.0-p353/bin/rake | |
Overwrite the executable? [yN] y | |
Successfully installed rake-10.1.1 | |
1 gem installed | |
$ rake --version | |
rake, version 10.1.1 |
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
namespace :math do | |
task :square, [:n] do |t, args| | |
n = args.n.to_i | |
puts n * n | |
end | |
task :cube, [:n] do |t, args| | |
n = args.n.to_i | |
puts n * n * n | |
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
$ rake | |
rake aborted! | |
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) | |
(See full trace by running task with --trace) |
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
$ ruby fork.rb | |
$ ps aux | grep "[r]uby" # (別ターミナルで) | |
hash 45929 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45928 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45927 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45926 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45925 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45924 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45923 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45922 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45921 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb | |
hash 45920 0.0 0.0 2457176 456 s001 S 8:33AM 0:00.00 ruby fork.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment