diff --git a/Gemfile b/Gemfile index d4b136f..eadac5f 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,10 @@ gemspec group 'test' do gem 'coveralls', require: false - gem 'simplecov-html', require: false + gem 'guard-rspec', require: false + gem 'neo4j-core' gem 'rake' gem 'rspec' gem 'rspec-its' - gem 'guard-rspec', require: false - gem 'neo4j-core' + gem 'simplecov-html', require: false end diff --git a/Guardfile b/Guardfile index 5258dcb..9ec08bd 100644 --- a/Guardfile +++ b/Guardfile @@ -30,6 +30,6 @@ end guard :rspec, cmd: 'bundle exec rspec' do watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } + watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } end diff --git a/lib/neo4j/rake_tasks/download.rb b/lib/neo4j/rake_tasks/download.rb index 06499bf..693e4a4 100644 --- a/lib/neo4j/rake_tasks/download.rb +++ b/lib/neo4j/rake_tasks/download.rb @@ -31,6 +31,7 @@ def create_progress_bar(message, total) def update_progress_bar(value) return unless @progress_bar + value = @progress_bar.total >= value ? value : @progress_bar.total @progress_bar.progress = value end diff --git a/lib/neo4j/rake_tasks/neo4j_server.rake b/lib/neo4j/rake_tasks/neo4j_server.rake index b537d00..b1bdb43 100644 --- a/lib/neo4j/rake_tasks/neo4j_server.rake +++ b/lib/neo4j/rake_tasks/neo4j_server.rake @@ -3,9 +3,8 @@ require 'os' require 'zip' require 'pathname' -require File.expand_path('../windows_server_manager', __FILE__) -require File.expand_path('../starnix_server_manager', __FILE__) - +require File.expand_path('windows_server_manager', __dir__) +require File.expand_path('starnix_server_manager', __dir__) namespace :neo4j do def clear_task_if_defined(task_name) @@ -38,9 +37,7 @@ namespace :neo4j do server_manager = server_manager(args[:environment]) server_manager.install(args[:edition]) - if server_manager.supports_auth? - server_manager.config_auth_enabeled!(false) - end + server_manager.config_auth_enabeled!(false) if server_manager.supports_auth? puts 'To start it type one of the following:' puts cyanize(' rake neo4j:start') @@ -94,7 +91,6 @@ namespace :neo4j do task :config, :environment, :port do |_, args| args.with_defaults(environment: :development, port: 7474) - puts "Config Neo4j in #{args[:environment]}" server_manager = server_manager(args[:environment]) diff --git a/lib/neo4j/rake_tasks/starnix_server_manager.rb b/lib/neo4j/rake_tasks/starnix_server_manager.rb index 5997fa5..918e624 100644 --- a/lib/neo4j/rake_tasks/starnix_server_manager.rb +++ b/lib/neo4j/rake_tasks/starnix_server_manager.rb @@ -1,4 +1,4 @@ -require File.expand_path('../server_manager', __FILE__) +require File.expand_path('server_manager', __dir__) module Neo4j module RakeTasks diff --git a/lib/neo4j/rake_tasks/version.rb b/lib/neo4j/rake_tasks/version.rb index 017ad6d..4ae0c43 100644 --- a/lib/neo4j/rake_tasks/version.rb +++ b/lib/neo4j/rake_tasks/version.rb @@ -1,5 +1,5 @@ module Neo4j module RakeTasks - VERSION = '0.7.19' + VERSION = '0.7.19'.freeze end end diff --git a/lib/neo4j/rake_tasks/windows_server_manager.rb b/lib/neo4j/rake_tasks/windows_server_manager.rb index de5e3da..536d535 100644 --- a/lib/neo4j/rake_tasks/windows_server_manager.rb +++ b/lib/neo4j/rake_tasks/windows_server_manager.rb @@ -1,4 +1,4 @@ -require File.expand_path('../server_manager', __FILE__) +require File.expand_path('server_manager', __dir__) module Neo4j module RakeTasks @@ -24,7 +24,7 @@ def install def validate_is_system_admin! return if nt_admin? - fail 'You do not have administrative rights to stop the Neo4j Service' + raise 'You do not have administrative rights to stop the Neo4j Service' end protected @@ -60,7 +60,7 @@ def each_file_in_zip(zip_path) end def nt_admin? - system_or_fail('reg query "HKU\\S-1-5-19"').size > 0 + !system_or_fail('reg query "HKU\\S-1-5-19"').empty? end end end diff --git a/neo4j-rake_tasks.gemspec b/neo4j-rake_tasks.gemspec index 89be258..fb5cf8c 100644 --- a/neo4j-rake_tasks.gemspec +++ b/neo4j-rake_tasks.gemspec @@ -1,4 +1,4 @@ -lib = File.expand_path('../lib/', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) require 'neo4j/rake_tasks/version' @@ -25,26 +25,27 @@ DESCRIPTION s.require_path = 'lib' s.files = Dir.glob('{bin,lib,config}/**/*') + - %w(README.md Gemfile neo4j-rake_tasks.gemspec) + %w[README.md Gemfile neo4j-rake_tasks.gemspec] s.has_rdoc = true - s.extra_rdoc_files = %w( README.md ) + s.extra_rdoc_files = %w[README.md] s.rdoc_options = [ '--quiet', '--title', '--line-numbers', '--main', 'README.rdoc', - '--inline-source'] + '--inline-source' + ] - s.add_dependency('rake') s.add_dependency('os') + s.add_dependency('rake') s.add_dependency('ruby-progressbar') s.add_dependency('rubyzip', '>= 1.1.7') # s.add_development_dependency('vcr') - s.add_development_dependency('pry') - s.add_development_dependency('simplecov') s.add_development_dependency('guard') s.add_development_dependency('guard-rubocop') + s.add_development_dependency('pry') s.add_development_dependency('rubocop') + s.add_development_dependency('simplecov') end diff --git a/release_if_new.rb b/release_if_new.rb index f57b3d7..4ec8686 100755 --- a/release_if_new.rb +++ b/release_if_new.rb @@ -7,23 +7,22 @@ gemspec_files = Dir.glob('*.gemspec') -fail 'Too many gemspecs!' if gemspec_files.size > 1 +raise 'Too many gemspecs!' if gemspec_files.size > 1 gemspec_file = gemspec_files.first gem_name = File.basename(gemspec_file, '.*') -spec = Gem::Specification::load(gemspec_file) +spec = Gem::Specification.load(gemspec_file) LOGGER.info "Checking to see if version #{spec.version} of gem `#{gem_name}` exists" http_result = `curl --head https://rubygems.org/gems/#{gem_name}/versions/#{spec.version} | head -1` -status_code = http_result.match(/^HTTP\/[\d\.]+ (\d+)/)[1].to_i +status_code = http_result.match(%r{^HTTP/[\d\.]+ (\d+)})[1].to_i if status_code == 200 - LOGGER.info "Version already exists" + LOGGER.info 'Version already exists' else - LOGGER.info "Version does not exist. Releasing..." + LOGGER.info 'Version does not exist. Releasing...' system('rake release') end - diff --git a/spec/starnix_server_manager_spec.rb b/spec/starnix_server_manager_spec.rb index 7e4007e..076aaee 100644 --- a/spec/starnix_server_manager_spec.rb +++ b/spec/starnix_server_manager_spec.rb @@ -6,7 +6,7 @@ require 'neo4j/rake_tasks/starnix_server_manager' -BASE_PATHNAME = Pathname.new(File.expand_path('../', __FILE__)) +BASE_PATHNAME = Pathname.new(File.expand_path(__dir__)) module Neo4j module RakeTasks @@ -19,7 +19,7 @@ module RakeTasks subject { server_manager.modify_config_contents(contents, properties) } after(:each) { path.rmtree } - let_context properties: {prop: 2} do + let_context properties: { prop: 2 } do let_context(contents: 'prop=1') { it { should eq('prop=2') } } let_context(contents: 'prop =1') { it { should eq('prop=2') } } let_context(contents: 'prop= 1') { it { should eq('prop=2') } } @@ -37,11 +37,11 @@ module RakeTasks end let_context contents: 'prop=false' do - let_context(properties: {prop: true}) { it { should eq('prop=true') } } + let_context(properties: { prop: true }) { it { should eq('prop=true') } } end let_context contents: 'prop=true' do - let_context(properties: {prop: false}) { it { should eq('prop=false') } } + let_context(properties: { prop: false }) { it { should eq('prop=false') } } end end @@ -57,14 +57,14 @@ def server_up(port) before(:each) do if server_up(neo4j_port) - fail "There is a server already running on port #{neo4j_port}. Can't run spec" + raise "There is a server already running on port #{neo4j_port}. Can't run spec" end if path.exist? message = 'DB temporary directory already exists! ' message += "Delete #{path} if safe to do so and then proceed" - fail message + raise message end end