-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit, basic mongoid3?, 4? and 5? questions.
- Loading branch information
0 parents
commit aa55f44
Showing
22 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Gemfile.lock | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--format documentation | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
AllCops: | ||
Exclude: | ||
- vendor/**/* | ||
|
||
inherit_from: .rubocop_todo.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2015-09-17 09:24:51 -0400 using RuboCop version 0.33.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 3 | ||
# Configuration parameters: AllowURI, URISchemes. | ||
Metrics/LineLength: | ||
Max: 95 | ||
|
||
# Offense count: 2 | ||
Style/Documentation: | ||
Exclude: | ||
- 'lib/mongoid-compatibility/self.rb' | ||
- 'lib/mongoid-compatibility/version.rb' | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: Exclude. | ||
Style/FileName: | ||
Exclude: | ||
- 'lib/mongoid-compatibility.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
rvm: | ||
- 2.2 | ||
- 2.1.1 | ||
- 2.0.0 | ||
- 1.9.3 | ||
- rbx-2.2.10 | ||
- jruby-19mode | ||
|
||
services: | ||
- mongodb | ||
|
||
env: | ||
- MONGOID_VERSION=3 | ||
- MONGOID_VERSION=4 | ||
- MONGOID_VERSION=5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 0.1.0 (Next) | ||
|
||
* Initial public release - [@dblock](https://github.com/dblock). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
Contributing to Mongoid::Compatibility | ||
======================================= | ||
|
||
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). | ||
|
||
#### Fork the Project | ||
|
||
Fork the [project on Github](https://github.com/dblock/mongoid-compatibility) and check out your copy. | ||
|
||
``` | ||
git clone https://github.com/contributor/mongoid-compatibility.git | ||
cd mongoid-compatibility | ||
git remote add upstream https://github.com/dblock/mongoid-compatibility.git | ||
``` | ||
|
||
#### Create a Topic Branch | ||
|
||
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. | ||
|
||
``` | ||
git checkout master | ||
git pull upstream master | ||
git checkout -b my-feature-branch | ||
``` | ||
|
||
#### Bundle Install and Test | ||
|
||
Ensure that you can build the project and run tests. | ||
|
||
``` | ||
bundle install | ||
bundle exec rake | ||
``` | ||
|
||
#### Write Tests | ||
|
||
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). | ||
|
||
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. | ||
|
||
#### Write Code | ||
|
||
Implement your feature or bug fix. | ||
|
||
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted. | ||
|
||
Make sure that `bundle exec rake` completes without errors. | ||
|
||
#### Write Documentation | ||
|
||
Document any external behavior in the [README](README.md). | ||
|
||
#### Update Changelog | ||
|
||
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. | ||
|
||
#### Commit Changes | ||
|
||
Make sure git knows your name and email address: | ||
|
||
``` | ||
git config --global user.name "Your Name" | ||
git config --global user.email "contributor@example.com" | ||
``` | ||
|
||
Writing good commit logs is important. A commit log should describe what changed and why. | ||
|
||
``` | ||
git add ... | ||
git commit | ||
``` | ||
|
||
#### Push | ||
|
||
``` | ||
git push origin my-feature-branch | ||
``` | ||
|
||
#### Make a Pull Request | ||
|
||
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. | ||
|
||
#### Rebase | ||
|
||
If you've been working on a change for a while, rebase with upstream/master. | ||
|
||
``` | ||
git fetch upstream | ||
git rebase upstream/master | ||
git push origin my-feature-branch -f | ||
``` | ||
|
||
#### Update CHANGELOG Again | ||
|
||
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. | ||
|
||
``` | ||
* [#123](https://github.com/dblock/mongoid-compatibility/pull/123): Reticulated splines - [@contributor](https://github.com/contributor). | ||
``` | ||
|
||
Amend your previous commit and force push the changes. | ||
|
||
``` | ||
git commit --amend | ||
git push origin my-feature-branch -f | ||
``` | ||
|
||
#### Check on Your Pull Request | ||
|
||
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. | ||
|
||
#### Be Patient | ||
|
||
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! | ||
|
||
#### Thank You | ||
|
||
Please do know that we really appreciate and value your time and work. We love you, really. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
source 'http://rubygems.org' | ||
|
||
gemspec | ||
|
||
case version = ENV['MONGOID_VERSION'] || '~> 5.0' | ||
when /5/ | ||
gem 'mongoid', '~> 5.0' | ||
when /4/ | ||
gem 'mongoid', '~> 4.0' | ||
when /3/ | ||
gem 'mongoid', '~> 3.1' | ||
else | ||
gem 'mongoid', version | ||
end | ||
|
||
group :test do | ||
gem 'rspec' | ||
end | ||
|
||
group :development do | ||
gem 'rake' | ||
gem 'rubocop', '0.33.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2015 Daniel Doubrovkine, Artsy and Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Mongoid::Compatibility | ||
======================= | ||
|
||
[](http://badge.fury.io/rb/mongoid-compatibility) | ||
[](https://travis-ci.org/dblock/mongoid-compatibility) | ||
[](https://gemnasium.com/dblock/mongoid-compatibility) | ||
[](https://codeclimate.com/github/dblock/mongoid-compatibility) | ||
|
||
Compatibility helpers for Mongoid 3, 4 and 5. | ||
|
||
### Install | ||
|
||
Add `mongoid-compatibility` to your Gemfile. | ||
|
||
``` | ||
gem 'mongoid-compatibility' | ||
``` | ||
|
||
### Use | ||
|
||
``` | ||
Mongoid::Compatibility.mongoid3? # => is this Mongoid 3.x? | ||
Mongoid::Compatibility.mongoid4? # => is this Mongoid 4.x? | ||
Mongoid::Compatibility.mongoid5? # => is this Mongoid 5.x? | ||
``` | ||
|
||
### Contribute | ||
|
||
See [CONTRIBUTING](CONTRIBUTING.md). | ||
|
||
### Copyright and License | ||
|
||
Copyright Daniel Doubrovkine and Contributors, Artsy Inc., 2015 | ||
|
||
[MIT License](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'rubygems' | ||
require 'bundler/gem_tasks' | ||
|
||
Bundler.setup :default, :development | ||
|
||
require 'rspec/core' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) do |spec| | ||
spec.pattern = FileList['spec/**/*_spec.rb'] | ||
end | ||
|
||
require 'rubocop/rake_task' | ||
RuboCop::RakeTask.new(:rubocop) | ||
|
||
task default: [:rubocop, :spec] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'mongoid' | ||
require 'active_support' | ||
|
||
require 'mongoid-compatibility/self' | ||
require 'mongoid-compatibility/version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Mongoid | ||
module Compatibility | ||
VERSION = '0.1.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Mongoid | ||
module Compatibility | ||
module Version | ||
def self.mongoid3? | ||
Mongoid::VERSION =~ /^3\./ | ||
end | ||
|
||
def self.mongoid4? | ||
Mongoid::VERSION =~ /^4\./ | ||
end | ||
|
||
def self.mongoid5? | ||
Mongoid::VERSION =~ /^5\./ | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'mongoid-compatibility' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$LOAD_PATH.push File.expand_path('../lib', __FILE__) | ||
require 'mongoid-compatibility/self' | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'mongoid-compatibility' | ||
s.version = Mongoid::Compatibility::VERSION | ||
s.authors = ['Daniel Doubrovkine'] | ||
s.email = 'dblock@dblock.org' | ||
s.platform = Gem::Platform::RUBY | ||
s.required_rubygems_version = '>= 1.3.6' | ||
s.files = `git ls-files`.split("\n") | ||
s.require_paths = ['lib'] | ||
s.homepage = 'http://github.com/dblock/mongoid-compatibility' | ||
s.licenses = ['MIT'] | ||
s.summary = 'Compatibility helpers for Mongoid.' | ||
s.add_dependency 'mongoid', '>= 3.0.0' | ||
s.add_dependency 'activesupport' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
test: | ||
sessions: | ||
default: | ||
database: mongoid-compatibility | ||
hosts: | ||
- localhost:27017 | ||
options: | ||
raise_not_found_error: false | ||
safe: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
test: | ||
sessions: | ||
default: | ||
database: mongoid-compatibility | ||
hosts: | ||
- localhost:27017 | ||
options: | ||
raise_not_found_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
test: | ||
clients: | ||
default: | ||
database: mongoid-compatibility | ||
hosts: | ||
- localhost:27017 | ||
options: | ||
raise_not_found_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
describe Mongoid::Compatibility do | ||
it 'has a version' do | ||
expect(Mongoid::Compatibility::VERSION).not_to be_nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
|
||
require 'rubygems' | ||
require 'rspec' | ||
require 'mongoid-compatibility' | ||
|
||
require 'support/mongoid' | ||
|
||
RSpec.configure(&:raise_errors_for_deprecations!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ENV['MONGOID_ENV'] = 'test' | ||
|
||
if Mongoid::Compatibility::Version.mongoid3? | ||
Mongoid.load! 'spec/config/mongoid3.yml' | ||
elsif Mongoid::Compatibility::Version.mongoid4? | ||
Mongoid.load! 'spec/config/mongoid4.yml' | ||
elsif Mongoid::Compatibility::Version.mongoid5? | ||
Mongoid.load! 'spec/config/mongoid5.yml' | ||
else | ||
fail "unsupported Mongoid version #{Mongoid::VERSION}" | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.before do | ||
Mongoid.purge! | ||
end | ||
config.after(:all) do | ||
if Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4? | ||
Mongoid.default_session.drop | ||
else | ||
Mongoid::Clients.default.database.drop | ||
end | ||
end | ||
end |