Class: Xmvc::Update::Updater
- Inherits:
-
Object
- Object
- Xmvc::Update::Updater
- Defined in:
- lib/xmvc/update.rb
Instance Method Summary collapse
- #delete_file(filename) ⇒ Object
- #ensure_build ⇒ Object
- #ensure_generate ⇒ Object
- #ensure_info ⇒ Object
- #ensure_setup ⇒ Object
- #ensure_stats ⇒ Object
- #ensure_update ⇒ Object
-
#initialize ⇒ Updater
constructor
A new instance of Updater.
- #install_file(filename, contents) ⇒ Object
Constructor Details
#initialize ⇒ Updater
Returns a new instance of Updater.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xmvc/update.rb', line 10 def initialize [:build, :generate, :info, :setup, :stats].each do |script| self.send("ensure_#{script}") end # Updates from 0.6a1 to 0.6b1... this is a bit shit :( changes = [ {:old => 'ExtMVC.Model', :new => 'ExtMVC.model'}, {:old => 'ExtMVC.Controller', :new => 'ExtMVC.controller.Controller'}, {:old => 'ExtMVC.CrudController', :new => 'ExtMVC.controller.CrudController'}, {:old => 'ExtMVC.Route', :new => 'ExtMVC.router.Route'}, {:old => 'ExtMVC.Router', :new => 'ExtMVC.router.Router'} ] changes.each do |pair| system("find ./app/**/*.js | xargs perl -wi -pe 's/#{pair[:old]}/#{pair[:new]}/g'") system("find ./config/*js | xargs perl -wi -pe 's/#{pair[:old]}/#{pair[:new]}/g'") end # End updates from 0.6a1 to 0.6b... it's still shit end |
Instance Method Details
#delete_file(filename) ⇒ Object
55 56 57 58 |
# File 'lib/xmvc/update.rb', line 55 def delete_file filename File.delete() rescue end |
#ensure_build ⇒ Object
31 32 33 |
# File 'lib/xmvc/update.rb', line 31 def ensure_build install_file('build', 'ExtMVC::Builder.dispatch') end |
#ensure_generate ⇒ Object
35 36 37 |
# File 'lib/xmvc/update.rb', line 35 def ensure_generate install_file('generate', 'ExtMVC::Generator.dispatch') end |
#ensure_info ⇒ Object
39 40 41 |
# File 'lib/xmvc/update.rb', line 39 def ensure_info install_file('info', 'ExtMVC.show_settings') end |
#ensure_setup ⇒ Object
43 44 45 |
# File 'lib/xmvc/update.rb', line 43 def ensure_setup install_file('setup', 'ExtMVC.setup(ARGV.shift)') end |
#ensure_stats ⇒ Object
47 48 49 |
# File 'lib/xmvc/update.rb', line 47 def ensure_stats install_file('stats', 'ExtMVC::Stats.dispatch') end |
#ensure_update ⇒ Object
51 52 53 |
# File 'lib/xmvc/update.rb', line 51 def ensure_update install_file('update', 'ExtMVC::Update.dispatch') end |
#install_file(filename, contents) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/xmvc/update.rb', line 60 def install_file filename, contents filename = "script/#{filename}" delete_file filename str = "require 'vendor/mvc/scripts/scripts'\n\n" + contents FileUtils.touch(filename) File.open(filename, "w") {|f| f.puts str} end |