diff --git a/.rubocop.yml b/.rubocop.yml index 0953e07..0b53dfb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,12 @@ AllCops: - Excludes: + Exclude: - vendor/** - bin/** +Metrics: + Enabled: false + +Style/Documentation: + Enabled: false + inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 048c644..5269cf6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,33 +1,23 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2015-01-01 18:05:17 -0500 using RuboCop version 0.27.1. +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2019-04-30 10:21:07 -0400 using RuboCop version 0.68.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -Metrics/AbcSize: - Max: 25 - -# Offense count: 14 -# Configuration parameters: AllowURI, URISchemes. -Metrics/LineLength: - Max: 155 - -# Offense count: 2 -# Configuration parameters: CountComments. -Metrics/MethodLength: - Max: 17 - -# Offense count: 3 -Style/Documentation: - Enabled: false - # Offense count: 1 -# Configuration parameters: Exclude. -Style/FileName: - Enabled: false +# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'lib/guard-rack.rb' -# Offense count: 3 -Style/RegexpLiteral: - MaxSlashes: 0 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/guard/rack/custom_process.rb' diff --git a/.travis.yml b/.travis.yml index 744d479..eb893ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ language: ruby rvm: - 2.4.0 - 2.3.3 - - 2.2.6 - - 2.1.10 + - 2.5.3 + - 2.6.3 - jruby - ruby-head - jruby-head diff --git a/CHANGELOG.md b/CHANGELOG.md index 36725af..c5b6d07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ 2.2.1 (Next) ============ +* [#24](https://github.com/dblock/guard-rack/pull/24): Use absolute module namespace to prevent conflict with Guard::Process - [@cristianbica](https://github.com/cristianbica). * Your contribution here. 2.2.0 (4/16/2016) ================= -* [#23](https://github.com/dblock/guard-rack/pull/23) Added Windows support - [@jonyeezs](https://github.com/jonyeezs). +* [#23](https://github.com/dblock/guard-rack/pull/23): Added Windows support - [@jonyeezs](https://github.com/jonyeezs). 2.1.1 (03/07/2015) ============ diff --git a/Gemfile b/Gemfile index d108fa1..9f2c77d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +3,14 @@ source 'http://rubygems.org' gemspec gem 'ffi' -gem 'spoon' gem 'guard', '~> 2.3.0' +gem 'spoon' group :development, :test do - gem 'guard-rspec', '~> 4.2.5' gem 'growl' - gem 'rb-inotify', require: false - gem 'rb-fsevent', require: false + gem 'guard-rspec', '~> 4.2.5' gem 'rb-fchange', require: false - gem 'rubocop', '0.27.1' + gem 'rb-fsevent', require: false + gem 'rb-inotify', require: false + gem 'rubocop', '0.68.0' end diff --git a/Rakefile b/Rakefile index 88dfb5e..92599d8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,13 @@ require 'rubygems' require 'bundler/gem_tasks' -require File.expand_path('../lib/guard/rack/version', __FILE__) +require File.expand_path('lib/guard/rack/version', __dir__) begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts 'Run `bundle install` to install missing gems' + warn e.message + warn 'Run `bundle install` to install missing gems' exit e.status_code end @@ -23,4 +23,4 @@ require 'rainbow/ext/string' unless String.respond_to?(:color) require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) -task default: [:rubocop, :spec] +task default: %i[rubocop spec] diff --git a/guard-rack.gemspec b/guard-rack.gemspec index d9b0300..bfc4dd7 100644 --- a/guard-rack.gemspec +++ b/guard-rack.gemspec @@ -1,5 +1,4 @@ -# -*- encoding: utf-8 -*- -require File.expand_path('../lib/guard/rack/version', __FILE__) +require File.expand_path('lib/guard/rack/version', __dir__) Gem::Specification.new do |gem| gem.authors = ['Daniel Doubrovkine'] @@ -15,15 +14,15 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split("\n") gem.version = Guard::RackVersion::VERSION - gem.add_dependency 'guard', '~> 2.3' gem.add_dependency 'ffi' + gem.add_dependency 'guard', '~> 2.3' gem.add_dependency 'spoon' - gem.add_development_dependency 'rake', '< 11' gem.add_development_dependency 'bundler' - gem.add_development_dependency 'rspec', '~> 3.0' gem.add_development_dependency 'fakefs' gem.add_development_dependency 'mocha', '~> 1.1' + gem.add_development_dependency 'rake', '< 11' + gem.add_development_dependency 'rspec', '~> 3.0' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0') gem.add_development_dependency 'rack', '< 2' diff --git a/lib/guard/rack.rb b/lib/guard/rack.rb index b9ea507..7155287 100644 --- a/lib/guard/rack.rb +++ b/lib/guard/rack.rb @@ -8,16 +8,16 @@ class Rack < ::Guard::Plugin attr_reader :options, :runner DEFAULT_OPTIONS = { - port: 9292, - host: '0.0.0.0', - environment: 'development', + port: 9292, + host: '0.0.0.0', + environment: 'development', start_on_start: true, - force_run: false, - timeout: 20, - debugger: false, - config: 'config.ru', - cmd: 'rackup' - } + force_run: false, + timeout: 20, + debugger: false, + config: 'config.ru', + cmd: 'rackup' + }.freeze def initialize(options = {}) super diff --git a/lib/guard/rack/custom_process.rb b/lib/guard/rack/custom_process.rb index 177e762..8a71307 100644 --- a/lib/guard/rack/custom_process.rb +++ b/lib/guard/rack/custom_process.rb @@ -6,11 +6,11 @@ class CustomProcess attr_reader :options def self.new(options = {}) - if Gem.win_platform? - os_instance = Windows.allocate - else - os_instance = Nix.allocate - end + os_instance = if Gem.win_platform? + Windows.allocate + else + Nix.allocate + end os_instance.send :initialize, options os_instance end @@ -24,10 +24,10 @@ def kill(pid, force = false) result = -1 UI.debug("Trying to kill Rack (PID #{pid})...") unless force - Process.kill('INT', pid) + ::Process.kill('INT', pid) begin Timeout.timeout(options[:timeout]) do - _, status = Process.wait2(pid) + _, status = ::Process.wait2(pid) result = status.exitstatus UI.debug("Killed Rack (Exit status: #{result})") end @@ -36,7 +36,7 @@ def kill(pid, force = false) force = true end end - Process.kill('TERM', pid) if force + ::Process.kill('TERM', pid) if force result end end diff --git a/lib/guard/rack/version.rb b/lib/guard/rack/version.rb index 8693d30..c6c4a91 100644 --- a/lib/guard/rack/version.rb +++ b/lib/guard/rack/version.rb @@ -1,5 +1,5 @@ module Guard module RackVersion - VERSION = '2.2.1' + VERSION = '2.2.1'.freeze end end diff --git a/spec/lib/guard/integration.ru b/spec/lib/guard/integration.ru index ce05c03..638ed06 100644 --- a/spec/lib/guard/integration.ru +++ b/spec/lib/guard/integration.ru @@ -1,9 +1,9 @@ class HelloWorld - def call(env) - return [ + def call(_env) + [ 200, - {'Content-Type' => 'text/html'}, - ["Hello world!"] + { 'Content-Type' => 'text/html' }, + ['Hello world!'] ] end end diff --git a/spec/lib/guard/process_spec.rb b/spec/lib/guard/process_spec.rb index 0166ef4..6a36d83 100644 --- a/spec/lib/guard/process_spec.rb +++ b/spec/lib/guard/process_spec.rb @@ -51,7 +51,7 @@ end it 'should return true' do - expect(subject.kill pid).to eq(0) + expect(subject.kill(pid)).to eq(0) end end @@ -63,7 +63,7 @@ end it 'should return false' do - expect(subject.kill pid).to eq(1) + expect(subject.kill(pid)).to eq(1) end end @@ -74,7 +74,7 @@ end it 'should return false' do - expect(subject.kill pid).to eq(-1) + expect(subject.kill(pid)).to eq(-1) end end end @@ -99,7 +99,7 @@ end it 'should result in 0' do - expect(subject.kill pid).to eq(0) + expect(subject.kill(pid)).to eq(0) end end end