Skip to content

Commit

Permalink
Rubocop cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lacostej committed Feb 20, 2020
1 parent 733cc5d commit bfa50ba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/u3d_core/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module U3dCore
class Env
def self.truthy?(env)
return false unless ENV[env]
return false if ["no", "false", "off", "0"].include?(ENV[env].to_s)
return false if %w[no false off 0].include?(ENV[env].to_s)
return true
end
end
end
end
6 changes: 4 additions & 2 deletions lib/u3d_core/update_checker/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class << self
def show_changes(gem_name, current_version, update_gem_command: "bundle update")
did_show_changelog = false

self.releases(gem_name).each_with_index do |release, index|
releases(gem_name).each_with_index do |release, index|
next unless Gem::Version.new(release['tag_name']) > Gem::Version.new(current_version)
puts("")
puts(release['name'].green)
Expand All @@ -43,7 +43,9 @@ def show_changes(gem_name, current_version, update_gem_command: "bundle update")

puts("")
puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
rescue
# rubocop:disable Lint/HandleExceptions
rescue StandardError
# rubocop:enable Lint/HandleExceptions
# Something went wrong, we don't care so much about this
end

Expand Down
24 changes: 12 additions & 12 deletions lib/u3d_core/update_checker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
# SOFTWARE.
## --- END LICENSE BLOCK ---

#require 'excon'
#require 'digest'
# require 'excon'
# require 'digest'

require_relative 'changelog'
#require_relative '../analytics/app_identifier_guesser'
#require_relative '../helper'
# require_relative '../analytics/app_identifier_guesser'
# require_relative '../helper'
require_relative '../ui/ui'

module U3dCore
Expand All @@ -41,7 +41,9 @@ def self.start_looking_for_update(gem_name)
Thread.new do
begin
server_results[gem_name] = fetch_latest(gem_name)
rescue
# rubocop:disable Lint/HandleExceptions
rescue StandardError
# rubocop:enable Lint/HandleExceptions
# we don't want to show a stack trace if something goes wrong
end
end
Expand All @@ -57,7 +59,7 @@ class << self

def self.update_available?(gem_name, current_version)
latest = server_results[gem_name]
return (latest and Gem::Version.new(latest) > Gem::Version.new(current_version))
return (latest && (Gem::Version.new(latest) > Gem::Version.new(current_version)))
end

# wait a abit for results when commands run real quick
Expand All @@ -67,9 +69,7 @@ def self.wait_for_results

def self.show_update_status(gem_name, current_version)
wait_for_results unless update_available?(gem_name, current_version)
if update_available?(gem_name, current_version)
show_update_message(gem_name, current_version)
end
show_update_message(gem_name, current_version) if update_available?(gem_name, current_version)
end

# Show a message to the user to update to a new version of u3d
Expand All @@ -85,7 +85,7 @@ def self.show_update_message(gem_name, current_version)
puts("# An update for #{gem_name} is available. You are on #{current_version}.")
end
puts("# You should use the latest version.")
puts("# Please update using `#{self.update_command(gem_name: gem_name)}`.")
puts("# Please update using `#{update_command(gem_name: gem_name)}`.")

# this could be fetched from the gem
puts("# To see what's new, open https://github.com/DragonBox/#{gem_name}/releases.") if U3dCore::Env.truthy?("U3D_HIDE_CHANGELOG")
Expand All @@ -105,9 +105,9 @@ def self.show_update_message(gem_name, current_version)
def self.update_command(gem_name: "u3d")
if Helper.bundler?
"bundle update #{gem_name.downcase}"
#elsif Helper.homebrew?
# elsif Helper.homebrew?
# "fastlane update_fastlane"
#elsif Helper.mac_app?
# elsif Helper.mac_app?
# "the Fabric app. Launch the app and navigate to the fastlane tab to get the most recent version."
else
"sudo gem install #{gem_name.downcase}"
Expand Down
2 changes: 1 addition & 1 deletion u3d.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Gem::Specification.new do |spec|

spec.add_dependency 'colored', '>= 1.2', '< 2.0.0' # terminal
spec.add_dependency 'commander', '>= 4.4.0', '< 5.0.0' # CLI parser
spec.add_dependency 'excon'
spec.add_dependency 'file-tail', '>= 1.2.0'
spec.add_dependency 'filesize', '>= 0.1.1' # File sizes prettifier
spec.add_dependency 'inifile', '>= 3.0.0', '< 4.0.0' # Parses INI files
spec.add_dependency 'plist', '>= 3.1.0', '< 4.0.0' # Generate the Xcode config plist file
spec.add_dependency 'rubyzip', '>= 1.0.0' # Installation of .zip files
spec.add_dependency 'security', '= 0.1.3' # macOS Keychain manager, a dead project, no updates expected
spec.add_dependency 'excon'
# Development only
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "coveralls"
Expand Down

0 comments on commit bfa50ba

Please sign in to comment.