icalendar-gcal 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 930d9a4120547cb9b187322e4922f6d421c6d83b0b7661f90e1d251364cf7394
4
+ data.tar.gz: 92c6ccec2a278b6ef6d0dae166c311423bbbc57b8e86eed002ec36dfd365c78b
5
+ SHA512:
6
+ metadata.gz: 1099cffb9818a4c5758996a66446697853638d50a22f1cef85cd6df5b8f526a469bcf23b9cce520a13f63253b99d3d220352f30fb1258c50e4b25580d0319ef6
7
+ data.tar.gz: 29ec192191d772425a9b1fac22a90334cf9127e4298f10b5b4ef97b1307dc0095a4327e6ca97c4fe640b8f60302f77f6a04f8d0af395b870736f95fd17956935
data/.gitignore ADDED
@@ -0,0 +1,52 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.5.1
4
+ before_install:
5
+ - gem install bundler -v 1.16.1
6
+ install:
7
+ - bundle install
8
+ script:
9
+ - bundle exec rspec
10
+ deploy:
11
+ provider: rubygems
12
+ api_key:
13
+ secure: oIQwTX17vACLZ+NSM35yNIBWZA9p0Rxsacg6tH95NZq5EKkaC3VA2w3sDADtQNSF2Hlu/q0UT7fuawpyhUojNTvzBwUKtAoHw0dpxqMpTcyuz5RaEWHGSD31DGTGFXsdgGusxBgevjXot6innungCZRlws+2yD2YCLpmaYQSam2PpjS3yy5eDbP1Gw5kR+asnVgLkSqj1wMbllLoJRxcZFu/giDoM12mXtWOEXSN6A9qOwuISaVs5GqUOVQ48ECvR0jJDX0p8f/D42AFOuU5O1TLGwdb9lgJBYBFKgj6FKZdkVR8qzAXwswHR9KmwInZY1EoIKj7+EYpc+t7XnUIqnk4GsDUCWKbBBsJg1sPDlhsrKeFnjoLEa+aeViu6PuJcQq1QqEo0qjixTOinHX3+3zOba1Bg/mSUnclu88aHiVzNnd9cUaNeXQceVmd63TJn86CBatZR4H52H6sO7T9N+qQL5wb3zRNBWgRMq49nHp2jczlD6FadgjuGmc8F1GSh6OC2n7Z45YvV/DCm+bHR/ywBw+JmCkjaF5/scbqG65JuPptYTcsAO8mfFxnss33AyhUUwUl7QWuP+Q42ak9kTpkAb0Q4DZVmhj735SHTXRe2OZF+DX2seLXDQtbwMtw23DmxMfRPdc2S+cWQc9S/hxQKzdlWSjoNrfEOhChP5s=
14
+ gem: icalendar-gcal
15
+ on:
16
+ tags: true
17
+ repo: amancevice/icalendar-gcal
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in icalendar-gcal.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ icalendar-gcal (0.1.0)
5
+ icalendar (~> 2.4)
6
+ tzinfo (~> 1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.2)
12
+ diff-lcs (1.3)
13
+ icalendar (2.4.1)
14
+ method_source (0.9.0)
15
+ pry (0.11.3)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.9.0)
18
+ rake (10.5.0)
19
+ rspec (3.7.0)
20
+ rspec-core (~> 3.7.0)
21
+ rspec-expectations (~> 3.7.0)
22
+ rspec-mocks (~> 3.7.0)
23
+ rspec-core (3.7.1)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-expectations (3.7.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.7.0)
28
+ rspec-mocks (3.7.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.7.0)
31
+ rspec-support (3.7.1)
32
+ thread_safe (0.3.6)
33
+ tzinfo (1.2.5)
34
+ thread_safe (~> 0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ bundler (~> 1.16)
41
+ icalendar-gcal!
42
+ pry (~> 0.11)
43
+ rake (~> 10.0)
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Alexander Mancevice
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Google iCalendar
2
+
3
+ [![build](https://travis-ci.org/amancevice/icalendar-gcal.svg?branch=master)](https://travis-ci.org/amancevice/icalendar-gcal)
4
+
5
+ Google Calendar extension for iCalendar
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'icalendar-gcal'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install icalendar-gcal
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require "icalendar/gcal"
27
+
28
+ gcal = GoogleCalendar.from_google_id("abcdefghijklmnopqrstuvwxyz@group.calendar.google.com")
29
+ # or
30
+ gcal = GoogleCalendar.from_ical_url("https://calendar.google.com/calendar/ical/abcdefghijklmnopqrstuvwxyz%40group.calendar.google.com/public/basic.ics")
31
+
32
+ gcal.google_id
33
+ # => "abcdefghijklmnopqrstuvwxyz@group.calendar.google.com"
34
+
35
+ gcal.webcal_url
36
+ # => "webcal://calendar.google.com/calendar/ical/abcdefghijklmnopqrstuvwxyz%40group.calendar.google.com/public/basic.ics"
37
+
38
+ gcal.event_url(gcal.events.last)
39
+ # => "https://calendar.google.com/calendar/event?eid=YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXogYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpAZw"
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/amancevice/icalendar-gcal.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "icalendar-gcal"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Alexander Mancevice"]
9
+ spec.email = ["alexander.mancevice@gmail.com"]
10
+
11
+ spec.summary = %q{GoogleCalendar extension for iCalendar gem}
12
+ spec.description = %q{Parse GoogleCalenders into iCalendar objects from ID or public iCal URL}
13
+ spec.homepage = "https://github.com/amancevice/icalendar-gcal"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "pry", "~> 0.11"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_dependency "icalendar", "~> 2.4"
38
+ spec.add_dependency "tzinfo", "~> 1.2"
39
+ end
@@ -0,0 +1,61 @@
1
+ require "icalendar"
2
+ require "net/http"
3
+ require "tzinfo"
4
+
5
+ module Icalendar
6
+ class GoogleCalendar < Icalendar::Calendar
7
+ attr_accessor :google_id, :ical_url
8
+
9
+ def cid
10
+ Base64.encode64(google_id).gsub(%r{\n|=+\Z}, "")
11
+ end
12
+
13
+ def eid(event)
14
+ seed = "#{event.uid.split(%r{@}).first} #{google_id[0..27]}"
15
+ Base64.encode64(seed).gsub(%r{\n|=+\Z}, "")
16
+ end
17
+
18
+ def event_url(event)
19
+ "https://calendar.google.com/calendar/event?eid=#{eid event}"
20
+ end
21
+
22
+ def events_on(date)
23
+ events.select do |event|
24
+ start = tz.utc_to_local event.dtstart.to_datetime
25
+ stop = tz.utc_to_local event.dtend.to_datetime
26
+ start.to_date <= date && date <= stop.to_date
27
+ end
28
+ end
29
+
30
+ def google_url
31
+ "https://calendar.google.com/calendar/r?cid=#{cid}"
32
+ end
33
+
34
+ def tz
35
+ TZInfo::Timezone.get self.x_wr_timezone.first
36
+ end
37
+
38
+ def webcal_url
39
+ ical_url.sub(%r{\Ahttps?://}, "webcal://")
40
+ end
41
+
42
+ class << self
43
+ def from_ical_url(url)
44
+ cid = url[%r{https://calendar.google.com/calendar/ical/(.*?)/public/basic.ics}, 1]
45
+ uri = URI.parse(url)
46
+ res = Net::HTTP.get(uri)
47
+ cal = self.parse(res).first
48
+ cal&.ical_url = url
49
+ cal&.google_id = CGI.unescape(cid)
50
+ cal
51
+ end
52
+
53
+ def from_google_id(id)
54
+ url = "https://calendar.google.com/calendar/ical/#{CGI::escape id}/public/basic.ics"
55
+ cal = from_ical_url(url)
56
+ cal&.google_id = id
57
+ cal
58
+ end
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icalendar-gcal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Mancevice
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: icalendar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tzinfo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ description: Parse GoogleCalenders into iCalendar objects from ID or public iCal URL
98
+ email:
99
+ - alexander.mancevice@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - icalendar-gcal.gemspec
113
+ - lib/icalendar/gcal.rb
114
+ homepage: https://github.com/amancevice/icalendar-gcal
115
+ licenses:
116
+ - MIT
117
+ metadata:
118
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.7.6
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: GoogleCalendar extension for iCalendar gem
139
+ test_files: []