diff --git a/.rubocop.yml b/.rubocop.yml index a513808..143c8d9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ inherit_gem: AllCops: DisplayCopNames: true - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 Naming/MemoizedInstanceVariableName: Enabled: false diff --git a/.travis.yml b/.travis.yml index a1f398c..0036019 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,17 @@ language: ruby - sudo: false - -rvm: - - 2.3 - - 2.4 - - 2.5 - - ruby-head - before_install: gem install bundler - env: SUITE="rspec" - script: bundle exec $SUITE - matrix: fast_finish: true - # Only run RuboCop on the latest Ruby include: - - rvm: 2.5 - env: SUITE="rubocop" + - rvm: 2.3 + - rvm: 2.4 + - rvm: 2.5 + - rvm: 2.6 + - rvm: 2.6 # Only run RuboCop on the latest Ruby + env: SUITE="rubocop" + - rvm: ruby-head allow_failures: - - rvm: ruby-head + - rvm: ruby-head diff --git a/LICENSE.txt b/LICENSE.txt index 15c2da9..eaa17da 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Yuri Smirnov +Copyright (c) 2017-2019 Yuri Smirnov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Rakefile b/Rakefile index b6ae734..39ad954 100644 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,19 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" +require "rubocop" +require "rubocop-rspec" +require "rubocop-performance" +require "rubocop/rake_task" -RSpec::Core::RakeTask.new(:spec) +RuboCop::RakeTask.new(:rubocop) do |t| + config_path = File.expand_path(File.join(".rubocop.yml"), __dir__) -task default: :spec + t.options = ["--config", config_path] + t.requires << "rubocop-rspec" + t.requires << "rubocop-performance" +end + +RSpec::Core::RakeTask.new(:rspec) + +task default: :rspec diff --git a/bin/console b/bin/console new file mode 100644 index 0000000..84d9112 --- /dev/null +++ b/bin/console @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'polist' + +require 'pry' +Pry.start diff --git a/lib/polist/service.rb b/lib/polist/service.rb index 977c98a..5c769dc 100644 --- a/lib/polist/service.rb +++ b/lib/polist/service.rb @@ -85,8 +85,8 @@ def call; end def run(&block) call(&block) - rescue self.class::Failure => error - @response = error.response + rescue self.class::Failure => e + @response = e.response @failure = true end diff --git a/polist.gemspec b/polist.gemspec index ec54a04..55cfe77 100644 --- a/polist.gemspec +++ b/polist.gemspec @@ -5,17 +5,17 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "polist/version" Gem::Specification.new do |spec| - spec.name = "polist" - spec.version = Polist::VERSION - spec.authors = ["Yuri Smirnov"] - spec.email = ["tycooon@yandex.ru"] + spec.name = "polist" + spec.version = Polist::VERSION + spec.authors = ["Yuri Smirnov"] + spec.email = ["tycooon@yandex.ru", "oss@umbrellio.biz"] - spec.summary = "A gem for creating simple service classes and more." - spec.description = "Polist is a gem for creating simple service classes and more." - spec.homepage = "https://github.com/umbrellio/polist" - spec.license = "MIT" + spec.summary = "A gem for creating simple service classes and more." + spec.description = "Polist is a gem for creating simple service classes and more." + spec.homepage = "https://github.com/umbrellio/polist" + spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) } + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) } spec.require_paths = ["lib"] spec.add_runtime_dependency "activemodel", ">= 3.0" @@ -28,5 +28,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "pry" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" + spec.add_development_dependency "rubocop-config-umbrellio" spec.add_development_dependency "simplecov" end diff --git a/spec/polist/service_spec.rb b/spec/polist/service_spec.rb index 2024ba8..46ee8b3 100644 --- a/spec/polist/service_spec.rb +++ b/spec/polist/service_spec.rb @@ -72,8 +72,8 @@ def call class ServiceWichRescueBlock < BasicService def call yield - rescue StandardError => error - success!(error) + rescue StandardError => e + success!(e) end end