tanita-api-client 0.5.0 → 0.5.1

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: 737f202f36b984c1ed0e834a6268232b876279f95dc5c8ef18c5e050b7bd1c81
4
- data.tar.gz: a43bd145e16d174f73cb9b5a1c7fc595eac5c1f2d277df7fca4fc52955b72659
3
+ metadata.gz: 2cb4cedf41e749ea0b6b75bb3477d80e3572ecb38fa39667af9b0aadabcdab11
4
+ data.tar.gz: 2beef47a5586a8b1fecf0c413d3bd330ee9ca2fb05031620ff85412eb5ec9af9
5
5
  SHA512:
6
- metadata.gz: 8e1ec5042d3cf0fca881b1080421733e96d56a83bb96e870f37143b63d1a3a4baced1e848f99f22099555afe03ab26ef0cc6444a5e78c38d469080c95af94ef7
7
- data.tar.gz: 54bf5cb16391d8ef4a53c3a08f6cef0eec6572640a14c998ac2fae375b5cfe1752d03a97ae901660ea2029abb37a489bc2ba85508268609913284199f88cdefc
6
+ metadata.gz: cdd24c58765cff70412a19471edd7a0349a472f180d62bda703756a59d03158e9a804e209cdd05d3c415e10080b5c3155b69e21e2a4b5486db10407321b9f139
7
+ data.tar.gz: efa02fb10dffbc58efc8009ebf5d98e53da1fe5df5d8ea0e4611bfeea1f6f78fa9115c39b4743931d5654fa18efb11a9b3e10721f00de33cb1fcc4f3b9f933d8
@@ -23,12 +23,11 @@ Metrics/BlockNesting:
23
23
  Max: 2
24
24
 
25
25
  Layout/LineLength:
26
- AllowURI: true
27
- Enabled: false
26
+ Max: 120
28
27
 
29
28
  Metrics/MethodLength:
30
29
  CountComments: false
31
- Max: 15
30
+ Max: 20
32
31
 
33
32
  Metrics/ParameterLists:
34
33
  Max: 4
@@ -39,10 +38,10 @@ Metrics/AbcSize:
39
38
 
40
39
  Style/CollectionMethods:
41
40
  PreferredMethods:
42
- map: 'collect'
43
- reduce: 'inject'
44
- find: 'detect'
45
- find_all: 'select'
41
+ map: "collect"
42
+ reduce: "inject"
43
+ find: "detect"
44
+ find_all: "select"
46
45
 
47
46
  Style/Documentation:
48
47
  Enabled: false
@@ -60,10 +59,13 @@ Style/ExpandPathArguments:
60
59
  Enabled: false
61
60
 
62
61
  Style/HashSyntax:
63
- EnforcedStyle: hash_rockets
62
+ EnforcedStyle: ruby19
64
63
 
65
64
  Style/Lambda:
66
65
  Enabled: false
67
66
 
68
67
  Style/RaiseArgs:
69
- EnforcedStyle: compact
68
+ EnforcedStyle: compact
69
+
70
+ Style/AsciiComments:
71
+ Enabled: false
@@ -1,17 +1,23 @@
1
- # 0.5.0
1
+ # CHANGELOG
2
+
3
+ ## 0.5.1
4
+
5
+ - fix rubocop warnings.
6
+
7
+ ## 0.5.0
2
8
 
3
9
  - refs #12 fix dependencies.
4
10
 
5
- # 0.4.1
11
+ ## 0.4.1
6
12
 
7
13
  - refs #4 fix settings for simplecov.
8
14
 
9
- # 0.4.0
15
+ ## 0.4.0
10
16
 
11
17
  - refs #4 measure code coverage
12
18
  - refs #5 setup GitHub Actions for rspec and pushing to RubyGems
13
19
 
14
- # 0.3.0
20
+ ## 0.3.0
15
21
 
16
22
  changed Result hash to be Object.
17
23
 
@@ -22,11 +28,11 @@ result.items[0][:weight]
22
28
  result.items[0].weight
23
29
  ```
24
30
 
25
- # 0.2.3
31
+ ## 0.2.3
26
32
 
27
33
  remove Gemfile.lock
28
34
 
29
- # 0.2.2
35
+ ## 0.2.2
30
36
 
31
37
  - define constants
32
38
  - `Tanita::Api::Client::AUTH_URL`
@@ -34,12 +40,12 @@ remove Gemfile.lock
34
40
  - `Tanita::Api::Client::TOKEN_URL`
35
41
  - `Tanita::Api::Client::TOKEN_URL_PATH`
36
42
 
37
- # 0.2.1
43
+ ## 0.2.1
38
44
 
39
45
  - rename constant
40
46
  - from `Tanita::Api::Client::HttpHelper::BASE_URL` to `Tanita::Api::Client::BASE_URL`
41
47
 
42
- # 0.2.0
48
+ ## 0.2.0
43
49
 
44
50
  - set required ruby version to greater than or equal to v2.4
45
51
  - added `data_type` argument in BaseApiClient#initialize
@@ -49,11 +55,11 @@ remove Gemfile.lock
49
55
  - `@data` to `@items`
50
56
  - `@data[0][:date]` to `@items[0][:measured_at]` or `@items[0][:registered_at]`
51
57
 
52
- # 0.1.1
58
+ ## 0.1.1
53
59
 
54
60
  - support Tanita::Api::Client.configure
55
61
  - wrote spec
56
62
 
57
- # 0.1.0
63
+ ## 0.1.0
58
64
 
59
65
  - Initial release
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "tanita/api/client"
5
- require "irb"
4
+ require 'bundler/setup'
5
+ require 'tanita/api/client'
6
+ require 'irb'
6
7
  IRB.start(__FILE__)
@@ -35,21 +35,21 @@ module Tanita
35
35
 
36
36
  def auth_uri
37
37
  params = {
38
- :client_id => @client_id,
39
- :redirect_uri => @redirect_uri,
40
- :scope => @scopes.join(','),
41
- :response_type => 'code'
38
+ client_id: @client_id,
39
+ redirect_uri: @redirect_uri,
40
+ scope: @scopes.join(','),
41
+ response_type: 'code'
42
42
  }
43
43
  generate_uri(AUTH_URL_PATH, params)
44
44
  end
45
45
 
46
46
  def exchange_token(auth_code:)
47
47
  params = {
48
- :client_id => @client_id,
49
- :client_secret => @client_secret,
50
- :redirect_uri => DEFAULT_REDIRECT_URI,
51
- :code => auth_code,
52
- :grant_type => 'authorization_code'
48
+ client_id: @client_id,
49
+ client_secret: @client_secret,
50
+ redirect_uri: DEFAULT_REDIRECT_URI,
51
+ code: auth_code,
52
+ grant_type: 'authorization_code'
53
53
  }
54
54
  res = request(TOKEN_URL_PATH, params)
55
55
  token = parse_json(res.body)
@@ -76,14 +76,14 @@ module Tanita
76
76
 
77
77
  def self.properties
78
78
  {
79
- :weight => {:code => '6021', :type => Float},
80
- :body_fat => {:code => '6022', :type => Float},
81
- :muscle_mass => {:code => '6023', :type => Float},
82
- :physique_rating => {:code => '6024', :type => Integer},
83
- :visceral_fat_rating => {:code => '6025', :type => Float},
84
- :basal_metabolic_rate => {:code => '6027', :type => Integer},
85
- :metabolic_age => {:code => '6028', :type => Integer},
86
- :bone_mass => {:code => '6029', :type => Float}
79
+ weight: {code: '6021', type: Float},
80
+ body_fat: {code: '6022', type: Float},
81
+ muscle_mass: {code: '6023', type: Float},
82
+ physique_rating: {code: '6024', type: Integer},
83
+ visceral_fat_rating: {code: '6025', type: Float},
84
+ basal_metabolic_rate: {code: '6027', type: Integer},
85
+ metabolic_age: {code: '6028', type: Integer},
86
+ bone_mass: {code: '6029', type: Float}
87
87
  }
88
88
  end
89
89
  end
@@ -95,9 +95,9 @@ module Tanita
95
95
 
96
96
  def self.properties
97
97
  {
98
- :maximal_pressure => {:code => '622E', :type => Integer},
99
- :minimal_pressure => {:code => '622F', :type => Integer},
100
- :pulse => {:code => '6230', :type => Integer}
98
+ maximal_pressure: {code: '622E', type: Integer},
99
+ minimal_pressure: {code: '622F', type: Integer},
100
+ pulse: {code: '6230', type: Integer}
101
101
  }
102
102
  end
103
103
  end
@@ -109,9 +109,9 @@ module Tanita
109
109
 
110
110
  def self.properties
111
111
  {
112
- :steps => {:code => '6331', :type => Integer},
113
- :exercise => {:code => '6335', :type => Integer},
114
- :calories => {:code => '6336', :type => Integer}
112
+ steps: {code: '6331', type: Integer},
113
+ exercise: {code: '6335', type: Integer},
114
+ calories: {code: '6336', type: Integer}
115
115
  }
116
116
  end
117
117
  end
@@ -123,7 +123,7 @@ module Tanita
123
123
 
124
124
  def self.properties
125
125
  {
126
- :urinary_sugar => {:code => '6240', :type => Integer}
126
+ urinary_sugar: {code: '6240', type: Integer}
127
127
  }
128
128
  end
129
129
  end
@@ -3,7 +3,6 @@
3
3
  module Tanita
4
4
  module Api
5
5
  module Client
6
-
7
6
  module Scope
8
7
  INNERSCAN = 'innerscan'
9
8
  SPHYGMOMANOMETER = 'sphygmomanometer'
@@ -16,7 +15,6 @@ module Tanita
16
15
 
17
16
  class Error < StandardError
18
17
  end
19
-
20
18
  end
21
19
  end
22
20
  end
@@ -26,7 +26,9 @@ module Tanita
26
26
  raise Error.new("param:'access_token' is required.'") if @access_token.nil?
27
27
 
28
28
  @date_type = date_type
29
- raise Error.new("param:'date_type' is invalid.'") unless [DATE_TYPE_REGISTERD_AT, DATE_TYPE_MEASURED_AT].include? date_type
29
+ unless [DATE_TYPE_REGISTERD_AT, DATE_TYPE_MEASURED_AT].include? date_type
30
+ raise Error.new("param:'date_type' is invalid.'")
31
+ end
30
32
 
31
33
  ClassBuilder.load
32
34
  end
@@ -37,9 +39,9 @@ module Tanita
37
39
  )
38
40
  tags = self.class.properties.values.map { |i| i[:code] }.join(',')
39
41
  params = {
40
- :access_token => @access_token,
41
- :date => @date_type,
42
- :tag => tags
42
+ access_token: @access_token,
43
+ date: @date_type,
44
+ tag: tags
43
45
  }
44
46
  params[:from] = time_format(from) unless from.nil?
45
47
  params[:to] = time_format(to) unless to.nil?
@@ -56,10 +58,10 @@ module Tanita
56
58
  def build_result(res)
57
59
  result = parse_json(res.body)
58
60
  Result.new(
59
- :birth_date => Date.parse(result[:birth_date]),
60
- :height => result[:height].to_f,
61
- :sex => result[:sex],
62
- :items => build_result_items(:raw_items => result[:data])
61
+ birth_date: Date.parse(result[:birth_date]),
62
+ height: result[:height].to_f,
63
+ sex: result[:sex],
64
+ items: build_result_items(raw_items: result[:data])
63
65
  )
64
66
  end
65
67
 
@@ -69,8 +71,8 @@ module Tanita
69
71
  date = item[:date]
70
72
  model = item[:model]
71
73
  key = "#{date}_#{model}"
72
- property = find_property_by_code(:code => item[:tag])
73
- value = cast(:value => item[:keydata], :type => property[:type])
74
+ property = find_property_by_code(code: item[:tag])
75
+ value = cast(value: item[:keydata], type: property[:type])
74
76
  item_dic[key] ||= {}
75
77
  item_dic[key][date_key] = Time.parse("#{date} +09:00").to_i unless item_dic[key].key? :date
76
78
  item_dic[key][:model] = model unless item_dic[key].key? :model
@@ -93,7 +95,7 @@ module Tanita
93
95
 
94
96
  @property_code_dic = {}
95
97
  self.class.properties.each do |m_name, m_info|
96
- @property_code_dic[m_info[:code]] = {:name => m_name, :type => m_info[:type]}
98
+ @property_code_dic[m_info[:code]] = {name: m_name, type: m_info[:type]}
97
99
  end
98
100
  @property_code_dic[code]
99
101
  end
@@ -12,7 +12,7 @@ module Tanita
12
12
  def to_h
13
13
  ret = {}
14
14
  self.class.properties.each do |property|
15
- ret[property.to_sym] = eval property.to_s
15
+ ret[property.to_sym] = eval property.to_s # rubocop:disable Security/Eval
16
16
  end
17
17
  ret
18
18
  end
@@ -4,19 +4,15 @@ module Tanita
4
4
  module Api
5
5
  module Client
6
6
  class Configuration
7
- # [String]
7
+ # @return [String]
8
8
  attr_accessor :client_id
9
-
10
- # [String]
9
+ # @return [String]
11
10
  attr_accessor :client_secret
12
-
13
- # [String]
11
+ # @return [String]
14
12
  attr_accessor :redirect_uri
15
-
16
- # [String]
13
+ # @return [String]
17
14
  attr_accessor :access_token
18
-
19
- # [Array<Tanita::Api::Client::Scope>]
15
+ # @return [Array<Tanita::Api::Client::Scope>]
20
16
  attr_accessor :scopes
21
17
  end
22
18
  end
@@ -33,7 +33,7 @@ module Tanita
33
33
  end
34
34
 
35
35
  def parse_json(str)
36
- JSON.parse(str, :symbolize_names => true)
36
+ JSON.parse(str, symbolize_names: true)
37
37
  rescue JSON::ParserError => e
38
38
  raise Error.new("JSON::ParseError: '#{e}'\nstr:#{str}")
39
39
  end
@@ -3,7 +3,7 @@
3
3
  module Tanita
4
4
  module Api
5
5
  module Client
6
- VERSION = '0.5.0'
6
+ VERSION = '0.5.1'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanita-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Koshikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-19 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,7 +130,7 @@ metadata:
130
130
  homepage_uri: https://github.com/koshilife/tanita-api-ruby-client
131
131
  source_code_uri: https://github.com/koshilife/tanita-api-ruby-client
132
132
  changelog_uri: https://github.com/koshilife/tanita-api-ruby-client/blob/master/CHANGELOG.md
133
- documentation_uri: https://www.rubydoc.info/gems/tanita-api-client/0.5.0
133
+ documentation_uri: https://www.rubydoc.info/gems/tanita-api-client/0.5.1
134
134
  post_install_message:
135
135
  rdoc_options: []
136
136
  require_paths: