matrix_dbus 0.2.3 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0abea51845bfb868f2c2c350cfdc8e798f003ec
4
- data.tar.gz: 48aae892c08bceb438402a2f0f21ebcb89e24b81
3
+ metadata.gz: 4ebf2f32f1469b4f1b51d9b95b40c8c1c0f5baeb
4
+ data.tar.gz: 3654864c75694264fe3bab451643aab2aed45e8c
5
5
  SHA512:
6
- metadata.gz: 807b960256087765b394125c5e38661fdb3201f2f0197d07f597d97b42f99aa2ac3beb95c93a2796acb1d54469963cf9b9437e71e69174ddd4aca90ad428fa7c
7
- data.tar.gz: 0ccba6afdc62cbc50dfffe540ff359c70f7df6b29d070b640a69c50830cfae1178c6504045347d67dbf209357c3a6921acd0fa2f6e09df1b793bd889ee46c2c0
6
+ metadata.gz: 890775cca95492ea0ef54aa1a8eb93ad2db5f0e29679773c0b3452ade8203dcc14901bb78436f8a5f52ebddb5acfeb42627ba4e99aed72f84871ef9f0b8d2cb7
7
+ data.tar.gz: 7c550514c6452dc32c79e9bb82d747963f342d23a0ec9d7ba1f7b7b912f0d1a364ffa179c4b7dfce9a02562b49537644cdfdf93fa878c69e4e6b4b2181f117f7
data/exe/matrix-dbus CHANGED
@@ -4,12 +4,12 @@ require 'matrix_dbus'
4
4
  Thread.abort_on_exception = true
5
5
 
6
6
  def send_if_exist(obj, name, json)
7
- obj.method(name).call json.to_json unless json.empty?
7
+ obj.method(name).call JSON.pretty_generate json unless json.empty?
8
8
  end
9
9
 
10
10
  def matrix2dbus(c, obj)
11
11
  j = c.json
12
- obj.all j.to_json
12
+ obj.all JSON.pretty_generate j
13
13
 
14
14
  %i[account_data to_device presence].each do |name|
15
15
  send_if_exist obj, name, j[name.to_s]['events']
@@ -14,33 +14,42 @@ module MatrixDBus
14
14
 
15
15
  dbus_interface 'org.dastudio.matrix' do
16
16
  %i[post put].each do |way|
17
- dbus_method way, 'in url:s, in args:s' do |url, args|
17
+ dbus_method way, 'in url:s, in args:s, out res:s' do |url, args|
18
+ args = '{}' if args == ''
18
19
  args = JSON.parse args
19
20
  url = URI(url)
20
21
  url.query = URI.encode_www_form access_token: @matrix.access_token
22
+ url = url.to_s
21
23
  begin
22
- @matrix.network.method(way).call url.to_s, args
24
+ [@matrix.network.method(way).call(url, args).to_json]
23
25
  rescue RestClient::Exception => e
26
+ puts e
24
27
  puts e.response.body
25
28
  end
26
29
  end
27
30
  end
28
31
 
29
32
  %i[get delete].each do |way|
30
- dbus_method way, 'in url:s, in args:s' do |url, args|
33
+ dbus_method way, 'in url:s, in args:s, out res:s' do |url, args|
34
+ args = '{}' if args == ''
31
35
  args = JSON.parse args
32
36
  args[:access_token] = @matrix.access_token
33
37
  begin
34
- @matrix.network.method(way).call url, args
38
+ [@matrix.network.method(way).call(url, args).to_json]
35
39
  rescue RestClient::Exception => e
40
+ puts e
36
41
  puts e.response.body
37
42
  end
38
43
  end
39
44
  end
40
45
 
41
- dbus_method :post_raw, 'in url:s, in body:s' do |url, body|
42
- body = Base64.decode64 body
43
- @matrix.network.post_raw url, body
46
+ dbus_method :post_raw, 'in url:s, in body:s, out res:s' do |url, body|
47
+ begin
48
+ [@matrix.network.post_raw(url, Base64.decode64(body)).to_json]
49
+ rescue RestClient::Exception => e
50
+ puts e
51
+ puts e.response.body
52
+ end
44
53
  end
45
54
 
46
55
  %i[
@@ -1,3 +1,3 @@
1
1
  module MatrixDBus
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrix_dbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-15 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler