Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 377
- Log:
Various files are in the gem, but apparently not in the source distribution
on GitHub. These have been copied in from the working gem.
- Author:
- rool
- Date:
- Mon Mar 21 13:46:18 +0000 2011
- Size:
- 1540 Bytes
1 | class ArchiveFinder |
2 | |
3 | def initialize(&block) |
4 | @block = block |
5 | end |
6 | |
7 | def find(method, options = {}) |
8 | @block.call(method, options) |
9 | end |
10 | |
11 | # stub for page tag finding |
12 | def all(method, options ={}) |
13 | self.find(:all) |
14 | end |
15 | |
16 | class << self |
17 | def year_finder(finder, year) |
18 | new do |method, options| |
19 | start = Time.local(year) |
20 | finish = start.next_year |
21 | add_condition(options, "published_at >= ? and published_at < ?", start, finish) |
22 | finder.find(method, options) |
23 | end |
24 | end |
25 | |
26 | def month_finder(finder, year, month) |
27 | new do |method, options| |
28 | start = Time.local(year, month) |
29 | finish = start.next_month |
30 | add_condition(options, "published_at >= ? and published_at < ?", start, finish) |
31 | finder.find(method, options) |
32 | end |
33 | end |
34 | |
35 | def day_finder(finder, year, month, day) |
36 | new do |method, options| |
37 | start = Time.local(year, month, day) |
38 | finish = start.tomorrow |
39 | add_condition(options, "published_at >= ? and published_at < ?", start, finish) |
40 | finder.find(method, options) |
41 | end |
42 | end |
43 | |
44 | private |
45 | |
46 | def concat_conditions(a, b) |
47 | sql = "(#{ [a.shift, b.shift].compact.join(") AND (") })" |
48 | params = a + b |
49 | [sql, *params] |
50 | end |
51 | |
52 | def add_condition(options, *condition) |
53 | old = options[:conditions] || [] |
54 | conditions = concat_conditions(old, condition) |
55 | options[:conditions] = conditions |
56 | options |
57 | end |
58 | |
59 | end |
60 | end |