Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
MDaubs committed May 3, 2011
1 parent 9bd1445 commit c631361
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -5,9 +5,12 @@ source "http://rubygems.org"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
gem "rails"
gem "ri_cal"
group :development do
gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.0"
gem "rcov", ">= 0"
gem "sqlite3"
end
23 changes: 20 additions & 3 deletions README.rdoc
@@ -1,6 +1,24 @@
= recurring_helpers

Description goes here.
This is a gem intended for private consumption! You are welcome to use it but I suggest you fork it first. Things may suddenly and drastically change on a whime!

== What's this for?

Recurring_helpers is a library of various tools for dealing with recurring events. It is essentially glue between an application's event-like model, the event-calendar gem, and the ri_cal gem. Some of the superpowers it gives event-like models are iCal export, recurring occurrence caching, and conflict detection. As a bonus you also get some view helpers for making it easier to deal with recurring event rules.

== Setup your event-like model

class Event < ActiveModel::Base
# The EventOccurrence model is updated automatically when Event is saved
has_many :event_occurrences
# The EventRule model should be user-updatable, it's attributes being directly set by a user interface
has_many :event_rules
# The is_recurring macro extends Event so that when it is saved an iCal file is generated, cached into the attribute cached_ical, and the event_occurrences collection is generated based on the rules, start, and end times. The event_occurrences collection should not be modified by the end user and treated as a read-only cache. The purpose of this is to simplify the logic needed by event-calendar to draw a pretty calendar. It allows event occurrences to be queried with little effort at the expense of a slightly more expensive save action.
is_recurring
end

== Setup your user interface


== Contributing to recurring_helpers

Expand All @@ -14,6 +32,5 @@ Description goes here.

== Copyright

Copyright (c) 2011 MDaubs. See LICENSE.txt for
further details.
Copyright (c) 2011 Matthew Daubert. See LICENSE.txt for further details.

4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "recurring_helpers"
gem.homepage = "http://github.com/mdaubs/recurring_helpers"
gem.license = "MIT"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.summary = %Q{Give event-like models super-human recurring powers. Includes iCal export, interface helpers for recurrence rules, and view helpers for event-calendar.}
gem.description = %Q{Give event-like models super-human recurring powers. Includes iCal export, interface helpers for recurrence rules, and view helpers for event-calendar.}
gem.email = "mdaubert@gmail.com"
gem.authors = ["MDaubs"]
# dependencies defined in Gemfile
Expand Down
14 changes: 14 additions & 0 deletions lib/recurring_helpers.rb
@@ -0,0 +1,14 @@
require 'rails'
require 'tzinfo'
require 'active_support/all'
require 'ri_cal'
require 'active_record'
require 'recurring_helpers/rails'

module RecurringHelpers
autoload :RecurringModel, 'recurring_helpers/recurring_model'
autoload :ActiveRecord, 'recurring_helpers/active_record'

end

ActiveRecord::Base.extend RecurringHelpers::ActiveRecord
29 changes: 28 additions & 1 deletion test/helper.rb
Expand Up @@ -14,5 +14,32 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'recurring_helpers'

class Test::Unit::TestCase
#Setup defaults otherwise set by Rails
Time.zone = "America/New_York"

#Setup test database
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Schema.define(:version => 1) do
create_table :events do |t|
t.string :description
t.string :summary
t.datetime :start_at
t.datetime :end_at
t.boolean :all_day, :default => false
t.text :cached_ical
end
create_table :event_occurrences do |t|
t.datetime :start_at
t.datetime :end_at
t.integer :event_id
end
create_table :event_rules do |t|
t.integer :count
t.datetime :until
t.string :freq
t.integer :interval
t.string :wkst
t.boolean :exclusion
t.integer :event_id
end
end
5 changes: 1 addition & 4 deletions test/test_recurring_helpers.rb
@@ -1,7 +1,4 @@
require 'helper'

class TestRecurringHelpers < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
class TestRecurringHelpers < ActiveSupport::TestCase
end

0 comments on commit c631361

Please sign in to comment.