module Odin
Public Instance Methods
bundle(task='')
click to toggle source
# File lib/r4/odin.rb, line 71 def bundle task='' system "bundle #{task}" end
concat(filename, part)
click to toggle source
# File lib/r4/odin.rb, line 35 def concat filename, part File.open(filename) do |f| content = f.read file filename, content + part end end
content(filename)
click to toggle source
# File lib/r4/odin.rb, line 31 def content filename File.open(filename).read end
cp(from, to)
click to toggle source
# File lib/r4/odin.rb, line 48 def cp from, to system "cp #{from} #{to}" end
cp_template(template_dir, path)
click to toggle source
# File lib/r4/odin.rb, line 55 def cp_template template_dir, path cp "#{template_dir}/#{path}", path end
file(filename, content)
click to toggle source
# File lib/r4/odin.rb, line 42 def file filename, content File.open(filename, 'w') do |f| f.write content end end
git(task)
click to toggle source
# File lib/r4/odin.rb, line 67 def git task system "git #{task}" end
gsub(filename, options={})
click to toggle source
# File lib/r4/odin.rb, line 3 def gsub filename, options={}, &block puts options[:log] if options[:log] fr = File.new(filename) content = fr.read fr.close change = content.clone block.call change unless content==change fw = File.new filename, 'w' fw.write change fw.close end end
rails(task)
click to toggle source
# File lib/r4/odin.rb, line 63 def rails task system "rails #{task}" end
rake(task)
click to toggle source
# File lib/r4/odin.rb, line 59 def rake task system "rake #{task}" end
rm(what)
click to toggle source
# File lib/r4/odin.rb, line 51 def rm what system "rm #{what}" end
sub(filename, mark, part, options={})
click to toggle source
# File lib/r4/odin.rb, line 17 def sub filename, mark, part, options={} File.open(filename) do |f| content = f.read if options[:global] change = content.gsub mark, part else change = content.sub mark, part end unless change==content file filename, change end end end