event-calendar 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGELOG.rdoc +38 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +274 -0
  4. data/Rakefile +37 -0
  5. data/VERSION +1 -0
  6. data/generators/event_calendar/USAGE +20 -0
  7. data/generators/event_calendar/event_calendar_generator.rb +50 -0
  8. data/generators/event_calendar/lib/insert_routes.rb +55 -0
  9. data/generators/event_calendar/templates/controller.rb.erb +12 -0
  10. data/generators/event_calendar/templates/helper.rb.erb +35 -0
  11. data/generators/event_calendar/templates/javascript.js +49 -0
  12. data/generators/event_calendar/templates/jq_javascript.js +35 -0
  13. data/generators/event_calendar/templates/migration.rb.erb +18 -0
  14. data/generators/event_calendar/templates/model.rb.erb +4 -0
  15. data/generators/event_calendar/templates/stylesheet.css +233 -0
  16. data/generators/event_calendar/templates/view.html.erb +6 -0
  17. data/init.rb +2 -0
  18. data/install.rb +1 -0
  19. data/lib/event_calendar.rb +189 -0
  20. data/lib/event_calendar/calendar_helper.rb +366 -0
  21. data/lib/event_calendar/railtie.rb +12 -0
  22. data/lib/generators/event_calendar/USAGE +20 -0
  23. data/lib/generators/event_calendar/event_calendar_generator.rb +92 -0
  24. data/lib/generators/event_calendar/templates/controller.rb.erb +12 -0
  25. data/lib/generators/event_calendar/templates/helper.rb.erb +35 -0
  26. data/lib/generators/event_calendar/templates/javascript.js +49 -0
  27. data/lib/generators/event_calendar/templates/jq_javascript.js +35 -0
  28. data/lib/generators/event_calendar/templates/migration.rb.erb +21 -0
  29. data/lib/generators/event_calendar/templates/model.rb.erb +3 -0
  30. data/lib/generators/event_calendar/templates/stylesheet.css +233 -0
  31. data/lib/generators/event_calendar/templates/view.html.erb +6 -0
  32. data/lib/tasks/event_calendar_tasks.rake +4 -0
  33. data/spec/event_calendar_spec.rb +78 -0
  34. data/spec/fixtures/models.rb +6 -0
  35. data/spec/spec.opts +3 -0
  36. data/spec/spec_helper.rb +30 -0
  37. data/uninstall.rb +1 -0
  38. metadata +105 -0
@@ -0,0 +1,6 @@
1
+ <!-- Probably move the stylesheet to you layout. Also make sure you include the javascript. -->
2
+ <%%= stylesheet_link_tag "event_calendar" %>
3
+
4
+ <h1>Calendar</h1>
5
+
6
+ <%%= raw(event_calendar) %>
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :event_calendar do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "event calendars" do
4
+ before(:each) do
5
+ @time = DateTime.new
6
+ end
7
+
8
+ context "setup" do
9
+ it "should find the event model" do
10
+ time = DateTime.now
11
+ event = Event.new
12
+ event.start_at = time
13
+ event.end_at = time
14
+ event.start_at.should eql( time )
15
+ event.end_at.should eql( time )
16
+ end
17
+
18
+ it "should load plugin" do
19
+ lambda { Event.has_event_calendar }.should_not raise_error
20
+ end
21
+
22
+ it "should use start_at for default field" do
23
+ Event.start_at_field.should eql('start_at')
24
+ end
25
+
26
+ it "should use end_at for default field" do
27
+ Event.end_at_field.should eql('end_at')
28
+ end
29
+ end
30
+
31
+ context "not overriding fields" do
32
+ it "should not alias the start_at method" do
33
+ event = Event.new
34
+ event.start_at = @time
35
+ event.start_at.should eql( @time )
36
+ end
37
+ it "should not alias the end_at method" do
38
+ event = Event.new
39
+ event.end_at = @time
40
+ event.end_at.should eql( @time )
41
+ end
42
+ context "generating database queries" do
43
+ it "should rely on the standard fields" do
44
+ yesterday = DateTime.now - 1.day
45
+ tomorrow = DateTime.now + 1.day
46
+ event = Event.create(:start_at => yesterday, :end_at => tomorrow)
47
+ Event.events_for_date_range((Date.today - 1.week ), (Date.today + 1.week)).should eql(
48
+ [ event ]
49
+ )
50
+ end
51
+ end
52
+ end
53
+
54
+ context "overriding fields" do
55
+ it "should alias the start_at method" do
56
+ event = CustomEvent.new
57
+ event.custom_start_at = @time
58
+ event.custom_start_at.should eql( @time )
59
+ event.start_at.should eql( @time )
60
+ end
61
+ it "should alias the end_at method" do
62
+ event = CustomEvent.new
63
+ event.custom_end_at = @time
64
+ event.custom_end_at.should eql( @time )
65
+ event.end_at.should eql( @time )
66
+ end
67
+ context "generating database queries" do
68
+ it "should rely on the overridden fields" do
69
+ yesterday = DateTime.now - 1.day
70
+ tomorrow = DateTime.now + 1.day
71
+ event = CustomEvent.create(:custom_start_at => yesterday, :custom_end_at => tomorrow)
72
+ CustomEvent.events_for_date_range((Date.today - 1.week ), (Date.today + 1.week)).should eql(
73
+ [ event ]
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,6 @@
1
+ class CustomEvent < ActiveRecord::Base
2
+ has_event_calendar :start_at_field => 'custom_start_at', :end_at_field => 'custom_end_at'
3
+ end
4
+
5
+ class Event < ActiveRecord::Base
6
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format
3
+ specdoc
@@ -0,0 +1,30 @@
1
+ ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + '/../../../..'
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ #require File.expand_path(File.dirname(ENV['RAILS_ROOT']) + "/config/environment")
5
+ require 'rubygems'
6
+ require 'spec'
7
+
8
+ require 'active_record'
9
+ require 'action_controller'
10
+ require 'action_view'
11
+
12
+
13
+ require 'event_calendar'
14
+ require 'event_calendar/calendar_helper'
15
+
16
+ require File.dirname(__FILE__) + '/../init.rb'
17
+ require 'spec/fixtures/models'
18
+
19
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
20
+ ActiveRecord::Migration.verbose = false
21
+ ActiveRecord::Schema.define(:version => 0) do
22
+ create_table :events do |t|
23
+ t.column :start_at, :datetime
24
+ t.column :end_at, :datetime
25
+ end
26
+ create_table :custom_events do |t|
27
+ t.column :custom_start_at, :datetime
28
+ t.column :custom_end_at, :datetime
29
+ end
30
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: event-calendar
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 3
9
+ - 1
10
+ version: 2.3.1
11
+ platform: ruby
12
+ authors:
13
+ - Jeff Schuil
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-17 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Rails helper for generating a calendar of events. These events can optionally span multiple days.
23
+ email: ""
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - CHANGELOG.rdoc
32
+ - MIT-LICENSE
33
+ - README.rdoc
34
+ - Rakefile
35
+ - VERSION
36
+ - generators/event_calendar/USAGE
37
+ - generators/event_calendar/event_calendar_generator.rb
38
+ - generators/event_calendar/lib/insert_routes.rb
39
+ - generators/event_calendar/templates/controller.rb.erb
40
+ - generators/event_calendar/templates/helper.rb.erb
41
+ - generators/event_calendar/templates/javascript.js
42
+ - generators/event_calendar/templates/jq_javascript.js
43
+ - generators/event_calendar/templates/migration.rb.erb
44
+ - generators/event_calendar/templates/model.rb.erb
45
+ - generators/event_calendar/templates/stylesheet.css
46
+ - generators/event_calendar/templates/view.html.erb
47
+ - init.rb
48
+ - install.rb
49
+ - lib/event_calendar.rb
50
+ - lib/event_calendar/calendar_helper.rb
51
+ - lib/event_calendar/railtie.rb
52
+ - lib/generators/event_calendar/USAGE
53
+ - lib/generators/event_calendar/event_calendar_generator.rb
54
+ - lib/generators/event_calendar/templates/controller.rb.erb
55
+ - lib/generators/event_calendar/templates/helper.rb.erb
56
+ - lib/generators/event_calendar/templates/javascript.js
57
+ - lib/generators/event_calendar/templates/jq_javascript.js
58
+ - lib/generators/event_calendar/templates/migration.rb.erb
59
+ - lib/generators/event_calendar/templates/model.rb.erb
60
+ - lib/generators/event_calendar/templates/stylesheet.css
61
+ - lib/generators/event_calendar/templates/view.html.erb
62
+ - lib/tasks/event_calendar_tasks.rake
63
+ - spec/event_calendar_spec.rb
64
+ - spec/fixtures/models.rb
65
+ - spec/spec.opts
66
+ - spec/spec_helper.rb
67
+ - uninstall.rb
68
+ has_rdoc: true
69
+ homepage: http://github.com/elevation/event_calendar
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Rails helper for generating a calendar of events.
102
+ test_files:
103
+ - spec/event_calendar_spec.rb
104
+ - spec/fixtures/models.rb
105
+ - spec/spec_helper.rb