Class: Bcupgrade::Cask
- Inherits:
-
Object
- Object
- Bcupgrade::Cask
- Defined in:
- lib/bcupgrade/cask.rb
Instance Attribute Summary collapse
-
#error_casks ⇒ Object
readonly
Returns the value of attribute error_casks.
-
#installed_casks ⇒ Object
readonly
Returns the value of attribute installed_casks.
Instance Method Summary collapse
- #check_version ⇒ Object
-
#initialize(options, args) ⇒ Cask
constructor
A new instance of Cask.
- #upgrade_version(casks) ⇒ Object
Constructor Details
#initialize(options, args) ⇒ Cask
Returns a new instance of Cask.
7 8 9 10 11 12 13 14 |
# File 'lib/bcupgrade/cask.rb', line 7 def initialize(, args) @config = config @options = @args = args.uniq @list = upgrade_target @installed_casks = @list[0] @error_casks = @list[1] end |
Instance Attribute Details
#error_casks ⇒ Object (readonly)
Returns the value of attribute error_casks.
5 6 7 |
# File 'lib/bcupgrade/cask.rb', line 5 def error_casks @error_casks end |
#installed_casks ⇒ Object (readonly)
Returns the value of attribute installed_casks.
5 6 7 |
# File 'lib/bcupgrade/cask.rb', line 5 def installed_casks @installed_casks end |
Instance Method Details
#check_version ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bcupgrade/cask.rb', line 16 def check_version update_casks = [] @installed_casks.each do |name| cask_info = BrewCask.info(name) version_number = trim_latest_version(cask_info) string = "/#{name}/#{version_number}" latest_version = cask_info.include?(string) ? nil : version_number if latest_version puts "#{name} (#{latest_version})" update_casks.push(name) end end update_casks end |
#upgrade_version(casks) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bcupgrade/cask.rb', line 35 def upgrade_version(casks) return if @options[:dry_run] casks.each do |cask| input = if @options[:install] 'y' else Readline.readline("\nUpgrade #{cask}? [y/n] ") end next unless input == 'y' if @options[:remove] puts "\n==> Remove #{cask}" BrewCask.remove(cask) end puts "\n==> Install #{cask}" BrewCask.install(cask) end end |