ar-enum 0.2.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e86b5917258828aad1000b878f4cf5f263c2f00d4c9bada348159f75410d864
4
- data.tar.gz: 5c97b8d8f4a81c72036ef4d4b627772965ac19cdbe0a4c4217aaf91f8abbaaa1
3
+ metadata.gz: d7a647f542cd5db3a64b56e35fa262c79b35b2f6a6aa4e6a1acaee79e04010c0
4
+ data.tar.gz: f893db3693548e1fc78e93d998f21bbdc8613a8ef0e7127fc3efb9cc0313332b
5
5
  SHA512:
6
- metadata.gz: 584a2323fad2de86e7e30979a037a7ae935f3d12d4590b6484ffc5733b266d458962a513b265af863dcb0f152815169687dd85bfce79df5c7fe7524c234c9658
7
- data.tar.gz: 6f713d4790f5f802775062448626e94e61698d4ba98d735ea3cd929a6202acb750f9210bced6a73b371c960225e15fc8072d95123e2bfafc04b9336b442486ca
6
+ metadata.gz: 2e97f11904a082300cd91c8f027f84af9570e1adf3d67b2a3cfb97a310922b65f853389c41b27df1ba30f9a037b02e4cb69cdbe686893e0b29802943ea2ec81b
7
+ data.tar.gz: e8a3bd1dbdceab1ddc77a14b933b69d3b5a458b81f137070e3b0def28ac9b00334293be7ac0d47a56d42bf12136d3755f13a5eea796843d6a38d2299a76ca57d
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+ ---
3
+ github: [fnando]
4
+ custom: ["https://paypal.me/nandovieira/🍕"]
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: "🐛 Bug Report"
3
+ about: Report a reproducible bug or regression.
4
+ title: 'Bug: '
5
+ labels: 'Status: Unconfirmed'
6
+
7
+ ---
8
+
9
+ <!--
10
+ - Please provide a clear and concise description of what the bug is.
11
+ - If possible, add an example reproducing your issue.
12
+ - Please test using the latest version of ar-enum
13
+ to make sure your issue has not already been fixed.
14
+ -->
15
+
16
+ ## Description
17
+
18
+ [Add bug description here]
19
+
20
+ ## How to reproduce
21
+
22
+ [Add steps on how to reproduce this issue]
23
+
24
+ ## What do you expect
25
+
26
+ [Describe what do you expect to happen]
27
+
28
+ ## What happened instead
29
+
30
+ [Describe the actual results]
31
+
32
+ ## Software:
33
+
34
+ - Gem version: [Add gem version here]
35
+ - Ruby version: [Add version here]
36
+
37
+ ## Full backtrace
38
+
39
+ ```text
40
+ [Paste full backtrace here]
41
+ ```
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: "💡 Feature request"
3
+ about: Have an idea that may be useful? Make a suggestion!
4
+ title: 'Feature Request: '
5
+ labels: 'Feature request'
6
+
7
+ ---
8
+
9
+ ## Description
10
+
11
+ _A clear and concise description of what the problem is._
12
+
13
+ ## Describe the solution
14
+
15
+ _A clear and concise description of what you want to happen._
16
+
17
+ ## Alternatives you considered
18
+
19
+ _A clear and concise description of any alternative solutions or features you've considered._
20
+
21
+ ## Additional context
22
+
23
+ _Add any other context, screenshots, links, etc about the feature request here._
@@ -0,0 +1,38 @@
1
+ <!--
2
+ If you're making a doc PR or something tiny where the below is irrelevant,
3
+ delete this template and use a short description, but in your description aim to
4
+ include both what the change is, and why it is being made, with enough context
5
+ for anyone to understand.
6
+ -->
7
+
8
+ <details>
9
+ <summary>PR Checklist</summary>
10
+
11
+ ### PR Structure
12
+
13
+ - [ ] This PR has reasonably narrow scope (if not, break it down into smaller
14
+ PRs).
15
+ - [ ] This PR avoids mixing refactoring changes with feature changes (split into
16
+ two PRs otherwise).
17
+ - [ ] This PR's title starts is concise and descriptive.
18
+
19
+ ### Thoroughness
20
+
21
+ - [ ] This PR adds tests for the most critical parts of the new functionality or
22
+ fixes.
23
+ - [ ] I've updated any docs, `.md` files, etc… affected by this change.
24
+
25
+ </details>
26
+
27
+ ### What
28
+
29
+ [TODO: Short statement about what is changing.]
30
+
31
+ ### Why
32
+
33
+ [TODO: Why this change is being made. Include any context required to understand
34
+ the why.]
35
+
36
+ ### Known limitations
37
+
38
+ [TODO or N/A]
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: Tests
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+ push:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ build:
14
+ name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
15
+ runs-on: "ubuntu-latest"
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [2.6.x, 2.7.x, 3.0.x]
20
+ gemfile:
21
+ - Gemfile
22
+ - gemfiles/6_1.gemfile
23
+ - gemfiles/6_0.gemfile
24
+
25
+ services:
26
+ postgres:
27
+ image: postgres:11.5
28
+ ports: ["5432:5432"]
29
+ options:
30
+ --health-cmd pg_isready --health-interval 10s --health-timeout 5s
31
+ --health-retries 5
32
+
33
+ steps:
34
+ - uses: actions/checkout@v1
35
+
36
+ - uses: actions/cache@v2
37
+ with:
38
+ path: vendor/bundle
39
+ key: >
40
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
41
+ hashFiles(matrix.gemfile) }}
42
+ restore-keys: >
43
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
44
+ hashFiles(matrix.gemfile) }}
45
+
46
+ - name: Set up Ruby
47
+ uses: actions/setup-ruby@v1
48
+ with:
49
+ ruby-version: ${{ matrix.ruby }}
50
+
51
+ - name: Install PostgreSQL client
52
+ env:
53
+ PGHOST: localhost
54
+ PGUSER: postgres
55
+ run: |
56
+ sudo apt-get -yqq install libpq-dev
57
+ psql -U postgres -c "create database test"
58
+
59
+ - name: Install gem dependencies
60
+ env:
61
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
62
+ run: |
63
+ gem install bundler
64
+ bundle config path vendor/bundle
65
+ bundle update --jobs 4 --retry 3
66
+
67
+ - name: Run Tests
68
+ env:
69
+ PGHOST: localhost
70
+ PGUSER: postgres
71
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
72
+ run: |
73
+ bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
7
+ NewCops: enable
8
+
9
+ Naming/FileName:
10
+ Exclude:
11
+ - lib/ar-enum.rb
12
+ - vendor/**/*
13
+ - gemfiles/**/*
14
+
15
+ Layout/LineLength:
16
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
- # ar-check
1
+ # Changelog
2
2
 
3
- #### v0.1.0
3
+ <!--
4
+ Prefix your message with one of the following:
4
5
 
5
- - Initial release
6
+ - [Added] for new features.
7
+ - [Changed] for changes in existing functionality.
8
+ - [Deprecated] for soon-to-be removed features.
9
+ - [Removed] for now removed features.
10
+ - [Fixed] for any bug fixes.
11
+ - [Security] in case of vulnerabilities.
12
+ -->
13
+
14
+ ## v0.5.0
15
+
16
+ - [Fixed] Add version restriction to ActiveRecord >= 6.0 and < 7.0, as Rails 7
17
+ now supports Postgres enums out of the box.
18
+
19
+ ## v0.4.0 - 2021-09-16
20
+
21
+ - [Changed] Sort enums by name.
22
+ - [Removed] Support for Rails 5.2
23
+
24
+ ## v0.3.0 - 2019-11-26
25
+
26
+ - [Added] Support for Rails 6.
27
+
28
+ ## v0.2.3 - 2019-03-12
29
+
30
+ - [Fixed] Don't try to recreate a type that already exists.
31
+
32
+ ## v0.2.2 - 2019-03-12
33
+
34
+ - [Fixed] Schema dumping.
35
+
36
+ ## v0.2.1 - 2019-03-11
37
+
38
+ - [Added] Define `enum` type so schema dumper can work appropriately.
39
+
40
+ ## v0.2.0 - 2019-03-10
41
+
42
+ - [Added] Add command recorder reversing.
43
+
44
+ ## v0.1.0 - 2019-03-10
45
+
46
+ - Initial release.
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,13 +1,74 @@
1
- # Contributor Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
4
4
 
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
6
11
 
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
12
+ ## Our Standards
8
13
 
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
10
16
 
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
12
22
 
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at me@fnando.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,79 @@
1
+ # Contributing to ar-enum
2
+
3
+ 👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4
+
5
+ The following is a set of guidelines for contributing to this project. These are
6
+ mostly guidelines, not rules. Use your best judgment, and feel free to propose
7
+ changes to this document in a pull request.
8
+
9
+ ## Code of Conduct
10
+
11
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and
12
+ mailing lists is expected to follow the [code of conduct](https://github.com/fnando/ar-enum/blob/main/CODE_OF_CONDUCT.md).
13
+
14
+ ## Reporting bugs
15
+
16
+ This section guides you through submitting a bug report. Following these
17
+ guidelines helps maintainers and the community understand your report, reproduce
18
+ the behavior, and find related reports.
19
+
20
+ - Before creating bug reports, please check the open issues; somebody may
21
+ already have submitted something similar, and you may not need to create a new
22
+ one.
23
+ - When you are creating a bug report, please include as many details as
24
+ possible, with an example reproducing the issue.
25
+
26
+ ## Contributing with code
27
+
28
+ Before making any radicals changes, please make sure you discuss your intention
29
+ by [opening an issue on Github](https://github.com/fnando/ar-enum/issues).
30
+
31
+ When you're ready to make your pull request, follow checklist below to make sure
32
+ your contribution is according to how this project works.
33
+
34
+ 1. [Fork](https://help.github.com/forking/) ar-enum
35
+ 2. Create a topic branch - `git checkout -b my_branch`
36
+ 3. Make your changes using [descriptive commit messages](#commit-messages)
37
+ 4. Update CHANGELOG.md describing your changes by adding an entry to the
38
+ "Unreleased" section. If this section is not available, create one right
39
+ before the last version.
40
+ 5. Push to your branch - `git push origin my_branch`
41
+ 6. [Create a pull request](https://docs.github.com/articles/creating-a-pull-request)
42
+ 7. That's it!
43
+
44
+ ## Styleguides
45
+
46
+ ### Commit messages
47
+
48
+ - Use the present tense ("Add feature" not "Added feature")
49
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
50
+ - Limit the first line to 72 characters or less
51
+ - Reference issues and pull requests liberally after the first line
52
+
53
+ ### Changelog
54
+
55
+ - Add a message describing your changes to the "Unreleased" section. The
56
+ changelog message should follow the same style as the commit message.
57
+ - Prefix your message with one of the following:
58
+ - `[Added]` for new features.
59
+ - `[Changed]` for changes in existing functionality.
60
+ - `[Deprecated]` for soon-to-be removed features.
61
+ - `[Removed]` for now removed features.
62
+ - `[Fixed]` for any bug fixes.
63
+ - `[Security]` in case of vulnerabilities.
64
+
65
+ ### Ruby code
66
+
67
+ - This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
68
+ submitting your changes, make sure your tests are passing and code conforms to
69
+ the expected style by running `rake`.
70
+ - Do not change the library version. This will be done by the maintainer
71
+ whenever a new version is about to be released.
72
+
73
+ ### JavaScript code
74
+
75
+ - This project uses [ESLint](https://eslint.org) to enforce code style. Before
76
+ submitting your changes, make sure your tests are passing and code conforms to
77
+ the expected style by running `yarn test:ci`.
78
+ - Do not change the library version. This will be done by the maintainer
79
+ whenever a new version is about to be released.
data/Gemfile CHANGED
@@ -2,5 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in ar-check.gemspec
6
5
  gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
- # AR::Enum
1
+ # ar-enum
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/ar-enum.svg)](https://travis-ci.org/fnando/ar-enum)
4
- [![Code Climate](https://codeclimate.com/github/fnando/ar-enum/badges/gpa.svg)](https://codeclimate.com/github/fnando/ar-enum)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/ar-enum/badges/coverage.svg)](https://codeclimate.com/github/fnando/ar-enum/coverage)
3
+ [![Tests](https://github.com/fnando/ar-enum/workflows/Tests/badge.svg)](https://github.com/fnando/ar-enum)
6
4
  [![Gem](https://img.shields.io/gem/v/ar-enum.svg)](https://rubygems.org/gems/ar-enum)
7
5
  [![Gem](https://img.shields.io/gem/dt/ar-enum.svg)](https://rubygems.org/gems/ar-enum)
8
6
 
9
- Add support for creating `ENUM` types in PostgreSQL with ActiveRecord.
7
+ Add support for creating `ENUM` types in PostgreSQL with ActiveRecord. This gem
8
+ is no longer required for Rails 7.0+.
10
9
 
11
10
  ## Installation
12
11
 
@@ -40,7 +39,8 @@ create_table :articles do |t|
40
39
  end
41
40
  ```
42
41
 
43
- You can even use the type shortcut if you want; i.e. you can use `t.article_status` instead of `t.column`.
42
+ You can even use the type shortcut if you want; i.e. you can use
43
+ `t.article_status` instead of `t.column`.
44
44
 
45
45
  ```ruby
46
46
  # The type is created independently from the table.
@@ -60,13 +60,16 @@ To remove the enum, use `drop_enum`.
60
60
  drop_enum :article_status
61
61
  ```
62
62
 
63
- You'll receive a `ActiveRecord::StatementInvalid` if any of your tables have a dependency on the type; i.e. you're have a column using that enum. You can drop these columns by specifying `cascade: true`.
63
+ You'll receive a `ActiveRecord::StatementInvalid` if any of your tables have a
64
+ dependency on the type; i.e. you're have a column using that enum. You can drop
65
+ these columns by specifying `cascade: true`.
64
66
 
65
67
  ```ruby
66
68
  drop_enum :article_status, cascade: true
67
69
  ```
68
70
 
69
- If you don't want to remove the column, change the column type before dropping the enum.
71
+ If you don't want to remove the column, change the column type before dropping
72
+ the enum.
70
73
 
71
74
  ```ruby
72
75
  change_column :articles, :status, :text
@@ -75,7 +78,8 @@ drop_enum :article_status
75
78
 
76
79
  ### Adding new labels
77
80
 
78
- Use `add_enum_label` to add new values to the enum type. You can control where the value will be inserted by using `before: label` and `after: label`.
81
+ Use `add_enum_label` to add new values to the enum type. You can control where
82
+ the value will be inserted by using `before: label` and `after: label`.
79
83
 
80
84
  ```ruby
81
85
  create_enum :article_status, %w[draft published]
@@ -110,7 +114,6 @@ The following commands can be reversed:
110
114
  - `create_enum`
111
115
  - `rename_enum_label`
112
116
 
113
-
114
117
  ```ruby
115
118
  class CreateColorEnumClass < ActiveRecord::Migration
116
119
  def change
@@ -121,16 +124,24 @@ end
121
124
 
122
125
  ## Development
123
126
 
124
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
127
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
128
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
129
+ prompt that will allow you to experiment.
125
130
 
126
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
131
+ To install this gem onto your local machine, run `bundle exec rake install`. To
132
+ release a new version, update the version number in `version.rb`, and then run
133
+ `bundle exec rake release`, which will create a git tag for the version, push
134
+ git commits and tags, and push the `.gem` file to
135
+ [rubygems.org](https://rubygems.org).
127
136
 
128
137
  ## Contributing
129
138
 
130
- Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/ar-enum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
131
-
139
+ Bug reports and pull requests are welcome on GitHub at
140
+ https://github.com/fnando/ar-enum. This project is intended to be a safe,
141
+ welcoming space for collaboration, and contributors are expected to adhere to
142
+ the [Contributor Covenant](contributor-covenant.org) code of conduct.
132
143
 
133
144
  ## License
134
145
 
135
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
136
-
146
+ The gem is available as open source under the terms of the
147
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << "test"
@@ -11,4 +12,6 @@ Rake::TestTask.new(:test) do |t|
11
12
  t.warning = false
12
13
  end
13
14
 
14
- task default: :test
15
+ RuboCop::RakeTask.new
16
+
17
+ task default: %i[test rubocop]
data/ar-enum.gemspec CHANGED
@@ -7,8 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.version = AR::Enum::VERSION
8
8
  spec.authors = ["Nando Vieira"]
9
9
  spec.email = ["fnando.vieira@gmail.com"]
10
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
10
11
 
11
- spec.summary = "Add support for creating `ENUM` types in PostgreSQL with ActiveRecord"
12
+ spec.summary = "Add support for creating `ENUM` types in PostgreSQL " \
13
+ "with ActiveRecord"
12
14
  spec.description = spec.summary
13
15
  spec.homepage = "https://rubygems.org/gems/ar-enum"
14
16
  spec.license = "MIT"
@@ -20,12 +22,15 @@ Gem::Specification.new do |spec|
20
22
  spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
21
23
  spec.require_paths = ["lib"]
22
24
 
23
- spec.add_dependency "activerecord"
25
+ spec.add_dependency "activerecord", ">= 6.0.0", "< 7.0.0"
24
26
 
25
27
  spec.add_development_dependency "bundler"
26
28
  spec.add_development_dependency "minitest-utils"
27
29
  spec.add_development_dependency "pg"
28
30
  spec.add_development_dependency "pry-meta"
29
31
  spec.add_development_dependency "rake"
32
+ spec.add_development_dependency "rubocop"
33
+ spec.add_development_dependency "rubocop-fnando"
30
34
  spec.add_development_dependency "simplecov"
35
+ spec.metadata["rubygems_mfa_required"] = "true"
31
36
  end
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ar-enum"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ begin
11
+ require "pry"
12
+ Pry.start
13
+ rescue LoadError
14
+ require "irb"
15
+ IRB.start(__FILE__)
16
+ end
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ IFS=$'\n\t'
6
+ set -vx
7
+
8
+ bundle install
9
+
10
+ # Do any other automated setup that you need to do here
@@ -3,4 +3,4 @@
3
3
  source "https://rubygems.org"
4
4
  gemspec path: ".."
5
5
 
6
- gem "activerecord", "~> 5.2.0"
6
+ gem "activerecord", "~> 6.0.0"
@@ -3,4 +3,4 @@
3
3
  source "https://rubygems.org"
4
4
  gemspec path: ".."
5
5
 
6
- gem "activerecord", "~> 6.0.0.beta2"
6
+ gem "activerecord", "~> 6.1.0"
@@ -30,6 +30,8 @@ module AR
30
30
  end
31
31
 
32
32
  def create_enum(name, values)
33
+ return if enum_exists?(name)
34
+
33
35
  values = values.map do |value|
34
36
  quote(value.to_s)
35
37
  end
@@ -42,6 +44,10 @@ module AR
42
44
  execute(sql)
43
45
  end
44
46
 
47
+ def enum_exists?(name)
48
+ enum_types.any? {|type| type["name"] == name.to_s }
49
+ end
50
+
45
51
  def add_enum_label(name, value, options = {})
46
52
  sql = "ALTER TYPE #{name} ADD VALUE #{quote(value.to_s)}"
47
53
 
@@ -55,7 +61,8 @@ module AR
55
61
  end
56
62
 
57
63
  def rename_enum_label(name, from, to)
58
- sql = "ALTER TYPE #{name} RENAME VALUE #{quote(from.to_s)} TO #{quote(to.to_s)}"
64
+ sql = "ALTER TYPE #{name} RENAME VALUE #{quote(from.to_s)}" \
65
+ " TO #{quote(to.to_s)}"
59
66
  execute(sql)
60
67
  end
61
68
 
@@ -9,7 +9,7 @@ module AR
9
9
  end
10
10
 
11
11
  def enum_types(stream)
12
- list = @connection.enum_types.to_a
12
+ list = @connection.enum_types.to_a.sort_by {|type| type["name"] }
13
13
 
14
14
  stream.puts(" # These are enum types available on this database") if list.any?
15
15
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AR
4
4
  module Enum
5
- VERSION = "0.2.2"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
data/lib/ar/enum.rb CHANGED
@@ -19,15 +19,21 @@ end
19
19
 
20
20
  ActiveSupport.on_load(:active_record) do
21
21
  require "active_record/connection_adapters/postgresql_adapter"
22
+ silence_warnings do
23
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES = ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.dup
24
+ end
22
25
 
23
26
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(
24
27
  Module.new do
25
- def create_table_definition(*args)
28
+ def create_table_definition(*args, **kwargs)
26
29
  ActiveRecord::Base.connection.enum_types.each do |enum|
27
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[enum["name"].to_sym] = {name: enum["name"]}
28
30
  ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods.class_eval do
31
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[enum["name"].to_sym] = {name: enum["name"]}
32
+
29
33
  define_method(enum["name"]) do |*names, **options|
30
- names.each {|name| column(name, enum["name"].to_sym, options) }
34
+ names.each do |name|
35
+ column(name, enum["name"].to_sym, **options)
36
+ end
31
37
  end
32
38
  end
33
39
  end
@@ -53,7 +59,7 @@ ActiveSupport.on_load(:active_record) do
53
59
  )
54
60
  type_metadata = ActiveRecord::ConnectionAdapters::PostgreSQLTypeMetadata.new(type_metadata)
55
61
 
56
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[type_metadata.type] = {name: "character varying"}
62
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[type_metadata.type] = {name: "character varying"}
57
63
  end
58
64
 
59
65
  type_metadata
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 6.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 6.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +100,34 @@ dependencies:
94
100
  - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-fnando
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
97
131
  - !ruby/object:Gem::Dependency
98
132
  name: simplecov
99
133
  requirement: !ruby/object:Gem::Requirement
@@ -115,17 +149,25 @@ executables: []
115
149
  extensions: []
116
150
  extra_rdoc_files: []
117
151
  files:
152
+ - ".github/FUNDING.yml"
153
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
154
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
155
+ - ".github/PULL_REQUEST_TEMPLATE.md"
156
+ - ".github/workflows/tests.yml"
118
157
  - ".gitignore"
119
- - ".travis.yml"
158
+ - ".rubocop.yml"
120
159
  - CHANGELOG.md
121
160
  - CODE_OF_CONDUCT.md
161
+ - CONTRIBUTING.md
122
162
  - Gemfile
123
- - LICENSE.txt
163
+ - LICENSE.md
124
164
  - README.md
125
165
  - Rakefile
126
166
  - ar-enum.gemspec
127
- - gemfiles/activerecord_5_2.gemfile
128
- - gemfiles/activerecord_6_0.gemfile
167
+ - bin/console
168
+ - bin/setup
169
+ - gemfiles/6_0.gemfile
170
+ - gemfiles/6_1.gemfile
129
171
  - lib/ar-enum.rb
130
172
  - lib/ar/enum.rb
131
173
  - lib/ar/enum/adapter.rb
@@ -135,8 +177,9 @@ files:
135
177
  homepage: https://rubygems.org/gems/ar-enum
136
178
  licenses:
137
179
  - MIT
138
- metadata: {}
139
- post_install_message:
180
+ metadata:
181
+ rubygems_mfa_required: 'true'
182
+ post_install_message:
140
183
  rdoc_options: []
141
184
  require_paths:
142
185
  - lib
@@ -144,15 +187,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
187
  requirements:
145
188
  - - ">="
146
189
  - !ruby/object:Gem::Version
147
- version: '0'
190
+ version: 2.6.0
148
191
  required_rubygems_version: !ruby/object:Gem::Requirement
149
192
  requirements:
150
193
  - - ">="
151
194
  - !ruby/object:Gem::Version
152
195
  version: '0'
153
196
  requirements: []
154
- rubygems_version: 3.0.1
155
- signing_key:
197
+ rubygems_version: 3.3.3
198
+ signing_key:
156
199
  specification_version: 4
157
200
  summary: Add support for creating `ENUM` types in PostgreSQL with ActiveRecord
158
201
  test_files: []
data/.travis.yml DELETED
@@ -1,33 +0,0 @@
1
- language: ruby
2
- addons:
3
- postgresql: "10"
4
- apt:
5
- packages:
6
- - postgresql-10
7
- - postgresql-client-10
8
- cache: bundler
9
- before_install:
10
- - sudo service postgresql stop
11
- - sed -e 's/^port.*/port = 5432/' /etc/postgresql/10/main/postgresql.conf > postgresql.conf
12
- - sudo chown postgres postgresql.conf
13
- - sudo mv postgresql.conf /etc/postgresql/10/main
14
- - sudo service postgresql start 10
15
- before_script:
16
- - createdb test
17
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
- - chmod +x ./cc-test-reporter
19
- - "./cc-test-reporter before-build"
20
- after_script:
21
- - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
22
- gemfile:
23
- - Gemfile
24
- - gemfiles/activerecord_6_0.gemfile
25
- - gemfiles/activerecord_5_2.gemfile
26
- rvm:
27
- - 2.6.1
28
- - 2.5.3
29
- notifications:
30
- email: false
31
- env:
32
- global:
33
- secure: ItWMub2Jbp/Xey50SAPWeYzZcKoEFORj716NmbQI1NbnOzqEDOF3pDZd9HHCxHoBA6gYYDIGWFCa15ymfugzBJ/eGaL7qzEF098xU7hwgG0DOlU31RAPOwn7ov3merGVJOttWOgYYmTR7pxyyg5iMc7/IzU5ag1As+Sz8s7vq9uR2HRdRALvuRFAS1Vty5lV1dINVNIs2vSHMIdgwWCaraWno8R3WupchXgkoA4WGwK6+n99ZUfuCv6kLwAJhlH3rWXEuwT49ILGRCYUp3rRZ/wawclUviYjxgVvS5xeEGzsh3X9AMkbq68up9zxcG1KYeL+EKxLDL6ieC2OtaqMst3k7UariK5QWro00TdGdNpw2M83d0ca81PUW8lpyZVvOJ8STDFR3Dtt8emaz/F0rHiBJlMP1vKWYxgQgpIEIv+WQV2YcVJBg0NNjQ8Ei6ujGG2s8pJNvJBudK/jL3okpXy/uPd5djQfoJcLnZk0xHOqJtcr1+Xg/9TUo/vh81U8cIgGJDtwssoyMastqv1U9Gm2AfsRKmjDyRoIhvwbF9V3dpdks4tRtmnEoYo91K9y2nv45tyO0R6PSEhNL8wDGlvgqUk4XlaaQEs2yNPgpX07ivs47+/x8ufkcyzAf0nHXN/FDzqLnHQBHqdk8a/BTY9wWQP1d5iIuojr30vR4X4=
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Nando Vieira
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.