mongoid-compatibility 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +6 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -4
- data/README.md +4 -1
- data/lib/mongoid/compatibility/self.rb +1 -1
- data/lib/mongoid/compatibility/version.rb +8 -8
- data/mongoid-compatibility.gemspec +1 -1
- data/spec/config/mongoid2.yml +3 -0
- data/spec/mongoid/compatibility/version_spec.rb +23 -0
- data/spec/support/mongoid.rb +6 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 873f442a8ff9a2b84c0d38cafd5a802ce0a28466
|
4
|
+
data.tar.gz: e9545691f356f72e835059e32913e3e4e30e8a28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc225ab3375d9edbf93dbe5f6174e6fdbe6cd588e2ef353b0809ae69fc1d70751566d1888765f01558e3f3c85f27360a5830d70bba544b92e03e700ca3ae17b
|
7
|
+
data.tar.gz: cdc4bf29128fc0660567c4c5491e3325b305934630c74c790d45124d36347e14fe09b202ac36a4e2ba7414df9e176bd66417439f34fd80631d369d851f0e6c06
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2015-09-
|
3
|
+
# on 2015-09-25 07:58:30 -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
|
@@ -18,6 +18,11 @@ Style/Documentation:
|
|
18
18
|
- 'lib/mongoid/compatibility/self.rb'
|
19
19
|
- 'lib/mongoid/compatibility/version.rb'
|
20
20
|
|
21
|
+
# Offense count: 1
|
22
|
+
Style/DoubleNegation:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/mongoid/compatibility/version.rb'
|
25
|
+
|
21
26
|
# Offense count: 1
|
22
27
|
# Configuration parameters: Exclude.
|
23
28
|
Style/FileName:
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 0.3.1 (2015/09/25)
|
2
|
+
|
3
|
+
* Compatibility with Mongoid 2 - [@dblock](https://github.com/dblock).
|
4
|
+
* Use constants to yield version, avoid matching regexp every time - [@dblock](https://github.com/dblock).
|
5
|
+
|
1
6
|
### 0.2.0 (2015/09/18)
|
2
7
|
|
3
8
|
* [#1](https://github.com/dblock/mongoid-compatibility/issues/1): Require `mongoid/compatibility` - [@dblock](https://github.com/dblock).
|
data/Gemfile
CHANGED
@@ -2,13 +2,16 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
case version = ENV['MONGOID_VERSION'] || '
|
6
|
-
when
|
5
|
+
case version = ENV['MONGOID_VERSION'] || '5.0'
|
6
|
+
when /^5/
|
7
7
|
gem 'mongoid', '~> 5.0'
|
8
|
-
when
|
8
|
+
when /^4/
|
9
9
|
gem 'mongoid', '~> 4.0'
|
10
|
-
when
|
10
|
+
when /^3/
|
11
11
|
gem 'mongoid', '~> 3.1'
|
12
|
+
when /^2/
|
13
|
+
gem 'mongoid', '~> 2.0'
|
14
|
+
gem 'bson_ext', platforms: :ruby
|
12
15
|
else
|
13
16
|
gem 'mongoid', version
|
14
17
|
end
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Mongoid::Compatibility
|
|
6
6
|
[![Dependency Status](https://gemnasium.com/dblock/mongoid-compatibility.svg)](https://gemnasium.com/dblock/mongoid-compatibility)
|
7
7
|
[![Code Climate](https://codeclimate.com/github/dblock/mongoid-compatibility.svg)](https://codeclimate.com/github/dblock/mongoid-compatibility)
|
8
8
|
|
9
|
-
Compatibility helpers for Mongoid 3, 4 and 5.
|
9
|
+
Compatibility helpers for Mongoid 2, 3, 4 and 5.
|
10
10
|
|
11
11
|
### Install
|
12
12
|
|
@@ -23,6 +23,9 @@ You may explicitly need to `require mongoid/compatibility`.
|
|
23
23
|
#### Mongoid::Compatibility::Version
|
24
24
|
|
25
25
|
```
|
26
|
+
Mongoid::Compatibility::Version.mongoid2?
|
27
|
+
# => is this Mongoid 2.x?
|
28
|
+
|
26
29
|
Mongoid::Compatibility::Version.mongoid3?
|
27
30
|
# => is this Mongoid 3.x?
|
28
31
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
module Mongoid
|
2
2
|
module Compatibility
|
3
3
|
module Version
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module ClassMethods
|
5
|
+
(2..5).each do |v|
|
6
|
+
const_set "V#{v}", Mongoid::VERSION =~ Regexp.new("^#{v}\.")
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
define_method "mongoid#{v}?" do
|
9
|
+
!!Mongoid::Compatibility::Version::ClassMethods.const_get("V#{v}")
|
10
|
+
end
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
Mongoid::VERSION =~ /^5\./
|
14
|
-
end
|
14
|
+
extend ClassMethods
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.homepage = 'http://github.com/dblock/mongoid-compatibility'
|
14
14
|
s.licenses = ['MIT']
|
15
15
|
s.summary = 'Compatibility helpers for Mongoid.'
|
16
|
-
s.add_dependency 'mongoid', '>=
|
16
|
+
s.add_dependency 'mongoid', '>= 2.0'
|
17
17
|
s.add_dependency 'activesupport'
|
18
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongoid::Compatibility::Version do
|
4
|
+
context 'mongoid? methods' do
|
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
|
11
|
+
end
|
12
|
+
it 'defines version methods' do
|
13
|
+
expect(Mongoid::Compatibility::Version.methods - Object.methods).to_not eq []
|
14
|
+
end
|
15
|
+
(2..5).each do |v|
|
16
|
+
context "mongoid #{v}" do
|
17
|
+
it "responds to mongoid#{v}?" do
|
18
|
+
expect(Mongoid::Compatibility::Version).to respond_to("mongoid#{v}?")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/support/mongoid.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
ENV['MONGOID_ENV'] = 'test'
|
2
2
|
|
3
|
-
if Mongoid::Compatibility::Version.
|
3
|
+
if Mongoid::Compatibility::Version.mongoid2?
|
4
|
+
Mongoid.load! 'spec/config/mongoid2.yml'
|
5
|
+
elsif Mongoid::Compatibility::Version.mongoid3?
|
4
6
|
Mongoid.load! 'spec/config/mongoid3.yml'
|
5
7
|
elsif Mongoid::Compatibility::Version.mongoid4?
|
6
8
|
Mongoid.load! 'spec/config/mongoid4.yml'
|
@@ -17,7 +19,9 @@ RSpec.configure do |config|
|
|
17
19
|
Mongoid.purge!
|
18
20
|
end
|
19
21
|
config.after(:all) do
|
20
|
-
if Mongoid::Compatibility::Version.
|
22
|
+
if Mongoid::Compatibility::Version.mongoid2?
|
23
|
+
Mongoid.master.connection.drop_database(Mongoid.database.name)
|
24
|
+
elsif Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4?
|
21
25
|
Mongoid.default_session.drop
|
22
26
|
else
|
23
27
|
Mongoid::Clients.default.database.drop
|
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.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,11 +62,13 @@ files:
|
|
62
62
|
- lib/mongoid/compatibility/version.rb
|
63
63
|
- lib/mongoid_compatibility.rb
|
64
64
|
- mongoid-compatibility.gemspec
|
65
|
+
- spec/config/mongoid2.yml
|
65
66
|
- spec/config/mongoid3.yml
|
66
67
|
- spec/config/mongoid4.yml
|
67
68
|
- spec/config/mongoid5.yml
|
68
69
|
- spec/mongoid/compatibility/object_id_spec.rb
|
69
70
|
- spec/mongoid/compatibility/self_spec.rb
|
71
|
+
- spec/mongoid/compatibility/version_spec.rb
|
70
72
|
- spec/spec_helper.rb
|
71
73
|
- spec/support/mongoid.rb
|
72
74
|
homepage: http://github.com/dblock/mongoid-compatibility
|