Skip to content

Commit aa55f44

Browse files
committedSep 17, 2015
Initial commit, basic mongoid3?, 4? and 5? questions.
0 parents  commit aa55f44

22 files changed

+377
-0
lines changed
 

Diff for: ‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Gemfile.lock
2+
pkg

Diff for: ‎.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

Diff for: ‎.rubocop.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
AllCops:
2+
Exclude:
3+
- vendor/**/*
4+
5+
inherit_from: .rubocop_todo.yml

Diff for: ‎.rubocop_todo.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2015-09-17 09:24:51 -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: 95
13+
14+
# Offense count: 2
15+
Style/Documentation:
16+
Exclude:
17+
- 'lib/mongoid-compatibility/self.rb'
18+
- 'lib/mongoid-compatibility/version.rb'
19+
20+
# Offense count: 1
21+
# Configuration parameters: Exclude.
22+
Style/FileName:
23+
Exclude:
24+
- 'lib/mongoid-compatibility.rb'

Diff for: ‎.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -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+

Diff for: ‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 0.1.0 (Next)
2+
3+
* Initial public release - [@dblock](https://github.com/dblock).

Diff for: ‎CONTRIBUTING.md

+118
Original file line numberDiff line numberDiff line change
@@ -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.

Diff for: ‎Gemfile

+23
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎LICENSE.md

+22
Original file line numberDiff line numberDiff line change
@@ -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.

Diff for: ‎README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
```
22+
Mongoid::Compatibility.mongoid3? # => is this Mongoid 3.x?
23+
Mongoid::Compatibility.mongoid4? # => is this Mongoid 4.x?
24+
Mongoid::Compatibility.mongoid5? # => is this Mongoid 5.x?
25+
```
26+
27+
### Contribute
28+
29+
See [CONTRIBUTING](CONTRIBUTING.md).
30+
31+
### Copyright and License
32+
33+
Copyright Daniel Doubrovkine and Contributors, Artsy Inc., 2015
34+
35+
[MIT License](LICENSE.md)

Diff for: ‎Rakefile

+16
Original file line numberDiff line numberDiff line change
@@ -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]

Diff for: ‎lib/mongoid-compatibility.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'mongoid'
2+
require 'active_support'
3+
4+
require 'mongoid-compatibility/self'
5+
require 'mongoid-compatibility/version'

Diff for: ‎lib/mongoid-compatibility/self.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Mongoid
2+
module Compatibility
3+
VERSION = '0.1.0'
4+
end
5+
end

Diff for: ‎lib/mongoid-compatibility/version.rb

+17
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎lib/mongoid_compatibility.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'mongoid-compatibility'

Diff for: ‎mongoid-compatibility.gemspec

+18
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎spec/config/mongoid3.yml

+9
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎spec/config/mongoid4.yml

+8
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎spec/config/mongoid5.yml

+8
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎spec/mongoid-compatibility/self_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -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

Diff for: ‎spec/spec_helper.rb

+9
Original file line numberDiff line numberDiff line change
@@ -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!)

Diff for: ‎spec/support/mongoid.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.purge!
16+
end
17+
config.after(:all) do
18+
if Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4?
19+
Mongoid.default_session.drop
20+
else
21+
Mongoid::Clients.default.database.drop
22+
end
23+
end
24+
end

0 commit comments

Comments
 (0)
Please sign in to comment.