noodall-core 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/noodall/indexer.rb +16 -3
- data/lib/noodall/node.rb +9 -5
- data/noodall-core.gemspec +2 -2
- data/spec/node_spec.rb +12 -0
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/noodall/indexer.rb
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
module Noodall
|
2
2
|
module Indexer
|
3
|
+
def self.configure(model)
|
4
|
+
model.class_eval do
|
5
|
+
puts "index on"
|
6
|
+
cattr_accessor :indexes
|
7
|
+
end
|
8
|
+
model.indexes = []
|
9
|
+
end
|
3
10
|
module ClassMethods
|
4
|
-
def ensure_index(
|
5
|
-
|
6
|
-
|
11
|
+
def ensure_index(*args)
|
12
|
+
indexes << args
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_indexes!
|
16
|
+
indexes.each do |args|
|
17
|
+
puts "Creating index #{args.inspect}"
|
18
|
+
collection.create_index(*args)
|
19
|
+
end
|
7
20
|
end
|
8
21
|
end
|
9
22
|
end
|
data/lib/noodall/node.rb
CHANGED
@@ -14,10 +14,10 @@ module Noodall
|
|
14
14
|
key :name, String
|
15
15
|
key :description, String
|
16
16
|
key :body, String
|
17
|
-
key :position, Integer, :default => nil
|
17
|
+
key :position, Integer, :default => nil, :index => true
|
18
18
|
key :_type, String
|
19
|
-
key :published_at, Time
|
20
|
-
key :published_to, Time
|
19
|
+
key :published_at, Time, :index => true
|
20
|
+
key :published_to, Time, :index => true
|
21
21
|
key :updatable_groups, Array
|
22
22
|
key :destroyable_groups, Array
|
23
23
|
key :publishable_groups, Array
|
@@ -151,6 +151,11 @@ module Noodall
|
|
151
151
|
Noodall::Site.contains?(self.permalink.to_s)
|
152
152
|
end
|
153
153
|
|
154
|
+
# A slug for creating the permalink
|
155
|
+
def slug
|
156
|
+
(self.name.blank? ? self.title : self.name).to_s.parameterize
|
157
|
+
end
|
158
|
+
|
154
159
|
private
|
155
160
|
|
156
161
|
def switch_position(sibling)
|
@@ -175,8 +180,7 @@ module Noodall
|
|
175
180
|
# this code takes name over title for the current node's slug
|
176
181
|
# this way enables children to inherit the parent's custom (user defined) permalink also
|
177
182
|
permalink_args = self.parent.nil? ? [] : self.parent.permalink.dup
|
178
|
-
|
179
|
-
permalink_args << self_slug unless self_slug.blank?
|
183
|
+
permalink_args << self.slug unless self.slug.blank?
|
180
184
|
self.permalink = Permalink.new(*permalink_args)
|
181
185
|
end
|
182
186
|
end
|
data/noodall-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{noodall-core}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve England"]
|
12
|
-
s.date = %q{2011-01
|
12
|
+
s.date = %q{2011-02-01}
|
13
13
|
s.description = %q{Core data objects for Noodall}
|
14
14
|
s.email = %q{steve@wearebeef.co.uk}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/node_spec.rb
CHANGED
@@ -410,4 +410,16 @@ describe Noodall::Node do
|
|
410
410
|
page.name.should == "Shorty"
|
411
411
|
end
|
412
412
|
|
413
|
+
it "should be indexed only when explicitly called" do
|
414
|
+
Noodall::Node.collection.drop_indexes
|
415
|
+
class LandingPage < Noodall::Node
|
416
|
+
key :dude, String, :index => true
|
417
|
+
end
|
418
|
+
|
419
|
+
Noodall::Node.indexes.should include ['dude']
|
420
|
+
|
421
|
+
Noodall::Node.create_indexes!
|
422
|
+
Noodall::Node.collection.index_information.keys.should include('dude_1')
|
423
|
+
end
|
424
|
+
|
413
425
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noodall-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve England
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01
|
18
|
+
date: 2011-02-01 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|