Socket
Book a DemoInstallSign in
Socket

add_to_google_cal

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add_to_google_cal

bundlerRubygems
Version
1.0.0
Version published
Maintainers
1
Created
Source

AddToGoogleCal

A view layer helper which takes an object (such as an ActiveRecord instance from your database) and generates an "Add To Google Calendar" URL based on it's attributes.

This follows the ISO RFC-2445 calendar standard of using dtstart, dtend, summary, etc. You can customize these fields to match your implementation (ie. start_date, end_date, event_name, etc). Details on this below.

Installation

Add this line to your application's Gemfile:

gem 'add_to_google_cal'

And then execute:

$ bundle

Or install it yourself as:

$ gem install add_to_google_cal

Usage

ActiveRecord:

class Wedding < AR::Base

  has_google_cal

end

Wedding.first.to_google_cal

# TODO: Support custom column names, ie:
has_google_cal {
  :dtstart_attribute => 'crazy_date_start_column_name'
}

Generic Object:

require 'ostruct'
object = OpenStruct.new({
  :summary => "Super awesome event coming up in 2009, y'all!",
  :dtstart => '2019-03-07'
})

AddToGoogleCal::Builder.new(object).call
=> "https://www.google.com/calendar/render?action=TEMPLATE&dates=20190726T000000Z/20190726T000000Z& ..." (or something like this)

Ruby Hash:

attributes = {
  {
    dtstart: Time.utc(2013, 01, 03, 12, 00),
    dtend:   Time.utc(2013, 01, 03, 14, 00),
    summary: 'This is the Title of the Event'
  }
}

AddToGoogleCal::Builder.new(attributes).call
=> 'https://www.google.com/calendar/render?action=TEMPLATE&dates=20130103T120000Z/20130103T140000Z&text=This+is+the+Title+of+the+Event'

erb might look like:

<%= link_to("Add To Google Calendar", AddToGoogleCal.new(object).call) %>

TODO:

  • Handle converting various types of date/time objects

    • Finish the argument validation for required fields
  • Support objects / structs

  • Finish implementing the ActiveRecord hook

  • Support custom column names in has_google_cal AR mixin

Thanks To

@pcreux and everyone else who has colloborated / paired on this project.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Why?

I was working on Handcrafted Video Wedding Invites and this project was born out of a need to allow wedding guests quickly adding a wedding event to their Google Calendar.

http://www.craftedtoyou.com/

FAQs

Package last updated on 04 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts