timetree 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: dd2a9142e5ee6614ec6e97f691d61a2b054d0db7616487efa84f7ecfa89aab82
4
- data.tar.gz: f41663400a01d61da7e4cb26ef302c415ff238f8bc58c1b54b1d10156934ab6d
3
+ metadata.gz: cd742156da72043bdb3d549064a3ea4c560fc8ef2c60c340c53647b6cc0ea43b
4
+ data.tar.gz: 828100939eadee2275fa189f34dfe9fdd86b58113941cee0eaaabea26a161753
5
5
  SHA512:
6
- metadata.gz: a7793feb335fcee92f1c19733206a67b3f2e94fcef7e809701db8fd31e80835689f4dbb604422223fcd9c2c6848a5a8ea8ece93dc401cfe65a2b99234c1dde65
7
- data.tar.gz: ce9319e7839ce5663e2b15723b5492825332bab5265e7d57ba3d9bd84c59dd3a2b999ffb5de1c77c941e215c226a43699c4b5267aab790539c19e3ce11eb4a8d
6
+ metadata.gz: f13a82f70529e872f34026d733875f05ef783c9dc5b89b23b6fc989b3256acf6f5640a8c5a377707b6adec96aa04a659cfab8ebd8a83bc9866a626179566a772
7
+ data.tar.gz: 38bf4a08b7e0bb92275ed0a9d20cf31f1623ba5955a560f3491625080e1b0ffdf2075c5e753d916f5aba64f860465582bf46f01a391af15b6c8c712211f9c168
@@ -1,3 +1,9 @@
1
+ # 0.2.1
2
+
3
+ - do refactor
4
+ - use `respond_to?(setter)` instead of `instance_methods.include?(setter)`.
5
+ - use getter method instead of instant variables if defined it.
6
+
1
7
  # 0.2.0
2
8
 
3
9
  - organize model classes.
@@ -23,7 +23,7 @@ module TimeTree
23
23
  end
24
24
 
25
25
  def inspect
26
- "\#<#{self.class}:#{object_id} title:#{@title}, status:#{@status}>"
26
+ "\#<#{self.class}:#{object_id} title:#{title}, status:#{status}>"
27
27
  end
28
28
  end
29
29
  end
@@ -240,10 +240,10 @@ module TimeTree
240
240
  def inspect
241
241
  limit_info = nil
242
242
  if defined?(@ratelimit_limit) && @ratelimit_limit
243
- limit_info = " ratelimit:#{@ratelimit_remaining}/#{@ratelimit_limit}"
243
+ limit_info = " ratelimit:#{ratelimit_remaining}/#{ratelimit_limit}"
244
244
  end
245
245
  if defined?(@ratelimit_reset_at) && @ratelimit_reset_at
246
- limit_info = "#{limit_info}, reset_at:#{@ratelimit_reset_at.strftime('%m/%d %R')}"
246
+ limit_info = "#{limit_info}, reset_at:#{ratelimit_reset_at.strftime('%m/%d %R')}"
247
247
  end
248
248
  "\#<#{self.class}:#{object_id}#{limit_info}>"
249
249
  end
@@ -11,9 +11,8 @@ module TimeTree
11
11
  attr_accessor :logger
12
12
 
13
13
  def initialize
14
- logger = Logger.new(STDOUT)
15
- logger.level = :warn
16
- @logger = logger
14
+ @logger = Logger.new(STDOUT)
15
+ @logger.level = :warn
17
16
  end
18
17
  end
19
18
  end
@@ -15,10 +15,10 @@ module TimeTree
15
15
  # @param path [String] String or URI to access.
16
16
  # @param params [Hash] Hash of URI query unencoded key/value pairs.
17
17
  def get(path, params = {})
18
- logger.info "GET #{connection.build_url("#{@host}#{path}", params)}"
18
+ @logger.info "GET #{connection.build_url("#{@host}#{path}", params)}"
19
19
  res = connection.get path, params
20
20
  @client.update_ratelimit(res)
21
- logger.debug "Response status:#{res.status}, body:#{res.body}"
21
+ @logger.debug "Response status:#{res.status}, body:#{res.body}"
22
22
  res
23
23
  end
24
24
 
@@ -30,7 +30,7 @@ module TimeTree
30
30
  headers = { 'Content-Type' => 'application/json' }
31
31
  res = connection.run_request :post, path, body_params.to_json, headers
32
32
  @client.update_ratelimit(res)
33
- logger.debug "Response status:#{res.status}, body:#{res.body}"
33
+ @logger.debug "Response status:#{res.status}, body:#{res.body}"
34
34
  res
35
35
  end
36
36
 
@@ -38,11 +38,11 @@ module TimeTree
38
38
  # @param body_params [Hash]
39
39
  # The request bodythat will eventually be converted to JSON.
40
40
  def put(path, body_params = {})
41
- logger.debug "PUT #{@host}#{path} body:#{body_params}"
41
+ @logger.debug "PUT #{@host}#{path} body:#{body_params}"
42
42
  headers = { 'Content-Type' => 'application/json' }
43
43
  res = connection.run_request :put, path, body_params.to_json, headers
44
44
  @client.update_ratelimit(res)
45
- logger.debug "Response status:#{res.status}, body:#{res.body}"
45
+ @logger.debug "Response status:#{res.status}, body:#{res.body}"
46
46
  res
47
47
  end
48
48
 
@@ -52,14 +52,12 @@ module TimeTree
52
52
  @logger.debug "DELETE #{@host}#{path} params:#{params}"
53
53
  res = connection.delete path, params
54
54
  @client.update_ratelimit(res)
55
- logger.debug "Response status:#{res.status}, body:#{res.body}"
55
+ @logger.debug "Response status:#{res.status}, body:#{res.body}"
56
56
  res
57
57
  end
58
58
 
59
59
  private
60
60
 
61
- attr_reader :logger
62
-
63
61
  def connection
64
62
  Faraday.new(
65
63
  url: @host,
@@ -78,10 +78,8 @@ module TimeTree
78
78
  return unless attributes.is_a? Hash
79
79
  return if attributes.empty?
80
80
 
81
- setter_methods = self.class.instance_methods.select { |method| method.to_s.end_with? '=' }
82
81
  attributes.each do |key, value|
83
- setter = "#{key.to_sym}=".to_sym
84
- next unless setter_methods.include? setter
82
+ next unless respond_to?("#{key}=".to_sym)
85
83
 
86
84
  if defined?(self.class::TIME_FIELDS) && self.class::TIME_FIELDS.include?(key)
87
85
  value = Time.parse value
@@ -126,7 +124,7 @@ module TimeTree
126
124
 
127
125
  @_relation_data_dic[type][id]
128
126
  }
129
- @relationships.each do |key, id_data|
127
+ relationships.each do |key, id_data|
130
128
  relation_data = nil
131
129
  if id_data.is_a? Array
132
130
  relation_data = []
@@ -123,8 +123,8 @@ module TimeTree
123
123
  private
124
124
 
125
125
  def relationships_params
126
- current_label = label ? { type: 'label', id: label.id } : @relationships[:label]
127
- current_attendees = attendees ? attendees.map { |u| { type: 'user', id: u.id } } : @relationships[:attendees]
126
+ current_label = label ? { type: 'label', id: label.id } : relationships[:label]
127
+ current_attendees = attendees ? attendees.map { |u| { type: 'user', id: u.id } } : relationships[:attendees]
128
128
  {
129
129
  label: { data: current_label },
130
130
  attendees: { data: current_attendees }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimeTree
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Koshikawa
@@ -189,7 +189,7 @@ metadata:
189
189
  homepage_uri: https://github.com/koshilife/timetree-api-ruby-client
190
190
  source_code_uri: https://github.com/koshilife/timetree-api-ruby-client
191
191
  changelog_uri: https://github.com/koshilife/timetree-api-ruby-client/blob/master/CHANGELOG.md
192
- documentation_uri: https://www.rubydoc.info/gems/timetree/0.2.0
192
+ documentation_uri: https://www.rubydoc.info/gems/timetree/0.2.1
193
193
  post_install_message:
194
194
  rdoc_options: []
195
195
  require_paths: