ruboty-treasure_data 0.1.0

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: 0a518a3b275752be4c3eb8026add377e1e89d14a
4
+ data.tar.gz: ec1f5ea96f1d055928ddcc5dcb81faa033cf5a7f
5
+ SHA512:
6
+ metadata.gz: cc4ff57ebd07f489a15df0e96038cc16770e751f8399b97aa4f66e7c25ecab2243de732c1df287c51a8a14d2f2c373861474b56bb077e13f6bd486488b77135e
7
+ data.tar.gz: 668b5dc1ef758112afa20b137d0e990fd95ddd6dd96c0aa06410715965af4c905e90f7a14b7fae051b5edd10c30b1dbc4d51c3f97554bcddf81ea6496f70e06c
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ .env
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ # Ruboty::TreasureData
2
+
3
+ Manage Treasure Data via Ruboty.
4
+
5
+ ## Install
6
+
7
+ ```rb
8
+ # Gemfile
9
+ gem "ruboty-treasure_data"
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ @ruboty run schedule <schedule>
16
+ ```
17
+
18
+ ## ENV
19
+
20
+ ```
21
+ TREASURE_DATA_API_KEY - An API key for treasure data
22
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class TreasureData < Base
4
+ env :TREASURE_DATA_API_KEY, "An API key for Treasure Data"
5
+
6
+ on(
7
+ /run schedule "(?<schedule>.+)"\z/,
8
+ name: "run_schedule",
9
+ description: "Run a schedule",
10
+ )
11
+
12
+ def run_schedule(message)
13
+ Ruboty::TreasureData::Actions::RunSchedule.new(message).call
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ require "pry"
2
+ require "td-client"
3
+ require "terminal-table"
4
+
5
+ require "ruboty/handlers/treasure_data"
6
+ require "ruboty/treasure_data/actions/run_schedule"
@@ -0,0 +1,49 @@
1
+ module Ruboty
2
+ module TreasureData
3
+ module Actions
4
+ class RunSchedule
5
+ attr_reader :message
6
+
7
+ def initialize(message)
8
+ @message = message
9
+ end
10
+
11
+ def call
12
+ begin
13
+ jobs = td_client.run_schedule(schedule, Time.now, nil)
14
+ rescue ::TreasureData::NotFoundError
15
+ message.reply("Resource not found", code: true)
16
+ return
17
+ rescue
18
+ message.reply("Something wrong", code: true)
19
+ return
20
+ end
21
+
22
+ job = jobs.first
23
+
24
+ while !job.finished?
25
+ sleep 2
26
+ job.update_progress!
27
+ end
28
+
29
+ if job.success?
30
+ table = Terminal::Table.new(rows: job.result)
31
+ message.reply(table, code: true)
32
+ else
33
+ message.reply(job.result, code: true)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def td_client
40
+ @td_client ||= ::TreasureData::Client.new(ENV["TREASURE_DATA_API_KEY"])
41
+ end
42
+
43
+ def schedule
44
+ message[:schedule]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "ruboty-treasure_data"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Naoto Kaneko"]
5
+ spec.email = ["naoty.k@gmail.com"]
6
+ spec.summary = "Manage Treasure Data via Ruboty."
7
+ spec.homepage = "https://github.com/naoty/ruboty-treasure_data"
8
+ spec.license = "MIT"
9
+
10
+ spec.files = `git ls-files -z`.split("\x0")
11
+ spec.test_files = spec.files.grep(%r{^spec/})
12
+ spec.require_paths = ["lib"]
13
+
14
+ spec.add_dependency "ruboty"
15
+ spec.add_dependency "td-client"
16
+ spec.add_dependency "terminal-table"
17
+ spec.add_development_dependency "bundler"
18
+ spec.add_development_dependency "rake"
19
+ spec.add_development_dependency "rspec"
20
+ spec.add_development_dependency "pry"
21
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-treasure_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Naoto Kaneko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-20 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: td-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
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: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - naoty.k@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - README.md
121
+ - Rakefile
122
+ - lib/ruboty/handlers/treasure_data.rb
123
+ - lib/ruboty/treasure_data.rb
124
+ - lib/ruboty/treasure_data/actions/run_schedule.rb
125
+ - ruboty-treasure_data.gemspec
126
+ homepage: https://github.com/naoty/ruboty-treasure_data
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.5.1
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Manage Treasure Data via Ruboty.
150
+ test_files: []