jadof 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/jadof/page.rb CHANGED
@@ -59,10 +59,11 @@ module JADOF #:nodoc:
59
59
  end
60
60
 
61
61
  # @return [Array(Page)] Get all Pages in Page.dir
62
- def all
63
- cache_for 'all' do
62
+ def all conditions = nil
63
+ pages = cache_for 'all' do
64
64
  Dir[ File.join(dir, "**/*") ].reject {|path| File.directory?(path) }.map {|path| from_path(path) }
65
65
  end
66
+ conditions.nil? ? pages : where(conditions)
66
67
  end
67
68
 
68
69
  # @return [Fixnum] Returns the count of all Pages
@@ -185,7 +185,7 @@ shared_examples_for "JADOF Page" do
185
185
  @jadof_page_class.first(:foo => 'bar' ).foo.should == 'bar'
186
186
  end
187
187
 
188
- it 'can get a page by *multiple* arbitrary conditions' do
188
+ it 'can get a page by *multiple* arbitrary conditions via #all or #where' do
189
189
  create_page 'foo.markdown', %{
190
190
  ---
191
191
  foo: bar
@@ -197,6 +197,11 @@ shared_examples_for "JADOF Page" do
197
197
  @jadof_page_class.where(:foo => 'not bar', :name => 'foo').should be_empty
198
198
  @jadof_page_class.where(:foo => 'bar', :name => 'foo').should_not be_empty
199
199
  @jadof_page_class.where(:foo => 'bar', :name => 'foo').first.name.should == 'foo'
200
+
201
+ @jadof_page_class.all(:foo => 'bar', :name => 'not foo').should be_empty
202
+ @jadof_page_class.all(:foo => 'not bar', :name => 'foo').should be_empty
203
+ @jadof_page_class.all(:foo => 'bar', :name => 'foo').should_not be_empty
204
+ @jadof_page_class.all(:foo => 'bar', :name => 'foo').first.name.should == 'foo'
200
205
  end
201
206
 
202
207
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jadof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - remi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-06 00:00:00 -07:00
12
+ date: 2010-02-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency