Class: Yap::Cli::Commands::Addon::Disable
- Inherits:
-
Object
- Object
- Yap::Cli::Commands::Addon::Disable
- Defined in:
- lib/yap/cli/commands/addon/disable.rb
Instance Method Summary collapse
-
#initialize(addon_name) ⇒ Disable
constructor
A new instance of Disable.
- #process ⇒ Object
Constructor Details
#initialize(addon_name) ⇒ Disable
Returns a new instance of Disable.
5 6 7 |
# File 'lib/yap/cli/commands/addon/disable.rb', line 5 def initialize(addon_name) @addon_name = addon_name end |
Instance Method Details
#process ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yap/cli/commands/addon/disable.rb', line 9 def process configuration = Yap.configuration addon_refs = Yap::Addon::Path.find_for_configuration(configuration) addon_config_hsh = {} found_addon_ref = nil addon_refs.each do |addon_ref| is_disabled = addon_ref.disabled? if addon_ref.name.to_s == @addon_name.to_s is_disabled = true found_addon_ref = addon_ref end addon_config_hsh[addon_ref.name] = { disabled: is_disabled } end if found_addon_ref destination = configuration.yap_addons_configuration_path.to_s FileUtils.mkdir_p File.dirname(destination) File.write destination, addon_config_hsh.to_yaml puts "Addon #{found_addon_ref.name} has been disabled" else puts "Could not find addon with name #{@addon_name}" end end |