data_calendar 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/README.rdoc +6 -6
- data/lib/data_calendar/data_calendar.rb +10 -9
- data/lib/data_calendar/version.rb +1 -1
- data/test/unit/data_calendar_test.rb +5 -3
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -16,12 +16,12 @@ Generates the data needed to represent a given schedule a calendar.
|
|
16
16
|
|
17
17
|
pp dc.all_days #=>
|
18
18
|
|
19
|
-
[{:types=>[:
|
20
|
-
{:types=>[:
|
21
|
-
{:types=>[:
|
22
|
-
{:types=>[:
|
23
|
-
{:types=>[:
|
24
|
-
{:types=>[:
|
19
|
+
[{:types=>[:previous_month], :date=>Mon, 26 Oct 2009},
|
20
|
+
{:types=>[:previous_month], :date=>Tue, 27 Oct 2009},
|
21
|
+
{:types=>[:previous_month], :date=>Wed, 28 Oct 2009},
|
22
|
+
{:types=>[:previous_month], :date=>Thu, 29 Oct 2009},
|
23
|
+
{:types=>[:previous_month], :date=>Fri, 30 Oct 2009},
|
24
|
+
{:types=>[:previous_month, :weekend], :date=>Sat, 31 Oct 2009},
|
25
25
|
{:types=>[:weekend], :date=>Sun, 01 Nov 2009},
|
26
26
|
{:types=>[], :date=>Mon, 02 Nov 2009},
|
27
27
|
{:types=>[], :date=>Tue, 03 Nov 2009},
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class DataCalendar
|
2
2
|
|
3
|
-
attr_accessor :events, :
|
3
|
+
attr_accessor :events, :previous_month, :date_method, :next_month
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
6
|
@date = options[:date]
|
7
7
|
@date = @date.to_date
|
8
|
-
@
|
8
|
+
@previous_month = options[:previous_month] || :previous_month
|
9
9
|
@date_method = options[:date_method] || :start_at
|
10
10
|
@next_month = options[:next_month] || :next_month
|
11
11
|
@events = options[:events] || []
|
@@ -14,7 +14,7 @@ class DataCalendar
|
|
14
14
|
|
15
15
|
|
16
16
|
def all_days
|
17
|
-
[
|
17
|
+
[days_to_previous_month,days_to_current_month,days_to_next_month].flatten
|
18
18
|
end
|
19
19
|
|
20
20
|
# Return the days of the current week
|
@@ -29,15 +29,16 @@ class DataCalendar
|
|
29
29
|
days_of_week
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def days_to_previous_month
|
33
33
|
fill_days = first_day_of_month.wday
|
34
|
-
fill_days = 7 if fill_days == 0
|
34
|
+
fill_days = 7 if fill_days == 0
|
35
35
|
fill_days -= 1
|
36
|
-
first_day_of_month - fill_days.days
|
37
36
|
|
38
|
-
days = []
|
39
|
-
|
40
|
-
|
37
|
+
days = []
|
38
|
+
fill_array = []
|
39
|
+
fill_days.times{|e| fill_array << e + 1}
|
40
|
+
fill_array.reverse.each do |time|
|
41
|
+
days << day_and_types(first_day_of_month - time.day, [@previous_month])
|
41
42
|
end
|
42
43
|
days
|
43
44
|
end
|
@@ -29,9 +29,11 @@ class DataCalendarTest < Test::Unit::TestCase
|
|
29
29
|
# TODO [:events]
|
30
30
|
end
|
31
31
|
|
32
|
-
should "return its days to
|
33
|
-
assert_equal ["2009-10-26", "2009-10-27", "2009-10-28", "2009-10-29", "2009-10-30", "2009-10-31"], @calendar.
|
34
|
-
|
32
|
+
should "return its days to previous month" do
|
33
|
+
assert_equal ["2009-10-26", "2009-10-27", "2009-10-28", "2009-10-29", "2009-10-30", "2009-10-31"], @calendar.days_to_previous_month.map{|x| x[:date].to_s}
|
34
|
+
dic_calendar = DataCalendar.new(:date => Date.parse('2009-12-5'))
|
35
|
+
assert_equal ["2009-11-30"], dic_calendar.days_to_previous_month.map{|x| x[:date].to_s}
|
36
|
+
#assert_equal [[:previous_month], [:previous_month], [:previous_month], [:previous_month], [:previous_month], [:previous_month, :weekend]], @calendar.days_to_previous_month.map{|x| x[:types]}
|
35
37
|
# TODO [:events]
|
36
38
|
end
|
37
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Galisteo Ruiz"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-24 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|