docomo-nlu 0.2.5 → 0.2.6

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: 6de79950035d20f4444b11463b7d359464d735c21acee112fcc52a52b8f49c15
4
- data.tar.gz: f458aa38e36609e17a211b0be7cd6137795eaf3111530c5c3e1c10c0a6d953e0
3
+ metadata.gz: '08034a60bf16379d40abb5485451e3bf4d1a8d1e61deeeb68f3f3df71e7122c0'
4
+ data.tar.gz: cebeb6e745af177a7ab841d7cd83787c920e0c7e06a656e0aba8f1ff6199a8ca
5
5
  SHA512:
6
- metadata.gz: cc3b6362a1e675319882d0d5751c8f60943f2a2a3d1dd127cb8a80a826bcdf9738e4bcc024a96ec55ffafa151259665cebcf1936a28286193be67dd2c244a525
7
- data.tar.gz: 2a0a75c7ad270727c190a3044ddd09d781d36a3b44d92ea7a43851e02e716f14564b9dab6cc62c966884aca5352984677e438fd1348f373ea17cb614e3d6c131
6
+ metadata.gz: 19ac577b2c46521c6d325b9c463fb3ecb98119958c799960bca48105a397fcbc21b251a7e750d463a46ecc8464fbb9b9ae34aaee596b195f4578508cbbbad9ae
7
+ data.tar.gz: f6daa422c37239930ebd6dd3dc34ee7a56a8c05cc81ef182378f5821f6a64285c2b55f0f6ed69d964c6933ca9707c39f101a8aa8cf96aa5def69f541b0baf709
data/.rubocop.yml CHANGED
@@ -9,7 +9,6 @@ AllCops:
9
9
  # If you use RuboCop with Ruby on Rails, specify TargetRailsVersion(default: 5.0).
10
10
  TargetRailsVersion: 5.1
11
11
  Rails:
12
- # If you use RuboCop with Ruby on Rails, turn on this option.
13
12
  Enabled: true
14
13
  Naming/FileName:
15
14
  Exclude:
@@ -18,4 +17,12 @@ Naming/FileName:
18
17
  Rails/HasManyOrHasOneDependent:
19
18
  Enabled: false
20
19
  Rails/SaveBang:
21
- Enabled: false
20
+ Enabled: false
21
+ RSpec/EmptyExampleGroup:
22
+ Enabled: false
23
+ Metrics/ClassLength:
24
+ Exclude:
25
+ - "lib/docomo-nlu/management/v23/aiml_base.rb"
26
+ RSpec/FilePath:
27
+ CustomTransform:
28
+ DocomoNlu: docomo-nlu
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docomo-nlu (0.2.5)
4
+ docomo-nlu (0.2.6)
5
5
  activeresource (~> 5.0.0)
6
6
  bundler
7
7
  faraday
@@ -105,7 +105,7 @@ GEM
105
105
  mini_mime (1.0.1)
106
106
  mini_portile2 (2.3.0)
107
107
  minitest (5.11.3)
108
- multipart-post (2.0.0)
108
+ multipart-post (2.1.1)
109
109
  nio4r (2.3.1)
110
110
  nokogiri (1.8.4)
111
111
  mini_portile2 (~> 2.3.0)
@@ -178,7 +178,7 @@ GEM
178
178
  rubocop-rspec (1.29.1)
179
179
  rubocop (>= 0.58.0)
180
180
  ruby-progressbar (1.10.0)
181
- rubyzip (1.2.2)
181
+ rubyzip (1.2.3)
182
182
  safe_yaml (1.0.4)
183
183
  sprockets (3.7.2)
184
184
  concurrent-ruby (~> 1.0)
@@ -222,4 +222,4 @@ DEPENDENCIES
222
222
  webmock (~> 3.4.2)
223
223
 
224
224
  BUNDLED WITH
225
- 1.16.3
225
+ 2.0.1
@@ -24,8 +24,8 @@ module DocomoNlu
24
24
  self.format = :json
25
25
 
26
26
  ## Get NLPManagement's AccessToken.
27
- def login(accountName, password)
28
- request_body = { accountName: accountName, password: password }.to_json
27
+ def login(account_name, password)
28
+ request_body = { accountName: account_name, password: password }.to_json
29
29
  response_body = JSON.parse(connection.post("/management/v2.2/login", request_body, self.class.headers).body)
30
30
  self.access_token = response_body["accessToken"]
31
31
  end
@@ -43,7 +43,7 @@ module DocomoNlu
43
43
 
44
44
  private
45
45
 
46
- def download(category = nil, prefix_options)
46
+ def download(category = nil, prefix_options = {})
47
47
  extention = category.blank? ? ".zip" : ".map"
48
48
 
49
49
  conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
@@ -7,7 +7,7 @@ module DocomoNlu
7
7
  self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
8
8
 
9
9
  @permitted_root_param = [:userScenarios, :templateScenarios]
10
- @permitted_userScenarios_param = [:scenarioId, :description, :compileFlag]
10
+ @permitted_user_scenarios_param = [:scenarioId, :description, :compileFlag]
11
11
 
12
12
  def save
13
13
  @attributes.select! {|a| a =~ /(userScenarios|templateScenarios)/ }
@@ -15,15 +15,15 @@ module DocomoNlu
15
15
  end
16
16
 
17
17
  def save
18
- print "Method not used"
18
+ Rails.logger.debug "Method not used"
19
19
  end
20
20
 
21
21
  def destroy
22
- print "Method not used"
22
+ Rails.logger.debug "Method not used"
23
23
  end
24
24
 
25
25
  def delete
26
- print "Method not used"
26
+ Rails.logger.debug "Method not used"
27
27
  end
28
28
  end
29
29
  end
@@ -19,7 +19,6 @@ require "tempfile"
19
19
  module DocomoNlu
20
20
  module Management::V26
21
21
  class AIMLBase < Base
22
-
23
22
  def download(extra_path = "")
24
23
  prefix_options[:bot_id] ||= botId
25
24
  @attributes[:file] = self.class.download(prefix_options, extra_path).file
@@ -99,7 +98,6 @@ module DocomoNlu
99
98
  while check_path && compile_status != "Completed"
100
99
  sleep(0.2)
101
100
  compile_status = check_status(:compile, check_path)
102
- raise ActiveResource::ServerError if %w[ErrorFinish NotCompiled].include?(compile_status)
103
101
  end
104
102
 
105
103
  # transfer and status check
@@ -108,15 +106,22 @@ module DocomoNlu
108
106
  while check_path && transfer_status != "Completed"
109
107
  sleep(0.2)
110
108
  transfer_status = check_status(:transfer, check_path)
111
- raise ActiveResource::ServerError if %w[ErrorFinish NotTransfered].include?(transfer_status)
112
109
  end
113
110
  true
114
111
  end
115
112
 
116
113
  def check_status(method, path)
114
+ response = connection.get(path, headers)
115
+
117
116
  case method
118
- when :compile then JSON.parse(connection.get(path, headers).body)["status"]
119
- when :transfer then JSON.parse(connection.get(path, headers).body)["transferStatusResponses"][0]["status"]
117
+ when :compile
118
+ JSON.parse(response.body)["status"].tap do |status|
119
+ raise ActiveResource::ServerError.new(response) if %w[ErrorFinish NotCompiled].include?(status)
120
+ end
121
+ when :transfer
122
+ JSON.parse(response.body)["transferStatusResponses"][0]["status"].tap do |status|
123
+ raise ActiveResource::ServerError.new(response) if %w[ErrorFinish NotTransfered].include?(status)
124
+ end
120
125
  end
121
126
  end
122
127
  end
@@ -24,8 +24,8 @@ module DocomoNlu
24
24
  self.format = :json
25
25
 
26
26
  ## Get NLPManagement's AccessToken.
27
- def login(accountName, password)
28
- request_body = { accountName: accountName, password: password }.to_json
27
+ def login(account_name, password)
28
+ request_body = { accountName: account_name, password: password }.to_json
29
29
  response_body = JSON.parse(connection.post("/management/v2.6/login", request_body, self.class.headers).body)
30
30
  self.access_token = response_body["accessToken"]
31
31
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "zip"
3
4
 
4
5
  module DocomoNlu
@@ -8,29 +9,30 @@ module DocomoNlu
8
9
  self.prefix = "/management/v2.6/projects/:project_id/"
9
10
 
10
11
  def all
11
- p "You shoud use 'download' method"
12
+ Rails.logger.debug "You shoud use 'download' method"
12
13
  end
13
14
 
14
15
  def find
15
- p "You shoud use 'download' method"
16
+ Rails.logger.debug "You shoud use 'download' method"
16
17
  end
17
18
 
18
19
  def where
19
- p "You shoud use 'download' method"
20
+ Rails.logger.debug "You shoud use 'download' method"
20
21
  end
21
22
 
22
23
  def download(bot_id, params = {})
23
24
  attributes[:file] = self.class.download(prefix_options, bot_id, params.slice(:start, :end))
24
- return attributes[:file]
25
+ attributes[:file]
25
26
  end
26
27
 
27
28
  def extract_data
28
29
  return unless attributes[:file]
30
+
29
31
  logs = []
30
- self.class.unzip(attributes[:file]) do |name, body|
31
- logs = body.map{ |b| JSON.parse(b) }
32
+ self.class.unzip(attributes[:file]) do |_name, body|
33
+ logs = body.map {|b| JSON.parse(b) }
32
34
  end
33
- return logs
35
+ logs
34
36
  end
35
37
 
36
38
  class << self
@@ -54,6 +56,7 @@ module DocomoNlu
54
56
  ::Zip::File.open(file.path) do |zf|
55
57
  zf.each do |entry|
56
58
  next unless entry.file?
59
+
57
60
  name = entry.name
58
61
  body = entry.get_input_stream.read.split(/\R/)
59
62
  yield name, body if block_given?
@@ -20,7 +20,6 @@ module DocomoNlu
20
20
  end
21
21
 
22
22
  class << self
23
-
24
23
  def check_status(prefix_options)
25
24
  JSON.parse(connection.get("#{collection_path(prefix_options)}/status", headers).body)
26
25
  end
@@ -18,24 +18,24 @@ module DocomoNlu
18
18
  # => It is possible to ambiguous search using "*" in the following target ( input|output|startTopic|endTopic|userId|language|projectSpecific)
19
19
  # query: String search within 200 characters.
20
20
 
21
- def download(params={})
22
- return JSON.parse(connection.post(collection_path(prefix_options), params.to_json, self.class.headers).body)
21
+ def download(params = {})
22
+ JSON.parse(connection.post(collection_path(prefix_options), params.to_json, self.class.headers).body)
23
23
  end
24
24
 
25
- def count(params={})
26
- return JSON.parse(connection.post("#{collection_path(prefix_options)}/count", params.to_json, self.class.headers).body)["count"]
25
+ def count(params = {})
26
+ JSON.parse(connection.post("#{collection_path(prefix_options)}/count", params.to_json, self.class.headers).body)["count"]
27
27
  end
28
28
 
29
29
  def all
30
- p "You shoud use 'download' or 'count' method"
30
+ Rails.logger.debug "You shoud use 'download' or 'count' method"
31
31
  end
32
32
 
33
33
  def find
34
- p "You shoud use 'download' or 'count' method"
34
+ Rails.logger.debug "You shoud use 'download' or 'count' method"
35
35
  end
36
36
 
37
37
  def where
38
- p "You shoud use 'download' or 'count' method"
38
+ Rails.logger.debug "You shoud use 'download' or 'count' method"
39
39
  end
40
40
  end
41
41
  end
@@ -43,7 +43,7 @@ module DocomoNlu
43
43
 
44
44
  private
45
45
 
46
- def download(category = nil, prefix_options)
46
+ def download(category = nil, prefix_options = {})
47
47
  extention = category.blank? ? ".zip" : ".map"
48
48
 
49
49
  conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
@@ -7,7 +7,7 @@ module DocomoNlu
7
7
  self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
8
 
9
9
  @permitted_root_param = [:userScenarios, :templateScenarios]
10
- @permitted_userScenarios_param = [:scenarioId, :description, :compileFlag]
10
+ @permitted_user_scenarios_param = [:scenarioId, :description, :compileFlag]
11
11
 
12
12
  def save
13
13
  @attributes.select! {|a| a =~ /(userScenarios|templateScenarios)/ }
@@ -15,15 +15,15 @@ module DocomoNlu
15
15
  end
16
16
 
17
17
  def save
18
- print "Method not used"
18
+ Rails.logger.debug "Method not used"
19
19
  end
20
20
 
21
21
  def destroy
22
- print "Method not used"
22
+ Rails.logger.debug "Method not used"
23
23
  end
24
24
 
25
25
  def delete
26
- print "Method not used"
26
+ Rails.logger.debug "Method not used"
27
27
  end
28
28
  end
29
29
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module DocomoNlu
3
4
  module Management
4
- NAMESPACE = (DocomoNlu.config.nlu_version == "v2.6" ? "V26" : "V23" ).freeze
5
+ NAMESPACE = ((DocomoNlu.config.nlu_version == "v2.6") ? "V26" : "V23").freeze
5
6
 
6
7
  module V23
7
8
  autoload :Account, "docomo-nlu/management/V23/account"
@@ -83,6 +84,5 @@ module DocomoNlu
83
84
  Scenario = const_get "DocomoNlu::Management::#{NAMESPACE}::Scenario"
84
85
  Set = const_get "DocomoNlu::Management::#{NAMESPACE}::Set"
85
86
  TaskProject = const_get "DocomoNlu::Management::#{NAMESPACE}::TaskProject"
86
-
87
87
  end
88
88
  end
@@ -19,8 +19,8 @@ module DocomoNlu
19
19
  clientVer: "1.0.4",
20
20
  language: "ja-JP",
21
21
  location: { lat: "0", lon: "0" },
22
- appRecvTime: DateTime.now.strftime("%Y-%m-%d %H:%M:%S"),
23
- appSendTime: DateTime.now.strftime("%Y-%m-%d %H:%M:%S"),
22
+ appRecvTime: Time.current.strftime("%Y-%m-%d %H:%M:%S"),
23
+ appSendTime: Time.current.strftime("%Y-%m-%d %H:%M:%S"),
24
24
  }.each do |k, v|
25
25
  @attributes.store(k, v)
26
26
  end
@@ -38,13 +38,13 @@ module DocomoNlu
38
38
  @attributes.store(:appId, JSON.parse(res.body)["app_id"])
39
39
  end
40
40
 
41
- def dialogue(voiceText, **params)
42
- @attributes[:voiceText] = voiceText
41
+ def dialogue(voice_text, **params)
42
+ @attributes[:voiceText] = voice_text
43
43
  params.each do |k, v|
44
44
  @attributes[k] ||= v
45
45
  end
46
46
  res = connection.post("/SpontaneousDialogueServer/dialogue", @attributes.to_json, self.class.headers)
47
- return JSON.parse(res.body)
47
+ JSON.parse(res.body)
48
48
  end
49
49
 
50
50
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocomoNlu
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.6"
5
5
  end
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: "<Host>management/<Version>/projects/176/botlogs?botId=176_89_main"
5
+ uri: "<Host>/management/<Version>/projects/176/botlogs?botId=176_89_main"
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: "<Host>management/<Version>/projects/176/botlogs?botId=176_89_main&end=20190313&start=20190312"
5
+ uri: "<Host>/management/<Version>/projects/176/botlogs?botId=176_89_main&end=20190313&start=20190312"
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: "<Host>management/<Version>/projects/176/logs"
5
+ uri: "<Host>/management/<Version>/projects/176/logs"
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "{}"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: "<Host>management/<Version>/projects/176/logs/count"
5
+ uri: "<Host>/management/<Version>/projects/176/logs/count"
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "{}"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: "<Host>management/<Version>/projects/176/logs/count"
5
+ uri: "<Host>/management/<Version>/projects/176/logs/count"
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"details":[{"operation":"","target":"input","query":"Hello"}]}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: "<Host>management/<Version>/projects/176/logs/count"
5
+ uri: "<Host>/management/<Version>/projects/176/logs/count"
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "{}"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: "<Host>management/<Version>/projects/176/logs"
5
+ uri: "<Host>/management/<Version>/projects/176/logs"
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"details":[{"operation":"","target":"input","query":"Hello"}]}'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docomo-nlu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koji Yamazaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-14 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource