mongoid-compatibility 0.5.0 → 0.6.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
- SHA1:
3
- metadata.gz: 4c9cc2a402a72a8af6bd7e28e93d8428605fe8c2
4
- data.tar.gz: 8d3c8435aa36bcdca204a5f15bc59de675c94ec4
2
+ SHA256:
3
+ metadata.gz: 67f56f2a4f261301d9ce8856177e0dc45dd0f490fffe58842cc65814cbc039b8
4
+ data.tar.gz: 603268d9a0f89b086f0d239d75289edfdb0948a653050e54e8c6811e97992628
5
5
  SHA512:
6
- metadata.gz: 227f291b3660311bad79c640fa6c278822698c65ecc397462a466a511128c61c6591a881dbb014481702d1b76dfe020aeb97fa6a0d4e1503cae8ee6ee3869e82
7
- data.tar.gz: a28e3cb6ddabff170b99029529030b8dc46fee41bc11768acaca5fafcdf470d4e2af30b4ac69d2eb3ba56fdf4c4aaef4cfddfcee2dd55e5c1ea2f5ce329344c5
6
+ metadata.gz: 91fd9d67679f2c7226dbde61790bb17640c0e8a2292f42251fadc0a507b1e96212c112dd8cbd1c23606a4316dd79d761a3e47205092dc1e3b49281f7244b88fc
7
+ data.tar.gz: 9c0ce0c31f6191162ce82cbb7685aa288015f9fb25aa48b0546761f4160d9dcb92563791711ad3559eae126bf0e93a302235b9b1730b4103126bc74d8e9b9056
@@ -0,0 +1,19 @@
1
+ name: PR Linter
2
+ on: [pull_request]
3
+ jobs:
4
+ danger:
5
+ runs-on: ubuntu-latest
6
+ env:
7
+ BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.danger
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ with:
11
+ fetch-depth: 0
12
+ - uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.6
15
+ bundler-cache: true
16
+ - run: |
17
+ # the personal token is public, this is ok, base64 encode to avoid tripping Github
18
+ TOKEN=$(echo -n NWY1ZmM5MzEyMzNlYWY4OTZiOGU3MmI3MWQ3Mzk0MzgxMWE4OGVmYwo= | base64 --decode)
19
+ DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
@@ -0,0 +1,13 @@
1
+ name: Rubocop
2
+ on: [push, pull_request]
3
+ jobs:
4
+ lint:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v2
8
+ - name: Set up Ruby
9
+ uses: ruby/setup-ruby@v1
10
+ with:
11
+ ruby-version: 2.7
12
+ bundler-cache: true
13
+ - run: bundle exec rubocop
@@ -0,0 +1,80 @@
1
+ name: CI RSpec Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: >-
8
+ Mongoid ${{ matrix.entry.mongoid }} - Ruby ${{ matrix.entry.ruby }} - MongoDB ${{ matrix.entry.mongodb }}
9
+ env:
10
+ CI: true
11
+ TESTOPTS: -v
12
+ runs-on: ubuntu-latest
13
+ continue-on-error: false
14
+ strategy:
15
+ matrix:
16
+ entry:
17
+ - { ruby: "2.1", mongoid: "3", bundler: "1", mongodb: "3.6" }
18
+ - { ruby: "2.1", mongoid: "4", bundler: "1", mongodb: "3.6" }
19
+ - { ruby: "2.2", mongoid: "4", bundler: "2", mongodb: "3.6" }
20
+ - { ruby: "2.2", mongoid: "5", bundler: "2", mongodb: "3.6" }
21
+ - { ruby: "2.3", mongoid: "5", bundler: "2", mongodb: "3.6" }
22
+ - { ruby: "2.4", mongoid: "6.1", bundler: "2", mongodb: "3.6" }
23
+ - { ruby: "2.5", mongoid: "6.2", bundler: "2", mongodb: "3.6" }
24
+ - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "3.6" }
25
+ - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "3.6" }
26
+ - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "3.6" }
27
+ - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "3.6" }
28
+ - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "3.6" }
29
+ - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "3.6" }
30
+ - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.0" }
31
+ - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.0" }
32
+ - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.0" }
33
+ - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.0" }
34
+ - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.0" }
35
+ - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.0" }
36
+ - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.2" }
37
+ - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.2" }
38
+ - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.2" }
39
+ - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.2" }
40
+ - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.2" }
41
+ - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.2" }
42
+ - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.4" }
43
+ - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.4" }
44
+ - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.4" }
45
+ - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.4" }
46
+ - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.4" }
47
+ - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.4" }
48
+ - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "5.0" }
49
+ - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "5.0" }
50
+ - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "5.0" }
51
+ - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "5.0" }
52
+ - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "5.0" }
53
+ - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "5.0" }
54
+ steps:
55
+ - name: repo checkout
56
+ uses: actions/checkout@v2
57
+
58
+ - name: start mongodb
59
+ uses: supercharge/mongodb-github-action@1.6.0
60
+ with:
61
+ mongodb-version: ${{ matrix.entry.mongodb }}
62
+ mongodb-replica-set: rs0
63
+
64
+ - name: load ruby
65
+ uses: ruby/setup-ruby@v1
66
+ with:
67
+ ruby-version: ${{ matrix.entry.ruby }}
68
+ bundler: ${{ matrix.entry.bundler }}
69
+
70
+ - name: bundle install
71
+ run: bundle install --jobs 4 --retry 3
72
+ env:
73
+ MONGOID_VERSION: ${{ matrix.entry.mongoid }}
74
+
75
+ - name: test
76
+ timeout-minutes: 10
77
+ run: bundle exec rspec spec
78
+ continue-on-error: false
79
+ env:
80
+ MONGOID_VERSION: ${{ matrix.entry.mongoid }}
data/.rubocop_todo.yml CHANGED
@@ -1,17 +1,17 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-09-25 07:58:30 -0400 using RuboCop version 0.33.0.
3
+ # on 2017-09-13 14:18:39 -0400 using RuboCop version 0.33.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
9
+ # Offense count: 20
10
10
  # Configuration parameters: AllowURI, URISchemes.
11
11
  Metrics/LineLength:
12
12
  Max: 118
13
13
 
14
- # Offense count: 3
14
+ # Offense count: 4
15
15
  Style/Documentation:
16
16
  Exclude:
17
17
  - 'lib/mongoid/compatibility/object_id.rb'
data/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
- ### 0.5.1 (Next)
1
+ ### 0.6.0 (2022/08/18)
2
2
 
3
- * Your contribution here.
3
+ * [#13](https://github.com/mongoid/mongoid-compatibility/pull/13): Compatibility with Mongoid 8.x - [@joe1chen](https://github.com/joe1chen).
4
+ * [#15](https://github.com/mongoid/mongoid-compatibility/pull/15): Upgraded to mongoid-danger 0.2.0 - [@dblock](https://github.com/dblock).
4
5
 
5
- ### 0.5.0
6
+ ### 0.5.1 (2017/12/02)
7
+
8
+ * [#8](https://github.com/mongoid/mongoid-compatibility/issues/8): Added `mongoidX_or_newer?` and `mongoidX_or_older?` helpers - [@dblock](https://github.com/dblock).
9
+
10
+ ### 0.5.0 (2017/09/13)
6
11
 
7
12
  * [#10](https://github.com/mongoid/mongoid-compatibility/pull/10): Compatibility with Mongoid 7.x - [@joeyAghion](https://github.com/joeyAghion).
8
13
 
data/Gemfile CHANGED
@@ -2,11 +2,13 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- case version = ENV['MONGOID_VERSION'] || '6.0'
5
+ case version = ENV['MONGOID_VERSION'] || '8.0.2'
6
6
  when 'HEAD'
7
7
  gem 'mongoid', github: 'mongodb/mongoid'
8
+ when /^8/
9
+ gem 'mongoid', '~> 8.0'
8
10
  when /^7/
9
- gem 'mongoid', github: 'mongodb/mongoid', branch: '7.0-dev'
11
+ gem 'mongoid', '~> 7.0'
10
12
  when /^6/
11
13
  gem 'mongoid', '~> 6.0'
12
14
  when /^5/
@@ -24,7 +26,6 @@ end
24
26
 
25
27
  group :test do
26
28
  gem 'rspec'
27
- gem 'mongoid-danger', '~> 0.1.1', require: false
28
29
  end
29
30
 
30
31
  group :development do
data/Gemfile.danger ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'mongoid-danger', '~> 0.2.0', require: false
5
+ end
data/README.md CHANGED
@@ -2,11 +2,10 @@ Mongoid::Compatibility
2
2
  =======================
3
3
 
4
4
  [![Gem Version](http://img.shields.io/gem/v/mongoid-compatibility.svg)](http://badge.fury.io/rb/mongoid-compatibility)
5
- [![Build Status](http://img.shields.io/travis/mongoid/mongoid-compatibility.svg)](https://travis-ci.org/mongoid/mongoid-compatibility)
6
- [![Dependency Status](https://gemnasium.com/mongoid/mongoid-compatibility.svg)](https://gemnasium.com/mongoid/mongoid-compatibility)
5
+ [![Build Status](https://github.com/mongoid/mongoid-compatibility/actions/workflows/test.yml/badge.svg)](https://github.com/mongoid/mongoid-compatibility/actions)
7
6
  [![Code Climate](https://codeclimate.com/github/mongoid/mongoid-compatibility.svg)](https://codeclimate.com/github/mongoid/mongoid-compatibility)
8
7
 
9
- Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6 and 7.
8
+ Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6, 7, and 8.
10
9
 
11
10
  ### Install
12
11
 
@@ -22,7 +21,7 @@ You may explicitly need to `require mongoid/compatibility`.
22
21
 
23
22
  #### Mongoid::Compatibility::Version
24
23
 
25
- ```
24
+ ``` ruby
26
25
  Mongoid::Compatibility::Version.mongoid2?
27
26
  # => is this Mongoid 2.x?
28
27
 
@@ -40,11 +39,24 @@ Mongoid::Compatibility::Version.mongoid6?
40
39
 
41
40
  Mongoid::Compatibility::Version.mongoid7?
42
41
  # => is this Mongoid 7.x?
42
+
43
+ Mongoid::Compatibility::Version.mongoid8?
44
+ # => is this Mongoid 8.x?
43
45
  ```
44
46
 
45
- #### Mongoid::Compatibility::ObjectId
47
+ Instead of checking for Mongoid 6 and 7 and 8, use `newer` and `older` helpers.
48
+
49
+ ``` ruby
50
+ Mongoid::Compatibility::Version.mongoid6_or_newer?
51
+ # => is this Mongoid 6.x or 7.x or 8.x, including beta 8?
46
52
 
53
+ Mongoid::Compatibility::Version.mongoid5_or_older?
54
+ # => is this Mongoid 2.x, 3.x, 4.x or 5.x?
47
55
  ```
56
+
57
+ #### Mongoid::Compatibility::ObjectId
58
+
59
+ ``` ruby
48
60
  Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')
49
61
  # => is this a valid BSON ID?
50
62
  ```
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Compatibility
3
- VERSION = '0.5.0'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
@@ -2,12 +2,20 @@ module Mongoid
2
2
  module Compatibility
3
3
  module Version
4
4
  module ClassMethods
5
- (2..7).each do |v|
5
+ (2..8).each do |v|
6
6
  const_set "V#{v}", Mongoid::VERSION =~ Regexp.new("^#{v}\.")
7
7
 
8
8
  define_method "mongoid#{v}?" do
9
9
  !!Mongoid::Compatibility::Version::ClassMethods.const_get("V#{v}")
10
10
  end
11
+
12
+ define_method "mongoid#{v}_or_newer?" do
13
+ Gem::Version.new(Mongoid::VERSION).segments.first >= v
14
+ end
15
+
16
+ define_method "mongoid#{v}_or_older?" do
17
+ Gem::Version.new(Mongoid::VERSION).segments.first <= v
18
+ end
11
19
  end
12
20
  end
13
21
 
@@ -0,0 +1,8 @@
1
+ test:
2
+ clients:
3
+ default:
4
+ database: mongoid-compatibility
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ raise_not_found_error: false
@@ -3,20 +3,52 @@ require 'spec_helper'
3
3
  describe Mongoid::Compatibility::Version do
4
4
  context 'mongoid? methods' do
5
5
  it 'only true for one version' do
6
- expect(
7
- (Mongoid::Compatibility::Version.methods - Object.methods).one? do |m|
8
- Mongoid::Compatibility::Version.send(m)
9
- end
10
- ).to be true
6
+ expect((2..8).one? do |v|
7
+ Mongoid::Compatibility::Version.send("mongoid#{v}?")
8
+ end).to be true
11
9
  end
12
- it 'defines version methods' do
13
- expect(Mongoid::Compatibility::Version.methods - Object.methods).to_not eq []
10
+ context "current version #{Mongoid::VERSION}" do
11
+ let(:version) { Mongoid::VERSION.split('.').first.to_i }
12
+ it 'mongoidX?' do
13
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version}?")).to be true
14
+ end
15
+ it 'mongoidX?_or_newer?' do
16
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_newer?")).to be true
17
+ if Mongoid::Compatibility::Version.respond_to?("mongoid#{version - 1}_or_newer?")
18
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version - 1}_or_newer?")).to be true
19
+ end
20
+ if Mongoid::Compatibility::Version.respond_to?("mongoid#{version - 1}_or_older?")
21
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version - 1}_or_older?")).to be false
22
+ end
23
+ if Mongoid::Compatibility::Version.respond_to?("mongoid#{version + 1}_or_older?")
24
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version + 1}_or_older?")).to be true
25
+ end
26
+ if Mongoid::Compatibility::Version.respond_to?("mongoid#{version + 1}_or_newer?")
27
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version + 1}_or_newer?")).to be false
28
+ end
29
+ end
30
+ it 'mongoidX?_or_older?' do
31
+ expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_older?")).to be true
32
+ end
14
33
  end
15
- (2..7).each do |v|
34
+ (2..8).each do |v|
16
35
  context "mongoid #{v}" do
36
+ before do
37
+ stub_const('::Mongoid::VERSION', "#{v}")
38
+ stub_const("::Mongoid::Compatibility::Version::ClassMethods::V#{v}", 1)
39
+ end
17
40
  it "responds to mongoid#{v}?" do
18
41
  expect(Mongoid::Compatibility::Version).to respond_to("mongoid#{v}?")
19
42
  end
43
+ it "mongoid#{v}?" do
44
+ expect(Mongoid::Compatibility::Version.send("mongoid#{v}?")).to be true
45
+ end
46
+ it "mongoid#{v}_or_newer?" do
47
+ expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_newer?")).to be true
48
+ end
49
+ it "mongoid#{v}_or_older?" do
50
+ expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_older?")).to be true
51
+ end
20
52
  end
21
53
  end
22
54
  end
@@ -12,6 +12,8 @@ elsif Mongoid::Compatibility::Version.mongoid6?
12
12
  Mongoid.load! 'spec/config/mongoid6.yml'
13
13
  elsif Mongoid::Compatibility::Version.mongoid7?
14
14
  Mongoid.load! 'spec/config/mongoid7.yml'
15
+ elsif Mongoid::Compatibility::Version.mongoid8?
16
+ Mongoid.load! 'spec/config/mongoid8.yml'
15
17
  else
16
18
  fail "unsupported Mongoid version #{Mongoid::VERSION}"
17
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-compatibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -38,12 +38,15 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
41
+ description:
42
42
  email: dblock@dblock.org
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - ".github/workflows/danger.yml"
48
+ - ".github/workflows/rubocop.yml"
49
+ - ".github/workflows/test.yml"
47
50
  - ".gitignore"
48
51
  - ".rspec"
49
52
  - ".rubocop.yml"
@@ -53,6 +56,7 @@ files:
53
56
  - CONTRIBUTING.md
54
57
  - Dangerfile
55
58
  - Gemfile
59
+ - Gemfile.danger
56
60
  - LICENSE.md
57
61
  - README.md
58
62
  - RELEASING.md
@@ -70,6 +74,7 @@ files:
70
74
  - spec/config/mongoid5.yml
71
75
  - spec/config/mongoid6.yml
72
76
  - spec/config/mongoid7.yml
77
+ - spec/config/mongoid8.yml
73
78
  - spec/mongoid/compatibility/object_id_spec.rb
74
79
  - spec/mongoid/compatibility/self_spec.rb
75
80
  - spec/mongoid/compatibility/version_spec.rb
@@ -79,7 +84,7 @@ homepage: http://github.com/mongoid/mongoid-compatibility
79
84
  licenses:
80
85
  - MIT
81
86
  metadata: {}
82
- post_install_message:
87
+ post_install_message:
83
88
  rdoc_options: []
84
89
  require_paths:
85
90
  - lib
@@ -94,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
99
  - !ruby/object:Gem::Version
95
100
  version: 1.3.6
96
101
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.5.2
99
- signing_key:
102
+ rubygems_version: 3.1.3
103
+ signing_key:
100
104
  specification_version: 4
101
105
  summary: Compatibility helpers for Mongoid.
102
106
  test_files: []