Class: VimEpidemic::Controller
- Inherits:
-
Object
- Object
- VimEpidemic::Controller
- Defined in:
- lib/vim-epidemic/controller.rb
Instance Method Summary collapse
- #add(args, options = {}) ⇒ Object
- #info(options = {}) ⇒ Object
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #update(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
6 7 8 |
# File 'lib/vim-epidemic/controller.rb', line 6 def initialize @config = Config.new end |
Instance Method Details
#add(args, options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vim-epidemic/controller.rb', line 44 def add args, = {} load_config! unless @config.has? *args @config.touch unless @config.exists? File.open(@config.file, 'a') do |f| f.write %|\ninstall "#{args.first}"| end @config.add *args end show_info end |
#info(options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/vim-epidemic/controller.rb', line 10 def info = {} load_config! show_info end |
#update(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vim-epidemic/controller.rb', line 15 def update = {} check_requirements! load_config! puts "\n#{}\n" if @config.empty? puts "\nNothing to update.\n\n" exit 0 end successful = true @config.plugins.each do |plugin| puts action = plugin.installed? ? 'Updating' : 'Installing' puts Paint["#{action} #{plugin}...", :yellow] if plugin.install puts Paint["Done!", :green] else successful = false puts Paint["Could not install.", :red] end end puts if successful puts Paint["All plugins were successfully installed/updated.", :green, :bold] else puts Paint["There were problems with some of the plugins.", :red, :bold] end puts end |