Sha256: fb88394eea0f54a500e4000c652b51ca3d5dbb43d5fc3a340586cc5c4669b2bd

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

module Odin

  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

  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

  def content filename
    File.open(filename).read
  end

  def concat filename, part
    File.open(filename) do |f|
      content = f.read
      file filename, content + part
    end
  end

  def file filename, content
    File.open(filename, 'w') do |f|
      f.write content
    end
  end

  def cp from, to
    system "cp #{from} #{to}"
  end
  def rm what
    system "rm #{what}"
  end

  def cp_template template_dir, path
    cp "#{template_dir}/#{path}", path
  end

  def rake task
    system "rake #{task}"
  end

  def rails task
    system "rails #{task}"
  end

  def git task
    system "git #{task}"
  end

  def bundle task=''
    system "bundle #{task}"
  end

end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
r5-0.5.0.0 lib/r5/odin.rb
r5-0.4.0.5 lib/r5/odin.rb
r5-0.4.0.4 lib/r5/odin.rb
r5-0.4.0.2 lib/r5/odin.rb
r5-0.4.0.1 lib/r5/odin.rb
r5-0.4.0.0 lib/r5/odin.rb
r5-0.3.0.0 lib/r5/odin.rb
r5-0.2.6.2 lib/r5/odin.rb
r5-0.2.6.1 lib/r5/odin.rb
r5-0.2.6.0 lib/r5/odin.rb
r5-0.2.5.2 lib/r5/odin.rb
r5-0.2.5 lib/r5/odin.rb
r5-0.2.4 lib/r5/odin.rb
r5-0.2.3 lib/r5/odin.rb
r5-0.2.0 lib/r5/odin.rb
r5-0.1.9 lib/r5/odin.rb
r5-0.1.8 lib/r5/odin.rb
r5-0.1.7 lib/r5/odin.rb
r5-0.1.6 lib/r5/odin.rb
r5-0.1.5 lib/r5/odin.rb