groupify 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +0 -4
- data/README.md +2 -1
- data/gemfiles/mongoid2.gemfile +10 -0
- data/gemfiles/mongoid3.gemfile +8 -0
- data/groupify.gemspec +4 -8
- data/lib/groupify.rb +6 -0
- data/lib/groupify/version.rb +1 -1
- data/spec/{mongoid2.yml → groupify/mongoid2.yml} +0 -0
- data/spec/{mongoid3.yml → groupify/mongoid3.yml} +0 -0
- data/spec/groupify/mongoid_spec.rb +17 -1
- data/spec/spec_helper.rb +0 -14
- metadata +110 -110
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
language: ruby
|
2
|
+
services: mongodb
|
2
3
|
rvm:
|
3
4
|
- ree
|
4
5
|
- 1.8.7
|
5
6
|
- 1.9.3
|
7
|
+
- 2.0.0
|
6
8
|
- jruby-18mode # JRuby in 1.8 mode
|
7
9
|
- jruby-19mode # JRuby in 1.9 mode
|
8
10
|
- rbx-18mode
|
9
11
|
- rbx-19mode
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/mongoid2.gemfile
|
14
|
+
- gemfiles/mongoid3.gemfile
|
15
|
+
matrix:
|
16
|
+
exclude:
|
17
|
+
- rvm: 1.8.7
|
18
|
+
gemfile: gemfiles/mongoid3.gemfile
|
19
|
+
- rvm: ree
|
20
|
+
gemfile: gemfiles/mongoid3.gemfile
|
21
|
+
- rvm: jruby-18mode
|
22
|
+
gemfile: gemfiles/mongoid3.gemfile
|
23
|
+
- rvm: rbx-18mode
|
24
|
+
gemfile: gemfiles/mongoid3.gemfile
|
25
|
+
allow_failures:
|
26
|
+
- rvm: rbx-18mode
|
27
|
+
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Groupify [![Build Status](https://secure.travis-ci.org/dwbutler/groupify.png)](http://travis-ci.org/dwbutler/groupify)
|
2
2
|
Adds group and membership functionality to Rails models.
|
3
3
|
|
4
|
-
Currently only Mongoid
|
4
|
+
Currently only Mongoid 2 and 3 are supported. Tested in Ruby 1.8.7 and 1.9.3 (MRI, REE, JRuby, and Rubinius).
|
5
|
+
It shouldn't be difficult to adapt to ActiveRecord.
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
data/groupify.gemspec
CHANGED
@@ -15,15 +15,11 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Groupify::VERSION
|
17
17
|
|
18
|
-
gem.
|
18
|
+
gem.add_dependency "mongoid", '>= 2'
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake"
|
19
21
|
gem.add_development_dependency "rspec"
|
20
22
|
|
21
|
-
|
22
|
-
gem.add_development_dependency "mongoid", "~> 2.0"
|
23
|
-
gem.add_development_dependency 'mongoid-rspec', '1.4.5'
|
24
|
-
else
|
25
|
-
gem.add_development_dependency "mongoid", "~> 3.0"
|
26
|
-
gem.add_development_dependency 'mongoid-rspec', '~> 1.5.1'
|
27
|
-
end
|
23
|
+
gem.add_development_dependency 'mongoid-rspec'
|
28
24
|
gem.add_development_dependency 'database_cleaner'
|
29
25
|
end
|
data/lib/groupify.rb
CHANGED
@@ -147,6 +147,12 @@ module Groupify
|
|
147
147
|
|
148
148
|
included do
|
149
149
|
field :named_groups, :type => Array, :default => []
|
150
|
+
|
151
|
+
before_save :uniq_named_groups
|
152
|
+
protected
|
153
|
+
def uniq_named_groups
|
154
|
+
named_groups.uniq!
|
155
|
+
end
|
150
156
|
end
|
151
157
|
|
152
158
|
def in_named_group?(group)
|
data/lib/groupify/version.rb
CHANGED
File without changes
|
File without changes
|
@@ -3,6 +3,17 @@ require 'mongoid'
|
|
3
3
|
require 'mongoid-rspec'
|
4
4
|
include Mongoid::Matchers
|
5
5
|
|
6
|
+
# Load mongoid config
|
7
|
+
if Mongoid::VERSION < '3'
|
8
|
+
ENV["MONGOID_ENV"] = "test"
|
9
|
+
Mongoid.load!('./spec/groupify/mongoid2.yml')
|
10
|
+
Mongoid.logger.level = Logger::INFO
|
11
|
+
else
|
12
|
+
Mongoid.load!('./spec/groupify/mongoid3.yml', :test)
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'groupify'
|
16
|
+
|
6
17
|
class MongoidUser
|
7
18
|
include Mongoid::Document
|
8
19
|
|
@@ -44,7 +55,7 @@ describe MongoidUser do
|
|
44
55
|
it { should have_and_belong_to_many(:groups).of_type(MongoidGroup) }
|
45
56
|
end
|
46
57
|
|
47
|
-
describe "
|
58
|
+
describe "Mongoid Model" do
|
48
59
|
let!(:user) { MongoidUser.create }
|
49
60
|
let!(:group) { MongoidGroup.create }
|
50
61
|
|
@@ -103,6 +114,11 @@ describe "MongoidUser" do
|
|
103
114
|
MongoidUser.in_named_group(:admin).first.should eql(user)
|
104
115
|
MongoidUser.in_any_named_group(:admin, :test).first.should eql(user)
|
105
116
|
MongoidUser.in_all_named_groups(:admin, :user).first.should eql(user)
|
117
|
+
|
118
|
+
# Uniqueness
|
119
|
+
user.named_groups << :admin
|
120
|
+
user.save
|
121
|
+
user.named_groups.count{|g| g == :admin}.should == 1
|
106
122
|
end
|
107
123
|
|
108
124
|
it "can check if groups are shared" do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,20 +3,6 @@ require 'bundler/setup'
|
|
3
3
|
|
4
4
|
Bundler.require(:default, :test, :development)
|
5
5
|
|
6
|
-
require 'active_support'
|
7
|
-
require 'active_support/all'
|
8
|
-
require 'rails'
|
9
|
-
require 'active_record'
|
10
|
-
|
11
|
-
# Load mongoid config
|
12
|
-
if Mongoid::VERSION < '3'
|
13
|
-
ENV["MONGOID_ENV"] = "test"
|
14
|
-
Mongoid.load!('./spec/mongoid2.yml')
|
15
|
-
else
|
16
|
-
Mongoid.load!('./spec/mongoid3.yml', :test)
|
17
|
-
end
|
18
|
-
#Mongoid.logger.level = :info
|
19
|
-
|
20
6
|
RSpec.configure do |config|
|
21
7
|
config.order = "random"
|
22
8
|
|
metadata
CHANGED
@@ -1,156 +1,156 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupify
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- dwbutler
|
14
|
-
autorequire:
|
9
|
+
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mongoid
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: !binary |-
|
21
|
+
Mg==
|
22
|
+
none: false
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: !binary |-
|
28
|
+
Mg==
|
29
|
+
none: false
|
23
30
|
prerelease: false
|
24
|
-
|
31
|
+
type: :runtime
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rake
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: !binary |-
|
39
|
+
MA==
|
25
40
|
none: false
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: !binary |-
|
46
|
+
MA==
|
47
|
+
none: false
|
48
|
+
prerelease: false
|
34
49
|
type: :development
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
- !ruby/object:Gem::Dependency
|
37
51
|
name: rspec
|
38
|
-
|
39
|
-
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: !binary |-
|
57
|
+
MA==
|
40
58
|
none: false
|
41
|
-
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
42
61
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 0
|
47
|
-
version: "0"
|
48
|
-
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: mongoid
|
52
|
-
prerelease: false
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: !binary |-
|
64
|
+
MA==
|
54
65
|
none: false
|
55
|
-
|
56
|
-
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
|
-
segments:
|
60
|
-
- 2
|
61
|
-
- 0
|
62
|
-
version: "2.0"
|
66
|
+
prerelease: false
|
63
67
|
type: :development
|
64
|
-
|
65
|
-
- !ruby/object:Gem::Dependency
|
68
|
+
- !ruby/object:Gem::Dependency
|
66
69
|
name: mongoid-rspec
|
67
|
-
|
68
|
-
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: !binary |-
|
75
|
+
MA==
|
69
76
|
none: false
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
version: 1.4.5
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: !binary |-
|
82
|
+
MA==
|
83
|
+
none: false
|
84
|
+
prerelease: false
|
79
85
|
type: :development
|
80
|
-
|
81
|
-
- !ruby/object:Gem::Dependency
|
86
|
+
- !ruby/object:Gem::Dependency
|
82
87
|
name: database_cleaner
|
83
|
-
|
84
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: !binary |-
|
93
|
+
MA==
|
85
94
|
none: false
|
86
|
-
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
87
97
|
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: !binary |-
|
100
|
+
MA==
|
101
|
+
none: false
|
102
|
+
prerelease: false
|
93
103
|
type: :development
|
94
|
-
version_requirements: *id005
|
95
104
|
description: Adds group and membership functionality to Rails models
|
96
|
-
email:
|
105
|
+
email:
|
97
106
|
- dwbutler@ucla.edu
|
98
107
|
executables: []
|
99
|
-
|
100
108
|
extensions: []
|
101
|
-
|
102
109
|
extra_rdoc_files: []
|
103
|
-
|
104
|
-
|
105
|
-
- .
|
106
|
-
- .travis.yml
|
110
|
+
files:
|
111
|
+
- ".gitignore"
|
112
|
+
- ".travis.yml"
|
107
113
|
- Gemfile
|
108
114
|
- LICENSE
|
109
115
|
- README.md
|
110
116
|
- Rakefile
|
117
|
+
- gemfiles/mongoid2.gemfile
|
118
|
+
- gemfiles/mongoid3.gemfile
|
111
119
|
- groupify.gemspec
|
112
120
|
- lib/groupify.rb
|
113
121
|
- lib/groupify/version.rb
|
122
|
+
- spec/groupify/mongoid2.yml
|
123
|
+
- spec/groupify/mongoid3.yml
|
114
124
|
- spec/groupify/mongoid_spec.rb
|
115
|
-
- spec/mongoid2.yml
|
116
|
-
- spec/mongoid3.yml
|
117
125
|
- spec/spec_helper.rb
|
118
|
-
has_rdoc: true
|
119
126
|
homepage: https://github.com/dwbutler/groupify
|
120
127
|
licenses: []
|
121
|
-
|
122
|
-
post_install_message:
|
128
|
+
post_install_message:
|
123
129
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
130
|
+
require_paths:
|
126
131
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
-
|
129
|
-
requirements:
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
130
134
|
- - ">="
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
- 0
|
135
|
-
version: "0"
|
136
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: !binary |-
|
137
|
+
MA==
|
137
138
|
none: false
|
138
|
-
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
139
141
|
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
version: "0"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: !binary |-
|
144
|
+
MA==
|
145
|
+
none: false
|
145
146
|
requirements: []
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.8.24
|
149
|
+
signing_key:
|
150
150
|
specification_version: 3
|
151
151
|
summary: Group functionality for Rails
|
152
|
-
test_files:
|
152
|
+
test_files:
|
153
|
+
- spec/groupify/mongoid2.yml
|
154
|
+
- spec/groupify/mongoid3.yml
|
153
155
|
- spec/groupify/mongoid_spec.rb
|
154
|
-
- spec/mongoid2.yml
|
155
|
-
- spec/mongoid3.yml
|
156
156
|
- spec/spec_helper.rb
|