gcal 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 837641f28f292af5d5be45ebe8db173894445185
4
+ data.tar.gz: 169b2773fda4947f48b9d22043e3f90993b4974f
5
+ SHA512:
6
+ metadata.gz: e9ae2c0d0fce4e0581f70a3977b10f1ed92eef5339178921a9790100baa8da4819c04ca84c9bbbc2d6d9e7ab75e068049ab5ba5b763617fe2b3aee2f30840f5f
7
+ data.tar.gz: bb87f56603229423d2ca5be5d110b40b630b8a3b126b9eb7f0082ba3b71ceb2fbcbfd4e2422a97e2a37b6a28fd52c3c0eb8cc1be817d178b811825d8b9449a8a
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gcal.gemspec
4
+ gemspec
5
+ gem 'google-api-client'
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gcal (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.2.0)
10
+ i18n (~> 0.7)
11
+ json (~> 1.7, >= 1.7.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ addressable (2.3.7)
16
+ autoparse (0.3.3)
17
+ addressable (>= 2.3.1)
18
+ extlib (>= 0.9.15)
19
+ multi_json (>= 1.0.0)
20
+ diff-lcs (1.2.5)
21
+ extlib (0.9.16)
22
+ faraday (0.9.1)
23
+ multipart-post (>= 1.2, < 3)
24
+ google-api-client (0.8.2)
25
+ activesupport (>= 3.2)
26
+ addressable (~> 2.3)
27
+ autoparse (~> 0.3)
28
+ extlib (~> 0.9)
29
+ faraday (~> 0.9)
30
+ launchy (~> 2.4)
31
+ multi_json (~> 1.10)
32
+ retriable (~> 1.4)
33
+ signet (~> 0.6)
34
+ i18n (0.7.0)
35
+ json (1.8.2)
36
+ jwt (1.2.1)
37
+ launchy (2.4.3)
38
+ addressable (~> 2.3)
39
+ minitest (5.5.1)
40
+ multi_json (1.10.1)
41
+ multipart-post (2.0.0)
42
+ rake (10.4.2)
43
+ retriable (1.4.1)
44
+ rspec (3.1.0)
45
+ rspec-core (~> 3.1.0)
46
+ rspec-expectations (~> 3.1.0)
47
+ rspec-mocks (~> 3.1.0)
48
+ rspec-core (3.1.7)
49
+ rspec-support (~> 3.1.0)
50
+ rspec-expectations (3.1.2)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.1.0)
53
+ rspec-mocks (3.1.3)
54
+ rspec-support (~> 3.1.0)
55
+ rspec-support (3.1.2)
56
+ signet (0.6.0)
57
+ addressable (~> 2.3)
58
+ extlib (~> 0.9)
59
+ faraday (~> 0.9)
60
+ jwt (~> 1.0)
61
+ multi_json (~> 1.10)
62
+ thread_safe (0.3.4)
63
+ tzinfo (1.2.2)
64
+ thread_safe (~> 0.1)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ bundler (~> 1.7)
71
+ gcal!
72
+ google-api-client
73
+ rake (~> 10.0)
74
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Surume
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # gcal
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/gcal.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gcal/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gcal"
8
+ spec.version = Gcal::VERSION
9
+ spec.authors = ["Surume"]
10
+ spec.email = ["surume0227@gmail.com"]
11
+ spec.summary = %q{get GoogleCalendar List}
12
+ spec.description = %q{get GoogleCalendar List}
13
+ spec.homepage = "https://github.com/Surume/gcal"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,3 @@
1
+ module Gcal
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gcal.rb ADDED
@@ -0,0 +1,82 @@
1
+ require "gcal/version"
2
+ require 'google/api_client'
3
+
4
+ module Gcal
5
+
6
+ class Gcal
7
+
8
+ TOKEN_CREDENTIAL_URI = 'https://accounts.google.com/o/oauth2/token'
9
+ AUDIENCE = 'https://accounts.google.com/o/oauth2/token'
10
+ SCOPE = 'https://www.googleapis.com/auth/calendar.readonly'
11
+
12
+ attr_reader :client, :calendar_id
13
+
14
+ def initialize(calendar_id, p12key_path, p12pass, mail_adress)
15
+ @client = Google::APIClient.new(application_name: '')
16
+ @calendar_id = calendar_id
17
+
18
+ key = Google::APIClient::KeyUtils.load_from_pkcs12(p12key_path, p12pass)
19
+ @client.authorization = Signet::OAuth2::Client.new(
20
+ token_credential_uri: TOKEN_CREDENTIAL_URI,
21
+ audience: AUDIENCE,
22
+ scope: SCOPE,
23
+ issuer: mail_adress,
24
+ signing_key: key)
25
+ @client.authorization.fetch_access_token!
26
+ end
27
+
28
+ def today_events
29
+ now = Time.now
30
+ tomorrow = now + (60*60*24)
31
+ params = event_get_params(now.iso8601, tomorrow.iso8601)
32
+ send_params(params)
33
+ end
34
+
35
+ def next_day_events
36
+ now = Time.now + (60*60*24)
37
+ tomorrow = now + (60*60*24)
38
+ params = event_get_params(now.iso8601, tomorrow.iso8601)
39
+ send_params(params)
40
+ end
41
+
42
+ def one_month_events
43
+ now = DateTime.now
44
+ one_month_after = now >> 1
45
+ params = event_get_params(now.iso8601, one_month_after.iso8601)
46
+ send_params(params)
47
+ end
48
+
49
+ def all_day_events
50
+ under_time = Time.new(1000, 1, 1, 0)
51
+ top_time = Time.new(3000, 1, 1, 0)
52
+ params = event_get_params(under_time.iso8601, top_time.iso8601)
53
+ send_params(params)
54
+ end
55
+
56
+ def send_params(params)
57
+ cal = discovered_cal_api
58
+ result = @client.execute(api_method: cal.events.list,
59
+ parameters: params)
60
+ events = []
61
+ result.data.items.each do |item|
62
+ events << item
63
+ end
64
+ events
65
+ end
66
+
67
+ def discovered_cal_api
68
+ @client.discovered_api('calendar', 'v3')
69
+ end
70
+
71
+ def event_get_params(start_time, end_time)
72
+ {
73
+ 'calendarId' => @calendar_id,
74
+ 'orderBy' => 'startTime',
75
+ 'timeMax' => end_time,
76
+ 'timeMin' => start_time,
77
+ 'singleEvents' => 'True'
78
+ }
79
+ end
80
+
81
+ end
82
+ end
data/spec/gcal_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gcal do
4
+ it 'has a version number' do
5
+ expect(Gcal::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'gcal'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gcal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Surume
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-22 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: get GoogleCalendar List
56
+ email:
57
+ - surume0227@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - gcal.gemspec
71
+ - lib/gcal.rb
72
+ - lib/gcal/version.rb
73
+ - spec/gcal_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: https://github.com/Surume/gcal
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.5
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: get GoogleCalendar List
99
+ test_files:
100
+ - spec/gcal_spec.rb
101
+ - spec/spec_helper.rb