mongoid_toggleable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rubocop.yml +36 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -0
- data/Guardfile +11 -0
- data/LICENSE +21 -0
- data/README.md +121 -0
- data/Rakefile +11 -0
- data/lib/mongoid/toggleable.rb +58 -0
- data/lib/mongoid_toggleable.rb +14 -0
- data/lib/mongoid_toggleable/version.rb +3 -0
- data/mongoid_toggleable.gemspec +38 -0
- data/spec/lib/mongoid_toggleable/version_spec.rb +7 -0
- data/spec/lib/mongoid_toggleable_spec.rb +100 -0
- data/spec/spec_helper.rb +41 -0
- metadata +246 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9bf380e09015d8f39e128879c40b2a54fa1585d3
|
4
|
+
data.tar.gz: 74c6e0e896de79030be4895351d08291ad2020af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 135c47408d8e7fcac33485ee0490f211f7f6a3973bc5dd476a06266bbef62a1a22682ffb8ee97d76bfad45ff6158799762ed1084814a79def9703eb5e480613e
|
7
|
+
data.tar.gz: 18fbeddad892e1178d4ecf9832300b8e940ae038cb56051daf8ded2e3208e3c23bcdd6a55db5f1107010af5d75bbfc21d8e5b90c0428f6ea13a7b62dee479109
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
AllCops:
|
2
|
+
RunRailsCops: false
|
3
|
+
|
4
|
+
LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
ClassLength:
|
8
|
+
CountComments: false # count full line comments?
|
9
|
+
Max: 175
|
10
|
+
|
11
|
+
MethodLength:
|
12
|
+
CountComments: false # count full line comments?
|
13
|
+
Max: 10
|
14
|
+
|
15
|
+
HashSyntax:
|
16
|
+
EnforcedStyle: hash_rockets
|
17
|
+
|
18
|
+
Documentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
DefaultScope:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
CollectionMethods:
|
25
|
+
PreferredMethods:
|
26
|
+
map: 'collect'
|
27
|
+
map!: 'collect!'
|
28
|
+
reduce: 'inject'
|
29
|
+
find: 'detect'
|
30
|
+
find_all: 'select'
|
31
|
+
|
32
|
+
Output:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
HasAndBelongsToMany:
|
36
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1.1
|
8
|
+
|
9
|
+
env:
|
10
|
+
- MONGOID_VERSION=3
|
11
|
+
- MONGOID_VERSION=4
|
12
|
+
|
13
|
+
script: 'CODECLIMATE_REPO_TOKEN=7050bed6ce4a3f2e94ea254180fe5b550fba23f010ff569e1dfe8cd30ee847b0 bundle exec rake'
|
14
|
+
|
15
|
+
services: mongodb
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
guard 'rspec', :cmd => 'rspec --colour', :all_on_start => false, :all_after_pass => false do
|
2
|
+
watch('spec/spec_helper.rb') { "spec" }
|
3
|
+
watch(%r{^spec/.+_spec\.rb})
|
4
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
5
|
+
end
|
6
|
+
|
7
|
+
guard :rubocop do
|
8
|
+
watch(%r{.+\.gemspec$})
|
9
|
+
watch(%r{.+\.rb$})
|
10
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
11
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2014 PJ Kelly (Crush & Lovely)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Mongoid::Toggleable
|
2
|
+
|
3
|
+
[![Build Status](http://img.shields.io/travis/crushlovely/mongoid_toggleable.svg?style=flat)](https://travis-ci.org/crushlovely/mongoid_toggleable)
|
4
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/crushlovely/mongoid_toggleable.svg?style=flat)](https://codeclimate.com/github/crushlovely/mongoid_toggleable)
|
5
|
+
[![Code Coverage](http://img.shields.io/codeclimate/coverage/github/crushlovely/mongoid_toggleable.svg?style=flat)](https://codeclimate.com/github/crushlovely/mongoid_toggleable)
|
6
|
+
|
7
|
+
Create toggleable attributes for your Mongoid models.
|
8
|
+
|
9
|
+
## Why?
|
10
|
+
|
11
|
+
We frequently require the ability to toggle the visibility of content on an application's front-end.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
`gem install mongoid_toggleable`
|
16
|
+
|
17
|
+
or in your `Gemfile`
|
18
|
+
|
19
|
+
``` ruby
|
20
|
+
gem 'mongoid_toggleable'
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Make sure you require the library.
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
require 'mongoid_toggleable'
|
29
|
+
```
|
30
|
+
|
31
|
+
This gem follows a similar API to many Mongoid plugins:
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
class Widget
|
35
|
+
include Mongoid::Document
|
36
|
+
include Mongoid::Toggleable
|
37
|
+
|
38
|
+
toggleable :visible
|
39
|
+
# toggleable :visible, :default => false
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
This sets up a boolean field on the model, and also makes the following instance methods available:
|
44
|
+
|
45
|
+
``` ruby
|
46
|
+
widget = Widget.new
|
47
|
+
widget.visible
|
48
|
+
# => true
|
49
|
+
|
50
|
+
# toggle the widget's visibility, but don't persist the change
|
51
|
+
widget.toggle(:visible)
|
52
|
+
widget.visible
|
53
|
+
# => false
|
54
|
+
|
55
|
+
# toggle the widget's visibility and persist the change
|
56
|
+
widget.toggle!(:visible)
|
57
|
+
```
|
58
|
+
|
59
|
+
### Options
|
60
|
+
|
61
|
+
In addition to the name of the attribute to create, you can also pass the following options:
|
62
|
+
|
63
|
+
* `:default`: The Boolean default of the attribute. (optional, default: true).
|
64
|
+
* `:scope_name`: The Symbol representing the name of the positive scope (optional, default: toggleable_attribute).
|
65
|
+
* `:inverse_scope_name`: The Symbol representing the name of the negative scope (optional, default: "not_#{toggleable_attribute}").
|
66
|
+
|
67
|
+
### Scopes
|
68
|
+
|
69
|
+
Two scopes are automatically created when you define a toggleable attribute:
|
70
|
+
|
71
|
+
``` ruby
|
72
|
+
class Widget
|
73
|
+
include Mongoid::Document
|
74
|
+
include Mongoid::Toggleable
|
75
|
+
|
76
|
+
toggleable :visible
|
77
|
+
end
|
78
|
+
|
79
|
+
widget1 = Widget.create
|
80
|
+
widget2 = Widget.create(:visible => false)
|
81
|
+
|
82
|
+
Widget.visible
|
83
|
+
# => [widget1]
|
84
|
+
|
85
|
+
Widget.not_visible
|
86
|
+
# => [widget2]
|
87
|
+
```
|
88
|
+
|
89
|
+
These are just plain old Mongoid scopes, so you can chain them together with other scopes as needed:
|
90
|
+
|
91
|
+
``` ruby
|
92
|
+
Widget.visible.where(:created_at.lte => 10.days.ago)
|
93
|
+
```
|
94
|
+
|
95
|
+
You can also customize the names of the scope created:
|
96
|
+
|
97
|
+
``` ruby
|
98
|
+
class Widget
|
99
|
+
include Mongoid::Document
|
100
|
+
include Mongoid::Toggleable
|
101
|
+
|
102
|
+
toggleable :published, :inverse_scope_name => :unpublished
|
103
|
+
end
|
104
|
+
|
105
|
+
Widget.published
|
106
|
+
Widget.unpublished
|
107
|
+
```
|
108
|
+
|
109
|
+
## Contributing to mongoid_toggleable
|
110
|
+
|
111
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
112
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
113
|
+
* Fork the project
|
114
|
+
* Start a feature/bugfix branch
|
115
|
+
* Commit and push until you are happy with your contribution
|
116
|
+
* Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
|
117
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so we can cherry-pick around it.
|
118
|
+
|
119
|
+
## Copyright
|
120
|
+
|
121
|
+
Copyright (c) 2014 PJ Kelly (Crush & Lovely). See LICENSE for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
7
|
+
spec.rspec_opts = ['--backtrace']
|
8
|
+
# spec.ruby_opts = ['-w']
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :spec
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module Toggleable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
# Public: Create a toggleable attribute on the model.
|
11
|
+
#
|
12
|
+
# toggleable_attribute - A symbol representing the name of the attribute to be created.
|
13
|
+
# options - The Hash options used to customize the attribute (default: {}):
|
14
|
+
# :default - The Boolean default of the attribute.
|
15
|
+
# (optional, default: true).
|
16
|
+
# :scope_name - The Symbol representing the name of the positive scope
|
17
|
+
# (optional, default: #{toggleable_attribute}).
|
18
|
+
# :inverse_scope_name - The Symbol representing the name of the negative scope
|
19
|
+
# (optional, default: #{toggleable_attribute}).
|
20
|
+
#
|
21
|
+
# Examples:
|
22
|
+
#
|
23
|
+
# toggleable :for_sale, :default => false
|
24
|
+
# toggleable :visible, :inverse_scope_name => :hidden
|
25
|
+
# toggleable :publishable, :default => false, :inverse_scope_name => :unpublishable
|
26
|
+
# toggleable :featured, :default => true, :scope_name => :features
|
27
|
+
#
|
28
|
+
# Defines the attribute specified as well as relevant scopes.
|
29
|
+
def toggleable(toggleable_attribute, options = {})
|
30
|
+
defaults = {
|
31
|
+
:default => true,
|
32
|
+
:scope_name => toggleable_attribute,
|
33
|
+
:inverse_scope_name => "not_#{toggleable_attribute}"
|
34
|
+
}
|
35
|
+
options = defaults.merge(options)
|
36
|
+
|
37
|
+
field toggleable_attribute, :type => MongoidToggleable.boolean_type, :default => options[:default]
|
38
|
+
scope options[:scope_name], -> { where(toggleable_attribute => true) }
|
39
|
+
scope options[:inverse_scope_name], -> { where(toggleable_attribute => false) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Public: Toggle the attribute specified
|
44
|
+
#
|
45
|
+
# Returns the value the attribute was changed to. Does not persist the change.
|
46
|
+
def toggle(toggleable_attribute)
|
47
|
+
send("#{toggleable_attribute}=", !send(toggleable_attribute))
|
48
|
+
end
|
49
|
+
|
50
|
+
# Public: Toggle the attribute specified and persist the change
|
51
|
+
#
|
52
|
+
# Returns the result of #save.
|
53
|
+
def toggle!(toggleable_attribute)
|
54
|
+
toggle(toggleable_attribute)
|
55
|
+
save
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'active_support/core_ext/array/extract_options'
|
2
|
+
require 'mongoid'
|
3
|
+
require 'mongoid_toggleable/version'
|
4
|
+
require 'mongoid/toggleable'
|
5
|
+
|
6
|
+
module MongoidToggleable
|
7
|
+
def self.mongoid3?
|
8
|
+
::Mongoid.const_defined? :Observer # deprecated in Mongoid 4.x
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.boolean_type
|
12
|
+
mongoid3? ? Boolean : Mongoid::Boolean
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'mongoid_toggleable/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'mongoid_toggleable'
|
9
|
+
spec.version = MongoidToggleable::VERSION
|
10
|
+
spec.authors = ['PJ Kelly']
|
11
|
+
spec.email = ['pj@crushlovely.com']
|
12
|
+
spec.homepage = 'https://github.com/crushlovely/mongoid_toggleable'
|
13
|
+
spec.summary = 'Toggleable attributes for your Mongoid models.'
|
14
|
+
spec.description = 'Toggleable attributes for your Mongoid models.'
|
15
|
+
|
16
|
+
spec.rubyforge_project = 'mongoid_toggleable'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split("\n")
|
19
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency('activesupport', '>=2.1.0')
|
24
|
+
|
25
|
+
spec.add_development_dependency('bundler', '~> 1.3')
|
26
|
+
spec.add_development_dependency('pry')
|
27
|
+
spec.add_development_dependency('rake')
|
28
|
+
spec.add_development_dependency('rspec')
|
29
|
+
spec.add_development_dependency('mongoid-rspec')
|
30
|
+
spec.add_development_dependency('rubocop')
|
31
|
+
spec.add_development_dependency('timecop')
|
32
|
+
spec.add_development_dependency('guard')
|
33
|
+
spec.add_development_dependency('guard-rspec')
|
34
|
+
spec.add_development_dependency('guard-rubocop')
|
35
|
+
spec.add_development_dependency('codeclimate-test-reporter')
|
36
|
+
|
37
|
+
spec.add_runtime_dependency('mongoid')
|
38
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongoid::Toggleable do
|
4
|
+
class Article
|
5
|
+
include Mongoid::Document
|
6
|
+
include Mongoid::Toggleable
|
7
|
+
|
8
|
+
toggleable :visible, :inverse_scope_name => :hidden
|
9
|
+
end
|
10
|
+
|
11
|
+
class Product
|
12
|
+
include Mongoid::Document
|
13
|
+
include Mongoid::Toggleable
|
14
|
+
|
15
|
+
toggleable :for_sale, :default => false
|
16
|
+
end
|
17
|
+
|
18
|
+
class Story
|
19
|
+
include Mongoid::Document
|
20
|
+
include Mongoid::Toggleable
|
21
|
+
|
22
|
+
toggleable :publishable, :default => false, :inverse_scope_name => :unpublishable
|
23
|
+
toggleable :featured, :default => true, :scope_name => :features
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'field setup' do
|
27
|
+
let(:article) { Article.new }
|
28
|
+
let(:product) { Product.new }
|
29
|
+
let(:story) { Story.new }
|
30
|
+
|
31
|
+
it 'creates the right fields' do
|
32
|
+
expect(article).to have_field(:visible).of_type(MongoidToggleable.boolean_type).with_default_value_of(true)
|
33
|
+
expect(product).to have_field(:for_sale).of_type(MongoidToggleable.boolean_type).with_default_value_of(false)
|
34
|
+
expect(story).to have_field(:publishable).of_type(MongoidToggleable.boolean_type).with_default_value_of(false)
|
35
|
+
expect(story).to have_field(:featured).of_type(MongoidToggleable.boolean_type).with_default_value_of(true)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'dynamic scopes' do
|
40
|
+
let!(:visible_article) { Article.create }
|
41
|
+
let!(:hidden_article) { Article.create(:visible => false) }
|
42
|
+
let!(:for_sale_product) { Product.create(:for_sale => true) }
|
43
|
+
let!(:not_for_sale_product) { Product.create }
|
44
|
+
|
45
|
+
describe 'scope definition' do
|
46
|
+
it 'creates scopes based on the parameters passed in' do
|
47
|
+
expect(Article).to respond_to(:visible)
|
48
|
+
expect(Article).to respond_to(:hidden)
|
49
|
+
expect(Product).to respond_to(:for_sale)
|
50
|
+
expect(Product).to respond_to(:not_for_sale)
|
51
|
+
expect(Story).to respond_to(:publishable)
|
52
|
+
expect(Story).to respond_to(:unpublishable)
|
53
|
+
expect(Story).to respond_to(:features)
|
54
|
+
expect(Story).to respond_to(:not_featured)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'positive scope' do
|
59
|
+
it 'returns the appropriate records' do
|
60
|
+
expect(Article.visible).to include(visible_article)
|
61
|
+
expect(Article.visible).not_to include(hidden_article)
|
62
|
+
expect(Product.for_sale).to include(for_sale_product)
|
63
|
+
expect(Product.for_sale).not_to include(not_for_sale_product)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'negative scope' do
|
68
|
+
it 'returns the appropriate records' do
|
69
|
+
expect(Article.hidden).to include(hidden_article)
|
70
|
+
expect(Article.hidden).not_to include(visible_article)
|
71
|
+
expect(Product.not_for_sale).to include(not_for_sale_product)
|
72
|
+
expect(Product.not_for_sale).not_to include(for_sale_product)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#toggle' do
|
78
|
+
let(:visible_article) { Article.new }
|
79
|
+
let(:hidden_article) { Article.new(:visible => false) }
|
80
|
+
|
81
|
+
it 'toggles the value of the toggleable field' do
|
82
|
+
expect { visible_article.toggle(:visible) }
|
83
|
+
.to change { visible_article.visible }.from(true).to(false)
|
84
|
+
expect { hidden_article.toggle(:visible) }
|
85
|
+
.to change { hidden_article.visible }.from(false).to(true)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#toggle!' do
|
90
|
+
let(:visible_article) { Article.create }
|
91
|
+
let(:hidden_article) { Article.create(:visible => false) }
|
92
|
+
|
93
|
+
it 'toggles the value of the toggleable field' do
|
94
|
+
expect { visible_article.toggle!(:visible) }
|
95
|
+
.to change { Article.find(visible_article.to_param).visible }.from(true).to(false)
|
96
|
+
expect { hidden_article.toggle!(:visible) }
|
97
|
+
.to change { Article.find(hidden_article.to_param).visible }.from(false).to(true)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'codeclimate-test-reporter'
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'mongoid'
|
6
|
+
require 'mongoid_toggleable'
|
7
|
+
require 'mongoid-rspec'
|
8
|
+
|
9
|
+
def database_name
|
10
|
+
ENV['CI'] ? "mongoid_toggleable_#{Process.pid}" : 'mongoid_toggleable_test'
|
11
|
+
end
|
12
|
+
|
13
|
+
def database_port
|
14
|
+
ENV['BOXEN_MONGODB_PORT'] || '27017'
|
15
|
+
end
|
16
|
+
|
17
|
+
Mongoid.configure do |config|
|
18
|
+
config.sessions = {
|
19
|
+
:default => {
|
20
|
+
:database => database_name,
|
21
|
+
:hosts => ["localhost:#{database_port}"],
|
22
|
+
:options => {
|
23
|
+
:read => :primary
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
30
|
+
|
31
|
+
RSpec.configure do |config|
|
32
|
+
config.include Mongoid::Matchers
|
33
|
+
config.before(:each) do
|
34
|
+
Mongoid.purge!
|
35
|
+
Mongoid::IdentityMap.clear if defined?(Mongoid::IdentityMap)
|
36
|
+
end
|
37
|
+
|
38
|
+
config.after(:suite) do
|
39
|
+
Mongoid::Threaded.sessions[:default].drop if ENV['CI']
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid_toggleable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- PJ Kelly
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mongoid-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: timecop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard-rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: codeclimate-test-reporter
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: mongoid
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description: Toggleable attributes for your Mongoid models.
|
196
|
+
email:
|
197
|
+
- pj@crushlovely.com
|
198
|
+
executables: []
|
199
|
+
extensions: []
|
200
|
+
extra_rdoc_files: []
|
201
|
+
files:
|
202
|
+
- .gitignore
|
203
|
+
- .rubocop.yml
|
204
|
+
- .ruby-version
|
205
|
+
- .travis.yml
|
206
|
+
- CHANGELOG.md
|
207
|
+
- Gemfile
|
208
|
+
- Guardfile
|
209
|
+
- LICENSE
|
210
|
+
- README.md
|
211
|
+
- Rakefile
|
212
|
+
- lib/mongoid/toggleable.rb
|
213
|
+
- lib/mongoid_toggleable.rb
|
214
|
+
- lib/mongoid_toggleable/version.rb
|
215
|
+
- mongoid_toggleable.gemspec
|
216
|
+
- spec/lib/mongoid_toggleable/version_spec.rb
|
217
|
+
- spec/lib/mongoid_toggleable_spec.rb
|
218
|
+
- spec/spec_helper.rb
|
219
|
+
homepage: https://github.com/crushlovely/mongoid_toggleable
|
220
|
+
licenses: []
|
221
|
+
metadata: {}
|
222
|
+
post_install_message:
|
223
|
+
rdoc_options: []
|
224
|
+
require_paths:
|
225
|
+
- lib
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - '>='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - '>='
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: '0'
|
236
|
+
requirements: []
|
237
|
+
rubyforge_project: mongoid_toggleable
|
238
|
+
rubygems_version: 2.0.3
|
239
|
+
signing_key:
|
240
|
+
specification_version: 4
|
241
|
+
summary: Toggleable attributes for your Mongoid models.
|
242
|
+
test_files:
|
243
|
+
- spec/lib/mongoid_toggleable/version_spec.rb
|
244
|
+
- spec/lib/mongoid_toggleable_spec.rb
|
245
|
+
- spec/spec_helper.rb
|
246
|
+
has_rdoc:
|