ruboty-gcal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c1d69fceaebd6dad3bbd7478d7f1e3e67517532d
4
+ data.tar.gz: 33e84dfa962a919ba78e6e697e36b1d981baaa0d
5
+ SHA512:
6
+ metadata.gz: 8eaf823e4cfadc132d914798b016f1b8bab4cfb0f220e866518c3f6f99e0d3dc113b13812d32b3cf25de0b77398d2c07536869ade8d92b1bcec73185a88096ed
7
+ data.tar.gz: 9cfa4b900c8cde1c2428fed7bc3921639b1e3985576564a7a00aa556b24cc7a2e415f22f904af47dfbd4c287738377bcdbd79f622a8442924e38d6a8b5f7d5ef
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-gcal.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 nekova
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.
@@ -0,0 +1,36 @@
1
+ # Ruboty::Gcal
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-gcal'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruboty-gcal
20
+
21
+ ## Usage
22
+ ```
23
+ @ruboty recent - Recent Events
24
+ @ruboty today - Today's Events
25
+ @ruboty schedule? <query> - Find a Event
26
+ @ruboty schedule "<title>" from "<start_time>" to "<end_time>" - Create a new Event
27
+ @ruboty unschedule <event_id> - Delete a Event
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/[my-github-username]/ruboty-gcal/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,4 @@
1
+ require "ruboty"
2
+ require "ruboty/gcal/version"
3
+ require "ruboty/gcal/client"
4
+ require "ruboty/handlers/gcal"
@@ -0,0 +1,55 @@
1
+ require "time"
2
+ require "date"
3
+ require 'google_calendar'
4
+ require 'addressable/uri'
5
+
6
+ module Ruboty
7
+ module Gcal
8
+ class Calendar
9
+ def initialize
10
+ @calendar ||= Google::Calendar.new({
11
+ username: ENV["GCAL_USERNAME"],
12
+ password: ENV["GCAL_PASSWORD"],
13
+ app_name: ENV["GCAL_APP_NAME"]
14
+ })
15
+ end
16
+
17
+ def today
18
+ today = Time.now.utc
19
+ tomorrow = today + 86400
20
+ @calendar.find_events_in_range(today, tomorrow) || "Event Not Found"
21
+ end
22
+
23
+ def recent
24
+ events = @calendar.find_future_events({max_results: 5})
25
+ events.map { |e| e.to_s }.join("\n") || "Event Not Found"
26
+ end
27
+
28
+ def find(message)
29
+ #Support Japanese
30
+ q = Addressable::URI.parse(message[:query]).normalize.to_s
31
+ message.reply(@calendar.find_events(q) || "Event Not Found")
32
+ end
33
+
34
+ def schedule(message)
35
+ event = @calendar.create_event { |e|
36
+ e.title = message[:title]
37
+ e.start_time = Time.parse(message[:start_time])
38
+ e.end_time = Time.parse(message[:end_time])
39
+ }
40
+ message.reply("Scheduled #{event}")
41
+ rescue ArgumentError
42
+ message.reply("Could not schedule the event")
43
+ end
44
+
45
+ def unschedule(message)
46
+ if event = @calendar.find_event_by_id(message[:event_id])
47
+ @calendar.delete_event(event)
48
+ message.reply("Deleted #{event.title}")
49
+ else
50
+ message.reply("Event Not Found")
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Gcal
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class Gcal < Base
4
+ on(
5
+ /recent/,
6
+ name: "recent",
7
+ description: "List recent events"
8
+ )
9
+
10
+ on(
11
+ /today/,
12
+ name: "today",
13
+ description: "List today's events"
14
+ )
15
+
16
+ on(
17
+ /schedule\? (?<query>.+)/,
18
+ name: "find",
19
+ description: "Find a event"
20
+ )
21
+
22
+ on(
23
+ /schedule "(?<title>.+)" from "(?<start_time>.+)" to "(?<end_time>.+)"/,
24
+ name: "schedule",
25
+ description: "Create a event"
26
+ )
27
+
28
+ on(
29
+ /unschedule (?<event_id>.+)/,
30
+ name: "unschedule",
31
+ description: "Delete a event"
32
+ )
33
+
34
+ def recent(message)
35
+ message.reply(calendar.recent)
36
+ end
37
+
38
+ def today(message)
39
+ message.reply(calendar.today)
40
+ end
41
+
42
+ def find(message)
43
+ calendar.find(message)
44
+ end
45
+
46
+ def schedule(message)
47
+ calendar.schedule(message)
48
+ end
49
+
50
+ def unschedule(message)
51
+ calendar.unschedule(message)
52
+ end
53
+
54
+ private
55
+
56
+ def calendar
57
+ Ruboty::Gcal::Calendar.new
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/gcal/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-gcal"
8
+ spec.version = Ruboty::Gcal::VERSION
9
+ spec.authors = ["nekova"]
10
+ spec.email = ["nekova07@gmail.com"]
11
+ spec.summary = "Google Calendar API Wrapper for ruboty"
12
+ spec.description = "Google Calendar API Wrapper for ruboty"
13
+ spec.homepage = "https://github.com/nekova/ruboty-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_dependency "ruboty", ">= 1.0.4"
22
+ spec.add_dependency "google_calendar", ">= 0.3.1"
23
+ spec.add_development_dependency "rspec", ">=3.1.0"
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,4 @@
1
+ require "spec_helper"
2
+
3
+ describe Ruboty::Handlers::Gcal do
4
+ end
@@ -0,0 +1 @@
1
+ require "ruboty/gcal"
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-gcal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - nekova
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruboty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: google_calendar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Google Calendar API Wrapper for ruboty
84
+ email:
85
+ - nekova07@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/ruboty/gcal.rb
96
+ - lib/ruboty/gcal/client.rb
97
+ - lib/ruboty/gcal/version.rb
98
+ - lib/ruboty/handlers/gcal.rb
99
+ - ruboty-gcal.gemspec
100
+ - spec/ruboty/handlers/gcal_spec.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/nekova/ruboty-gcal
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.2
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Google Calendar API Wrapper for ruboty
126
+ test_files:
127
+ - spec/ruboty/handlers/gcal_spec.rb
128
+ - spec/spec_helper.rb