Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
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: 3.0, allowed-failure: true }
- { 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 }}
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

23 changes: 12 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 4 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

changelog.check!
toc.check!
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).

Expand Down