mattermost-api4-ruby 0.0.4 → 0.0.5

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: 19d64e50d31233c3c823ca05b2bde709d004e2b4
4
- data.tar.gz: 8ecbb00dff5bfcdbdebeca57d9d56b294e7f7076
3
+ metadata.gz: 453726be51caf53eb629876117442a8c82554ded
4
+ data.tar.gz: 4ef64f428543c919563490ea52991d5aee0fc677
5
5
  SHA512:
6
- metadata.gz: 7d85a810c0a898da5c6fb26f59b48e59cf32603f52f867310394799456ae78ffdd87e16569242fcafeb3b63e414d0511a3377144ec2ebf8ffe3145b80dc6c930
7
- data.tar.gz: 5fd7a8abae791675cb01a738d5c89897ef8685fc9b649ec5494345b651d79c6ed6f496a40637333d1bb276fa05fac4235e57c2040182f0a7e6a5aa58a0b7ac58
6
+ metadata.gz: a8989c285bfd95deaf758499d8e1ac23204ee9e4904cab4aba8d4a8d57347888695706a8205a9ef75023e13c2292f9748a4ba1241011fc9788131d0901164fe9
7
+ data.tar.gz: ac82028d997ede72781cc152baa4de928ab1c1e0099506e6c9295f6ecf551bcf704a0595711d452e43f6a4f5664bf30e8e283b411a5168e5b16649be31a1badb
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Change Log
2
+
3
+ ## [v0.0.5](https://github.com/maruTA-bis5/mattermost-api4-ruby/tree/v0.0.5) (2018-01-17)
4
+ [Full Changelog](https://github.com/maruTA-bis5/mattermost-api4-ruby/compare/v0.0.4...v0.0.5)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - Could not receive WebSocket event after few seconds [\#9](https://github.com/maruTA-bis5/mattermost-api4-ruby/issues/9)
9
+ - WebSocketClient\#connected? throws NoMethodError [\#8](https://github.com/maruTA-bis5/mattermost-api4-ruby/issues/8)
10
+
11
+ ## [v0.0.4](https://github.com/maruTA-bis5/mattermost-api4-ruby/tree/v0.0.4) (2018-01-13)
12
+ [Full Changelog](https://github.com/maruTA-bis5/mattermost-api4-ruby/compare/v0.0.3...v0.0.4)
13
+
14
+ **Implemented enhancements:**
15
+
16
+ - WebSocket Support [\#1](https://github.com/maruTA-bis5/mattermost-api4-ruby/issues/1)
17
+
18
+ **Closed issues:**
19
+
20
+ - 0.0.1 doesn't work [\#3](https://github.com/maruTA-bis5/mattermost-api4-ruby/issues/3)
21
+
22
+ ## [v0.0.3](https://github.com/maruTA-bis5/mattermost-api4-ruby/tree/v0.0.3) (2018-01-09)
23
+ [Full Changelog](https://github.com/maruTA-bis5/mattermost-api4-ruby/compare/v0.0.2...v0.0.3)
24
+
25
+ ## [v0.0.2](https://github.com/maruTA-bis5/mattermost-api4-ruby/tree/v0.0.2) (2018-01-09)
26
+ [Full Changelog](https://github.com/maruTA-bis5/mattermost-api4-ruby/compare/v0.0.1...v0.0.2)
27
+
28
+ ## [v0.0.1](https://github.com/maruTA-bis5/mattermost-api4-ruby/tree/v0.0.1) (2018-01-08)
29
+
30
+
31
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -26,7 +26,7 @@ TODO: Write usage instructions here
26
26
 
27
27
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
28
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update CHANGELOG.md by `bundle exec github_changelog_generator --future-release=<new version> --since-tag=<latest version> maruTA-bis5/mattermost-api4-ruby`, update the version number in gemspec, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
30
 
31
31
  ## Contributing
32
32
 
@@ -1,4 +1,4 @@
1
- require 'websocket-client-simple'
1
+ require 'faye/websocket'
2
2
  require 'event_emitter'
3
3
  require 'json'
4
4
 
@@ -9,29 +9,26 @@ module Mattermost
9
9
  def initialize(url, token, option = {})
10
10
  @token = token
11
11
  @url = url
12
+ @option = option
12
13
  @seq_mutex = Mutex.new
13
- @seq = 0
14
14
  @connected = false
15
+ yield self if block_given?
16
+ connect
17
+ self
18
+ end
19
+
20
+ def connect
21
+ return self if connected?
15
22
  mm_ws = self
16
- @client = WebSocket::Client::Simple.connect(url, option) do |ws|
17
- ws.on :open do
18
- mm_ws.on_open
19
- end
20
- ws.on :message do |msg|
21
- mm_ws.on_message msg.data
22
- end
23
- ws.on :close do |e|
24
- mm_ws.on_close e
25
- end
26
- ws.on :error do |e|
27
- mm_ws.on_error e
23
+ @em = Thread.new do
24
+ EM.run do
25
+ mm_ws.connect_internal
28
26
  end
29
27
  end
30
- yield self if block_given?
31
28
  end
32
29
 
33
- def on_open
34
- emit :open
30
+ def on_open(e)
31
+ emit :open, e
35
32
  end
36
33
 
37
34
  def on_message(data)
@@ -44,8 +41,8 @@ module Mattermost
44
41
  @connected = true
45
42
  else
46
43
  emit event.to_sym, json
47
- emit :message, json
48
44
  end
45
+ emit :message, json
49
46
  end
50
47
 
51
48
  def on_close(msg)
@@ -67,11 +64,35 @@ module Mattermost
67
64
  end
68
65
 
69
66
  def connected?
70
- @connected && @client.connected?
67
+ @connected && (@client != nil && @client.ready_state == Faye::WebSocket::API::OPEN)
71
68
  end
72
69
 
73
70
  def close
74
- @client.close
71
+ @connected = false
72
+ @client.close if @client != nil
73
+ @client = nil
74
+ Thread.kill @em if @em != nil
75
+ @em = nil
76
+ end
77
+
78
+ def connect_internal
79
+ @seq = 0
80
+ mm_ws = self
81
+ @client = Faye::WebSocket::Client.new(@url.gsub(/^http(s?):/, 'ws\1:'), {}, { :headers => {
82
+ 'Authorization' => "Bearer #{@token}"
83
+ }})
84
+ @client.on :open do |e|
85
+ mm_ws.on_open e
86
+ end
87
+ @client.on :message do |msg|
88
+ mm_ws.on_message msg.data
89
+ end
90
+ @client.on :close do |e|
91
+ mm_ws.on_close e
92
+ end
93
+ @client.on :error do |e|
94
+ mm_ws.on_error e
95
+ end
75
96
  end
76
97
 
77
98
  private
@@ -90,5 +111,6 @@ module Mattermost
90
111
  @seq
91
112
  end
92
113
  end
114
+
93
115
  end
94
116
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "mattermost-api4-ruby"
5
- spec.version = "0.0.4"
5
+ spec.version = "0.0.5"
6
6
  spec.authors = ["Takayuki Maruyama"]
7
7
  spec.email = ["bis5.wsys@gmail.com"]
8
8
 
@@ -20,8 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "bundler", "~> 1.13"
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "github_changelog_generator"
23
24
 
24
25
  spec.add_dependency "httparty", "~> 0.15"
25
- spec.add_dependency "websocket-client-simple", "~> 0.3"
26
+ spec.add_dependency "faye-websocket", "~> 0.10"
27
+ spec.add_dependency "event_emitter", "~> 0.2"
26
28
 
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mattermost-api4-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takayuki Maruyama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-13 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github_changelog_generator
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'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: httparty
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +81,33 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.15'
69
83
  - !ruby/object:Gem::Dependency
70
- name: websocket-client-simple
84
+ name: faye-websocket
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: event_emitter
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '0.3'
103
+ version: '0.2'
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '0.3'
110
+ version: '0.2'
83
111
  description:
84
112
  email:
85
113
  - bis5.wsys@gmail.com
@@ -90,6 +118,7 @@ files:
90
118
  - ".gitignore"
91
119
  - ".rspec"
92
120
  - ".travis.yml"
121
+ - CHANGELOG.md
93
122
  - Gemfile
94
123
  - LICENSE.txt
95
124
  - README.md