Dear Home Owner, このページをアンテナに追加 RSSフィード

 | 

2006-09-03

Config File Management with Rake  Config File Management with Rake - Dear Home Owner, を含むブックマーク はてなブックマーク -  Config File Management with Rake - Dear Home Owner,  Config File Management with Rake - Dear Home Owner, のブックマークコメント

f:id:youpy:20060905014718j:image

inspired by

Rakefile

require 'rake'

EXT = '.__config'

SRC = FileList[File.join('config', '**', '*' + EXT)]
DST = SRC.gsub(/^config/, '').ext('')

SRC.zip(DST) do |src, dst|
  desc "Deploy #{dst}"
  file dst => src do
    cp src, dst
  end
end

desc "Add file (rake add FILE=filename)"
task :add do
  dst = ENV['FILE']
  raise "Not a file" unless File.file?(dst)
  src = File.join('config', dst)
  mkdir_p File.dirname(src)
  cp dst, src + EXT
end
  
desc "Remove file (rake remove FILE=filename)"
task :remove do
  SRC.zip(DST) do |src, dst|
    if ENV['FILE'] == dst
      rm src
      break
    end
  end
end

desc "List files under management"
task :list do
  puts DST.join("\n")
end

task :default => DST
$ rake add FILE=/etc/httpd/users/youpy.conf
(in /Users/youpy/work/ruby/config_management_with_rake)
mkdir -p config/etc/httpd/users
cp /etc/httpd/users/youpy.conf config/etc/httpd/users/youpy.conf.__config
$ rake --tasks
(in /Users/youpy/work/ruby/config_management_with_rake)
rake /etc/httpd/users/youpy.conf  # Deploy /etc/httpd/users/youpy.conf
rake add                          # Add file (rake add FILE=filename)
rake list                         # List files under management
rake remove                       # Remove file (rake remove FILE=filename)
$ rake list
(in /Users/youpy/work/ruby/config_management_with_rake)
/etc/httpd/users/youpy.conf
$ vi config/etc/httpd/httpd.conf.__config
$ sudo rake
(in /Users/youpy/work/ruby/config_management_with_rake)
cp config/etc/httpd/users/youpy.conf.__config /etc/httpd/users/youpy.conf

casino bettingcasino betting2006/12/25 11:38Interesting, but navigation system is a little bit confusing

----------

トラックバック - http://subtech.g.hatena.ne.jp/youpy/20060903
 |