icalendar-google 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/icalendar/google.rb +11 -0
- data/lib/icalendar/google/helpers.rb +43 -0
- data/lib/icalendar/google/parsers.rb +30 -0
- data/lib/icalendar/google/version.rb +5 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13de64abb6efa76bf863ec19edf1981094afc8789741884731de681d66511d1c
|
4
|
+
data.tar.gz: 279f6c8aaea08ff18b84fdc461c4cb36bb8dbd005e78af378b1d7091a481ea41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cf14f88a3fd41a7d1b88d6c7c1190af2a40ff93a0336f306a15033a8fa21bd2ccfa9ff1c131a3d891b948e76283656397af58f718ddfed6b8dbfe8978cf3b1d
|
7
|
+
data.tar.gz: 881fe8c5945d494a9684b805416a7a6da48311e0d870ec9de4738dd770922974c6c79ae80cb9e970c16d1610031ae04ff29d1618be413688d246ebbe430e3e46
|
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 Status](https://travis-ci.com/amancevice/icalendar-google.svg?branch=master)](https://travis-ci.com/amancevice/icalendar-google)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/icalendar-google.svg)](https://badge.fury.io/rb/icalendar-google)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/9262efaca53e186d1801/test_coverage)](https://codeclimate.com/github/amancevice/icalendar-google/test_coverage)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9262efaca53e186d1801/maintainability)](https://codeclimate.com/github/amancevice/icalendar-google/maintainability)
|
7
|
+
|
8
|
+
Google Calendar extension for iCalendar
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'icalendar-google'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install icalendar-google
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require "icalendar/google"
|
30
|
+
|
31
|
+
google_id = "ht3jlfaac5lfd6263ulfh4tql8@group.calendar.google.com"
|
32
|
+
public_url = "https://calendar.google.com/calendar/ical/#{CGI.escape google_id}/public/basic.ics"
|
33
|
+
|
34
|
+
gcal = Icalendar::Calendar.from_google_id(google_id).first
|
35
|
+
# or
|
36
|
+
gcal = Icalendar::Calendar.from_url(public_url).first
|
37
|
+
|
38
|
+
gcal.google_id
|
39
|
+
# => "ht3jlfaac5lfd6263ulfh4tql8@group.calendar.google.com"
|
40
|
+
|
41
|
+
gcal.webcal_url
|
42
|
+
# => "webcal://calendar.google.com/calendar/ical/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic.ics"
|
43
|
+
|
44
|
+
gcal.event_url(gcal.events.last)
|
45
|
+
# => "https://calendar.google.com/calendar/event?eid=bW9vbnBoYXNlKzE1MTY4MzI0MDAwMDAgaHQzamxmYWFjNWxmZDYyNjN1bGZoNHRxbDhAZw"
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/amancevice/icalendar-google.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "tzinfo"
|
3
|
+
|
4
|
+
module Icalendar
|
5
|
+
module Google
|
6
|
+
module Helpers
|
7
|
+
attr_accessor :google_id, :ical_url
|
8
|
+
|
9
|
+
def cid
|
10
|
+
Base64.encode64(@google_id.to_s).gsub(%r{\n|=+\Z}, "")
|
11
|
+
end
|
12
|
+
|
13
|
+
def eid(event)
|
14
|
+
seed = "#{event.uid.split(%r{@}).first} #{@google_id&.slice(0, 28)}"
|
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(x_wr_timezone.first.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
def webcal_url
|
39
|
+
ical_url&.sub(%r{\Ahttps?://}, "webcal://")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module Icalendar
|
4
|
+
module Google
|
5
|
+
module Parsers
|
6
|
+
def from_google_id(id)
|
7
|
+
cid = CGI.escape(id)
|
8
|
+
url = "https://calendar.google.com/calendar/ical/#{cid}/public/basic.ics"
|
9
|
+
from_url(url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_url(url)
|
13
|
+
cid = url[%r{https://calendar.google.com/calendar/ical/(.*?)/public/basic.ics}, 1]
|
14
|
+
uri = URI.parse(url)
|
15
|
+
ssl = uri.scheme == "https"
|
16
|
+
# require "pry"; binding.pry
|
17
|
+
body = Net::HTTP.start(uri.host, uri.port, use_ssl: ssl) do |http|
|
18
|
+
req = Net::HTTP::Get.new(uri.request_uri)
|
19
|
+
res = http.request(req)
|
20
|
+
enc = res['content-type'][%r{charset=(.*)}, 1]
|
21
|
+
enc.nil? ? res.body : res.body.force_encoding(enc)
|
22
|
+
end
|
23
|
+
Calendar.parse(body).each do |calendar|
|
24
|
+
calendar.ical_url = url
|
25
|
+
calendar.google_id = CGI.unescape(cid)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: icalendar-google
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Mancevice
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: icalendar
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tzinfo
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.16'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.16'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.7'
|
125
|
+
description: Parse GoogleCalenders into iCalendar objects from ID or public iCal URL
|
126
|
+
email:
|
127
|
+
- alexander.mancevice@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- LICENSE
|
133
|
+
- README.md
|
134
|
+
- lib/icalendar/google.rb
|
135
|
+
- lib/icalendar/google/helpers.rb
|
136
|
+
- lib/icalendar/google/parsers.rb
|
137
|
+
- lib/icalendar/google/version.rb
|
138
|
+
homepage: https://github.com/amancevice/icalendar-google
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 2.2.0
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.0.3
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: GoogleCalendar extension for iCalendar gem
|
161
|
+
test_files: []
|