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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 301622474ab7870e4bc7b6d51888c6af0f16224de722f865925b180ac8aa55b5
4
- data.tar.gz: 745b6eaae10a5911cfd14ea8e53d587e8891e41e803fae50ba6ba502bb3b481c
3
+ metadata.gz: bbc0b45bd43456ece01cee8ee7cb111ddd153c401b5d2bf2c4f3fe994c6ded53
4
+ data.tar.gz: da276d6fe8554b88c5627e0183e86070ac09b34dfb991a09beeaf7c58127cf06
5
5
  SHA512:
6
- metadata.gz: 6d3b4a9e19b02158ca9939980ab02e2f5665a98d5d004b8d63d4f2eda7e76eacddf253c1ef1c16cb17b24780bce853c04814bd3dd98763c372148fd777ca89dd
7
- data.tar.gz: 0e65991b921fb0e541a50c2aa6cc92ac700ebcde31539bc8a562cb47d244956790f0dec64c033717fc87ca2315ef8c135fd42461d531c9a1353059357c494b58
6
+ metadata.gz: a37b6b08583b45874a91db8f2d5e9a82bb29d4ffbf0aa90606a94f78d0862bd7c3028dfaddcd3bb715f570bcd6a211bc542f2de8361d30eda1fdc91f45df2f46
7
+ data.tar.gz: a84e438fb953c64d47cbd7c12925e01acdb52b6fc105bda7cbac45d5e7cdd97a275612626bfdb02ccd11064084388fb823677449676739fd5648af7a65066aee
@@ -1,6 +1,12 @@
1
1
  # Change Log
2
2
  ## Unreleased
3
- [Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.8.0...master)
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
@@ -7,3 +7,11 @@ begin
7
7
  rescue
8
8
  warn("Install rspec")
9
9
  end
10
+
11
+ desc "Update API schama"
12
+ task :update_api_schema do
13
+ command = "git submodule foreach git pull origin master --ff"
14
+ sh command
15
+ sh "git add api"
16
+ sh "git commit -m '#{command}'"
17
+ end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path("../lib", __FILE__)
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/}) { |f| File.basename(f) }
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.52.1.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.52.1"
35
- spec.add_development_dependency "rubocop-rspec", "1.21.0"
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 [Integer]
42
- # @param body [String] message 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
@@ -1,7 +1,7 @@
1
1
  module ChatWork
2
2
  module Converter
3
3
  def hash_compact(hash)
4
- hash.reject { |_k, v| v.nil? }
4
+ hash.reject {|_k, v| v.nil? }
5
5
  end
6
6
 
7
7
  def boolean_to_integer(value)
@@ -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 [Integer]
43
- # @param body [String] message 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
@@ -1,3 +1,3 @@
1
1
  module ChatWork
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
@@ -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) { 123 }
28
- let(:body) { "Hello ChatWork!" }
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) { 123 }
28
- let(:body) { "Hello ChatWork!" }
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
@@ -25,7 +25,7 @@ begin
25
25
  rescue LoadError # rubocop:disable Lint/HandleExceptions
26
26
  end
27
27
 
28
- Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
28
+ Dir["#{__dir__}/support/**/*.rb"].each {|f| require f }
29
29
 
30
30
  def spec_dir
31
31
  Pathname(__dir__)
@@ -1,6 +1,6 @@
1
1
  module RamlParser
2
2
  def self.find_resource(verb, path)
3
- elements = path.split("/").reject(&:empty?).map { |str| "/#{str}" }
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 ||= YAML.load_file(schema_file)
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.8.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-02-21 00:00:00.000000000 Z
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.52.1.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.52.1.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.52.1
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.52.1
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.21.0
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.21.0
223
+ version: 1.24.0
224
224
  - !ruby/object:Gem::Dependency
225
225
  name: webmock
226
226
  requirement: !ruby/object:Gem::Requirement