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.
@@ -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=>[:preview_month], :date=>Mon, 26 Oct 2009},
20
- {:types=>[:preview_month], :date=>Tue, 27 Oct 2009},
21
- {:types=>[:preview_month], :date=>Wed, 28 Oct 2009},
22
- {:types=>[:preview_month], :date=>Thu, 29 Oct 2009},
23
- {:types=>[:preview_month], :date=>Fri, 30 Oct 2009},
24
- {:types=>[:preview_month, :weekend], :date=>Sat, 31 Oct 2009},
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, :preview_month, :date_method, :next_month
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
- @preview_month = options[:preview_month] || :preview_month
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
- [days_to_preview_month,days_to_current_month,days_to_next_month].flatten
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 days_to_preview_month
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
- fill_days.times do |time|
40
- days << day_and_types(first_day_of_month - (6 - time).day, [@preview_month])
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
@@ -3,7 +3,7 @@ module DataCalendar
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 2
6
+ TINY = 3
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -29,9 +29,11 @@ class DataCalendarTest < Test::Unit::TestCase
29
29
  # TODO [:events]
30
30
  end
31
31
 
32
- should "return its days to preview 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_preview_month.map{|x| x[:date].to_s}
34
- #assert_equal [[:preview_month], [:preview_month], [:preview_month], [:preview_month], [:preview_month], [:preview_month, :weekend]], @calendar.days_to_preview_month.map{|x| x[:types]}
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.2
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-11-23 00:00:00 +01:00
12
+ date: 2009-12-24 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency