connpass_to_calendar 1.0.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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/connpass_to_calendar.gemspec +44 -0
- data/exe/connpass_to_calendar +5 -0
- data/lib/connpass_to_calendar.rb +12 -0
- data/lib/connpass_to_calendar/.command.rb.swp +0 -0
- data/lib/connpass_to_calendar/api/connpass/event.rb +113 -0
- data/lib/connpass_to_calendar/api/google_apis/.calendar.rb.swp +0 -0
- data/lib/connpass_to_calendar/api/google_apis/calendar.rb +67 -0
- data/lib/connpass_to_calendar/cli.rb +38 -0
- data/lib/connpass_to_calendar/command.rb +78 -0
- data/lib/connpass_to_calendar/db.rb +54 -0
- data/lib/connpass_to_calendar/models/env.rb +9 -0
- data/lib/connpass_to_calendar/models/event.rb +8 -0
- data/lib/connpass_to_calendar/version.rb +3 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 21e5db4c703d6fa525c519063c45f394d991d1c2ba2e5455d347cf4771acab50
|
4
|
+
data.tar.gz: de5c309dcc9f14c3db51333502a326e651f18c1b0db6a0de6edda236994957db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2df758e26795fe11b11a2ce9ae91a6e4ecad8f3c3ac76bdfc20b89399a3d39169ad78bdd1e925becf11b3146e2983cca1f15f52d46113ad4686c7dcb2e9627c
|
7
|
+
data.tar.gz: e7e322af1c9d3ea32b3b1ca7b1d17f2c08f3b6d322d54ef5849cec6add5a1919141b90d265683c8c3d58f0cb24e2104e7b74472063ca3f8c47ece7e859f5b70f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 tech_rui
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# ConnpassToCalendar
|
2
|
+
|
3
|
+
ConnpassToCalendarは[connpass API](https://connpass.com/about/api/) で取得したイベントを[Googleカレンダー](https://calendar.google.com/)に登録することができるCLIアプリケーションです。
|
4
|
+
|
5
|
+
## インストール
|
6
|
+
|
7
|
+
gemでインストール:
|
8
|
+
|
9
|
+
$ gem install connpass_to_calendar
|
10
|
+
|
11
|
+
## 初期設定
|
12
|
+
|
13
|
+
### GoogleCalendarAPIの登録
|
14
|
+
|
15
|
+
このアプリを使うにはGoogleCalendarのAPI登録が必要です。
|
16
|
+
Gmailアカウント(Googleアカウント)は取得済みの前提とします。
|
17
|
+
1.[GoogleAPIsのコンソール](https://console.developers.google.com/apis/dashboard)からプロジェクトを作成します。
|
18
|
+
|
19
|
+
2.左のライブラリタブでGoogle Calendar APIを検索し、有効にします。
|
20
|
+
|
21
|
+
3.認証情報タブのOAuth同意画面でOAuth認証情報の登録をします。
|
22
|
+
|
23
|
+
4.認証情報タブの認証情報で「認証情報の作成」、「OAuthクライアントIDの作成」、「その他」と進みクライアントIDを作成します。
|
24
|
+
|
25
|
+
5.作成したクライアントIDのjsonファイルをダウンロードします。
|
26
|
+
|
27
|
+
### 設定
|
28
|
+
|
29
|
+
`config`コマンドを使用して以下を設定します。
|
30
|
+
|
31
|
+
$ connpass_to_calendar config application_name <作成したプロジェクト名>
|
32
|
+
|
33
|
+
$ connpass_to_calendar config credentials_path <ダウンロードしたjsonファイルのフルパス> # Example => /Users/user/.connpass_to_calendar/oauth/client_secrets.json
|
34
|
+
|
35
|
+
$ connpass_to_calendar config token_path <tokenファイルのフルパス> # Example => /Users/user/.connpass_to_calendar/oauth/tokens.yaml
|
36
|
+
|
37
|
+
$ connpass_to_calendar config user_id <APIを登録したGmailアカウント>
|
38
|
+
|
39
|
+
設定した内容は`config --list`で確認できます。
|
40
|
+
|
41
|
+
## 使い方
|
42
|
+
|
43
|
+
`put`コマンドを使用してカレンダーにイベントを登録します。
|
44
|
+
|
45
|
+
$ connpass_to_calendar put
|
46
|
+
|
47
|
+
[connpass API](https://connpass.com/about/api/)のパラメータを使用する場合は以下のようにオプションをつけます。
|
48
|
+
オプションはリファレンスに乗っている`format`以外使用可能です。
|
49
|
+
|
50
|
+
$ connpass_to_calendar put --keyword "ruby"
|
51
|
+
|
52
|
+
初回のみ以下のメッセージがでます。
|
53
|
+
メッセージに従いURLへアクセスしカレンダーへのアクセスを許可し、表示されたコードを貼り付けてください。
|
54
|
+
|
55
|
+
Open https://accounts.google.com/o/oauth2/auth?<params> in your browser and enter the resulting code:
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tech_rui/connpass_to_calendar.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "connpass_to_calendar"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "connpass_to_calendar/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "connpass_to_calendar"
|
8
|
+
spec.version = ConnpassToCalendar::VERSION
|
9
|
+
spec.authors = ["tech_rui"]
|
10
|
+
spec.email = ["gitkurukuru@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Register connpass's event in gmail}
|
13
|
+
spec.description = %q{Register connpass's event in gmail}
|
14
|
+
spec.homepage = "https://github.com/ruihub/connpass_to_calendar"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
#end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
|
39
|
+
spec.add_dependency "thor", "~> 0.20.0"
|
40
|
+
spec.add_dependency "googleauth"
|
41
|
+
spec.add_dependency "google-api-client", "~> 0.8"
|
42
|
+
spec.add_dependency "activerecord"
|
43
|
+
spec.add_dependency "sqlite3", "~> 1.3"
|
44
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "connpass_to_calendar/version"
|
2
|
+
require "connpass_to_calendar/cli"
|
3
|
+
require "connpass_to_calendar/db"
|
4
|
+
require "connpass_to_calendar/command.rb"
|
5
|
+
require "connpass_to_calendar/api/connpass/event"
|
6
|
+
require "connpass_to_calendar/api/google_apis/calendar"
|
7
|
+
require "connpass_to_calendar/models/env"
|
8
|
+
require "connpass_to_calendar/models/event"
|
9
|
+
|
10
|
+
module ConnpassToCalendar
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
Binary file
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
require "json"
|
4
|
+
require "date"
|
5
|
+
|
6
|
+
module ConnpassToCalendar
|
7
|
+
module Api
|
8
|
+
module Connpass
|
9
|
+
class Event
|
10
|
+
def self.get(params)
|
11
|
+
begin
|
12
|
+
validation params
|
13
|
+
params = URI.encode_www_form params
|
14
|
+
uri = URI.parse("https://connpass.com/api/v1/event/?#{params}")
|
15
|
+
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) { |http|
|
16
|
+
request = Net::HTTP::Get.new uri
|
17
|
+
http.request request
|
18
|
+
}
|
19
|
+
JSON.parse response.body
|
20
|
+
rescue ArgumentError => e
|
21
|
+
puts e.message
|
22
|
+
exit
|
23
|
+
rescue IOError => e
|
24
|
+
puts e.message
|
25
|
+
exit
|
26
|
+
rescue Timeout::Error => e
|
27
|
+
puts e.message
|
28
|
+
exit
|
29
|
+
rescue JSON::ParserError => e
|
30
|
+
puts e.message
|
31
|
+
exit
|
32
|
+
rescue => e
|
33
|
+
puts e.message
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.validation(params)
|
39
|
+
params = Hash[params.map { |k, v| [k.to_sym, v] }]
|
40
|
+
params.each do |key, value|
|
41
|
+
case key
|
42
|
+
when :event_id
|
43
|
+
unless value.kind_of?(Array)
|
44
|
+
value = Array[value]
|
45
|
+
end
|
46
|
+
value.each do |event_id|
|
47
|
+
unless event_id =~ /^[0-9]+$/
|
48
|
+
raise ArgumentError, "event_id validation error"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
when :keyword
|
52
|
+
when :keyword_or
|
53
|
+
when :ym
|
54
|
+
unless value.kind_of?(Array)
|
55
|
+
value = Array[value]
|
56
|
+
end
|
57
|
+
format = "%Y%m"
|
58
|
+
begin
|
59
|
+
value.each do |ym|
|
60
|
+
DateTime.strptime(ym, format)
|
61
|
+
end
|
62
|
+
rescue ArgumentError
|
63
|
+
raise ArgumentError, "ym validation error"
|
64
|
+
end
|
65
|
+
when :ymd
|
66
|
+
unless value.kind_of?(Array)
|
67
|
+
value = Array[value]
|
68
|
+
end
|
69
|
+
format = "%Y%m%d"
|
70
|
+
begin
|
71
|
+
value.each do |ymd|
|
72
|
+
DateTime.strptime(ymd, format)
|
73
|
+
end
|
74
|
+
rescue ArgumentError
|
75
|
+
raise ArgumentError, "ymd validation error"
|
76
|
+
end
|
77
|
+
when :nickname
|
78
|
+
when :owner_nickname
|
79
|
+
when :series_id
|
80
|
+
unless value.kind_of?(Array)
|
81
|
+
value = Array[value]
|
82
|
+
end
|
83
|
+
value.each do |series_id|
|
84
|
+
unless series_id =~ /^[0-9]+$/
|
85
|
+
raise ArgumentError, "series_id validation error"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
when :start
|
89
|
+
unless value =~ /^[0-9]+$/
|
90
|
+
raise ArgumentError, "start validation error"
|
91
|
+
end
|
92
|
+
when :order
|
93
|
+
unless value =~ /^[1-3]$/
|
94
|
+
raise ArgumentError, "order validation error"
|
95
|
+
end
|
96
|
+
when :count
|
97
|
+
unless value =~ /^[0-9]+$/
|
98
|
+
raise ArgumentError, "count validation error"
|
99
|
+
end
|
100
|
+
if value.to_i < 0 || 100 < value.to_i
|
101
|
+
raise ArgumentError, "count validation error"
|
102
|
+
end
|
103
|
+
else
|
104
|
+
raise ArgumentError, "parameter not exist"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
private_class_method :validation
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "google/apis/calendar_v3"
|
2
|
+
require "googleauth"
|
3
|
+
require "googleauth/stores/file_token_store"
|
4
|
+
|
5
|
+
module ConnpassToCalendar
|
6
|
+
module Api
|
7
|
+
module GoogleApis
|
8
|
+
class Calendar
|
9
|
+
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
|
10
|
+
SCOPE = "https://www.googleapis.com/auth/calendar"
|
11
|
+
|
12
|
+
def initialize(application_name, credentials_path, token_path, user_id)
|
13
|
+
@application_name = application_name
|
14
|
+
@credentials_path = credentials_path
|
15
|
+
@token_path = token_path
|
16
|
+
@user_id = user_id
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Ensure valid credentials, either by restoring from the saved credentials
|
21
|
+
# files or intitiating an OAuth2 authorization. If authorization is required,
|
22
|
+
# the user's default browser will be launched to approve the request.
|
23
|
+
#
|
24
|
+
# @return [Google::Auth::UserRefreshCredentials] OAuth2 credentials
|
25
|
+
def authorize
|
26
|
+
client_id = Google::Auth::ClientId.from_file(@credentials_path)
|
27
|
+
token_store = Google::Auth::Stores::FileTokenStore.new(file: @token_path)
|
28
|
+
authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
|
29
|
+
credentials = authorizer.get_credentials(@user_id)
|
30
|
+
if credentials.nil?
|
31
|
+
url = authorizer.get_authorization_url(base_url: OOB_URI)
|
32
|
+
puts "Open #{url} in your browser and enter the resulting code:"
|
33
|
+
code = STDIN.gets.chomp
|
34
|
+
credentials = authorizer.get_and_store_credentials_from_code(
|
35
|
+
user_id: @user_id, code: code, base_url: OOB_URI,
|
36
|
+
)
|
37
|
+
end
|
38
|
+
credentials
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_event(summary, location, description, start_date_time, end_date_time)
|
42
|
+
client = Google::Apis::CalendarV3::CalendarService.new
|
43
|
+
client.client_options.application_name = @application_name
|
44
|
+
client.authorization = authorize
|
45
|
+
|
46
|
+
event = Google::Apis::CalendarV3::Event.new({
|
47
|
+
summary: summary,
|
48
|
+
location: location,
|
49
|
+
description: description,
|
50
|
+
start: {
|
51
|
+
date_time: start_date_time,
|
52
|
+
time_zone: "Japan",
|
53
|
+
},
|
54
|
+
end: {
|
55
|
+
date_time: end_date_time,
|
56
|
+
time_zone: "Japan",
|
57
|
+
},
|
58
|
+
})
|
59
|
+
result = client.insert_event("primary", event)
|
60
|
+
puts "Event created: #{result.html_link}"
|
61
|
+
end
|
62
|
+
|
63
|
+
private :authorize
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module ConnpassToCalendar
|
4
|
+
class Cli < Thor
|
5
|
+
option :event_id
|
6
|
+
option :keyword
|
7
|
+
option :keyword_or
|
8
|
+
option :ym
|
9
|
+
option :ymd
|
10
|
+
option :nickkey
|
11
|
+
option :owner_nickkey
|
12
|
+
option :series_id
|
13
|
+
option :start
|
14
|
+
option :order
|
15
|
+
option :count
|
16
|
+
desc "put [--event_id=<event_id>] [--keyword=<keyword>] [--keyword_or=<keyword list>] [--ym=<start date>] [--ymd=<start datetime>] [--nickname=<menber nickname>] [--owner_nickname=<owner nickname>] [--series_id=<series_id>] [--start=<sarch result from>] [--order=<1:update datetime | 2:starting datetime | 3:new>] [--count=<1 to 100>]", "event put on calendar"
|
17
|
+
|
18
|
+
def put
|
19
|
+
Command.put_on_event(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "config key value", "set environment"
|
23
|
+
|
24
|
+
def config(key, value = nil)
|
25
|
+
if Models::Env::KEYS_LIST.include? key
|
26
|
+
if value
|
27
|
+
Command.set_config(key, value)
|
28
|
+
else
|
29
|
+
Command.show_config(key)
|
30
|
+
end
|
31
|
+
elsif key == "--list" && value == nil
|
32
|
+
Command.list_config()
|
33
|
+
else
|
34
|
+
puts "error: key does not contain a section: #{key}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module ConnpassToCalendar
|
2
|
+
class Command
|
3
|
+
def self.put_on_event(params)
|
4
|
+
check_env
|
5
|
+
|
6
|
+
DB.prepare
|
7
|
+
|
8
|
+
result = Api::Connpass::Event.get(params)
|
9
|
+
events = result["events"]
|
10
|
+
events.each do |event|
|
11
|
+
event_id = event["event_id"]
|
12
|
+
summary = event["title"]
|
13
|
+
location = "#{event["address"]} #{event["place"]}"
|
14
|
+
description = "#{event["catch"]}
|
15
|
+
イベントURL:#{event["event_url"]}
|
16
|
+
定員:#{event["limit"]}"
|
17
|
+
start_date_time = event["started_at"]
|
18
|
+
end_date_time = event["ended_at"]
|
19
|
+
|
20
|
+
puts summary
|
21
|
+
puts location
|
22
|
+
puts description
|
23
|
+
puts start_date_time
|
24
|
+
puts end_date_time
|
25
|
+
|
26
|
+
unless Models::Event.find_by(id: event_id)
|
27
|
+
Models::Event.create(id: event_id, summary: summary, description: description, start_date_time: start_date_time, end_date_time: end_date_time)
|
28
|
+
|
29
|
+
application_name = Models::Env.find_by(keyword: "application_name").value
|
30
|
+
credentials_path = Models::Env.find_by(keyword: "credentials_path").value
|
31
|
+
token_path = Models::Env.find_by(keyword: "token_path").value
|
32
|
+
user_id = Models::Env.find_by(keyword: "user_id").value
|
33
|
+
calendar = Api::GoogleApis::Calendar.new(application_name, credentials_path, token_path, user_id)
|
34
|
+
calendar.create_event(summary, location, description, start_date_time, end_date_time)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.set_config(key, value)
|
40
|
+
DB.prepare
|
41
|
+
|
42
|
+
env = Models::Env.find_by(keyword: key)
|
43
|
+
if env
|
44
|
+
env.update(value: value)
|
45
|
+
else
|
46
|
+
Models::Env.create(keyword: key, value: value)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.show_config(key)
|
51
|
+
DB.prepare
|
52
|
+
|
53
|
+
puts Models::Env.find_by(keyword: key).value
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.list_config()
|
57
|
+
DB.prepare
|
58
|
+
|
59
|
+
envs = Models::Env.order(:keyword)
|
60
|
+
envs.each do |env|
|
61
|
+
puts "#{env.keyword}=#{env.value}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.check_env
|
66
|
+
DB.prepare
|
67
|
+
|
68
|
+
Models::Env::KEYS_LIST.each do |key|
|
69
|
+
unless Models::Env.find_by(keyword: key)
|
70
|
+
puts "Not enough env. Please use the [config] command to set the env."
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private_class_method :check_env
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "active_record"
|
3
|
+
|
4
|
+
module ConnpassToCalendar
|
5
|
+
module DB
|
6
|
+
def self.prepare
|
7
|
+
database_path = File.join(ENV["HOME"], ".connpass_to_calendar", "db", "connpass_to_calendar.sqlite3")
|
8
|
+
|
9
|
+
connect_database database_path
|
10
|
+
create_database_path database_path
|
11
|
+
create_envs_table
|
12
|
+
create_events_table
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.connect_database(path)
|
16
|
+
config = {adapter: "sqlite3", database: path}
|
17
|
+
ActiveRecord::Base.establish_connection config
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create_envs_table
|
21
|
+
connection = ActiveRecord::Base.connection
|
22
|
+
|
23
|
+
return if connection.table_exists?(:envs)
|
24
|
+
|
25
|
+
connection.create_table :envs do |t|
|
26
|
+
t.column :keyword, :string, :null => false
|
27
|
+
t.column :value, :string, :null => false
|
28
|
+
t.timestamps
|
29
|
+
end
|
30
|
+
connection.add_index :envs, :keyword, unique: true
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.create_events_table
|
34
|
+
connection = ActiveRecord::Base.connection
|
35
|
+
|
36
|
+
return if connection.table_exists?(:events)
|
37
|
+
|
38
|
+
connection.create_table :events do |t|
|
39
|
+
t.column :summary, :string
|
40
|
+
t.column :location, :string
|
41
|
+
t.column :description, :string
|
42
|
+
t.column :start_date_time, :datetime
|
43
|
+
t.column :end_date_time, :datetime
|
44
|
+
t.timestamps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.create_database_path(path)
|
49
|
+
FileUtils.mkdir_p File.dirname(path)
|
50
|
+
end
|
51
|
+
|
52
|
+
private_class_method :connect_database, :create_envs_table, :create_events_table, :create_database_path
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: connpass_to_calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tech_rui
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-28 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: 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: '3.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.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.20.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.20.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: googleauth
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: google-api-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activerecord
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.3'
|
125
|
+
description: Register connpass's event in gmail
|
126
|
+
email:
|
127
|
+
- gitkurukuru@gmail.com
|
128
|
+
executables:
|
129
|
+
- connpass_to_calendar
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- connpass_to_calendar.gemspec
|
143
|
+
- exe/connpass_to_calendar
|
144
|
+
- lib/connpass_to_calendar.rb
|
145
|
+
- lib/connpass_to_calendar/.command.rb.swp
|
146
|
+
- lib/connpass_to_calendar/api/connpass/event.rb
|
147
|
+
- lib/connpass_to_calendar/api/google_apis/.calendar.rb.swp
|
148
|
+
- lib/connpass_to_calendar/api/google_apis/calendar.rb
|
149
|
+
- lib/connpass_to_calendar/cli.rb
|
150
|
+
- lib/connpass_to_calendar/command.rb
|
151
|
+
- lib/connpass_to_calendar/db.rb
|
152
|
+
- lib/connpass_to_calendar/models/env.rb
|
153
|
+
- lib/connpass_to_calendar/models/event.rb
|
154
|
+
- lib/connpass_to_calendar/version.rb
|
155
|
+
homepage: https://github.com/ruihub/connpass_to_calendar
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.7.6
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: Register connpass's event in gmail
|
179
|
+
test_files: []
|