chatwork 0.0.6 → 0.0.7

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: 0002230b882c6ce42c5ab7e35754175d54a2f5fc
4
- data.tar.gz: 4e9e4fbf1d37fd2c5afce26b74edcf57dcab0307
3
+ metadata.gz: 25204d174d123a033c044404f9c910d6241e5ff1
4
+ data.tar.gz: 69e0eae2716d3daf0e106aab1fa503adc963b209
5
5
  SHA512:
6
- metadata.gz: 650015698c78315f6e9271e5293f48aa003dcbf55737060ae14b5078ebd1181dc49d4a388f0b34fc1efbc0f739ae4dedfd718cc586b12a633476d30dfb831463
7
- data.tar.gz: 3284b33fbd4553484dcf0d19f675e3f02e0248af7f54be4148fc3675cbcbfb0c770bf5f8dd9093ebde5866de6420502a14955a085bfa3f90fef309c79bf5ca82
6
+ metadata.gz: d5b2e1d16fb62d7d060d30e829cf870e820912cf18ecb82c6d517270967238541ca3b2583d693352dcdb2f73f0710095ac3cd0cc5f4985a05fd9ca4508216b49
7
+ data.tar.gz: d99e7c85eafec243c9125d394b8f9fc9160565154a8dcf8a9f2b469fcf07dad048a7eeed8751b4adae488c24665eb7fee8a5fac1c553ddd3d45c49439afe5844
@@ -1,6 +1,6 @@
1
1
  module ChatWork
2
2
  class Message < Entity
3
- install_class_operations :create
3
+ install_class_operations :create, :get
4
4
 
5
5
  def self.path
6
6
  "/rooms/%d/messages"
@@ -8,7 +8,8 @@ module ChatWork
8
8
  def define_get
9
9
  instance_eval do
10
10
  def get(params = {})
11
- convert(ChatWork.client.get(path, params))
11
+ assign_path = parse_if_hash_key_exists(path, params, :room_id)
12
+ convert(ChatWork.client.get(assign_path, params))
12
13
  end
13
14
  end
14
15
  end
@@ -18,14 +19,19 @@ module ChatWork
18
19
  def create(params = {})
19
20
  # TODO: Consider other pattern
20
21
  # /rooms and /rooms/:room_id
21
- assign_path = if params.include?(:room_id)
22
- path % params.delete(:room_id)
23
- else
24
- path
25
- end
22
+ assign_path = parse_if_hash_key_exists(path, params, :room_id)
26
23
  convert(ChatWork.client.post(assign_path, params))
27
24
  end
28
25
  end
29
26
  end
27
+
28
+ private
29
+ def parse_if_hash_key_exists(string, hash, key)
30
+ if hash.include?(key)
31
+ string % hash.delete(key)
32
+ else
33
+ string
34
+ end
35
+ end
30
36
  end
31
37
  end
@@ -1,3 +1,3 @@
1
1
  module ChatWork
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - asonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -118,3 +118,4 @@ summary: Ruby bindings of Chatwork API
118
118
  test_files:
119
119
  - spec/lib/chatwork_spec.rb
120
120
  - spec/spec_helper.rb
121
+ has_rdoc: