mongoid-compatibility 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ced1a2496825c857cffa03669ab2b0159286fc58
4
+ data.tar.gz: f4b716bd949683d710485e517717cfc3dcff8d0e
5
+ SHA512:
6
+ metadata.gz: 77bbca3b1528b028ec3d2f7c4f6647a0849040e0fa412fd2af96eb70a999a45900a0c676edc34459132923ce17d002b9d36cd110ba0575439fed0eef97595c58
7
+ data.tar.gz: d472abda0aa0909be221b3936c1354fd5d8ce86c13c27a10c986578f7e5deb5b9d90ac084abe0381a38786b95c1bf62297446fb63a8ca385652f4aca0789cace
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/**/*
4
+
5
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,25 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-09-17 09:33:57 -0400 using RuboCop version 0.33.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Configuration parameters: AllowURI, URISchemes.
11
+ Metrics/LineLength:
12
+ Max: 118
13
+
14
+ # Offense count: 3
15
+ Style/Documentation:
16
+ Exclude:
17
+ - 'lib/mongoid-compatibility/object_id.rb'
18
+ - 'lib/mongoid-compatibility/self.rb'
19
+ - 'lib/mongoid-compatibility/version.rb'
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: Exclude.
23
+ Style/FileName:
24
+ Exclude:
25
+ - 'lib/mongoid-compatibility.rb'
@@ -0,0 +1,16 @@
1
+ rvm:
2
+ - 2.2
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - rbx-2.2.10
7
+ - jruby-19mode
8
+
9
+ services:
10
+ - mongodb
11
+
12
+ env:
13
+ - MONGOID_VERSION=3
14
+ - MONGOID_VERSION=4
15
+ - MONGOID_VERSION=5
16
+
@@ -0,0 +1,3 @@
1
+ ### 0.1.0 (2015/09/17)
2
+
3
+ * Initial public release - [@dblock](https://github.com/dblock).
@@ -0,0 +1,118 @@
1
+ Contributing to Mongoid::Compatibility
2
+ =======================================
3
+
4
+ Mongoid::Compatibility is work of [many of contributors](https://github.com/dblock/mongoid-compatibility/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/dblock/mongoid-compatibility/pulls), [propose features, ask questions and discuss issues](https://github.com/dblock/mongoid-compatibility/issues).
5
+
6
+ #### Fork the Project
7
+
8
+ Fork the [project on Github](https://github.com/dblock/mongoid-compatibility) and check out your copy.
9
+
10
+ ```
11
+ git clone https://github.com/contributor/mongoid-compatibility.git
12
+ cd mongoid-compatibility
13
+ git remote add upstream https://github.com/dblock/mongoid-compatibility.git
14
+ ```
15
+
16
+ #### Create a Topic Branch
17
+
18
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
+
20
+ ```
21
+ git checkout master
22
+ git pull upstream master
23
+ git checkout -b my-feature-branch
24
+ ```
25
+
26
+ #### Bundle Install and Test
27
+
28
+ Ensure that you can build the project and run tests.
29
+
30
+ ```
31
+ bundle install
32
+ bundle exec rake
33
+ ```
34
+
35
+ #### Write Tests
36
+
37
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/mongoid-compatibility](spec/mongoid-compatibility).
38
+
39
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
40
+
41
+ #### Write Code
42
+
43
+ Implement your feature or bug fix.
44
+
45
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
46
+
47
+ Make sure that `bundle exec rake` completes without errors.
48
+
49
+ #### Write Documentation
50
+
51
+ Document any external behavior in the [README](README.md).
52
+
53
+ #### Update Changelog
54
+
55
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
56
+
57
+ #### Commit Changes
58
+
59
+ Make sure git knows your name and email address:
60
+
61
+ ```
62
+ git config --global user.name "Your Name"
63
+ git config --global user.email "contributor@example.com"
64
+ ```
65
+
66
+ Writing good commit logs is important. A commit log should describe what changed and why.
67
+
68
+ ```
69
+ git add ...
70
+ git commit
71
+ ```
72
+
73
+ #### Push
74
+
75
+ ```
76
+ git push origin my-feature-branch
77
+ ```
78
+
79
+ #### Make a Pull Request
80
+
81
+ Go to https://github.com/contributor/mongoid-compatibility and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
82
+
83
+ #### Rebase
84
+
85
+ If you've been working on a change for a while, rebase with upstream/master.
86
+
87
+ ```
88
+ git fetch upstream
89
+ git rebase upstream/master
90
+ git push origin my-feature-branch -f
91
+ ```
92
+
93
+ #### Update CHANGELOG Again
94
+
95
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
+
97
+ ```
98
+ * [#123](https://github.com/dblock/mongoid-compatibility/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
+ ```
100
+
101
+ Amend your previous commit and force push the changes.
102
+
103
+ ```
104
+ git commit --amend
105
+ git push origin my-feature-branch -f
106
+ ```
107
+
108
+ #### Check on Your Pull Request
109
+
110
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
111
+
112
+ #### Be Patient
113
+
114
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
115
+
116
+ #### Thank You
117
+
118
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ case version = ENV['MONGOID_VERSION'] || '~> 5.0'
6
+ when /5/
7
+ gem 'mongoid', '~> 5.0'
8
+ when /4/
9
+ gem 'mongoid', '~> 4.0'
10
+ when /3/
11
+ gem 'mongoid', '~> 3.1'
12
+ else
13
+ gem 'mongoid', version
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec'
18
+ end
19
+
20
+ group :development do
21
+ gem 'rake'
22
+ gem 'rubocop', '0.33.0'
23
+ end
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2015 Daniel Doubrovkine, Artsy and Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ Mongoid::Compatibility
2
+ =======================
3
+
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/dblock/mongoid-compatibility.svg)](https://travis-ci.org/dblock/mongoid-compatibility)
6
+ [![Dependency Status](https://gemnasium.com/dblock/mongoid-compatibility.svg)](https://gemnasium.com/dblock/mongoid-compatibility)
7
+ [![Code Climate](https://codeclimate.com/github/dblock/mongoid-compatibility.svg)](https://codeclimate.com/github/dblock/mongoid-compatibility)
8
+
9
+ Compatibility helpers for Mongoid 3, 4 and 5.
10
+
11
+ ### Install
12
+
13
+ Add `mongoid-compatibility` to your Gemfile.
14
+
15
+ ```
16
+ gem 'mongoid-compatibility'
17
+ ```
18
+
19
+ ### Use
20
+
21
+ #### Mongoid::Compatibility::Version
22
+
23
+ ```
24
+ Mongoid::Compatibility::Version.mongoid3?
25
+ # => is this Mongoid 3.x?
26
+
27
+ Mongoid::Compatibility::Version.mongoid4?
28
+ # => is this Mongoid 4.x?
29
+
30
+ Mongoid::Compatibility::Version.mongoid5?
31
+ # => is this Mongoid 5.x?
32
+ ```
33
+
34
+ #### Mongoid::Compatibility::ObjectId
35
+
36
+ ```
37
+ Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')
38
+ # => is this a valid BSON ID?
39
+ ```
40
+
41
+ ### Contribute
42
+
43
+ See [CONTRIBUTING](CONTRIBUTING.md).
44
+
45
+ ### Copyright and License
46
+
47
+ Copyright Daniel Doubrovkine and Contributors, Artsy Inc., 2015
48
+
49
+ [MIT License](LICENSE.md)
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler/gem_tasks'
3
+
4
+ Bundler.setup :default, :development
5
+
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+
9
+ RSpec::Core::RakeTask.new(:spec) do |spec|
10
+ spec.pattern = FileList['spec/**/*_spec.rb']
11
+ end
12
+
13
+ require 'rubocop/rake_task'
14
+ RuboCop::RakeTask.new(:rubocop)
15
+
16
+ task default: [:rubocop, :spec]
@@ -0,0 +1,6 @@
1
+ require 'mongoid'
2
+ require 'active_support'
3
+
4
+ require 'mongoid-compatibility/self'
5
+ require 'mongoid-compatibility/version'
6
+ require 'mongoid-compatibility/object_id'
@@ -0,0 +1,9 @@
1
+ module Mongoid
2
+ module Compatibility
3
+ module ObjectId
4
+ def self.legal?(value)
5
+ Mongoid::Compatibility::Version.mongoid3? ? Moped::BSON::ObjectId.legal?(value) : BSON::ObjectId.legal?(value)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Mongoid
2
+ module Compatibility
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module Mongoid
2
+ module Compatibility
3
+ module Version
4
+ def self.mongoid3?
5
+ Mongoid::VERSION =~ /^3\./
6
+ end
7
+
8
+ def self.mongoid4?
9
+ Mongoid::VERSION =~ /^4\./
10
+ end
11
+
12
+ def self.mongoid5?
13
+ Mongoid::VERSION =~ /^5\./
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ require 'mongoid-compatibility'
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+ require 'mongoid-compatibility/self'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'mongoid-compatibility'
6
+ s.version = Mongoid::Compatibility::VERSION
7
+ s.authors = ['Daniel Doubrovkine']
8
+ s.email = 'dblock@dblock.org'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.required_rubygems_version = '>= 1.3.6'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.require_paths = ['lib']
13
+ s.homepage = 'http://github.com/dblock/mongoid-compatibility'
14
+ s.licenses = ['MIT']
15
+ s.summary = 'Compatibility helpers for Mongoid.'
16
+ s.add_dependency 'mongoid', '>= 3.0.0'
17
+ s.add_dependency 'activesupport'
18
+ end
@@ -0,0 +1,9 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: mongoid-compatibility
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ raise_not_found_error: false
9
+ safe: true
@@ -0,0 +1,8 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: mongoid-compatibility
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ raise_not_found_error: false
@@ -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
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::Compatibility::ObjectId do
4
+ it 'valid' do
5
+ expect(Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')).to be true
6
+ end
7
+ it 'invalid' do
8
+ expect(Mongoid::Compatibility::ObjectId.legal?('asadsf')).to be false
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::Compatibility do
4
+ it 'has a version' do
5
+ expect(Mongoid::Compatibility::VERSION).not_to be_nil
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'rubygems'
4
+ require 'rspec'
5
+ require 'mongoid-compatibility'
6
+
7
+ require 'support/mongoid'
8
+
9
+ RSpec.configure(&:raise_errors_for_deprecations!)
@@ -0,0 +1,26 @@
1
+ ENV['MONGOID_ENV'] = 'test'
2
+
3
+ if Mongoid::Compatibility::Version.mongoid3?
4
+ Mongoid.load! 'spec/config/mongoid3.yml'
5
+ elsif Mongoid::Compatibility::Version.mongoid4?
6
+ Mongoid.load! 'spec/config/mongoid4.yml'
7
+ elsif Mongoid::Compatibility::Version.mongoid5?
8
+ Mongoid.load! 'spec/config/mongoid5.yml'
9
+ else
10
+ fail "unsupported Mongoid version #{Mongoid::VERSION}"
11
+ end
12
+
13
+ RSpec.configure do |config|
14
+ config.before do
15
+ Mongoid.logger.level = Logger::INFO
16
+ Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5?
17
+ Mongoid.purge!
18
+ end
19
+ config.after(:all) do
20
+ if Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4?
21
+ Mongoid.default_session.drop
22
+ else
23
+ Mongoid::Clients.default.database.drop
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid-compatibility
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Doubrovkine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: dblock@dblock.org
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - ".rubocop_todo.yml"
51
+ - ".travis.yml"
52
+ - CHANGELOG.md
53
+ - CONTRIBUTING.md
54
+ - Gemfile
55
+ - LICENSE.md
56
+ - README.md
57
+ - Rakefile
58
+ - lib/mongoid-compatibility.rb
59
+ - lib/mongoid-compatibility/object_id.rb
60
+ - lib/mongoid-compatibility/self.rb
61
+ - lib/mongoid-compatibility/version.rb
62
+ - lib/mongoid_compatibility.rb
63
+ - mongoid-compatibility.gemspec
64
+ - spec/config/mongoid3.yml
65
+ - spec/config/mongoid4.yml
66
+ - spec/config/mongoid5.yml
67
+ - spec/mongoid-compatibility/object_id_spec.rb
68
+ - spec/mongoid-compatibility/self_spec.rb
69
+ - spec/spec_helper.rb
70
+ - spec/support/mongoid.rb
71
+ homepage: http://github.com/dblock/mongoid-compatibility
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.6
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Compatibility helpers for Mongoid.
95
+ test_files: []