Sha256: 455c19b7b63b710f6d4c007fcfe7e9967df8fed7471b132a8fedd476de3f6631

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

EDITOR_LIB_HOME = File.expand_path(File.dirname(__FILE__) + "/../")
require "rubygems"
require "rake/gempackagetask"
require "fileutils"
class RailsEditor
  attr_accessor :rails_root
  def initialize(args = {:rails_root => ENV['PWD']})
    @rails_root = args[:rails_root]
  end

  def create
    rails_home = EDITOR_LIB_HOME + "/rails"
    files = FileList[rails_home + "/**/*"].to_a 
    files += FileList[rails_home + "/.vim/**/*"]
    files += [rails_home + "/.vimrc",rails_home + "/config/.screenrc.code.erb"]
    files.to_a.each do |editor_file|
      save_dir = @rails_root + File.dirname(editor_file.split(rails_home)[1])
      if FileTest.directory?(editor_file)
        if not File.exists?(save_dir)
          puts 'Dir.mkdir("' + save_dir + '")'
          Dir.mkdir(save_dir)
        end
        next
      end
      if not File.exists?(save_dir) or not FileTest.directory?(save_dir)
          puts "Dir.mkdir(" + save_dir + ") "
          Dir.mkdir(save_dir) 
      end
      puts "FileUtils.cp(" + editor_file + "," + save_dir  + "/" + File.basename(editor_file) +  ") "
      FileUtils.cp(editor_file,save_dir  + "/" + File.basename(editor_file)) 
    end
    if File.exists? editor_script = @rails_root + "/script/editor"
      File.chmod(0755,editor_script) 
    end
    puts "******************************************************"
    puts "** Rails Editor Installed, ./script/editor to start **"
    puts "******************************************************"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
RailsEditor-0.0.29 lib/rails-editor.rb