icalendar-gcal 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +5 -5
- data/lib/icalendar/gcal.rb +2 -61
- data/lib/icalendar/gcal/google_calendar.rb +65 -0
- data/lib/icalendar/gcal/version.rb +5 -0
- metadata +15 -21
- data/.gitignore +0 -52
- data/.rspec +0 -3
- data/.travis.yml +0 -25
- data/Gemfile +0 -6
- data/Rakefile +0 -6
- data/icalendar-gcal.gemspec +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 786501b946d1ea2d3aec927a29d9b94b120305a8e17c87a29a818dd19aede514
|
4
|
+
data.tar.gz: c3349fdc75c35bc3abdd6c648b3b911b8a889cc9b6fa8db5f739e66b80e8e04c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d6db7651e2dbbefbf250dcf4709f38ff8ac95c2a39ef0353f31d22b58a711f5e155846c5e1a9866b79360934eaf1e08d0989c11b7f6c78f3a8d0ef3029b802
|
7
|
+
data.tar.gz: 1d95b72b7aa05249cb02315584b3e415ff8ba6b438efaf9d62c5436b426683efd305b7df63e0cafc377af31cedd6ebf706661dee879d1fc4ab90dfeacc356d6b
|
data/README.md
CHANGED
@@ -28,18 +28,18 @@ Or install it yourself as:
|
|
28
28
|
```ruby
|
29
29
|
require "icalendar/gcal"
|
30
30
|
|
31
|
-
gcal = Icalendar::
|
31
|
+
gcal = Icalendar::Google::Calendar.from_google_id("ht3jlfaac5lfd6263ulfh4tql8@group.calendar.google.com")
|
32
32
|
# or
|
33
|
-
gcal = Icalendar::
|
33
|
+
gcal = Icalendar::Google::Calendar.from_ical_url("https://calendar.google.com/calendar/ical/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic.ics")
|
34
34
|
|
35
35
|
gcal.google_id
|
36
|
-
# => "
|
36
|
+
# => "ht3jlfaac5lfd6263ulfh4tql8@group.calendar.google.com"
|
37
37
|
|
38
38
|
gcal.webcal_url
|
39
|
-
# => "webcal://calendar.google.com/calendar/ical/
|
39
|
+
# => "webcal://calendar.google.com/calendar/ical/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic.ics"
|
40
40
|
|
41
41
|
gcal.event_url(gcal.events.last)
|
42
|
-
# => "https://calendar.google.com/calendar/event?eid=
|
42
|
+
# => "https://calendar.google.com/calendar/event?eid=bW9vbnBoYXNlKzE1MTY4MzI0MDAwMDAgaHQzamxmYWFjNWxmZDYyNjN1bGZoNHRxbDhAZw"
|
43
43
|
```
|
44
44
|
|
45
45
|
## Development
|
data/lib/icalendar/gcal.rb
CHANGED
@@ -1,61 +1,2 @@
|
|
1
|
-
require "icalendar"
|
2
|
-
require "
|
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
|
1
|
+
require "icalendar/gcal/google_calendar"
|
2
|
+
require "icalendar/gcal/version"
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "icalendar"
|
2
|
+
require "net/http"
|
3
|
+
require "tzinfo"
|
4
|
+
|
5
|
+
module Icalendar
|
6
|
+
module Google
|
7
|
+
class Calendar < Icalendar::Calendar
|
8
|
+
ENDPOINT = "https://calendar.google.com/calendar"
|
9
|
+
|
10
|
+
attr_accessor :google_id, :ical_url
|
11
|
+
|
12
|
+
def cid
|
13
|
+
Base64.encode64(google_id.to_s).gsub(%r{\n|=+\Z}, "")
|
14
|
+
end
|
15
|
+
|
16
|
+
def eid(event)
|
17
|
+
seed = "#{event.uid.split(%r{@}).first} #{google_id&.slice(0, 28)}"
|
18
|
+
Base64.encode64(seed).gsub(%r{\n|=+\Z}, "")
|
19
|
+
end
|
20
|
+
|
21
|
+
def event_url(event)
|
22
|
+
"#{ENDPOINT}/event?eid=#{eid(event)}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def events_on(date)
|
26
|
+
events.select do |event|
|
27
|
+
start = tz.utc_to_local event.dtstart.to_datetime
|
28
|
+
stop = tz.utc_to_local event.dtend.to_datetime
|
29
|
+
start.to_date <= date && date <= stop.to_date
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def google_url
|
34
|
+
"#{ENDPOINT}/r?cid=#{cid}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def tz
|
38
|
+
TZInfo::Timezone.get(x_wr_timezone.first.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
def webcal_url
|
42
|
+
ical_url&.sub(%r{\Ahttps?://}, "webcal://")
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
def from_ical_url(url)
|
47
|
+
cid = url[%r{#{ENDPOINT}/ical/(.*?)/public/basic.ics}, 1]
|
48
|
+
uri = URI.parse(url)
|
49
|
+
res = Net::HTTP.get(uri)
|
50
|
+
cal = parse(res).first
|
51
|
+
cal&.ical_url = url
|
52
|
+
cal&.google_id = CGI.unescape(cid)
|
53
|
+
cal
|
54
|
+
end
|
55
|
+
|
56
|
+
def from_google_id(id)
|
57
|
+
url = "#{ENDPOINT}/ical/#{CGI::escape(id)}/public/basic.ics"
|
58
|
+
cal = from_ical_url(url)
|
59
|
+
cal&.google_id = id
|
60
|
+
cal
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar-gcal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Mancevice
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: icalendar
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tzinfo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '12.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '12.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,20 +115,15 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".gitignore"
|
119
|
-
- ".rspec"
|
120
|
-
- ".travis.yml"
|
121
|
-
- Gemfile
|
122
118
|
- LICENSE
|
123
119
|
- README.md
|
124
|
-
- Rakefile
|
125
|
-
- icalendar-gcal.gemspec
|
126
120
|
- lib/icalendar/gcal.rb
|
121
|
+
- lib/icalendar/gcal/google_calendar.rb
|
122
|
+
- lib/icalendar/gcal/version.rb
|
127
123
|
homepage: https://github.com/amancevice/icalendar-gcal
|
128
124
|
licenses:
|
129
125
|
- MIT
|
130
|
-
metadata:
|
131
|
-
allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
|
126
|
+
metadata: {}
|
132
127
|
post_install_message:
|
133
128
|
rdoc_options: []
|
134
129
|
require_paths:
|
@@ -144,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
139
|
- !ruby/object:Gem::Version
|
145
140
|
version: '0'
|
146
141
|
requirements: []
|
147
|
-
|
148
|
-
rubygems_version: 2.6.14.4
|
142
|
+
rubygems_version: 3.0.3
|
149
143
|
signing_key:
|
150
144
|
specification_version: 4
|
151
145
|
summary: GoogleCalendar extension for iCalendar gem
|
data/.gitignore
DELETED
@@ -1,52 +0,0 @@
|
|
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
DELETED
data/.travis.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3.8
|
4
|
-
- 2.4.6
|
5
|
-
- 2.5.5
|
6
|
-
- 2.6.3
|
7
|
-
before_install:
|
8
|
-
- gem install bundler -v 2.0.2
|
9
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
|
-
- chmod +x ./cc-test-reporter
|
11
|
-
- ./cc-test-reporter before-build
|
12
|
-
install:
|
13
|
-
- bundle install
|
14
|
-
script:
|
15
|
-
- rspec
|
16
|
-
after_script:
|
17
|
-
- ./cc-test-reporter after-build --exit-code ${TRAVIS_TEST_RESULT}
|
18
|
-
deploy:
|
19
|
-
provider: rubygems
|
20
|
-
api_key:
|
21
|
-
secure: oIQwTX17vACLZ+NSM35yNIBWZA9p0Rxsacg6tH95NZq5EKkaC3VA2w3sDADtQNSF2Hlu/q0UT7fuawpyhUojNTvzBwUKtAoHw0dpxqMpTcyuz5RaEWHGSD31DGTGFXsdgGusxBgevjXot6innungCZRlws+2yD2YCLpmaYQSam2PpjS3yy5eDbP1Gw5kR+asnVgLkSqj1wMbllLoJRxcZFu/giDoM12mXtWOEXSN6A9qOwuISaVs5GqUOVQ48ECvR0jJDX0p8f/D42AFOuU5O1TLGwdb9lgJBYBFKgj6FKZdkVR8qzAXwswHR9KmwInZY1EoIKj7+EYpc+t7XnUIqnk4GsDUCWKbBBsJg1sPDlhsrKeFnjoLEa+aeViu6PuJcQq1QqEo0qjixTOinHX3+3zOba1Bg/mSUnclu88aHiVzNnd9cUaNeXQceVmd63TJn86CBatZR4H52H6sO7T9N+qQL5wb3zRNBWgRMq49nHp2jczlD6FadgjuGmc8F1GSh6OC2n7Z45YvV/DCm+bHR/ywBw+JmCkjaF5/scbqG65JuPptYTcsAO8mfFxnss33AyhUUwUl7QWuP+Q42ak9kTpkAb0Q4DZVmhj735SHTXRe2OZF+DX2seLXDQtbwMtw23DmxMfRPdc2S+cWQc9S/hxQKzdlWSjoNrfEOhChP5s=
|
22
|
-
gem: icalendar-gcal
|
23
|
-
on:
|
24
|
-
tags: true
|
25
|
-
repo: amancevice/icalendar-gcal
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/icalendar-gcal.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
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.2.1"
|
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.required_ruby_version = Gem::Requirement.new(">= 2.2.0")
|
33
|
-
|
34
|
-
spec.add_runtime_dependency "icalendar", "~> 2.4"
|
35
|
-
spec.add_runtime_dependency "tzinfo", "~> 1.2"
|
36
|
-
|
37
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
38
|
-
spec.add_development_dependency "pry", "~> 0.11"
|
39
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
-
spec.add_development_dependency "simplecov", "~> 0.16"
|
42
|
-
end
|