groupify 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile +12 -2
- data/README.md +9 -3
- data/gemfiles/rails_3.2.gemfile +13 -2
- data/gemfiles/rails_4.0.gemfile +13 -2
- data/gemfiles/rails_4.1.gemfile +13 -2
- data/gemfiles/rails_4.2.gemfile +13 -2
- data/groupify.gemspec +4 -5
- data/lib/groupify/adapter/active_record/group_member.rb +2 -2
- data/lib/groupify/adapter/active_record/named_group_member.rb +2 -2
- data/lib/groupify/version.rb +1 -1
- data/spec/active_record_spec.rb +17 -48
- data/spec/db/database.yml +20 -0
- data/spec/db/schema.rb +35 -0
- metadata +26 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 330d329200d0dda6ac489a0c099fd54655e2899d
|
4
|
+
data.tar.gz: 95a7c8c3d68c7e409818cd8fe816957325da8112
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f256fc9f5d55ad7feb210c9af83ae7005f0c1921ad76af0f3f5287f8f0e71653a5a54e99f335460cada5dd11466ad96b70b862951e4eb8f52362f3175fa004f4
|
7
|
+
data.tar.gz: 2be5800f07ea8e8b32f13e349557ebfb6f795fe490433a7468e4f5606c349573728ce47e59a40894705967cc4599b38000b966ca10a37c4d5bf2e8993d0d40c3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -11,5 +11,15 @@ end
|
|
11
11
|
# Specify your gem's dependencies in groupify.gemspec
|
12
12
|
gemspec
|
13
13
|
|
14
|
-
|
15
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
14
|
+
platforms :jruby do
|
15
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
16
|
+
gem "activerecord-jdbcmysql-adapter"
|
17
|
+
gem "jdbc-mysql"
|
18
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
19
|
+
end
|
20
|
+
|
21
|
+
platforms :ruby do
|
22
|
+
gem "sqlite3"
|
23
|
+
gem "mysql2"
|
24
|
+
gem "pg"
|
25
|
+
end
|
data/README.md
CHANGED
@@ -7,13 +7,19 @@ model? Use named groups instead to add members to named groups such as
|
|
7
7
|
`:admin` or `"Team Rocketpants"`.
|
8
8
|
|
9
9
|
The following ORMs are supported:
|
10
|
-
* ActiveRecord 3.2, 4.x
|
11
|
-
* Mongoid 3.1, 4.0
|
10
|
+
* ActiveRecord 3.2, 4.1.x, 4.2.x
|
11
|
+
* Mongoid 3.1, 4.0
|
12
12
|
|
13
13
|
The following Rubies are supported:
|
14
|
-
* MRI Ruby 1.9.3, 2.0.x, 2.1.x
|
14
|
+
* MRI Ruby 1.9.3, 2.0.x, 2.1.x, 2.2.x
|
15
15
|
* JRuby (1.9 mode)
|
16
16
|
|
17
|
+
The following databases are supported:
|
18
|
+
* MySQL
|
19
|
+
* PostgreSQL
|
20
|
+
* SQLite
|
21
|
+
* MongoDB
|
22
|
+
|
17
23
|
## Installation
|
18
24
|
|
19
25
|
Add this line to your application's Gemfile:
|
data/gemfiles/rails_3.2.gemfile
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "jdbc-sqlite3", :platform => :jruby
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
5
|
gem "activerecord", "~> 3.2"
|
8
6
|
gem "mongoid", ">= 3.0", "< 4"
|
9
7
|
|
@@ -15,4 +13,17 @@ group :test do
|
|
15
13
|
gem "coveralls", :require => false
|
16
14
|
end
|
17
15
|
|
16
|
+
platforms :jruby do
|
17
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
18
|
+
gem "activerecord-jdbcmysql-adapter"
|
19
|
+
gem "jdbc-mysql"
|
20
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
21
|
+
end
|
22
|
+
|
23
|
+
platforms :ruby do
|
24
|
+
gem "sqlite3"
|
25
|
+
gem "mysql2"
|
26
|
+
gem "pg"
|
27
|
+
end
|
28
|
+
|
18
29
|
gemspec :path => "../"
|
data/gemfiles/rails_4.0.gemfile
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "jdbc-sqlite3", :platform => :jruby
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
5
|
gem "activerecord", "~> 4.0.0"
|
8
6
|
gem "mongoid", "~> 4.0"
|
9
7
|
|
@@ -15,4 +13,17 @@ group :test do
|
|
15
13
|
gem "coveralls", :require => false
|
16
14
|
end
|
17
15
|
|
16
|
+
platforms :jruby do
|
17
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
18
|
+
gem "activerecord-jdbcmysql-adapter"
|
19
|
+
gem "jdbc-mysql"
|
20
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
21
|
+
end
|
22
|
+
|
23
|
+
platforms :ruby do
|
24
|
+
gem "sqlite3"
|
25
|
+
gem "mysql2"
|
26
|
+
gem "pg"
|
27
|
+
end
|
28
|
+
|
18
29
|
gemspec :path => "../"
|
data/gemfiles/rails_4.1.gemfile
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "jdbc-sqlite3", :platform => :jruby
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
5
|
gem "activerecord", "~> 4.1.0"
|
8
6
|
gem "mongoid", "~> 4.0"
|
9
7
|
|
@@ -15,4 +13,17 @@ group :test do
|
|
15
13
|
gem "coveralls", :require => false
|
16
14
|
end
|
17
15
|
|
16
|
+
platforms :jruby do
|
17
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
18
|
+
gem "activerecord-jdbcmysql-adapter"
|
19
|
+
gem "jdbc-mysql"
|
20
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
21
|
+
end
|
22
|
+
|
23
|
+
platforms :ruby do
|
24
|
+
gem "sqlite3"
|
25
|
+
gem "mysql2"
|
26
|
+
gem "pg"
|
27
|
+
end
|
28
|
+
|
18
29
|
gemspec :path => "../"
|
data/gemfiles/rails_4.2.gemfile
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "jdbc-sqlite3", :platform => :jruby
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
5
|
gem "activerecord", "~> 4.2.0"
|
8
6
|
gem "mongoid", "~> 4.0"
|
9
7
|
|
@@ -15,4 +13,17 @@ group :test do
|
|
15
13
|
gem "coveralls", :require => false
|
16
14
|
end
|
17
15
|
|
16
|
+
platforms :jruby do
|
17
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
18
|
+
gem "activerecord-jdbcmysql-adapter"
|
19
|
+
gem "jdbc-mysql"
|
20
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
21
|
+
end
|
22
|
+
|
23
|
+
platforms :ruby do
|
24
|
+
gem "sqlite3"
|
25
|
+
gem "mysql2"
|
26
|
+
gem "pg"
|
27
|
+
end
|
28
|
+
|
18
29
|
gemspec :path => "../"
|
data/groupify.gemspec
CHANGED
@@ -16,15 +16,14 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Groupify::VERSION
|
17
17
|
gem.license = 'MIT'
|
18
18
|
|
19
|
-
gem.
|
20
|
-
gem.add_development_dependency "activerecord", ">= 3.2"
|
19
|
+
gem.required_ruby_version = ">= 1.9.3"
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
gem.add_development_dependency "mongoid", ">= 3.1"
|
22
|
+
gem.add_development_dependency "activerecord", ">= 3.2", "< 5"
|
25
23
|
|
26
24
|
gem.add_development_dependency "rspec", ">= 3"
|
27
25
|
|
28
26
|
gem.add_development_dependency "database_cleaner", "~> 1.3.0"
|
27
|
+
gem.add_development_dependency 'combustion'
|
29
28
|
gem.add_development_dependency "appraisal"
|
30
29
|
end
|
@@ -117,7 +117,7 @@ module Groupify
|
|
117
117
|
return none unless groups.present?
|
118
118
|
|
119
119
|
joins(:group_memberships).
|
120
|
-
group(
|
120
|
+
group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
|
121
121
|
where(:group_memberships => {:group_id => groups.map(&:id)}).
|
122
122
|
having("COUNT(group_memberships.group_id) = #{groups.count}").
|
123
123
|
uniq
|
@@ -128,7 +128,7 @@ module Groupify
|
|
128
128
|
return none unless groups.present?
|
129
129
|
|
130
130
|
joins(:group_memberships).
|
131
|
-
group(
|
131
|
+
group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
|
132
132
|
having("COUNT(DISTINCT group_memberships.group_id) = #{groups.count}").
|
133
133
|
uniq
|
134
134
|
end
|
@@ -80,7 +80,7 @@ module Groupify
|
|
80
80
|
return none unless named_groups.present?
|
81
81
|
|
82
82
|
joins(:group_memberships).
|
83
|
-
group(
|
83
|
+
group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
|
84
84
|
where(:group_memberships => {:group_name => named_groups}).
|
85
85
|
having("COUNT(DISTINCT group_memberships.group_name) = #{named_groups.count}").
|
86
86
|
uniq
|
@@ -91,7 +91,7 @@ module Groupify
|
|
91
91
|
return none unless named_groups.present?
|
92
92
|
|
93
93
|
joins(:group_memberships).
|
94
|
-
group("
|
94
|
+
group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
|
95
95
|
having("COUNT(DISTINCT group_memberships.group_name) = #{named_groups.count}").
|
96
96
|
uniq
|
97
97
|
end
|
data/lib/groupify/version.rb
CHANGED
data/spec/active_record_spec.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
DATABASE = ENV.fetch('DATABASE', 'sqlite3mem')
|
4
|
+
|
5
|
+
puts "ActiveRecord Version: #{ActiveSupport::VERSION::STRING}, Database: #{DATABASE}"
|
6
|
+
|
7
|
+
require 'yaml'
|
8
|
+
require 'erb'
|
9
|
+
ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read("#{File.dirname(__FILE__)}/db/database.yml")).result)
|
10
|
+
ActiveRecord::Base.establish_connection(DATABASE.to_sym)
|
11
|
+
ActiveRecord::Migration.verbose = false
|
12
|
+
|
13
|
+
require 'combustion/database'
|
14
|
+
Combustion::Database.create_database(ActiveRecord::Base.configurations[DATABASE])
|
15
|
+
load(File.join(File.dirname(__FILE__), "db", "schema.rb"))
|
13
16
|
|
14
17
|
RSpec.configure do |config|
|
15
18
|
config.before(:suite) do
|
@@ -23,45 +26,11 @@ RSpec.configure do |config|
|
|
23
26
|
config.after(:each) do
|
24
27
|
DatabaseCleaner[:active_record].clean
|
25
28
|
end
|
26
|
-
end
|
27
|
-
|
28
|
-
ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => ":memory:" )
|
29
|
-
|
30
|
-
ActiveRecord::Migration.verbose = false
|
31
|
-
ActiveRecord::Schema.define(:version => 1) do
|
32
|
-
|
33
|
-
create_table :groups do |t|
|
34
|
-
t.string :name
|
35
|
-
t.string :type
|
36
|
-
end
|
37
|
-
|
38
|
-
create_table :group_memberships do |t|
|
39
|
-
t.string :member_type
|
40
|
-
t.integer :member_id
|
41
|
-
t.integer :group_id
|
42
|
-
t.string :group_name
|
43
|
-
t.string :membership_type
|
44
|
-
end
|
45
|
-
|
46
|
-
create_table :users do |t|
|
47
|
-
t.string :name
|
48
|
-
t.string :type
|
49
|
-
end
|
50
|
-
|
51
|
-
create_table :widgets do |t|
|
52
|
-
t.string :name
|
53
|
-
end
|
54
29
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
create_table :organizations do |t|
|
60
|
-
t.string :name
|
61
|
-
end
|
62
|
-
|
63
|
-
create_table :members do |t|
|
64
|
-
t.string :name
|
30
|
+
config.after(:suite) do
|
31
|
+
unless ENV['DB'] =~ /sqlite/
|
32
|
+
Combustion::Database.drop_database(ActiveRecord::Base.configurations[DATABASE])
|
33
|
+
end
|
65
34
|
end
|
66
35
|
end
|
67
36
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
sqlite3:
|
2
|
+
adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
|
3
|
+
database: groupify.sqlite3.db
|
4
|
+
sqlite3mem:
|
5
|
+
adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
|
6
|
+
database: ":memory:"
|
7
|
+
postgresql:
|
8
|
+
adapter: postgresql
|
9
|
+
encoding: unicode
|
10
|
+
database: groupify_test
|
11
|
+
pool: 5
|
12
|
+
username: postgres
|
13
|
+
password: postgres
|
14
|
+
min_messages: warning
|
15
|
+
mysql:
|
16
|
+
adapter: <%= defined?(JRUBY_VERSION) ? "jdbcmysql" : "mysql2" %>
|
17
|
+
host: localhost
|
18
|
+
username: root
|
19
|
+
password:
|
20
|
+
database: groupify_test
|
data/spec/db/schema.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
ActiveRecord::Schema.define(version: 0) do
|
2
|
+
create_table :groups do |t|
|
3
|
+
t.string :name
|
4
|
+
t.string :type
|
5
|
+
end
|
6
|
+
|
7
|
+
create_table :group_memberships do |t|
|
8
|
+
t.string :member_type
|
9
|
+
t.integer :member_id
|
10
|
+
t.integer :group_id
|
11
|
+
t.string :group_name
|
12
|
+
t.string :membership_type
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :users do |t|
|
16
|
+
t.string :name
|
17
|
+
t.string :type
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table :widgets do |t|
|
21
|
+
t.string :name
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table :projects do |t|
|
25
|
+
t.string :name
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table :organizations do |t|
|
29
|
+
t.string :name
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table :members do |t|
|
33
|
+
t.string :name
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dwbutler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.2'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5'
|
34
37
|
type: :development
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,20 +41,9 @@ dependencies:
|
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '3.2'
|
41
|
-
-
|
42
|
-
name: sqlite3
|
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
|
-
- - ">="
|
44
|
+
- - "<"
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
46
|
+
version: '5'
|
55
47
|
- !ruby/object:Gem::Dependency
|
56
48
|
name: rspec
|
57
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +72,20 @@ dependencies:
|
|
80
72
|
- - "~>"
|
81
73
|
- !ruby/object:Gem::Version
|
82
74
|
version: 1.3.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: combustion
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: appraisal
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +139,8 @@ files:
|
|
133
139
|
- lib/groupify/railtie.rb
|
134
140
|
- lib/groupify/version.rb
|
135
141
|
- spec/active_record_spec.rb
|
142
|
+
- spec/db/database.yml
|
143
|
+
- spec/db/schema.rb
|
136
144
|
- spec/mongoid_spec.rb
|
137
145
|
- spec/spec_helper.rb
|
138
146
|
homepage: https://github.com/dwbutler/groupify
|
@@ -147,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
155
|
requirements:
|
148
156
|
- - ">="
|
149
157
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
158
|
+
version: 1.9.3
|
151
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
160
|
requirements:
|
153
161
|
- - ">="
|
@@ -161,5 +169,7 @@ specification_version: 4
|
|
161
169
|
summary: Group functionality for Rails
|
162
170
|
test_files:
|
163
171
|
- spec/active_record_spec.rb
|
172
|
+
- spec/db/database.yml
|
173
|
+
- spec/db/schema.rb
|
164
174
|
- spec/mongoid_spec.rb
|
165
175
|
- spec/spec_helper.rb
|