archive_tree 1.0.0.rc → 1.0.0.rc2
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.
@@ -1,7 +1,8 @@
|
|
1
1
|
module ArchiveTree
|
2
2
|
module ActionViewExtensions
|
3
3
|
|
4
|
-
# Defines the helper methods that will be included in the ActionView::Base in
|
4
|
+
# Defines the helper methods that will be included in the ActionView::Base in
|
5
|
+
# order to return the html representation of the archive tree
|
5
6
|
module DrawArchiveTree
|
6
7
|
|
7
8
|
# In the presence of records for a given model it draws the archive tree. Otherwise, returns an empty string
|
data/lib/archive_tree/core.rb
CHANGED
@@ -19,8 +19,8 @@ module ArchiveTree
|
|
19
19
|
options.reverse_merge! ({ :year => Time.now.year })
|
20
20
|
|
21
21
|
where("#{date_field} IS NOT NULL").
|
22
|
-
where("YEAR
|
23
|
-
where("MONTH
|
22
|
+
where("EXTRACT(YEAR FROM #{date_field}) = :year", :year => options[:year]).
|
23
|
+
where("EXTRACT(MONTH FROM #{date_field}) = :month OR :month IS NULL", :month => options[:month])
|
24
24
|
end
|
25
25
|
|
26
26
|
# Constructs a single-level hash of years using the defined +date_field+ column.
|
@@ -37,7 +37,7 @@ module ArchiveTree
|
|
37
37
|
def archived_years
|
38
38
|
years = {}
|
39
39
|
where("#{date_field} IS NOT NULL").
|
40
|
-
group("YEAR
|
40
|
+
group("EXTRACT(YEAR FROM #{date_field})").size.each { |year, count| years[year.to_i] = count }
|
41
41
|
|
42
42
|
years
|
43
43
|
end # archived_years
|
@@ -65,8 +65,8 @@ module ArchiveTree
|
|
65
65
|
months = {}
|
66
66
|
month_format = options.delete(:month_names) || :int
|
67
67
|
|
68
|
-
where("YEAR
|
69
|
-
group("MONTH
|
68
|
+
where("EXTRACT(YEAR FROM #{date_field}) = #{options[:year] || Time.now.year}").
|
69
|
+
group("EXTRACT(MONTH FROM #{date_field})").size.each do |month, c|
|
70
70
|
key = case month_format
|
71
71
|
when :long
|
72
72
|
Date::MONTHNAMES[month.to_i]
|
@@ -141,7 +141,7 @@ module ArchiveTree
|
|
141
141
|
|
142
142
|
months.each do |month|
|
143
143
|
tree[year][month] = {}
|
144
|
-
tree[year][month] = archive_node year, month
|
144
|
+
tree[year][month] = archive_node(:year => year, :month => month)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.0.
|
9
|
+
- rc2
|
10
|
+
version: 1.0.0.rc2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Diogo Almeida
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-11-02 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|