chatwork 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +0 -1
- data/Rakefile +8 -0
- data/chatwork.gemspec +5 -5
- data/lib/chatwork/client/message_methods.rb +5 -4
- data/lib/chatwork/converter.rb +1 -1
- data/lib/chatwork/message.rb +5 -4
- data/lib/chatwork/version.rb +1 -1
- data/spec/lib/chatwork/client/message_methods_spec.rb +4 -3
- data/spec/lib/chatwork/message_spec.rb +4 -3
- data/spec/lib/support/utils/raml_parser_spec.rb +18 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/utils/raml_parser.rb +9 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbc0b45bd43456ece01cee8ee7cb111ddd153c401b5d2bf2c4f3fe994c6ded53
|
4
|
+
data.tar.gz: da276d6fe8554b88c5627e0183e86070ac09b34dfb991a09beeaf7c58127cf06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37b6b08583b45874a91db8f2d5e9a82bb29d4ffbf0aa90606a94f78d0862bd7c3028dfaddcd3bb715f570bcd6a211bc542f2de8361d30eda1fdc91f45df2f46
|
7
|
+
data.tar.gz: a84e438fb953c64d47cbd7c12925e01acdb52b6fc105bda7cbac45d5e7cdd97a275612626bfdb02ccd11064084388fb823677449676739fd5648af7a65066aee
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
## Unreleased
|
3
|
-
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.
|
3
|
+
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.9.0...master)
|
4
|
+
|
5
|
+
## v0.9.0
|
6
|
+
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.8.0...v0.9.0)
|
7
|
+
|
8
|
+
* Add `self_unread` option to `ChatWork::Client#create_message` and `ChatWork::Message.create`
|
9
|
+
* https://github.com/asonas/chatwork-ruby/pull/52
|
4
10
|
|
5
11
|
## v0.8.0
|
6
12
|
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.7.0...v0.8.0)
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@ Ruby bindings of ChatWork API
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/chatwork.svg)](https://badge.fury.io/rb/chatwork)
|
6
6
|
[![Build Status](https://travis-ci.org/asonas/chatwork-ruby.svg?branch=master)](https://travis-ci.org/asonas/chatwork-ruby)
|
7
7
|
[![Coverage Status](https://coveralls.io/repos/github/asonas/chatwork-ruby/badge.svg?branch=master)](https://coveralls.io/github/asonas/chatwork-ruby)
|
8
|
-
[![Dependency Status](https://gemnasium.com/badges/github.com/asonas/chatwork-ruby.svg)](https://gemnasium.com/github.com/asonas/chatwork-ruby)
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
data/Rakefile
CHANGED
data/chatwork.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path("
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require "chatwork/version"
|
4
4
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
-
spec.executables = spec.files.grep(%r{^exe/}) {
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
@@ -25,14 +25,14 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
26
|
spec.add_development_dependency "coveralls"
|
27
27
|
spec.add_development_dependency "dotenv"
|
28
|
-
spec.add_development_dependency "onkcop", "0.
|
28
|
+
spec.add_development_dependency "onkcop", "0.53.0.0"
|
29
29
|
spec.add_development_dependency "pry-byebug"
|
30
30
|
spec.add_development_dependency "rake"
|
31
31
|
spec.add_development_dependency "rspec"
|
32
32
|
spec.add_development_dependency "rspec-its"
|
33
33
|
spec.add_development_dependency "rspec-parameterized"
|
34
|
-
spec.add_development_dependency "rubocop", "0.
|
35
|
-
spec.add_development_dependency "rubocop-rspec", "1.
|
34
|
+
spec.add_development_dependency "rubocop", "0.53.0"
|
35
|
+
spec.add_development_dependency "rubocop-rspec", "1.24.0"
|
36
36
|
spec.add_development_dependency "webmock"
|
37
37
|
spec.add_development_dependency "yard"
|
38
38
|
end
|
@@ -38,8 +38,9 @@ module ChatWork::Client::MessageMethods
|
|
38
38
|
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-messages
|
39
39
|
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
40
40
|
#
|
41
|
-
# @param room_id
|
42
|
-
# @param body
|
41
|
+
# @param room_id [Integer]
|
42
|
+
# @param body [String] message body
|
43
|
+
# @param self_unread [Boolean] Whether to add the added message as unread by looking at it from myself
|
43
44
|
#
|
44
45
|
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
45
46
|
# @yieldparam response_body [Hashie::Mash] response body
|
@@ -51,8 +52,8 @@ module ChatWork::Client::MessageMethods
|
|
51
52
|
# {
|
52
53
|
# "message_id": "1234"
|
53
54
|
# }
|
54
|
-
def create_message(room_id:, body:, &block)
|
55
|
-
post("/rooms/#{room_id}/messages", body: body, &block)
|
55
|
+
def create_message(room_id:, body:, self_unread: false, &block)
|
56
|
+
post("/rooms/#{room_id}/messages", body: body, self_unread: boolean_to_integer(self_unread), &block)
|
56
57
|
end
|
57
58
|
|
58
59
|
# Mark messages as read
|
data/lib/chatwork/converter.rb
CHANGED
data/lib/chatwork/message.rb
CHANGED
@@ -39,8 +39,9 @@ module ChatWork
|
|
39
39
|
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-messages
|
40
40
|
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
41
41
|
#
|
42
|
-
# @param room_id
|
43
|
-
# @param body
|
42
|
+
# @param room_id [Integer]
|
43
|
+
# @param body [String] message body
|
44
|
+
# @param self_unread [Boolean] Whether to add the added message as unread by looking at it from myself
|
44
45
|
#
|
45
46
|
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
46
47
|
# @yieldparam response_body [Hashie::Mash] response body
|
@@ -52,8 +53,8 @@ module ChatWork
|
|
52
53
|
# {
|
53
54
|
# "message_id": "1234"
|
54
55
|
# }
|
55
|
-
def self.create(room_id:, body:, &block)
|
56
|
-
ChatWork.client.create_message(room_id: room_id, body: body, &block)
|
56
|
+
def self.create(room_id:, body:, self_unread: false, &block)
|
57
|
+
ChatWork.client.create_message(room_id: room_id, body: body, self_unread: self_unread, &block)
|
57
58
|
end
|
58
59
|
|
59
60
|
# Mark messages as read
|
data/lib/chatwork/version.rb
CHANGED
@@ -22,10 +22,11 @@ describe ChatWork::Client::MessageMethods do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "#create_message", type: :api do
|
25
|
-
subject { client.create_message(room_id: room_id, body: body, &block) }
|
25
|
+
subject { client.create_message(room_id: room_id, body: body, self_unread: self_unread, &block) }
|
26
26
|
|
27
|
-
let(:room_id)
|
28
|
-
let(:body)
|
27
|
+
let(:room_id) { 123 }
|
28
|
+
let(:body) { "Hello ChatWork!" }
|
29
|
+
let(:self_unread) { false }
|
29
30
|
|
30
31
|
before do
|
31
32
|
stub_chatwork_request(:post, "/rooms/#{room_id}/messages", "/rooms/{room_id}/messages")
|
@@ -22,10 +22,11 @@ describe ChatWork::Message do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe ".create", type: :api do
|
25
|
-
subject { ChatWork::Message.create(room_id: room_id, body: body, &block) }
|
25
|
+
subject { ChatWork::Message.create(room_id: room_id, body: body, self_unread: self_unread, &block) }
|
26
26
|
|
27
|
-
let(:room_id)
|
28
|
-
let(:body)
|
27
|
+
let(:room_id) { 123 }
|
28
|
+
let(:body) { "Hello ChatWork!" }
|
29
|
+
let(:self_unread) { false }
|
29
30
|
|
30
31
|
before do
|
31
32
|
stub_chatwork_request(:post, "/rooms/#{room_id}/messages", "/rooms/{room_id}/messages")
|
@@ -5,7 +5,7 @@ RSpec.describe RamlParser do
|
|
5
5
|
let(:verb) { :get }
|
6
6
|
let(:path) { "/rooms/{room_id}/members" }
|
7
7
|
|
8
|
-
its(["description"]) { should eq "
|
8
|
+
its(["description"]) { should eq "チャットのメンバー一覧を取得\n" }
|
9
9
|
its(["is"]) { should eq ["room_member_list_response", "unauthorized_response"] }
|
10
10
|
end
|
11
11
|
|
@@ -76,4 +76,21 @@ RSpec.describe RamlParser do
|
|
76
76
|
its(["description"]) { should eq "group chat description" }
|
77
77
|
its(["icon_preset"]) { should eq "meeting" }
|
78
78
|
end
|
79
|
+
|
80
|
+
describe ".raml" do
|
81
|
+
subject { RamlParser.raml }
|
82
|
+
|
83
|
+
before do
|
84
|
+
RamlParser.instance_variable_set(:@raml, nil)
|
85
|
+
end
|
86
|
+
|
87
|
+
after do
|
88
|
+
RamlParser.instance_variable_set(:@raml, nil)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "3 digit number can be read as a string" do
|
92
|
+
comma_separated_integer_list = subject["traits"][0]["room_members"]["queryParameters"]["members_admin_ids"]["example"]
|
93
|
+
expect(comma_separated_integer_list).to eq "123,542,1001"
|
94
|
+
end
|
95
|
+
end
|
79
96
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RamlParser
|
2
2
|
def self.find_resource(verb, path)
|
3
|
-
elements = path.split("/").reject(&:empty?).map {
|
3
|
+
elements = path.split("/").reject(&:empty?).map {|str| "/#{str}" }
|
4
4
|
elements << verb.to_s.upcase
|
5
5
|
find_node(elements)
|
6
6
|
end
|
@@ -68,9 +68,15 @@ module RamlParser
|
|
68
68
|
private_class_method :find_node
|
69
69
|
|
70
70
|
def self.raml
|
71
|
-
@raml
|
71
|
+
return @raml if @raml
|
72
|
+
|
73
|
+
yaml_data = schema_file.read
|
74
|
+
|
75
|
+
# e.g. example: 123,542,1001 -> example: '123,542,1001'
|
76
|
+
yaml_data.gsub!(/example: ([0-9,]+)/) { "example: '#{Regexp.last_match(1)}'" }
|
77
|
+
|
78
|
+
@raml = YAML.safe_load(yaml_data)
|
72
79
|
end
|
73
|
-
private_class_method :raml
|
74
80
|
|
75
81
|
def self.parse_response(response_json)
|
76
82
|
JSON.parse(response_json)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asonas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -115,14 +115,14 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
118
|
+
version: 0.53.0.0
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
125
|
+
version: 0.53.0.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: pry-byebug
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,28 +199,28 @@ dependencies:
|
|
199
199
|
requirements:
|
200
200
|
- - '='
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 0.
|
202
|
+
version: 0.53.0
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
207
|
- - '='
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 0.
|
209
|
+
version: 0.53.0
|
210
210
|
- !ruby/object:Gem::Dependency
|
211
211
|
name: rubocop-rspec
|
212
212
|
requirement: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
214
|
- - '='
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: 1.
|
216
|
+
version: 1.24.0
|
217
217
|
type: :development
|
218
218
|
prerelease: false
|
219
219
|
version_requirements: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
221
|
- - '='
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version: 1.
|
223
|
+
version: 1.24.0
|
224
224
|
- !ruby/object:Gem::Dependency
|
225
225
|
name: webmock
|
226
226
|
requirement: !ruby/object:Gem::Requirement
|