glebtv-mongoid_nested_set 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f74b01b36e9f6e96dbc59aacdc68b68069182d
4
- data.tar.gz: 7acff99227594a6601f8141a99bf60408987d16d
3
+ metadata.gz: c33f021b3089d426f8cd762d26c1527892c483c2
4
+ data.tar.gz: a2c4b42b74fac204f78bdead4dab8ded122389ff
5
5
  SHA512:
6
- metadata.gz: 0cb2a314591b0f6b80c1c6caa626c6b249980c2a6c91a8fef10921abc930f91d8370aa54494ac7b1f4f7b18d686ee5a963f934f8ac8a2747ca8d988c3cf59a9d
7
- data.tar.gz: 36eca30d0546e7f262cc103731500a528c341ff2e5a9ae00ddd86f3880dde97e6886155295b8c16d429c0e8f64ff6045ae86b78ac8173c58c8a909016670f07e
6
+ metadata.gz: 28bec66a742952b69fe7fbedbeeac8e4377a8ff33330c5e81767314f34a78cc5dd9519806424cc43657d8fd33afeb7bc87833b1d59412c4917082949acc13743
7
+ data.tar.gz: 7b60408b936e2adc0bf80138b316a7a6255c85a721a451a4c56d64afef3e46f93486c2ae147ce50f3b8d747b56b6578883f7742ec6b10f862e8ce486d008c410
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0-p247
1
+ 2.0.0-p353
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ services: mongodb
3
+
4
+ notifications:
5
+ email: false
6
+
7
+ rvm:
8
+ - 1.9.3
9
+ - 2.0.0
10
+ - 2.1.0
11
+ - jruby-20mode
12
+
13
+ gemfile:
14
+ - gemfiles/mongoid-3.1.gemfile
15
+ - gemfiles/mongoid-4.0.gemfile
16
+ - gemfiles/am-4.1.gemfile
data/Gemfile CHANGED
@@ -1,10 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ #gem "activemodel", "~> 4.1.0.beta1"
4
+ #gem "mongoid", "~> 4.0.0.beta1"
5
+
3
6
  # Specify your gem's dependencies in glebtv-mongoid_nested_set.gemspec
4
7
  gemspec
5
8
 
6
- group :test do
7
- gem 'rspec-expectations', "~> 2.0"
8
- gem 'rr'
9
- gem 'remarkable_mongoid'
10
- end
data/README.markdown CHANGED
@@ -1,9 +1,13 @@
1
1
  Mongoid Nested Set
2
2
  ==================
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/glebtv-mongoid_nested_set.png)](http://badge.fury.io/rb/glebtv-mongoid_nested_set)
5
+ [![Build Status](https://travis-ci.org/glebtv/mongoid_nested_set.png?branch=master)](https://travis-ci.org/glebtv/mongoid_nested_set)
6
+ [![Dependency Status](https://gemnasium.com/glebtv/mongoid_nested_set.png)](https://gemnasium.com/glebtv/mongoid_nested_set)
7
+
4
8
  Mongoid Nested Set is an implementation of the nested set pattern for Mongoid.
5
9
  It is a port of [AwesomeNestedSet for ActiveRecord](https://github.com/galetahub/awesome_nested_set).
6
- It supports Mongoid 2 and Rails 3.
10
+ It supports Mongoid 3/4 and Rails 3/4.
7
11
 
8
12
  Nested Set represents hierarchies of trees in MongoDB using references rather
9
13
  than embedded documents. A tree is stored as a flat list of documents in a
@@ -18,11 +22,11 @@ For more on the nested set pattern: <http://en.wikipedia.org/wiki/Nested_set_mod
18
22
 
19
23
  Install as Gem
20
24
 
21
- gem install mongoid_nested_set
25
+ gem install glebtv-mongoid_nested_set
22
26
 
23
27
  via Gemfile
24
28
 
25
- gem 'mongoid_nested_set', '0.1.3'
29
+ gem 'glebtv-mongoid_nested_set', '~> 0.4.2'
26
30
 
27
31
 
28
32
  ## Usage
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
- require 'bundler/gem_tasks'
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activemodel", "~> 4.1.0.beta1"
4
+ gem "mongoid", "~> 4.0.0.beta1"
5
+
6
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongoid", github: "mongoid/mongoid", branch: "3.1.0-stable"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongoid", "~> 4.0.0.beta1"
4
+
5
+ gemspec path: "../"
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = MongoidNestedSet::VERSION
8
8
  s.authors = ["GlebTV", "Brandon Turner"]
9
9
  s.email = ["bt@brandonturner.net"]
10
- s.homepage = "http://github.com/55ideas/mongoid_nested_set"
10
+ s.homepage = "http://github.com/glebtv/mongoid_nested_set"
11
11
  s.summary = %q{Nested set based tree implementation for Mongoid}
12
12
  s.description = %q{Fully featured tree implementation for Mongoid using the nested set model}
13
13
  s.licenses = ["MIT"]
@@ -19,11 +19,16 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency(%q<mongoid>, [">= 3.0.0"])
22
+ s.add_runtime_dependency 'mongoid', [">= 3.1.0", "< 4.1"]
23
23
 
24
- s.add_development_dependency(%q<rspec>, [">= 2.7.0"])
25
- s.add_development_dependency(%q<bundler>, [">= 1.0.21"])
26
- s.add_development_dependency(%q<simplecov>)
27
- s.add_development_dependency(%q<simplecov-rcov>)
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'rspec'
26
+ s.add_development_dependency 'bundler'
27
+ s.add_development_dependency 'simplecov'
28
+ s.add_development_dependency 'simplecov-rcov'
29
+
30
+ s.add_development_dependency 'rspec-expectations', "~> 2.0"
31
+ s.add_development_dependency 'rr'
32
+ s.add_development_dependency 'remarkable_mongoid'
28
33
  end
29
34
 
@@ -1,7 +1,5 @@
1
1
  module Mongoid::Acts::NestedSet
2
-
3
2
  module Base
4
-
5
3
  # Configuration options are:
6
4
  #
7
5
  # * +:parent_field+ - field name to use for keeping the parent id (default: parent_id)
@@ -53,15 +51,7 @@ module Mongoid::Acts::NestedSet
53
51
 
54
52
  attr_accessor :skip_before_destroy
55
53
 
56
- # Rails 4 no longer uses "attr_protected" and "attr_accessible" for
57
- # mass assignment control by default, but this methods can be restored
58
- # by installing 'protected_attributes' gem. So here we just check
59
- # accessible_attributes method presence
60
- if respond_to?(:accessible_attributes) && accessible_attributes.blank?
61
- attr_protected left_field_name.intern, right_field_name.intern
62
- end
63
-
64
- define_callbacks :move, :terminator => "result == false"
54
+ define_callbacks :move, :terminator => callback_terminator
65
55
 
66
56
  before_create :set_default_left_and_right
67
57
  before_save :store_new_parent
@@ -89,6 +79,15 @@ module Mongoid::Acts::NestedSet
89
79
 
90
80
  end
91
81
  end
92
- end
93
82
 
83
+ private
84
+ def callback_terminator
85
+ if ::ActiveSupport::VERSION::STRING >= '4.1'
86
+ lambda { |target, result| result == false }
87
+ else
88
+ 'result == false'
89
+ end
90
+ end
91
+ end
94
92
  end
93
+
@@ -105,7 +105,11 @@ module Mongoid::Acts::NestedSet
105
105
  conditions = parents.map do |parent|
106
106
  {left_field_name => {"$gt" => parent.left}, right_field_name => {"$lt" => parent.right}}
107
107
  end
108
- where("$or" => conditions)
108
+ if conditions.empty?
109
+ where({})
110
+ else
111
+ where("$or" => conditions)
112
+ end
109
113
  end
110
114
 
111
115
 
@@ -1,3 +1,3 @@
1
1
  module MongoidNestedSet
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -22,11 +22,7 @@ module Mongoid::Acts::NestedSet
22
22
  def test_set_attributes(attrs)
23
23
  attrs.each do |key, val|
24
24
  key = key.to_s
25
- if Mongoid.allow_dynamic_fields ||
26
- fields.keys.any? { |k| k.to_s == key } ||
27
- associations.any? { |a| a[0].to_s == key || a[1].foreign_key.to_s == key }
28
- @attributes[key] = fields[key].mongoize(val)
29
- end
25
+ @attributes[key] = val
30
26
  end
31
27
  self
32
28
  end
@@ -191,13 +191,17 @@ describe "A Mongoid::Document" do
191
191
  end
192
192
 
193
193
  it "does not allow assigning the left field" do
194
- expect { Node.new.lft = 1 }.to raise_error(NameError)
195
- expect { RenamedFields.new.red = 1 }.to raise_error(NameError)
194
+ # expect { Node.new.lft = 1 }.to raise_error(NameError)
195
+ # expect { RenamedFields.new.red = 1 }.to raise_error(NameError)
196
+ expect { Node.new.lft = 1 }.to raise_error
197
+ expect { RenamedFields.new.red = 1 }.to raise_error
196
198
  end
197
199
 
198
200
  it "does not allow assigning the right field" do
199
- expect { Node.new.rgt = 1 }.to raise_error(NameError)
200
- expect { RenamedFields.new.black = 1 }.to raise_error(NameError)
201
+ # expect { Node.new.rgt = 1 }.to raise_error(NameError)
202
+ # expect { RenamedFields.new.black = 1 }.to raise_error(NameError)
203
+ expect { Node.new.rgt = 1 }.to raise_error
204
+ expect { RenamedFields.new.black = 1 }.to raise_error
201
205
  end
202
206
 
203
207
 
@@ -360,7 +364,7 @@ describe "A Mongoid::Document" do
360
364
  # Scopes
361
365
 
362
366
  it "fetches all root nodes" do
363
- Node.roots.should have(2).entries
367
+ Node.roots.entries.size.should eq(2)
364
368
  end
365
369
 
366
370
  it "fetches all leaf nodes in order" do
@@ -376,7 +380,7 @@ describe "A Mongoid::Document" do
376
380
 
377
381
  it "fetches descendants of multiple parents" do
378
382
  parents = Node.any_in(:name => %w[Men's Dresses])
379
- Node.where(:root_id=>1).descendants_of(parents).should have(5).entries
383
+ Node.where(:root_id=>1).descendants_of(parents).entries.size.should eq(5)
380
384
  end
381
385
 
382
386
  it "fetches self and ancestors in order" do
@@ -478,7 +482,11 @@ describe "A Mongoid::Document" do
478
482
  end
479
483
 
480
484
  it "cannot move a node to a non-existent target" do
481
- @nodes[:mens].parent_id = Moped::BSON::ObjectId.new
485
+ if defined?(Moped::BSON)
486
+ @nodes[:mens].parent_id = Moped::BSON::ObjectId.new
487
+ else
488
+ @nodes[:mens].parent_id = BSON::ObjectId.new
489
+ end
482
490
  expect {
483
491
  @nodes[:mens].save
484
492
  }.to raise_error(Mongoid::Errors::MongoidError, /possible.*(exist|found)/)
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'rr'
5
+ require 'active_support'
6
+ require 'active_support/deprecation'
5
7
  require 'mongoid'
6
8
  require 'mongoid_nested_set'
7
9
  require 'remarkable/mongoid'
@@ -24,17 +26,20 @@ end
24
26
  module Mongoid::Acts::NestedSet::Matchers
25
27
  end
26
28
 
29
+ #Mongoid.logger = Logger.new($stdout)
30
+ #Moped.logger = Logger.new($stdout)
31
+ #Moped.logger.level = Logger::DEBUG
32
+
27
33
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
28
34
  Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|file| require file }
29
35
  Dir["#{File.dirname(__FILE__)}/matchers/*.rb"].each {|file| require file }
30
36
 
31
37
  Mongoid.configure do |config|
32
38
  config.connect_to("mongoid_nested_set_test")
33
- config.allow_dynamic_fields = false
34
39
  end
35
40
 
36
41
  RSpec.configure do |config|
37
- config.mock_with :rr
42
+ #config.mock_with :rr
38
43
  config.include(Mongoid::Acts::NestedSet::Matchers)
39
44
 
40
45
  config.after(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-mongoid_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GlebTV
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-07 00:00:00.000000000 Z
12
+ date: 2014-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -17,42 +17,62 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 3.1.0
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: '4.1'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
28
  - - '>='
26
29
  - !ruby/object:Gem::Version
27
- version: 3.0.0
30
+ version: 3.1.0
31
+ - - <
32
+ - !ruby/object:Gem::Version
33
+ version: '4.1'
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
28
48
  - !ruby/object:Gem::Dependency
29
49
  name: rspec
30
50
  requirement: !ruby/object:Gem::Requirement
31
51
  requirements:
32
52
  - - '>='
33
53
  - !ruby/object:Gem::Version
34
- version: 2.7.0
54
+ version: '0'
35
55
  type: :development
36
56
  prerelease: false
37
57
  version_requirements: !ruby/object:Gem::Requirement
38
58
  requirements:
39
59
  - - '>='
40
60
  - !ruby/object:Gem::Version
41
- version: 2.7.0
61
+ version: '0'
42
62
  - !ruby/object:Gem::Dependency
43
63
  name: bundler
44
64
  requirement: !ruby/object:Gem::Requirement
45
65
  requirements:
46
66
  - - '>='
47
67
  - !ruby/object:Gem::Version
48
- version: 1.0.21
68
+ version: '0'
49
69
  type: :development
50
70
  prerelease: false
51
71
  version_requirements: !ruby/object:Gem::Requirement
52
72
  requirements:
53
73
  - - '>='
54
74
  - !ruby/object:Gem::Version
55
- version: 1.0.21
75
+ version: '0'
56
76
  - !ruby/object:Gem::Dependency
57
77
  name: simplecov
58
78
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +101,48 @@ dependencies:
81
101
  - - '>='
82
102
  - !ruby/object:Gem::Version
83
103
  version: '0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rspec-expectations
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ - !ruby/object:Gem::Dependency
119
+ name: rr
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ - !ruby/object:Gem::Dependency
133
+ name: remarkable_mongoid
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
84
146
  description: Fully featured tree implementation for Mongoid using the nested set model
85
147
  email:
86
148
  - bt@brandonturner.net
@@ -93,10 +155,14 @@ files:
93
155
  - .rspec
94
156
  - .ruby-gemset
95
157
  - .ruby-version
158
+ - .travis.yml
96
159
  - Gemfile
97
160
  - LICENSE.txt
98
161
  - README.markdown
99
162
  - Rakefile
163
+ - gemfiles/am-4.1.gemfile
164
+ - gemfiles/mongoid-3.1.gemfile
165
+ - gemfiles/mongoid-4.0.gemfile
100
166
  - glebtv-mongoid_nested_set.gemspec
101
167
  - lib/glebtv-mongoid_nested_set.rb
102
168
  - lib/mongoid_nested_set.rb
@@ -122,7 +188,7 @@ files:
122
188
  - spec/models/unscoped_node.rb
123
189
  - spec/mongoid_nested_set_spec.rb
124
190
  - spec/spec_helper.rb
125
- homepage: http://github.com/55ideas/mongoid_nested_set
191
+ homepage: http://github.com/glebtv/mongoid_nested_set
126
192
  licenses:
127
193
  - MIT
128
194
  metadata: {}
@@ -142,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
208
  version: '0'
143
209
  requirements: []
144
210
  rubyforge_project: mongoid_nested_set
145
- rubygems_version: 2.0.6
211
+ rubygems_version: 2.2.1
146
212
  signing_key:
147
213
  specification_version: 4
148
214
  summary: Nested set based tree implementation for Mongoid