[DRE-commits] [ruby-aruba] 89/98: Fixed offenses
Hideki Yamane
henrich at moszumanska.debian.org
Tue Mar 22 12:20:44 UTC 2016
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository ruby-aruba.
commit eefb1fd5f538fc017574464919f44057f8c2d914
Author: Dennis Günnewig <dg1 at ratiodata.de>
Date: Tue Mar 8 16:37:53 2016 +0100
Fixed offenses
---
.rubocop.yml | 10 +++++--
Gemfile | 2 +-
Rakefile | 12 ++------
features/support/env.rb | 10 +++----
fixtures/cli-app/lib/cli/app/version.rb | 2 +-
fixtures/empty-app/lib/cli/app/version.rb | 2 +-
lib/aruba/api/core.rb | 2 +-
lib/aruba/api/deprecated.rb | 26 ++---------------
lib/aruba/api/filesystem.rb | 2 +-
lib/aruba/aruba_path.rb | 2 +-
lib/aruba/colorizer.rb | 2 +-
lib/aruba/command.rb | 4 +--
lib/aruba/config/jruby.rb | 2 +-
lib/aruba/config_wrapper.rb | 2 +-
lib/aruba/cucumber/command.rb | 1 -
lib/aruba/file_size.rb | 4 +--
lib/aruba/matchers/base/object_formatter.rb | 4 +--
lib/aruba/matchers/path/match_path_pattern.rb | 2 +-
lib/aruba/platforms/announcer.rb | 18 ++++++------
lib/aruba/platforms/filesystem_status.rb | 2 +-
lib/aruba/platforms/local_environment.rb | 2 +-
lib/aruba/platforms/simple_table.rb | 2 +-
lib/aruba/platforms/unix_command_string.rb | 2 +-
lib/aruba/platforms/unix_environment_variables.rb | 34 ++++++++++------------
lib/aruba/platforms/windows_command_string.rb | 2 +-
.../platforms/windows_environment_variables.rb | 28 +++++++++---------
lib/aruba/processes/basic_process.rb | 2 +-
lib/aruba/processes/debug_process.rb | 4 ---
lib/aruba/processes/spawn_process.rb | 8 ++---
lib/aruba/runtime.rb | 10 +++----
lib/aruba/setup.rb | 2 +-
lib/aruba/version.rb | 2 +-
spec/aruba/api_spec.rb | 24 +++++++--------
spec/aruba/jruby_spec.rb | 2 +-
spec/aruba/matchers/file_spec.rb | 4 +--
spec/support/helpers/reporting.rb | 2 +-
spec/support/shared_examples/configuration.rb | 2 +-
37 files changed, 105 insertions(+), 138 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index 8a99978..47c8a6d 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -128,7 +128,7 @@ Style/SingleLineBlockParams:
Enabled: false
# Cop supports --auto-correct.
-Style/SingleSpaceBeforeFirstArg:
+Style/SpaceBeforeFirstArg:
Enabled: false
# Cop supports --auto-correct.
@@ -136,7 +136,7 @@ Style/SpaceAfterComma:
Enabled: false
# Cop supports --auto-correct.
-Style/SpaceAfterControlKeyword:
+Style/SpaceAroundKeyword:
Enabled: false
# Cop supports --auto-correct.
@@ -180,3 +180,9 @@ Style/RaiseArgs:
Metrics/ParameterLists:
Enabled: false
+
+Style/IfInsideElse:
+ Enabled: false
+
+Style/IdenticalConditionalBranches:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index b5b83ac..bd40a22 100644
--- a/Gemfile
+++ b/Gemfile
@@ -55,7 +55,7 @@ group :development, :test do
if RUBY_VERSION >= '1.9.3'
# Make aruba compliant to ruby community guide
- gem 'rubocop', '~> 0.32.0'
+ gem 'rubocop', '~> 0.32'
end
if RUBY_VERSION >= '1.9.3'
diff --git a/Rakefile b/Rakefile
index dcbba00..78583c3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -36,17 +36,11 @@ namespace :travis do
end
end
-if RUBY_VERSION < '1.9.3'
+task :rubocop do
begin
- require 'rubocop/rake_task'
- RuboCop::RakeTask.new
- rescue LoadError
- desc 'Stub task to make rake happy'
- task(:rubocop) {}
+ sh 'rubocop --fail-level E'
+ rescue
end
-else
- require 'rubocop/rake_task'
- RuboCop::RakeTask.new
end
desc "Run tests, both RSpec and Cucumber"
diff --git a/features/support/env.rb b/features/support/env.rb
index aa3598b..a7f8043 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -25,9 +25,9 @@ Before do |scenario|
simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
# set environment variable so child processes will merge their coverage data with parent process's coverage data.
- if RUBY_VERSION < '1.9'
- ENV['RUBYOPT'] = "-r rubygems -r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}"
- else
- ENV['RUBYOPT'] = "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}"
- end
+ ENV['RUBYOPT'] = if RUBY_VERSION < '1.9'
+ "-r rubygems -r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}"
+ else
+ "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}"
+ end
end
diff --git a/fixtures/cli-app/lib/cli/app/version.rb b/fixtures/cli-app/lib/cli/app/version.rb
index 07b8ed6..f2f5d82 100644
--- a/fixtures/cli-app/lib/cli/app/version.rb
+++ b/fixtures/cli-app/lib/cli/app/version.rb
@@ -1,5 +1,5 @@
module Cli
module App
- VERSION = "0.1.0"
+ VERSION = "0.1.0".freeze
end
end
diff --git a/fixtures/empty-app/lib/cli/app/version.rb b/fixtures/empty-app/lib/cli/app/version.rb
index 07b8ed6..f2f5d82 100644
--- a/fixtures/empty-app/lib/cli/app/version.rb
+++ b/fixtures/empty-app/lib/cli/app/version.rb
@@ -1,5 +1,5 @@
module Cli
module App
- VERSION = "0.1.0"
+ VERSION = "0.1.0".freeze
end
end
diff --git a/lib/aruba/api/core.rb b/lib/aruba/api/core.rb
index a24c60f..3d23f3a 100644
--- a/lib/aruba/api/core.rb
+++ b/lib/aruba/api/core.rb
@@ -57,7 +57,7 @@ module Aruba
aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:old => old_directory, :new => new_directory)
- old_dir = Aruba.platform.getwd
+ old_dir = Aruba.platform.getwd
Aruba.platform.chdir File.join(aruba.root_directory, aruba.current_directory)
diff --git a/lib/aruba/api/deprecated.rb b/lib/aruba/api/deprecated.rb
index 628a2d4..81d5c50 100644
--- a/lib/aruba/api/deprecated.rb
+++ b/lib/aruba/api/deprecated.rb
@@ -289,7 +289,7 @@ module Aruba
stop_all_commands
- cd('') { block.call }
+ cd('') { yield }
end
# @deprecated
@@ -388,7 +388,7 @@ module Aruba
env.each do |k,v|
set_env k, v
end
- block.call
+ yield
restore_env
end
@@ -565,9 +565,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If arg1 is exactly the same as arg2 return true, otherwise false
def assert_exact_output(expected, actual)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_exact_output" is deprecated. Use "expect(command).to have_output \'exact\'" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
expect(Aruba.platform.unescape(actual, aruba.config.keep_ansi)).to eq Aruba.platform.unescape(expected, aruba.config.keep_ansi)
@@ -580,9 +578,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If arg2 contains arg1 return true, otherwise false
def assert_partial_output(expected, actual)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_partial_output" is deprecated. Use "expect(command).to have_output /partial/" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
expect(Aruba.platform.unescape(actual, aruba.config.keep_ansi)).to include(Aruba.platform.unescape(expected, aruba.config.keep_ansi))
@@ -595,9 +591,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If arg2 matches arg1 return true, otherwise false
def assert_matching_output(expected, actual)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_matching_output" is deprecated. Use "expect(command).to have_output /partial/" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
expect(Aruba.platform.unescape(actual, aruba.config.keep_ansi)).to match(/#{Aruba.platform.unescape(expected, aruba.config.keep_ansi)}/m)
@@ -610,9 +604,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If arg2 does not match arg1 return true, otherwise false
def assert_not_matching_output(expected, actual)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_not_matching_output" is deprecated. Use "expect(command).not_to have_output /partial/" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
expect(Aruba.platform.unescape(actual, aruba.config.keep_ansi)).not_to match(/#{Aruba.platform.unescape(expected, aruba.config.keep_ansi)}/m)
@@ -625,9 +617,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If arg2 does not match/include arg1 return true, otherwise false
def assert_no_partial_output(unexpected, actual)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_no_partial_output" is deprecated. Use "expect(command).not_to have_output /partial/" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
actual.force_encoding(unexpected.encoding) if RUBY_VERSION >= "1.9"
if Regexp === unexpected
@@ -644,9 +634,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If output of interactive command includes arg1 return true, otherwise false
def assert_partial_output_interactive(expected)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_partial_output_interactive" is deprecated. Use "expect(last_command_started).to have_output /partial/" instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
Aruba.platform.unescape(last_command_started.stdout, aruba.config.keep_ansi).include?(Aruba.platform.unescape(expected, aruba.config.keep_ansi)) ? true : false
end
@@ -658,9 +646,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If exit status is 0 and arg1 is included in output return true, otherwise false
def assert_passing_with(expected)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_passing_with" is deprecated. Use "expect(all_commands).to all(be_successfully_executed).and include_an_object(have_output(/partial/))" or something similar instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
assert_success(true)
assert_partial_output(expected, all_output)
@@ -673,9 +659,7 @@ module Aruba
# @return [TrueClass, FalseClass]
# If exit status is not equal 0 and arg1 is included in output return true, otherwise false
def assert_failing_with(expected)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_passing_with" is deprecated. Use "expect(all_commands).not_to include_an_object(be_successfully_executed).and include_an_object(have_output(/partial/))" or something similar instead. There are also special matchers for "stdout" and "stderr"')
- # rubocop:enable Metrics/LineLength
assert_success(false)
assert_partial_output(expected, all_output)
@@ -689,9 +673,7 @@ module Aruba
# If arg1 is true, return true if command was successful
# If arg1 is false, return true if command failed
def assert_success(success)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_success" is deprecated. Use "expect(last_command_started).to be_successfully_executed" or with "not_to" or the negative form "have_failed_running" (requires rspec >= 3.1)')
- # rubocop:enable Metrics/LineLength
if success
expect(last_command_started).to be_successfully_executed
@@ -702,18 +684,14 @@ module Aruba
# @deprecated
def assert_exit_status(status)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_success" is deprecated. Use "expect(last_command_started).to have_exit_status(status)"')
- # rubocop:enable Metrics/LineLength
expect(last_command_started).to have_exit_status(status)
end
# @deprecated
def assert_not_exit_status(status)
- # rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "#assert_success" is deprecated. Use "expect(last_command_started).not_to have_exit_status(status)"')
- # rubocop:enable Metrics/LineLength
expect(last_exit_status).not_to eq(status),
append_output_to("Exit status was #{last_exit_status} which was not expected.")
diff --git a/lib/aruba/api/filesystem.rb b/lib/aruba/api/filesystem.rb
index f0d6906..eff45bf 100644
--- a/lib/aruba/api/filesystem.rb
+++ b/lib/aruba/api/filesystem.rb
@@ -43,7 +43,7 @@ module Aruba
# @param [String] file
# The file which should exist
def executable?(path)
- path = expand_path(path)
+ path = expand_path(path)
Aruba.platform.file?(path) && Aruba.platform.executable?(path)
end
diff --git a/lib/aruba/aruba_path.rb b/lib/aruba/aruba_path.rb
index 56bcacd..28d5461 100644
--- a/lib/aruba/aruba_path.rb
+++ b/lib/aruba/aruba_path.rb
@@ -41,7 +41,7 @@ module Aruba
def push(p)
@delegate_sd_obj << p
end
- alias_method :<<, :push
+ alias << push
# Remove last component of path
#
diff --git a/lib/aruba/colorizer.rb b/lib/aruba/colorizer.rb
index 5d61770..2db79c7 100644
--- a/lib/aruba/colorizer.rb
+++ b/lib/aruba/colorizer.rb
@@ -32,7 +32,7 @@ module Aruba
[ :on_magenta , 45 ],
[ :on_cyan , 46 ],
[ :on_white , 47 ]
- ]
+ ].freeze
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
# :startdoc:
diff --git a/lib/aruba/command.rb b/lib/aruba/command.rb
index 352722a..8073b95 100644
--- a/lib/aruba/command.rb
+++ b/lib/aruba/command.rb
@@ -22,7 +22,6 @@ module Aruba
public
- # rubocop:disable Metrics/MethodLength
def initialize(command, opts = {})
launchers = []
launchers << Processes::DebugProcess
@@ -46,7 +45,6 @@ module Aruba
rescue KeyError => e
raise ArgumentError, e.message
end
- # rubocop:enable Metrics/MethodLength
# Stop command
def stop(*)
@@ -71,6 +69,6 @@ module Aruba
self
end
- alias_method :run!, :start
+ alias run! start
end
end
diff --git a/lib/aruba/config/jruby.rb b/lib/aruba/config/jruby.rb
index 579de43..0247162 100644
--- a/lib/aruba/config/jruby.rb
+++ b/lib/aruba/config/jruby.rb
@@ -9,7 +9,7 @@ Aruba.configure do |config|
ENV['JRUBY_OPTS'] = "-X-C #{ENV['JRUBY_OPTS']}" unless ENV['JRUBY_OPTS'].include? '-X-C'
# Faster startup for jruby
- ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless ENV['JRUBY_OPTS'].include? '--dev'
+ ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless ENV['JRUBY_OPTS'].include? '--dev'
# force jRuby to use client JVM for faster startup times
ENV['JAVA_OPTS'] = "-d32 #{ENV['JAVA_OPTS']}" if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i && !ENV['JAVA_OPTS'].include?('-d32')
diff --git a/lib/aruba/config_wrapper.rb b/lib/aruba/config_wrapper.rb
index 8698b8b..51b53a8 100644
--- a/lib/aruba/config_wrapper.rb
+++ b/lib/aruba/config_wrapper.rb
@@ -21,7 +21,7 @@ module Aruba
# @param [#notify] event_bus
# The event queue which should be notified.
def initialize(config, event_bus)
- @config = config
+ @config = config
@event_bus = event_bus
end
diff --git a/lib/aruba/cucumber/command.rb b/lib/aruba/cucumber/command.rb
index 53a9fca..a285fae 100644
--- a/lib/aruba/cucumber/command.rb
+++ b/lib/aruba/cucumber/command.rb
@@ -420,4 +420,3 @@ end
Given(/^I look for executables in "(.*)" within the current directory$/) do |directory|
prepend_environment_variable 'PATH', expand_path(directory) + ':'
end
-
diff --git a/lib/aruba/file_size.rb b/lib/aruba/file_size.rb
index 0c7d07d..ae6d695 100644
--- a/lib/aruba/file_size.rb
+++ b/lib/aruba/file_size.rb
@@ -22,7 +22,7 @@ module Aruba
def to_byte
bytes
end
- alias_method :to_i, :to_byte
+ alias to_i to_byte
# Convert to float
def to_f
@@ -33,7 +33,7 @@ module Aruba
def to_s
to_i.to_s
end
- alias_method :inspect, :to_s
+ alias inspect to_s
# Move to other
def coerce(other)
diff --git a/lib/aruba/matchers/base/object_formatter.rb b/lib/aruba/matchers/base/object_formatter.rb
index 8f2602b..9d4f6ca 100644
--- a/lib/aruba/matchers/base/object_formatter.rb
+++ b/lib/aruba/matchers/base/object_formatter.rb
@@ -57,7 +57,7 @@ module Aruba
end
end
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
+ TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
if Time.method_defined?(:nsec)
# @private
@@ -71,7 +71,7 @@ module Aruba
end
end
- DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z"
+ DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z".freeze
# ActiveSupport sometimes overrides inspect. If `ActiveSupport` is
# defined use a custom format string that includes more time precision.
diff --git a/lib/aruba/matchers/path/match_path_pattern.rb b/lib/aruba/matchers/path/match_path_pattern.rb
index 29e4d7d..e588357 100644
--- a/lib/aruba/matchers/path/match_path_pattern.rb
+++ b/lib/aruba/matchers/path/match_path_pattern.rb
@@ -26,7 +26,7 @@ RSpec::Matchers.define :match_path_pattern do |_|
match do |actual|
Aruba.platform.deprecated('The use of `expect().to match_path_pattern` is deprecated. Please use `expect().to include pattern /regex/` instead.')
- next !actual.select { |a| a == expected }.empty? if expected.is_a? String
+ next !actual.select { |a| a == expected }.empty? if expected.is_a? String
!actual.grep(expected).empty?
end
diff --git a/lib/aruba/platforms/announcer.rb b/lib/aruba/platforms/announcer.rb
index 0b5330e..9b6a65b 100644
--- a/lib/aruba/platforms/announcer.rb
+++ b/lib/aruba/platforms/announcer.rb
@@ -118,20 +118,20 @@ module Aruba
# rubocop:enable Metrics/MethodLength
def output_format(channel, string = '%s', &block)
- if block_given?
- output_formats[channel.to_sym] = block
- elsif string.is_a?(Proc)
- output_formats[channel.to_sym] = string
- else
- output_formats[channel.to_sym] = proc { |*args| format(string, *args) }
- end
+ output_formats[channel.to_sym] = if block_given?
+ block
+ elsif string.is_a?(Proc)
+ string
+ else
+ proc { |*args| format(string, *args) }
+ end
end
public
# Reset announcer
def reset
- @announcer = @announcers.first
+ @announcer = @announcers.first
end
# Change mode of announcer
@@ -185,7 +185,7 @@ module Aruba
return unless activated?(channel)
message = if block_given?
- the_output_format.call(block.call)
+ the_output_format.call(yield)
else
the_output_format.call(*args)
end
diff --git a/lib/aruba/platforms/filesystem_status.rb b/lib/aruba/platforms/filesystem_status.rb
index fd17338..04ba85d 100644
--- a/lib/aruba/platforms/filesystem_status.rb
+++ b/lib/aruba/platforms/filesystem_status.rb
@@ -12,7 +12,7 @@ module Aruba
:atime,
:mtime,
:size
- ]
+ ].freeze
extend Forwardable
diff --git a/lib/aruba/platforms/local_environment.rb b/lib/aruba/platforms/local_environment.rb
index 31cbec2..e1f7e81 100644
--- a/lib/aruba/platforms/local_environment.rb
+++ b/lib/aruba/platforms/local_environment.rb
@@ -19,7 +19,7 @@ module Aruba
ENV.clear
ENV.update env
- block.call if block_given?
+ yield if block_given?
ensure
ENV.clear
ENV.update old_env
diff --git a/lib/aruba/platforms/simple_table.rb b/lib/aruba/platforms/simple_table.rb
index d6b6080..e2b91e8 100644
--- a/lib/aruba/platforms/simple_table.rb
+++ b/lib/aruba/platforms/simple_table.rb
@@ -29,7 +29,7 @@ module Aruba
longest_key = hash.keys.map(&:to_s).max_by(&:length)
return '' if longest_key.nil?
- name_size = longest_key.length
+ name_size = longest_key.length
if RUBY_VERSION < '2'
rows = []
diff --git a/lib/aruba/platforms/unix_command_string.rb b/lib/aruba/platforms/unix_command_string.rb
index 3fca29c..8750075 100644
--- a/lib/aruba/platforms/unix_command_string.rb
+++ b/lib/aruba/platforms/unix_command_string.rb
@@ -20,7 +20,7 @@ module Aruba
def to_s
__getobj__.to_s
end
- alias_method :inspect, :to_s
+ alias inspect to_s
end
end
end
diff --git a/lib/aruba/platforms/unix_environment_variables.rb b/lib/aruba/platforms/unix_environment_variables.rb
index 4d20471..6dca2e5 100644
--- a/lib/aruba/platforms/unix_environment_variables.rb
+++ b/lib/aruba/platforms/unix_environment_variables.rb
@@ -11,19 +11,17 @@ module Aruba
def initialize(other_env, &block)
@other_env = other_env
- if RUBY_VERSION <= '1.9.3'
- # rubocop:disable Style/EachWithObject
- @other_env = @other_env.to_hash.inject({}) { |a, (k, v)| a[k] = v.to_s; a }
- # rubocop:enable Style/EachWithObject
- else
- @other_env = @other_env.to_h.each_with_object({}) { |(k, v), a| a[k] = v.to_s }
- end
-
- if block_given?
- @block = block
- else
- @block = nil
- end
+ @other_env = if RUBY_VERSION <= '1.9.3'
+ # rubocop:disable Style/EachWithObject
+ @other_env.to_hash.inject({}) { |a, (k, v)| a[k] = v.to_s; a }
+ # rubocop:enable Style/EachWithObject
+ else
+ @other_env.to_h.each_with_object({}) { |(k, v), a| a[k] = v.to_s }
+ end
+
+ @block = if block_given?
+ block
+ end
end
def call(env)
@@ -62,11 +60,11 @@ module Aruba
def initialize(env = ENV)
@actions = []
- if RUBY_VERSION < '2.0'
- @env = env.to_hash
- else
- @env = env.to_h
- end
+ @env = if RUBY_VERSION < '2.0'
+ env.to_hash
+ else
+ env.to_h
+ end
end
# Update environment with other en
diff --git a/lib/aruba/platforms/windows_command_string.rb b/lib/aruba/platforms/windows_command_string.rb
index 4b13a8c..9195a3a 100644
--- a/lib/aruba/platforms/windows_command_string.rb
+++ b/lib/aruba/platforms/windows_command_string.rb
@@ -23,7 +23,7 @@ module Aruba
def to_s
__getobj__.to_s
end
- alias_method :inspect, :to_s
+ alias inspect to_s
end
end
end
diff --git a/lib/aruba/platforms/windows_environment_variables.rb b/lib/aruba/platforms/windows_environment_variables.rb
index 2855cf3..845869f 100644
--- a/lib/aruba/platforms/windows_environment_variables.rb
+++ b/lib/aruba/platforms/windows_environment_variables.rb
@@ -36,23 +36,23 @@ module Aruba
def initialize(env = ENV.to_hash)
@actions = []
- if RUBY_VERSION <= '1.9.3'
- # rubocop:disable Style/EachWithObject
- @env = env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
- # rubocop:enable Style/EachWithObject
- else
- @env = env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
- end
+ @env = if RUBY_VERSION <= '1.9.3'
+ # rubocop:disable Style/EachWithObject
+ env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
+ # rubocop:enable Style/EachWithObject
+ else
+ env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
+ end
end
def update(other_env, &block)
- if RUBY_VERSION <= '1.9.3'
- # rubocop:disable Style/EachWithObject
- other_env = other_env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
- # rubocop:enable Style/EachWithObject
- else
- other_env = other_env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
- end
+ other_env = if RUBY_VERSION <= '1.9.3'
+ # rubocop:disable Style/EachWithObject
+ other_env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
+ # rubocop:enable Style/EachWithObject
+ else
+ other_env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
+ end
super(other_env, &block)
end
diff --git a/lib/aruba/processes/basic_process.rb b/lib/aruba/processes/basic_process.rb
index 60d1fda..44bc07c 100644
--- a/lib/aruba/processes/basic_process.rb
+++ b/lib/aruba/processes/basic_process.rb
@@ -125,7 +125,7 @@ module Aruba
format '#<%s:%s commandline="%s": output="%s">', self.class, self.object_id, commandline, out
end
- alias_method :to_s, :inspect
+ alias to_s inspect
private
diff --git a/lib/aruba/processes/debug_process.rb b/lib/aruba/processes/debug_process.rb
index 2be85d4..f283444 100644
--- a/lib/aruba/processes/debug_process.rb
+++ b/lib/aruba/processes/debug_process.rb
@@ -17,8 +17,6 @@ module Aruba
mode == :debug || (mode.is_a?(Class) && mode <= DebugProcess)
end
- # rubocop:disable Metrics/MethodLength
- # rubocop:disable Metrics/CyclomaticComplexity
def start
Dir.chdir @working_directory do
Aruba.platform.with_environment(environment) do
@@ -26,8 +24,6 @@ module Aruba
end
end
end
- # rubocop:enable Metrics/CyclomaticComplexity
- # rubocop:enable Metrics/MethodLength
# Return stdin
#
diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb
index c6e236a..1d4dcc4 100644
--- a/lib/aruba/processes/spawn_process.rb
+++ b/lib/aruba/processes/spawn_process.rb
@@ -50,7 +50,6 @@ module Aruba
# Run code for process which was started
#
# rubocop:disable Metrics/MethodLength
- # rubocop:disable Metrics/CyclomaticComplexity
def start
# rubocop:disable Metrics/LineLength
fail CommandAlreadyStartedError, %(Command "#{commandline}" has already been started. Please `#stop` the command first and `#start` it again. Alternatively use `#restart`.\n#{caller.join("\n")}) if started?
@@ -58,7 +57,7 @@ module Aruba
@started = true
- @process = ChildProcess.build(*[command_string.to_a, arguments].flatten)
+ @process = ChildProcess.build(*[command_string.to_a, arguments].flatten)
@stdout_file = Tempfile.new('aruba-stdout-')
@stderr_file = Tempfile.new('aruba-stderr-')
@@ -91,8 +90,7 @@ module Aruba
yield self if block_given?
end
- # rubocop:enable Metrics/MethodLength
- # rubocop:enable Metrics/CyclomaticComplexity
+ # rubocop:disable Metrics/MethodLength
# Access to stdout of process
def stdin
@@ -264,7 +262,7 @@ module Aruba
def wait_for_io(time_to_wait, &block)
sleep time_to_wait.to_i
- block.call
+ yield
end
def read_temporary_output_file(file)
diff --git a/lib/aruba/runtime.rb b/lib/aruba/runtime.rb
index 0d6491d..a126fb2 100644
--- a/lib/aruba/runtime.rb
+++ b/lib/aruba/runtime.rb
@@ -49,11 +49,11 @@ module Aruba
@environment.update(@config.command_runtime_environment)
- if Aruba::VERSION < '1'
- @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
- else
- @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
- end
+ @command_monitor = if Aruba::VERSION < '1'
+ opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
+ else
+ opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
+ end
@logger = opts.fetch(:logger, Aruba.platform.logger.new)
@logger.mode = @config.log_level
diff --git a/lib/aruba/setup.rb b/lib/aruba/setup.rb
index 2af6f6a..22558c9 100644
--- a/lib/aruba/setup.rb
+++ b/lib/aruba/setup.rb
@@ -7,7 +7,7 @@ module Aruba
public
def initialize(runtime)
- @runtime = runtime
+ @runtime = runtime
end
def call
diff --git a/lib/aruba/version.rb b/lib/aruba/version.rb
index 45d68a7..085fbc1 100644
--- a/lib/aruba/version.rb
+++ b/lib/aruba/version.rb
@@ -1,3 +1,3 @@
module Aruba
- VERSION = '0.13.0'
+ VERSION = '0.14.0'.freeze
end
diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb
index 3b6375f..c34f2ca 100644
--- a/spec/aruba/api_spec.rb
+++ b/spec/aruba/api_spec.rb
@@ -3,7 +3,7 @@ require 'securerandom'
require 'aruba/api'
require 'fileutils'
-describe Aruba::Api do
+describe Aruba::Api do
include_context 'uses aruba API'
describe '#all_paths' do
@@ -110,7 +110,7 @@ describe Aruba::Api do
let(:content) { 'asdf' }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
context 'when does not exist' do
@@ -164,7 +164,7 @@ describe Aruba::Api do
let(:path) { File.join(@aruba.aruba.current_directory, name) }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
context 'when does not exist' do
@@ -196,7 +196,7 @@ describe Aruba::Api do
context 'when has subdirectories' do
context 'when is simple path' do
let(:existing_files) { @aruba.list(name) }
- let(:expected_files) { content.map { |c| File.join(name, c) }.sort }
+ let(:expected_files) { content.map { |c| File.join(name, c) }.sort }
it { expect(expected_files - existing_files).to be_empty}
end
@@ -227,7 +227,7 @@ describe Aruba::Api do
let(:options) { {} }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
context 'when file' do
@@ -326,7 +326,7 @@ describe Aruba::Api do
let(:options) { {} }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
context 'when file' do
@@ -784,7 +784,7 @@ describe Aruba::Api do
let(:permissions) { '0655' }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
before(:each) do
@@ -822,7 +822,7 @@ describe Aruba::Api do
let(:permissions) { '0655' }
before :each do
- @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
end
before(:each) do
@@ -1047,7 +1047,7 @@ describe Aruba::Api do
end . not_to raise_error
end
- it "raises RSpec::Expectations::ExpectationNotMetError when the inner expectations don't match" do
+ it "raises RSpec::Expectations::ExpectationNotMetError when the inner expectations don't match" do
expect do
@aruba.with_file_content @file_name do |full_content|
expect(full_content).to match(/zoo/)
@@ -1125,20 +1125,20 @@ describe Aruba::Api do
it "respond to input" do
@aruba.type "Hello"
@aruba.type ""
- expect(@aruba.all_output).to eq "Hello\n"
+ expect(@aruba.all_output).to eq "Hello\n"
end
it "respond to close_input" do
@aruba.type "Hello"
@aruba.close_input
- expect(@aruba.all_output).to eq "Hello\n"
+ expect(@aruba.all_output).to eq "Hello\n"
end
it "pipes data" do
@aruba.write_file(@file_name, "Hello\nWorld!")
@aruba.pipe_in_file(@file_name)
@aruba.close_input
- expect(@aruba.all_output).to eq "Hello\nWorld!"
+ expect(@aruba.all_output).to eq "Hello\nWorld!"
end
end
diff --git a/spec/aruba/jruby_spec.rb b/spec/aruba/jruby_spec.rb
index f31475a..e079cb4 100644
--- a/spec/aruba/jruby_spec.rb
+++ b/spec/aruba/jruby_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'aruba/api'
-describe "Aruba JRuby Startup Helper" do
+describe "Aruba JRuby Startup Helper" do
before(:all) do
@fake_env = ENV.clone
end
diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb
index 28f6c6f..f417ea6 100644
--- a/spec/aruba/matchers/file_spec.rb
+++ b/spec/aruba/matchers/file_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe 'File Matchers' do
end
context "when matcher" do
- it { expect(have_file_content(a_string_starting_with "a").description).to eq('have file content: a string starting with "a"') }
+ it { expect(have_file_content(a_string_starting_with("a")).description).to eq('have file content: a string starting with "a"') }
end
end
@@ -99,7 +99,7 @@ RSpec.describe 'File Matchers' do
example 'for a matcher' do
expect do
- expect(@file_name).to have_file_content(a_string_starting_with "z")
+ expect(@file_name).to have_file_content(a_string_starting_with("z"))
end.to fail_with('expected "test.txt" to have file content: a string starting with "z"')
end
end
diff --git a/spec/support/helpers/reporting.rb b/spec/support/helpers/reporting.rb
index 7aaeb65..e3f8165 100644
--- a/spec/support/helpers/reporting.rb
+++ b/spec/support/helpers/reporting.rb
@@ -35,7 +35,7 @@ module SpecHelpers
captured_stream.unlink
stream_io.reopen(origin_stream)
end
- alias_method :silence, :capture
+ alias silence capture
end
end
diff --git a/spec/support/shared_examples/configuration.rb b/spec/support/shared_examples/configuration.rb
index 13d71aa..2daab9b 100644
--- a/spec/support/shared_examples/configuration.rb
+++ b/spec/support/shared_examples/configuration.rb
@@ -21,7 +21,7 @@ RSpec.shared_examples 'a basic configuration' do
end
context 'when one tries to write a value' do
- it { expect{ config.new_opt = 1}.to raise_error NoMethodError }
+ it { expect{ config.new_opt = 1}.to raise_error NoMethodError }
end
context 'when block is defined' do
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-aruba.git
More information about the Pkg-ruby-extras-commits
mailing list