hiptail 0.0.2 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/examples/integrate_sinatra/README.md +1 -1
- data/examples/simple_rack_app_1/README.md +1 -1
- data/examples/simple_rack_app_2/README.md +1 -1
- data/hiptail.gemspec +2 -2
- data/lib/hiptail/authority.rb +47 -9
- data/lib/hiptail/util.rb +4 -4
- data/lib/hiptail/version.rb +1 -1
- data/lib/hiptail/web/handler.rb +5 -8
- data/lib/hiptail/web/rack_app.rb +11 -11
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 080df2b0b73328a9b0604413adfeefc8292fc9aa
|
4
|
+
data.tar.gz: fd4008027616aeda25d04578e75f9c4f0bdd7109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a84d101dcce6ac0ea5bda7b3bcda1c963a21792223dd086fed53020f1fb149b995301d8facbc6ae00a50a8d6edf7acd2827e81470d6634f6e5cda1fa3b532c5a
|
7
|
+
data.tar.gz: 069b76c1859dd8981b6149487b8a581dfb7699d3fdaf2182d28c17ba8f5554d11a854bcaf9ae2087adac441dbb9497d9c9673d6666a2d6a0d562afa205e272ee
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,5 +5,5 @@
|
|
5
5
|
$ bundle install
|
6
6
|
$ bundle exec -- rackup
|
7
7
|
|
8
|
-
Then install this
|
8
|
+
Then install this integration on integrations page in HipChat administration page.
|
9
9
|
Specify the application capability URL (e.g. http://example.com:4567/cap).
|
@@ -5,5 +5,5 @@
|
|
5
5
|
$ bundle install
|
6
6
|
$ bundle exec -- rackup
|
7
7
|
|
8
|
-
Then install this
|
8
|
+
Then install this integration on integrations page in HipChat administration page.
|
9
9
|
Specify the application capability URL (e.g. http://example.com:9292/cap).
|
@@ -5,5 +5,5 @@
|
|
5
5
|
$ bundle install
|
6
6
|
$ bundle exec -- rackup
|
7
7
|
|
8
|
-
Then install this
|
8
|
+
Then install this integration on integrations page in HipChat administration page.
|
9
9
|
Specify the application capability URL (e.g. http://example.com:9292/cap).
|
data/hiptail.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = HipTail::VERSION
|
9
9
|
spec.authors = ["ITO Nobuaki"]
|
10
10
|
spec.email = ["daydream.trippers@gmail.com"]
|
11
|
-
spec.summary = %q{HipChat Add-on Framework}
|
12
|
-
spec.description = %q{HipChat Add-on Framework}
|
11
|
+
spec.summary = %q{HipChat Integration (Add-on) Framework}
|
12
|
+
spec.description = %q{HipChat Integration (Add-on) Framework}
|
13
13
|
spec.homepage = "https://github.com/dayflower/hiptail"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/hiptail/authority.rb
CHANGED
@@ -96,7 +96,8 @@ module HipTail
|
|
96
96
|
# @return [HipTail::Rooms]
|
97
97
|
def get_all_rooms(params = {})
|
98
98
|
res = call_api(:method => :get, :uri => @api_base.merge("room"), :query_params => params)
|
99
|
-
|
99
|
+
return unless res.successful?
|
100
|
+
Rooms.new(res.data)
|
100
101
|
end
|
101
102
|
|
102
103
|
# Issues get room API.
|
@@ -107,27 +108,30 @@ module HipTail
|
|
107
108
|
room_id = self.room_id || params.delete(:room_id)
|
108
109
|
raise ArgumentError.new("room_id required") unless room_id
|
109
110
|
res = call_api(:method => :get, :uri => @api_base.merge("room/#{room_id}"), :query_params => params)
|
110
|
-
|
111
|
+
return unless res.successful?
|
112
|
+
Room::Detail.new(res.data)
|
111
113
|
end
|
112
114
|
|
113
115
|
# Issues get all members API.
|
114
116
|
# @param [Hash] params Parameters for get all members API.
|
115
117
|
# @return [HipTail::Users]
|
116
|
-
def get_all_members(params)
|
118
|
+
def get_all_members(params = {})
|
117
119
|
room_id = self.room_id || params.delete(:room_id)
|
118
120
|
raise ArgumentError.new("room_id required") unless room_id
|
119
121
|
res = call_api(:method => :get, :uri => @api_base.merge("room/#{room_id}/member"), :query_params => params)
|
120
|
-
|
122
|
+
return unless res.successful?
|
123
|
+
Users.new(res.data)
|
121
124
|
end
|
122
125
|
|
123
126
|
# Issues get all participants API.
|
124
127
|
# @param [Hash] params Parameters for get all participants API.
|
125
128
|
# @return [HipTail::Users]
|
126
|
-
def get_all_participants(params)
|
129
|
+
def get_all_participants(params = {})
|
127
130
|
room_id = self.room_id || params.delete(:room_id)
|
128
131
|
raise ArgumentError.new("room_id required") unless room_id
|
129
132
|
res = call_api(:method => :get, :uri => @api_base.merge("room/#{room_id}/participant"), :query_params => params)
|
130
|
-
|
133
|
+
return unless res.successful?
|
134
|
+
Users.new(res.data)
|
131
135
|
end
|
132
136
|
|
133
137
|
# Issues add member API.
|
@@ -164,6 +168,27 @@ module HipTail
|
|
164
168
|
call_api(:method => :delete, :uri => @api_base.merge("room/#{room_id}/member/#{user_name}"), :body_params => params)
|
165
169
|
end
|
166
170
|
|
171
|
+
# Issues view user API.
|
172
|
+
# @param [Hash] params Parameters for view user API with :user_id.
|
173
|
+
# @option params [String] :user_id User ID or email or mention name (beginning with an '@').
|
174
|
+
# @return [HipTail::User]
|
175
|
+
def view_user(params)
|
176
|
+
user_id = params.delete(:user_id)
|
177
|
+
raise ArgumentError.new("user_id required") unless user_id
|
178
|
+
res = call_api(:method => :get, :uri => @api_base.merge("user/#{user_id}"), :query_params => params)
|
179
|
+
return unless res.successful?
|
180
|
+
User::Person.new(res.data)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Issues get all users API.
|
184
|
+
# @param [Hash] params Parameters for get all users API.
|
185
|
+
# @return [HipTail::Users]
|
186
|
+
def get_all_users(params = {})
|
187
|
+
res = call_api(:method => :get, :uri => @api_base.merge("user"), :query_params => params)
|
188
|
+
return unless res.successful?
|
189
|
+
Users.new(res.data)
|
190
|
+
end
|
191
|
+
|
167
192
|
private
|
168
193
|
|
169
194
|
def user_name_from_params(params)
|
@@ -190,7 +215,7 @@ module HipTail
|
|
190
215
|
}
|
191
216
|
|
192
217
|
if args[:body_params]
|
193
|
-
body = JSON.generate(args[:body_params] || {})
|
218
|
+
body = JSON.generate(args[:body_params] || {}, :ascii_only => true)
|
194
219
|
headers['Content-Length'] = body.bytesize.to_s
|
195
220
|
else
|
196
221
|
body = nil
|
@@ -215,11 +240,24 @@ module HipTail
|
|
215
240
|
http.request(req)
|
216
241
|
end
|
217
242
|
|
243
|
+
def res.successful?
|
244
|
+
self.is_a?(Net::HTTPSuccess)
|
245
|
+
end
|
246
|
+
|
218
247
|
if res.content_type =~ %r{\A application/json}x
|
219
|
-
|
248
|
+
body_data = JSON.parse(res.body)
|
220
249
|
else
|
221
|
-
|
250
|
+
body_data = {}
|
222
251
|
end
|
252
|
+
|
253
|
+
res_class = class << res; self; end
|
254
|
+
res_class.class_eval do
|
255
|
+
define_method(:data) do
|
256
|
+
body_data
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
res
|
223
261
|
end
|
224
262
|
|
225
263
|
def token
|
data/lib/hiptail/util.rb
CHANGED
@@ -5,13 +5,13 @@ module HipTail
|
|
5
5
|
|
6
6
|
# Build capability object.
|
7
7
|
# @param [Hash] params
|
8
|
-
# @option params [String] :key Identical key for
|
9
|
-
# @option params [String] :name
|
10
|
-
# @option params [String] :base_url Base URL for
|
8
|
+
# @option params [String] :key Identical key for integration
|
9
|
+
# @option params [String] :name integration name
|
10
|
+
# @option params [String] :base_url Base URL for integration
|
11
11
|
# @option params [String] :capability_url URL for capability
|
12
12
|
# @option params [String] :webhook_url URL for event webhook
|
13
13
|
# @option params [String] :installed_url URL for installed / uninstalled event webhook
|
14
|
-
# @option params [String] :description (same as :name)
|
14
|
+
# @option params [String] :description (same as :name) integration description (optional)
|
15
15
|
# @option params [String] :vendor_name (same as :name) Vendor name (optional)
|
16
16
|
# @option params [String] :vendor_url (same as :base_url) Vendor URL (optional)
|
17
17
|
# @option params [String] :homepage_url (same as :base_url) Homepage (optional)
|
data/lib/hiptail/version.rb
CHANGED
data/lib/hiptail/web/handler.rb
CHANGED
@@ -46,13 +46,13 @@ module HipTail
|
|
46
46
|
# Handles retrieving capability request.
|
47
47
|
# @param [Rack::Request] request
|
48
48
|
# @param [Hash] params Capability parameters
|
49
|
-
# @option params [String] :key Identical key for
|
50
|
-
# @option params [String] :name
|
51
|
-
# @option params [String] :base_url Base URL for
|
49
|
+
# @option params [String] :key Identical key for integration
|
50
|
+
# @option params [String] :name integration name
|
51
|
+
# @option params [String] :base_url Base URL for integration
|
52
52
|
# @option params [String] :capability_url URL for capability
|
53
53
|
# @option params [String] :webhook_url URL for event webhook
|
54
54
|
# @option params [String] :installed_url URL for installed / uninstalled event webhook
|
55
|
-
# @option params [String] :description (same as :name)
|
55
|
+
# @option params [String] :description (same as :name) integration description (optional)
|
56
56
|
# @option params [String] :vendor_name (same as :name) Vendor name (optional)
|
57
57
|
# @option params [String] :vendor_url (same as :base_url) Vendor URL (optional)
|
58
58
|
# @option params [String] :homepage_url (same as :base_url) Homepage (optional)
|
@@ -85,10 +85,7 @@ module HipTail
|
|
85
85
|
# @param [Hash] data
|
86
86
|
# @param [Integer] status (200)
|
87
87
|
def create_response(data, status = 200)
|
88
|
-
body = JSON.generate(data)
|
89
|
-
|
90
|
-
body.gsub!(/[\u{007f}-\u{10ffff}]+/) { |match| match.unpack("U*").map! { |i| "\\u#{i.to_s(16)}" }.join }
|
91
|
-
|
88
|
+
body = JSON.generate(data, :ascii_only => true)
|
92
89
|
headers = {
|
93
90
|
'Content-Type' => 'application/json; charset=UTF-8',
|
94
91
|
'Content-Length' => body.bytesize.to_s,
|
data/lib/hiptail/web/rack_app.rb
CHANGED
@@ -8,17 +8,17 @@ module HipTail
|
|
8
8
|
|
9
9
|
class Web::RackApp
|
10
10
|
# @return [HipTail::Manager] Returns HipTail::Manager.
|
11
|
-
attr_reader :manager
|
11
|
+
attr_reader :manager, :path
|
12
12
|
|
13
13
|
# @param [Hash] params Capability parameters (and manager)
|
14
14
|
# @option params [HipTail::Manager] :manager HipTail::Manager instance (optional)
|
15
|
-
# @option params [String] :key Identical key for
|
16
|
-
# @option params [String] :name
|
17
|
-
# @option params [String] :base_url Base URL for
|
15
|
+
# @option params [String] :key Identical key for integration
|
16
|
+
# @option params [String] :name integration name
|
17
|
+
# @option params [String] :base_url Base URL for integration
|
18
18
|
# @option params [String] :capability_url URL for capability
|
19
19
|
# @option params [String] :webhook_url URL for event webhook
|
20
20
|
# @option params [String] :installed_url URL for installed / uninstalled event webhook
|
21
|
-
# @option params [String] :description (same as :name)
|
21
|
+
# @option params [String] :description (same as :name) integration description (optional)
|
22
22
|
# @option params [String] :vendor_name (same as :name) Vendor name (optional)
|
23
23
|
# @option params [String] :vendor_url (same as :base_url) Vendor URL (optional)
|
24
24
|
# @option params [String] :homepage_url (same as :base_url) Homepage (optional)
|
@@ -38,19 +38,19 @@ module HipTail
|
|
38
38
|
@capability_params = params
|
39
39
|
|
40
40
|
base_url = URI.parse('http://example.com/').merge(params[:base_path])
|
41
|
-
path = {
|
41
|
+
@path = {
|
42
42
|
:base => base_url.request_uri,
|
43
43
|
}
|
44
44
|
[ :webhook, :installed, :capability ].each do |key|
|
45
|
-
path[key] = base_url.merge('./' + params["#{key}_path".to_sym]).request_uri
|
45
|
+
@path[key] = base_url.merge('./' + params["#{key}_path".to_sym]).request_uri
|
46
46
|
end
|
47
47
|
|
48
48
|
@regex = {}
|
49
|
-
@regex[:capability] = %r{\A #{Regexp.escape(path[:capability])} \z}xm
|
50
|
-
@regex[:event] = %r{\A #{Regexp.escape(path[:webhook])} \z}xm
|
49
|
+
@regex[:capability] = %r{\A #{Regexp.escape(@path[:capability])} \z}xm
|
50
|
+
@regex[:event] = %r{\A #{Regexp.escape(@path[:webhook])} \z}xm
|
51
51
|
|
52
|
-
@regex[:install] = %r{\A #{Regexp.escape(path[:installed])} \z}xm
|
53
|
-
@regex[:uninstall] = %r{\A #{Regexp.escape(path[:installed])} / ([-0-9a-fA-F]+) \z}xm
|
52
|
+
@regex[:install] = %r{\A #{Regexp.escape(@path[:installed])} \z}xm
|
53
|
+
@regex[:uninstall] = %r{\A #{Regexp.escape(@path[:installed])} / ([-0-9a-fA-F]+) \z}xm
|
54
54
|
end
|
55
55
|
|
56
56
|
def call(env)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiptail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ITO Nobuaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
-
description: HipChat Add-on Framework
|
69
|
+
description: HipChat Integration (Add-on) Framework
|
70
70
|
email:
|
71
71
|
- daydream.trippers@gmail.com
|
72
72
|
executables: []
|
@@ -123,5 +123,5 @@ rubyforge_project:
|
|
123
123
|
rubygems_version: 2.2.2
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
|
-
summary: HipChat Add-on Framework
|
126
|
+
summary: HipChat Integration (Add-on) Framework
|
127
127
|
test_files: []
|