Class: RailsEditor
- Inherits:
-
Object
- Object
- RailsEditor
- Defined in:
- lib/rails-editor.rb
Instance Attribute Summary collapse
-
#rails_root ⇒ Object
Returns the value of attribute rails_root.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(args = {:rails_root => ENV['PWD']}) ⇒ RailsEditor
constructor
A new instance of RailsEditor.
Constructor Details
#initialize(args = {:rails_root => ENV['PWD']}) ⇒ RailsEditor
Returns a new instance of RailsEditor.
7 8 9 |
# File 'lib/rails-editor.rb', line 7 def initialize(args = {:rails_root => ENV['PWD']}) @rails_root = args[:rails_root] end |
Instance Attribute Details
#rails_root ⇒ Object
Returns the value of attribute rails_root.
6 7 8 |
# File 'lib/rails-editor.rb', line 6 def rails_root @rails_root end |
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails-editor.rb', line 11 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 |