Skip to content

Commit

Permalink
Update to Ruby 2.7, all deps, migrate to GH actions.
Browse files Browse the repository at this point in the history
Copying changes from other project over at
https://github.com/nathankleyn/sliding_window to improve the ease with
which I can maintain this project!
  • Loading branch information
nathankleyn committed Dec 1, 2020
1 parent 2410f86 commit 4d2937c
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 132 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish

on:
push:
tags:
- 'v*'

jobs:
build:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7

- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}

- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rspec
- name: Run Rubocop
run: bundle exec rubocop
- name: Update Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
*.gem
coverage
Gemfile.lock
*.gem
61 changes: 54 additions & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,66 @@
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

LineLength:
Layout/LineLength:
Enabled: true
Max: 120

BlockLength:
Metrics/BlockLength:
Enabled: true
Max: 200

MethodLength:
Metrics/MethodLength:
Enabled: true
Max: 20

ExampleLength:
RSpec/ExampleLength:
Enabled: true
Max: 20

MultipleExpectations:
Max: 5
Metrics/AbcSize:
Enabled: true
Max: 20

Lint/DuplicateBranch:
Enabled: true

Lint/DuplicateRegexpCharacterClassElement:
Enabled: true

Lint/EmptyBlock:
Enabled: true

Lint/EmptyClass:
Enabled: true

Lint/NoReturnInBeginEndBlocks:
Enabled: true

Lint/ToEnumArguments:
Enabled: true

Lint/UnmodifiedReduceAccumulator:
Enabled: true

Style/ArgumentsForwarding:
Enabled: true

Style/CollectionCompact:
Enabled: true

Style/DocumentDynamicEvalDefinition:
Enabled: true

Style/NegatedIfElseCondition:
Enabled: true

Style/NilLambda:
Enabled: true

Style/RedundantArgument:
Enabled: true

Style/SwapValues:
Enabled: true
17 changes: 17 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'simplecov-lcov'

SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end

SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter
]
)

SimpleCov.start('rspec')
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

85 changes: 0 additions & 85 deletions Gemfile.lock

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Nathan Kleyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
24 changes: 2 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# attr_combined_accessor [![Build Status](https://travis-ci.org/nathankleyn/attr_combined_accessor.svg?branch=master)](https://travis-ci.org/nathankleyn/attr_combined_accessor) [![Coverage Status](https://coveralls.io/repos/nathankleyn/attr_combined_accessor/badge.png?branch=master)](https://coveralls.io/r/nathankleyn/attr_combined_accessor?branch=master)
# attr_combined_accessor [![Build Status](https://github.com/nathankleyn/attr_combined_accessor/workflows/Tests/badge.svg)](https://github.com/nathankleyn/attr_combined_accessor/actions?query=workflow%3ATests) [![Coverage Status](https://coveralls.io/repos/github/nathankleyn/attr_combined_accessor/badge.svg?branch=master)](https://coveralls.io/github/nathankleyn/attr_combined_accessor?branch=master) [![RubyGems Version](https://img.shields.io/gem/v/attr_combined_accessor.svg)](https://rubygems.org/gems/attr_combined_accessor)

Combined reader/writer accessors in Ruby, ideal for chaining or DSLs.

Expand Down Expand Up @@ -52,24 +52,4 @@ my_amazing_class.foo # => 'notfoo!'

## License

The MIT License (MIT)

Copyright (c) 2015 Nathan Kleyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
This project is licensed [via MIT license](LICENSE).
23 changes: 15 additions & 8 deletions attr_combined_accessor.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(__dir__, 'lib'))

Gem::Specification.new do |gem|
gem.name = 'attr_combined_accessor'
gem.version = '1.1.0'
# If current commit is tagged, that will be our version.
# Otherwise we'll get some suffixed version, eg. 1.1.2-1-g0fc2ecd
# Which represents a "distance" we are away from the last tag.
#
# Notice we tag as 'v1.2.3' but the gemspec expects just '1.2.3' so
# we have to strip the prefix.
gem.version = `git describe --tags`.chomp.delete_prefix('v')
gem.homepage = 'https://github.com/nathankleyn/attr_combined_accessor'
gem.license = 'MIT'

Expand All @@ -20,10 +24,13 @@ Gem::Specification.new do |gem|

gem.files = Dir['**/*'].select { |d| d =~ %r{^(README.md|lib/)} }

gem.add_development_dependency 'coveralls', '~> 0.8.22'
gem.required_ruby_version = '>= 2.7.2'

gem.add_development_dependency 'filewatcher', '~> 1.1', '>= 1.1.1'
gem.add_development_dependency 'pry-byebug', '~> 3.6', '>= 3.6.0'
gem.add_development_dependency 'rspec', '~> 3.8', '>= 3.8.0'
gem.add_development_dependency 'rubocop', '~> 0.59.2'
gem.add_development_dependency 'rubocop-rspec', '~> 1.29', '>= 1.29.1'
gem.add_development_dependency 'pry-byebug', '~> 3.9', '>= 3.9.0'
gem.add_development_dependency 'rspec', '~> 3.10', '>= 3.10.0'
gem.add_development_dependency 'rubocop', '~> 1.4', '>= 1.4.2'
gem.add_development_dependency 'rubocop-rspec', '~> 2.0', '>= 2.0.0'
gem.add_development_dependency 'simplecov', '~> 0.20', '>= 0.20.0'
gem.add_development_dependency 'simplecov-lcov', '~> 0.8', '>= 0.8.0'
end
10 changes: 8 additions & 2 deletions spec/lib/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
test_class.instance_variable_set(:@bar, 'bar')
end

it('adds a combined reader/writer method for each name specified') do
it('adds a combined reader/writer method for foo') do
expect(test_class.respond_to?(:foo)).to be(true)
end

it('adds a combined reader/writer method for bar') do
expect(test_class.respond_to?(:bar)).to be(true)
end

it('adds a writer method for each name specified') do
it('adds a writer method for foo') do
expect(test_class.respond_to?(:foo=)).to be(true)
end

it('adds a writer method for bar') do
expect(test_class.respond_to?(:bar=)).to be(true)
end

Expand Down
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'coveralls'
Coveralls.wear!
if ENV['CI']
require 'simplecov'
SimpleCov.start
end

RSpec.configure do |config|
config.mock_with(:rspec) do |mocks|
Expand Down

0 comments on commit 4d2937c

Please sign in to comment.