table_builder 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .DS_Store
2
- pkg
2
+ pkg
3
+ *.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -44,7 +44,7 @@ module CalendarHelper
44
44
  options[:class] = css.join(' ')
45
45
  options[:id] = day.strftime(id_pattern) if id_pattern
46
46
 
47
- options.delete_if{ |k,v| v.blank? }
47
+ options.delete_if{ |k,v| v.blank? }
48
48
  options
49
49
  end
50
50
 
@@ -64,12 +64,14 @@ module CalendarHelper
64
64
  end
65
65
 
66
66
  def each_day &block
67
- (first_day..last_day).map(&block)
67
+ (first_day..last_day).map &block
68
68
  end
69
69
 
70
- def objects_for_days objects, &day_method
71
- objects = objects.group_by(&day_method)
72
- each_day { |day| [day, objects[day] || []] }
70
+ def objects_for_days objects
71
+ objects = objects.group_by{ |o| yield(o).strftime "%Y-%m-%d" }
72
+ each_day do |day|
73
+ [day, objects[day.strftime("%Y-%m-%d")] || []]
74
+ end
73
75
  end
74
76
 
75
77
  def days
@@ -5,7 +5,7 @@ class CalendarHelperTest < ActionView::TestCase
5
5
 
6
6
  def setup
7
7
  @events = [
8
- Event.new(3, 'Jimmy Page', Date.civil(2008, 12, 26)),
8
+ Event.new(3, 'Jimmy Page', DateTime.civil(2008, 12, 26, 1)), # In case is an hour of that day
9
9
  Event.new(4, 'Robert Plant', Date.civil(2008, 12, 26))
10
10
  ]
11
11
  end
@@ -28,6 +28,14 @@ class CalendarHelperTest < ActionView::TestCase
28
28
  end
29
29
  assert_equal objects_for_days, calendar.objects_for_days(@events, &:date)
30
30
  end
31
+
32
+ should 'return objects_for_days with days accepting a block' do
33
+ calendar = CalendarHelper::Calendar.new :year=> 2008, :month => 12
34
+ objects_for_days = (Date.civil(2008, 11, 30)..Date.civil(2009, 1, 3)).map do |day|
35
+ [day, Date.civil(2008, 12, 26) == day ? @events : []]
36
+ end
37
+ assert_equal objects_for_days, calendar.objects_for_days(@events){ |o| o.date }
38
+ end
31
39
 
32
40
  should 'map day range for calendar' do
33
41
  calendar = CalendarHelper::Calendar.new(:year=> 2008, :month => 12)
@@ -53,7 +61,6 @@ class CalendarHelperTest < ActionView::TestCase
53
61
  calendar = CalendarHelper::Calendar.new(:year=> 2008, :month => 12, :first_weekday => 1)
54
62
  assert_equal Date.civil(2009, 1, 4), calendar.last_day
55
63
  end
56
-
57
64
  end
58
65
 
59
66
  context 'ERB Rendering' do
data/test/test_helper.rb CHANGED
@@ -14,3 +14,10 @@ require "#{ File.dirname(__FILE__) }/../lib/table_builder"
14
14
 
15
15
  class Drummer < Struct.new(:id, :name); end
16
16
  class Event < Struct.new(:id, :name, :date); end
17
+
18
+ # Stub!!
19
+ module ActiveRecord
20
+ module NamedScope
21
+ class Scope < Array; end
22
+ end
23
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Petrik de Heus
@@ -37,7 +37,6 @@ files:
37
37
  - lib/table_builder.rb
38
38
  - lib/table_builder/calendar_helper.rb
39
39
  - lib/table_builder/table_builder.rb
40
- - table_builder.gemspec
41
40
  - test/calendar_helper_test.rb
42
41
  - test/table_builder_test.rb
43
42
  - test/test_helper.rb
@@ -1,55 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{table_builder}
8
- s.version = "0.2.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Petrik de Heus"]
12
- s.date = %q{2010-07-05}
13
- s.description = %q{Rails builder for creating tables and calendars inspired by ActionView's FormBuilder.}
14
- s.email = %q{}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".autotest",
20
- ".gitignore",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "init.rb",
26
- "lib/table_builder.rb",
27
- "lib/table_builder/calendar_helper.rb",
28
- "lib/table_builder/table_builder.rb",
29
- "table_builder.gemspec",
30
- "test/calendar_helper_test.rb",
31
- "test/table_builder_test.rb",
32
- "test/test_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/maca/table_builder}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.6}
38
- s.summary = %q{Rails builder for creating tables and calendars inspired by ActionView's FormBuilder.}
39
- s.test_files = [
40
- "test/calendar_helper_test.rb",
41
- "test/table_builder_test.rb",
42
- "test/test_helper.rb"
43
- ]
44
-
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
- else
51
- end
52
- else
53
- end
54
- end
55
-