diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..eaf6e6c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +Documentation: + Enabled: false + +Style/MultilineOperationIndentation: + Enabled: false + +Style/Encoding: + Enabled: false + +AllCops: + # Include gemspec and Rakefile + Include: + - '**/*.gemspec' + - '**/Rakefile' diff --git a/.travis.yml b/.travis.yml index 906b381..15c225a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: ruby -rvm: - - "1.9.3" - - "2.0.0" - - "2.1.0" - - "2.2.4" - - "2.3.0" install: bundle install -j 4 --retry 3 script: - RAILS_ENV=test bundle exec rspec spec +matrix: + include: + - rvm: 2.3 + - rvm: 2.4 + - rvm: 2.5 + - rvm: 2.6 + - rvm: 2.7 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6b822d1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/). + +## [1.0.0] - 2020-03-11 +## Changed +- Add support for ruby 2.7 +- Remove support for ruby < 2.3 +- Change required version for gem heartcheck to fit for newer supported ruby versions + +## [0.1.0] - 2015-07-08 +## Changed +- A plugin to check CAS accessibility connection with heartcheck diff --git a/heartcheck-cas.gemspec b/heartcheck-cas.gemspec index b473708..965ecf0 100644 --- a/heartcheck-cas.gemspec +++ b/heartcheck-cas.gemspec @@ -1,24 +1,30 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'heartcheck/cas/version' Gem::Specification.new do |spec| - spec.name = "heartcheck-cas" + spec.name = 'heartcheck-cas' spec.version = Heartcheck::Cas::VERSION - spec.authors = ["andrerocker"] - spec.email = ["andre.souza@gmail.com"] + spec.authors = ['andrerocker'] + spec.email = ['andre.souza@gmail.com'] spec.summary = 'cas checkers to heartcheck' spec.description = 'Provides cas checkers to heartcheck' spec.homepage = 'http://github.com/locaweb/heartcheck-cas' - spec.license = "MIT" + spec.license = 'MIT' spec.files = Dir.glob('lib/**/*') - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] + + spec.required_ruby_version = '>= 2.3' + + spec.add_dependency 'heartcheck', '~> 2.0' spec.add_development_dependency 'bundler', '> 1.6' + spec.add_development_dependency 'pry-nav', '~> 0.2.4' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec', '~> 3.3' - spec.add_development_dependency 'pry-nav', '~> 0.2.4' - spec.add_dependency 'heartcheck', '~> 1.0' + spec.add_development_dependency 'rubocop' end diff --git a/lib/heartcheck/cas/http_client.rb b/lib/heartcheck/cas/http_client.rb index 66c8b19..f0fcf52 100644 --- a/lib/heartcheck/cas/http_client.rb +++ b/lib/heartcheck/cas/http_client.rb @@ -1,4 +1,7 @@ # enconding: utf-8 +require 'net/http' +require 'openssl' + module Heartcheck module Cas class HttpClient @@ -12,7 +15,7 @@ def post(url, params) request.set_form_data(params) base_client(uri).request(request) end - + def base_client(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme.eql?('https') diff --git a/lib/heartcheck/cas/version.rb b/lib/heartcheck/cas/version.rb index 28b8b78..59fb7ca 100644 --- a/lib/heartcheck/cas/version.rb +++ b/lib/heartcheck/cas/version.rb @@ -1,5 +1,5 @@ module Heartcheck module Cas - VERSION = "0.1.0" + VERSION = "1.0.0" end end diff --git a/spec/heartcheck/cas/http_client_spec.rb b/spec/heartcheck/cas/http_client_spec.rb index ae474c3..cd5e6a1 100644 --- a/spec/heartcheck/cas/http_client_spec.rb +++ b/spec/heartcheck/cas/http_client_spec.rb @@ -4,9 +4,11 @@ describe '#post' do context 'make a post request' do it 'should create a hastebin document' do - response = described_class.post('http://hastebin.com/documents', {data: "Bacon"}) + response = described_class.post( + 'https://reqbin.com/echo/post/json', { data: 'Bacon' } + ) expect(response.code).to eq "200" - expect(response.body).to match /key/ + expect(response.body).to match /success/ end end end