lita-irkit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/lita/handlers/irkit.rb +11 -7
- data/lita-irkit.gemspec +2 -2
- 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: d8fd505367b9e0c72152dde9c7153fb18675c236
|
4
|
+
data.tar.gz: f2e2a3ce84fbb32234973f766481964d856219d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba81d73d002f2d2043dcc39e83a4335703620b88350d41991fd045b5ed42d2bcb5504c9b05204c9e574a34203e77cf77bb7f1a50f44900f425c6a62a6244e4b
|
7
|
+
data.tar.gz: df040079f3895ab7136066216ee91b6ec86bce6202cdd5392a8238f4d565d7f3ca78966cf0e4ba4f55a871ee5e7de02669d67c143c0257cc63d8915e9dddac70
|
data/README.md
CHANGED
@@ -15,8 +15,8 @@ gem "lita-irkit"
|
|
15
15
|
|
16
16
|
```
|
17
17
|
def self.default_config(handler_config)
|
18
|
-
|
19
|
-
|
18
|
+
config.handlers.irkit.deviceid = ENV["IRKIT_DEVICEID"]
|
19
|
+
config.handlers.irkit.clientkey = ENV["IRKIT_CLIENTKEY"]
|
20
20
|
end
|
21
21
|
```
|
22
22
|
|
data/lib/lita/handlers/irkit.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module Lita
|
@@ -20,10 +20,10 @@ module Lita
|
|
20
20
|
|
21
21
|
def ir_save(response)
|
22
22
|
cmd = response.matches[0][0]
|
23
|
-
ir_data =
|
24
|
-
return response.reply "ir data not found"
|
23
|
+
ir_data = irkit_api.get('/1/messages', clientkey: config.clientkey).body
|
24
|
+
return response.reply "ir data not found" if ir_data.length == 0
|
25
25
|
|
26
|
-
Lita.redis["irkit:messages:#{cmd}"] = ir_data
|
26
|
+
Lita.redis["irkit:messages:#{cmd}"] = JSON.parse(ir_data)['message'].to_json
|
27
27
|
response.reply "ir data saved: #{cmd}"
|
28
28
|
end
|
29
29
|
|
@@ -32,7 +32,7 @@ module Lita
|
|
32
32
|
message = Lita.redis["irkit:messages:#{cmd}"]
|
33
33
|
return response.reply 'ir data not found' unless message
|
34
34
|
|
35
|
-
|
35
|
+
irkit_api.post('/1/messages', clientkey: config.clientkey, deviceid: config.deviceid, message: message)
|
36
36
|
response.reply "ir data send: #{cmd}"
|
37
37
|
end
|
38
38
|
|
@@ -46,8 +46,12 @@ module Lita
|
|
46
46
|
Lita.config.handlers.irkit
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
@
|
49
|
+
def irkit_api
|
50
|
+
@conn ||= Faraday.new(url: 'https://api.getirkit.com') do |faraday|
|
51
|
+
faraday.request :url_encoded # form-encode POST params
|
52
|
+
faraday.response :logger # log requests to STDOUT
|
53
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
data/lita-irkit.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-irkit"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.2"
|
4
4
|
spec.authors = ["fukayatsu"]
|
5
5
|
spec.email = ["fukayatsu@gmail.com"]
|
6
6
|
spec.description = %q{Use IRKit on Lita}
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
17
|
spec.add_runtime_dependency "lita", ">= 3.0"
|
18
|
-
spec.add_runtime_dependency "
|
18
|
+
spec.add_runtime_dependency "faraday", "~> 0.9.0"
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.3"
|
21
21
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-irkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukayatsu
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0
|
33
|
+
version: 0.9.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0
|
40
|
+
version: 0.9.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|