lib/csd/container.rb in csd-0.1.8 vs lib/csd/container.rb in csd-0.1.9

- old
+ new

@@ -1,14 +1,28 @@ # -*- encoding: UTF-8 -*- module CSD class << self - # This method chooses and holds the user interface instance. + + # This method holds the user interface instance. # def ui - @@ui ||= UserInterface::CLI.new + # In testmode we don't want to perform caching + return choose_ui if Options.testmode + # Otherwise we choose and cache the UI here + @@ui ||= choose_ui end + + # This method chooses an user interface instance according to the Options and returns a new instance of it. + # + def choose_ui + if Options.silent + UserInterface::Silent.new + else + UserInterface::CLI.new + end + end # This method chooses and holds the command execution instance. # def cmd @@cmd ||= Commands.new @@ -52,9 +66,14 @@ end # A wrapper for the Options class to be able to run all methods as class methods. # class Options + # Because the Options class will respond to clear, we must pass it on explicitly to the OptionsParser instance residing in CSD.options + # + def self.clear + ::CSD.options.clear + end def self.method_missing(meth, *args, &block) ::CSD.options.send(meth, *args, &block) end end end \ No newline at end of file