couch_cloner 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ module Hidden
2
+ def conditions
3
+ "#{super} && doc.couch_visible == false"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Published
2
+ def conditions
3
+ "#{super} && doc.milestone_memories.length > 0"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Shown
2
+ def conditions
3
+ "#{super} && doc.couch_visible == true"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Unpublished
2
+ def conditions
3
+ "#{super} && doc.milestone_memories.length == 0"
4
+ end
5
+ end
@@ -4,5 +4,13 @@ module CouchCloner
4
4
  base.send :include, CouchCloner::Clone
5
5
  base.send :include, CouchCloner::Scheduling
6
6
  base.send :include, CouchCloner::Query
7
+
8
+ if defined? ::CouchPublish && base.ancestors.include?(::CouchPublish)
9
+ base.send :include, CouchCloner::CouchPublish
10
+ end
11
+
12
+ if defined? ::CouchVisible && base.ancestors.include?(::CouchVisible)
13
+ base.send :include, CouchCloner::CouchVisible
14
+ end
7
15
  end
8
16
  end
@@ -0,0 +1,14 @@
1
+ module CouchCloner
2
+ module CouchPublish
3
+ def self.included(base)
4
+ base.map :clone_id do
5
+ conditions ::Published, ::Unpublished
6
+ end
7
+
8
+ base.couch_view :by_clone_id_and_start_time do
9
+ map CouchCloner::ByCloneIdAndStartTime
10
+ conditions ::Published, ::Unpublished
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module CouchCloner
2
+ module CouchVisible
3
+ def self.included(base)
4
+ base.map :clone_id do
5
+ conditions ::Shown, ::Hidden
6
+ end
7
+
8
+ base.couch_view :by_clone_id_and_start_time do
9
+ map CouchCloner::ByCloneIdAndStartTime do
10
+ conditions ::Shown, ::Hidden
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -32,7 +32,6 @@ module CouchCloner
32
32
  endkey!([clone_id, {:end => nil}])
33
33
  end
34
34
 
35
- #new
36
35
  def count_future_by_clone_id(clone_id)
37
36
  count_by_clone_id_and_start_time.
38
37
  startkey!([clone_id, Time.now]).
data/lib/couch_cloner.rb CHANGED
@@ -5,3 +5,9 @@ require 'couch_cloner/clone'
5
5
  require 'couch_cloner/scheduling'
6
6
  require 'couch_cloner/query'
7
7
  require 'couch_cloner/maps/by_clone_id_and_start_time'
8
+ require 'couch_cloner/integration/couch_publish'
9
+ require 'couch_cloner/integration/couch_visible'
10
+ require 'couch_cloner/conditions/published'
11
+ require 'couch_cloner/conditions/unpublished'
12
+ require 'couch_cloner/conditions/hidden'
13
+ require 'couch_cloner/conditions/shown'
data/readme.markdown CHANGED
@@ -204,20 +204,20 @@ You can also get a count of all clone_ids:
204
204
 
205
205
  ## Retreiving the clone created farthest in the future for a clone_id group (.map_last_future_by_clone_id)
206
206
 
207
- If you'd like to retrieve the latest clone within a clone group, you could of course call `future_clones_by_clone_id` and then call `last` on the resulting array - however, that would be quite silly and idiotically inefficiant. So, instead, call `last_future_clone_by_clone_id`:
207
+ If you'd like to retrieve the latest clone within a clone group, you could of course call `future_clones_by_clone_id` and then call `last` on the resulting array - however, that would be quite silly and idiotically inefficiant. So, instead, call `last_future_by_clone_id`:
208
208
 
209
209
  snippet_1 = HtmlSnippet.create :clone_id => "snippety", :start => Time.now
210
210
  snippet_2 = HtmlSnippet.create :clone_id => "snippety", :start => 1000.years.from_now
211
211
 
212
212
  HtmlSnippet.map_last_future_by_clone_id("snippety").get!.first.should == snippet_2
213
213
 
214
- After creating these two snippet's, calling `HtmlSnippet.last_future_clone_by_clone_id "snippety"` would return `snippet_2`. However, if we create another "snippety" snippet without a `start` date:
214
+ After creating these two snippet's, calling `HtmlSnippet.last_future_by_clone_id "snippety"` would return `snippet_2`. However, if we create another "snippety" snippet without a `start` date:
215
215
 
216
216
  snippet_3 = HtmlSnippet.create :clone_id => "snippety"
217
217
 
218
218
  HtmlSnippet.map_last_future_by_clone_id("snippety").get!.first.should == snippet_3
219
219
 
220
- Then calling `HtmlSnippet.last_future_clone_by_clone_id "snippety"` would return `snippet3`. Basically, you can imagine clones with a null start date or an empty string start date to have a start scheduled for `infinity + created_at`; in other words, they sort at the end of the map of clones in a clone_id group, and if there are multiple clones without a start date, then they sort by created at (still at the end of the map).
220
+ Then calling `HtmlSnippet.last_future_by_clone_id "snippety"` would return `snippet3`. Basically, you can imagine clones with a null start date or an empty string start date to have a start scheduled for `infinity + created_at`; in other words, they sort at the end of the map of clones in a clone_id group, and if there are multiple clones without a start date, then they sort by created at (still at the end of the map).
221
221
 
222
222
 
223
223
  ## CouchPublish Integration
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_cloner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Parker
@@ -177,7 +177,13 @@ extra_rdoc_files: []
177
177
 
178
178
  files:
179
179
  - lib/couch_cloner/clone.rb
180
+ - lib/couch_cloner/conditions/hidden.rb
181
+ - lib/couch_cloner/conditions/published.rb
182
+ - lib/couch_cloner/conditions/shown.rb
183
+ - lib/couch_cloner/conditions/unpublished.rb
180
184
  - lib/couch_cloner/couch_cloner.rb
185
+ - lib/couch_cloner/integration/couch_publish.rb
186
+ - lib/couch_cloner/integration/couch_visible.rb
181
187
  - lib/couch_cloner/maps/by_clone_id_and_start_time.rb
182
188
  - lib/couch_cloner/query.rb
183
189
  - lib/couch_cloner/scheduling.rb