diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000..c24890a --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,20 @@ +--- +name: danger +on: + pull_request: + types: [opened, reopened, edited, synchronize] +jobs: + danger: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + - name: Run Danger + run: | + # the personal token is public, this is ok, base64 encode to avoid tripping Github + TOKEN=$(echo -n NWY1ZmM5MzEyMzNlYWY4OTZiOGU3MmI3MWQ3Mzk0MzgxMWE4OGVmYwo= | base64 --decode) + DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..734ce1f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +--- +name: test +on: [push, pull_request] +jobs: + lint: + name: RuboCop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - name: Run RuboCop + run: bundle exec rubocop + test: + runs-on: ubuntu-latest + strategy: + matrix: + entry: + - { ruby: 2.4, allowed-failure: false } + - { ruby: 2.5, allowed-failure: false } + - { ruby: 2.6, allowed-failure: false } + - { ruby: 2.7, allowed-failure: false } + - { ruby: ruby-head, allowed-failure: true } + - { ruby: truffleruby-head, allowed-failure: true } + - { ruby: jruby-head, allowed-failure: true } + name: test (${{ matrix.entry.ruby }}) + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.entry.ruby }} + - run: bundle install --jobs=3 --retry=3 --path=vendor/bundle + - run: bundle exec rake spec + continue-on-error: ${{ matrix.entry.allowed-failure }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06dd202..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: ruby - -cache: bundler - -before_install: - - gem update --system - -rvm: - - 2.7.2 - - 2.6.5 - - 2.4.0 - - 2.3.1 - - ruby-head - - jruby-head - -matrix: - allow_failures: - - rvm: ruby-head - - rvm: jruby-head diff --git a/CHANGELOG.md b/CHANGELOG.md index ee3ac9c..2d58a1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,48 +1,49 @@ ### 0.9.0 (Next) -* Your contribution here. * [#29](https://github.com/dblock/ruby-enum/pull/29): Added superclass values when enumerating with `Ruby::Enum#values` - [@gi](https://github.com/gi). * [#30](https://github.com/dblock/ruby-enum/pull/30): Default value to key - [@gi](https://github.com/gi). +* [#34](https://github.com/dblock/ruby-enum/pull/34): Replaced Travis-CI with Github Actions, added Danger PR linter - [@dblock](https://github.com/dblock). +* Your contribution here. -### 0.8.0 (2020/3/27) +### 0.8.0 (2020/03/27) * [#22](https://github.com/dblock/ruby-enum/pull/22): Added `Ruby::Enum#each_key` and `Ruby::Enum#each_value` - [@dblock](https://github.com/dblock). * [#22](https://github.com/dblock/ruby-enum/pull/22): Dropped support for Ruby 2.2 - [@dblock](https://github.com/dblock). * [#22](https://github.com/dblock/ruby-enum/pull/22): Upgraded RuboCop to 0.80.1 - [@dblock](https://github.com/dblock). -### 0.7.2 (2017/3/15) +### 0.7.2 (2017/03/15) * [#18](https://github.com/dblock/ruby-enum/pull/18): Added support for non constant definition - [@laertispappas](https://github.com/laertispappas). -### 0.7.1 (2017/2/23) +### 0.7.1 (2017/02/23) * [#16](https://github.com/dblock/ruby-enum/pull/16): Replaced `const_missing` with `const_set` - [@laertispappas](https://github.com/laertispappas). -### 0.7.0 (2017/2/21) +### 0.7.0 (2017/02/21) * [#3](https://github.com/dblock/ruby-enum/pull/13): Added support for subclassing an Enum - [@laertispappas](https://github.com/laertispappas). -### 0.6.0 (2016/5/12) +### 0.6.0 (2016/05/12) * [#12](https://github.com/dblock/ruby-enum/pull/12): A `Ruby::Enum::Errors::DuplicateKeyError` or a `Ruby::Enum::Errors::DuplciateKeyValyeError` will now be raised when duplicate keys / values are defined - [@laertispappas](https://github.com/laertispappas). -### 0.5.0 (2015/20/11) +### 0.5.0 (2015/11/20) * [#8](https://github.com/dblock/ruby-enum/pull/8): Added `Ruby::Enum#key`, `Ruby::Enum#value`, `Ruby::Enum#key?`, and `Ruby::Enum#value?` - [@dmolesUC3](https://github.com/dmolesUC3). -### 0.4.0 (2014/29/6) +### 0.4.0 (2014/06/29) * [#5](https://github.com/dblock/ruby-enum/pull/5): Mixed in `Enumerable` - [@kgann](https://github.com/kgann). -### 0.3.0 (2014/19/5) +### 0.3.0 (2014/05/19) * [#4](https://github.com/dblock/ruby-enum/pull/4): Added `Ruby::Enum#map` - [@ArnaudRinquin](https://github.com/ArnaudRinquin). -### 0.2.1 (2013/15/5) +### 0.2.1 (2013/05/15) * Added `Ruby::Enum#values`, `Ruby::Enum#keys` and `Ruby::Enum#to_h` - [@dblock](https://github.com/dblock). * A `Ruby::Enum::Errors::UninitializedConstantError` will now be raised when referencing an undefined enum - [@dblock](https://github.com/dblock). -### 0.1.0 (2013/14/5) +### 0.1.0 (2013/05/14) * Initial public release, live-coded during [May 2013 NYC.rb](http://code.dblock.org/your-first-ruby-gem) - [@dblock](https://github.com/dblock). diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..a0a4a57 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +changelog.check! +toc.check! diff --git a/Gemfile b/Gemfile index 7089426..a53f887 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,9 @@ gemspec gem 'rake' group :development, :test do + gem 'danger' + gem 'danger-changelog', '0.6.1' + gem 'danger-toc', '0.2.0' gem 'rspec', '~> 3.0' gem 'rubocop', '0.80.1' end diff --git a/LICENSE.md b/LICENSE.md index 786edf3..a450dc3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2013-2020 Daniel Doubrovkine. +Copyright (c) 2013-2021 Daniel Doubrovkine. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 1388992..461170c 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,32 @@ Ruby::Enum ========== [![Gem Version](http://img.shields.io/gem/v/ruby-enum.svg)](http://badge.fury.io/rb/ruby-enum) -[![Build Status](https://travis-ci.org/dblock/ruby-enum.svg?branch=master)](https://travis-ci.org/dblock/ruby-enum) +[![Build Status](https://github.com/dblock/ruby-enum/workflows/test/badge.svg?branch=master)](https://github.com/dblock/ruby-enum/actions) [![Code Climate](https://codeclimate.com/github/dblock/ruby-enum.svg)](https://codeclimate.com/github/dblock/ruby-enum) Enum-like behavior for Ruby, heavily inspired by [this](http://www.rubyfleebie.com/enumerations-and-ruby) and improved upon [another blog post](http://code.dblock.org/how-to-define-enums-in-ruby). +## Table of Contents + +- [Usage](#usage) + - [Constants](#constants) + - [Class Methods](#class-methods) + - [Default Value](#default-value) + - [Enumerating](#enumerating) + - [Iterating](#iterating) + - [Mapping](#mapping) + - [Reducing](#reducing) + - [Sorting](#sorting) + - [Hashing](#hashing) + - [Retrieving keys and values](#retrieving-keys-and-values) + - [Mapping keys to values](#mapping-keys-to-values) + - [Mapping values to keys](#mapping-values-to-keys) + - [Duplicate enumerator keys or duplicate values](#duplicate-enumerator-keys-or-duplicate-values) + - [Inheritance behavior](#inheritance-behavior) +- [Contributing](#contributing) +- [Copyright and License](#copyright-and-license) +- [Related Projects](#related-projects) + ## Usage Enums can be defined and accessed either as constants or class methods, which is a matter of preference. @@ -250,7 +271,7 @@ You're encouraged to contribute to this gem. See [CONTRIBUTING](CONTRIBUTING.md) ## Copyright and License -Copyright (c) 2013-2020, Daniel Doubrovkine and [Contributors](CHANGELOG.md). +Copyright (c) 2013-2021, Daniel Doubrovkine and [Contributors](CHANGELOG.md). This project is licensed under the [MIT License](LICENSE.md).