Skip to content

Commit c31e6b0

Browse files
committed
Fixing robocop issues, extending travis build with pin commands
1 parent 9f30914 commit c31e6b0

File tree

6 files changed

+32
-34
lines changed

6 files changed

+32
-34
lines changed

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ language: ruby
33
os: osx
44

55
rvm:
6-
# - 2.5
76
- 2.6
8-
# - 2.7
97

108
before_install:
119
- brew update
@@ -21,4 +19,8 @@ script:
2119
- cd /usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade
2220
- rubocop --version
2321
- rubocop
22+
- brew cu pin java
23+
- brew cu pinned
24+
- brew cu -y --no-brew-update
25+
- brew cu unpin java
2426
- brew cu -y --no-brew-update

lib/bcu/command/pin_list.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def list_pinned(_args, _options)
2121
def add_cask(cask_name, casks)
2222
casks.push Cask.load_cask(cask_name)
2323
rescue Cask::CaskUnavailableError
24-
Bcu::Pin::Remove.remove_pin cask:cask_name
24+
Bcu::Pin::Remove.remove_pin cask: cask_name
2525
end
2626
end
2727
end

lib/bcu/command/pin_remove.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def process(args, options)
88
# TODO: If we used deprecated --pin option, the value is not any more in the args
99
pin = options.unpin if pin.nil?
1010

11-
remove_pin cask:pin
11+
remove_pin cask: pin
1212
end
1313

1414
private

lib/bcu/command/upgrade.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ def find_outdated_apps(installed, options)
113113
found
114114
end
115115

116-
if installed.empty?
117-
odie empty_message(options.casks)
118-
end
116+
odie empty_message(options.casks) if installed.empty?
119117
end
120118

121119
installed.each do |app|

lib/bcu/options.rb

+24-26
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,9 @@ def self.validate_options(options)
119119
end
120120
end
121121

122-
def self.build_config(use_config_file = true)
123-
if use_config_file
124-
options = load_default_options
125-
else
126-
options = create_default_options
127-
end
122+
def self.build_config(use_config_file: true)
123+
options = use_config_file ? load_default_options : create_default_options
124+
128125
options.casks = nil
129126
options.install_options = ""
130127
options.list_pinned = false
@@ -145,10 +142,12 @@ def self.load_default_options
145142
default_options = create_default_options
146143
if File.exist?(config_filename)
147144
odebug "Loading configuration from config file"
148-
handle = File.open(config_filename)
149-
options = YAML::load handle.read
150-
odebug "Configuration loaded", options
151-
OpenStruct.new(options.to_h)
145+
options = {}
146+
File.open(config_filename) do |f|
147+
options = (YAML.safe_load f.read).to_h
148+
odebug "Configuration loaded", options
149+
end
150+
OpenStruct.new options
152151
else
153152
# something went wrong while reading config file
154153
odebug "Config file wasn't created, setting default config"
@@ -172,27 +171,26 @@ def self.create_default_options
172171
end
173172

174173
def self.create_default_config_file(config_filename)
175-
begin
176-
system "touch #{config_filename}"
177-
handle = File.open(config_filename, "w")
178-
handle.write default_config_hash.to_yaml
179-
handle.close
180-
rescue Exception => e
181-
odebug "RESCUE: File couldn't be created", e
182-
system "rm -f #{config_filename}"
174+
File.unlink config_filename
175+
system "touch #{config_filename}"
176+
File.open(config_filename, "w") do |f|
177+
f.write default_config_hash.to_yaml
183178
end
179+
rescue => e
180+
odebug "RESCUE: File couldn't be created", e
181+
system "rm -f #{config_filename}"
184182
end
185183

186184
def self.default_config_hash
187185
{
188-
"all" => false,
189-
"force" => false,
190-
"cleanup" => false,
191-
"force_yes" => false,
192-
"no_brew_update" => false,
193-
"quiet" => false,
194-
"verbose" => false,
195-
"interactive" => false,
186+
"all" => false,
187+
"force" => false,
188+
"cleanup" => false,
189+
"force_yes" => false,
190+
"no_brew_update" => false,
191+
"quiet" => false,
192+
"verbose" => false,
193+
"interactive" => false,
196194
}
197195
end
198196
end

lib/extend/cask.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# For backward-compatibility
22
# See https://github.com/buo/homebrew-cask-upgrade/issues/97
3-
CASKROOM = Cask.methods.include?(:caskroom) ? Cask.caskroom.freeze : Cask::Caskroom.path.freeze
3+
CASKROOM = (Cask.methods.include?(:caskroom) ? Cask.caskroom : Cask::Caskroom.path).freeze
44

55
module Cask
66
def self.installed_apps

0 commit comments

Comments
 (0)