navi_client 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/navi_client.sample.yml +9 -0
- data/lib/client.rb +7 -2
- data/lib/cloud/navi_cloud_client.rb +1 -1
- data/lib/http_service/naviai.rb +1 -4
- data/lib/local/navi_local_client.rb +10 -20
- data/lib/navi_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 455132fb8d355d46bb9309a7616d6f293e640674612196f8b814c73924c40ef4
|
4
|
+
data.tar.gz: f7be2fcac208fa91cbc865223741a241e4d101d43d750feddd678392cb329f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d9a1109bcb3d6bc2167762e66304ca0189867c79faf9e609de89d935d5f6d78f113416c7323f3383caa8ce09dd2012c6ce09d7e8c863815d3a2a323909a5be
|
7
|
+
data.tar.gz: 1b3c23480c58316541d482c36317c7b95b268c3bf602142902d1d04b68cffccc2c46da942904c0ca6692bf8bcaeb9c9148f8d09ca1428eff413b9eb8d6940ebb
|
data/lib/client.rb
CHANGED
@@ -131,7 +131,7 @@ module Client
|
|
131
131
|
# Process each email downloaded from imap-server and creates meta file that will be sent over to the navi-ai service.
|
132
132
|
# Meta will content information like: ['from', 'to', 'cc', ..., 'body_url']. This information is then used by navi-ai to parse the body content.
|
133
133
|
#
|
134
|
-
def process_email(mail, uid)
|
134
|
+
def process_email(mail, uid, stamp = nil)
|
135
135
|
meta = Hash.new
|
136
136
|
custom_uid = (Time.now.to_f * 1000).to_s + "_" + mail.__id__.to_s
|
137
137
|
|
@@ -151,7 +151,12 @@ module Client
|
|
151
151
|
meta.merge!(m) unless m.nil?
|
152
152
|
end
|
153
153
|
|
154
|
-
|
154
|
+
if stamp.nil?
|
155
|
+
save(meta, "meta/#{uid.to_s + '_' + custom_uid}")
|
156
|
+
else
|
157
|
+
save(meta, "meta/#{uid.to_s + '_' + custom_uid}", stamp)
|
158
|
+
end
|
159
|
+
|
155
160
|
end
|
156
161
|
|
157
162
|
def encrypt(data)
|
data/lib/http_service/naviai.rb
CHANGED
@@ -4,10 +4,7 @@ module HTTPService
|
|
4
4
|
class NaviAI
|
5
5
|
|
6
6
|
def self.start(filepath:, client_id: nil, client_type:, token:, email:)
|
7
|
-
go_url = '
|
8
|
-
if client_type == 'cloud'
|
9
|
-
go_url = 'http://34.214.134.104:9090/v2/metas'
|
10
|
-
end
|
7
|
+
go_url = "#{ENV['parser_url']}/v2/metas"
|
11
8
|
HTTParty.post(go_url, body: { client_id: client_id, client_type: client_type, list_meta_path: filepath, token: token, email: email }.to_json, timeout: 400)
|
12
9
|
end
|
13
10
|
|
@@ -10,7 +10,7 @@ module NaviClient
|
|
10
10
|
include Client
|
11
11
|
CONFIG_PATH = File.join(ENV['HOME'], '/.navi/config.yml')
|
12
12
|
|
13
|
-
def initialize(sso_web_url = '
|
13
|
+
def initialize(sso_web_url = ENV['api_url'], client_type = "local", gen_csv_url = "#{ENV['api_url']}/v2/generate_csv_input", debug = true, env = ENV['env']?ENV['env']:Rails.env )
|
14
14
|
# flag to print Ruby library debug info (very detailed)
|
15
15
|
@net_imap_debug = false
|
16
16
|
|
@@ -87,9 +87,9 @@ module NaviClient
|
|
87
87
|
# save data to download_path with file named by filename params.
|
88
88
|
# Input is hashmap, and it save the hashmap as yml format.
|
89
89
|
#
|
90
|
-
def save(data={}, filename)
|
90
|
+
def save(data={}, filename, stamp)
|
91
91
|
download_path = config['download_path'] + config['username'] + '/'
|
92
|
-
temp_path = config['download_path'] + config['username'] +
|
92
|
+
temp_path = config['download_path'] + config['username'] + "/inputs/temp-#{stamp}"
|
93
93
|
filepath = download_path + filename + ".yml"
|
94
94
|
|
95
95
|
mkdir_if_not_exist(filepath)
|
@@ -108,12 +108,10 @@ module NaviClient
|
|
108
108
|
##
|
109
109
|
# send bulk request to navi-ai service with list of input files downloaded from imap server.
|
110
110
|
#
|
111
|
-
def send_request(in_filenames = [])
|
111
|
+
def send_request(in_filenames = [], stamp)
|
112
112
|
unless in_filenames.empty?
|
113
113
|
download_path = config['download_path']
|
114
|
-
filename = download_path + config['username'] + "/inputs
|
115
|
-
|
116
|
-
filename_temp = download_path + config['username'] + "/inputs/temp"
|
114
|
+
filename = download_path + config['username'] + "/inputs/#{stamp}"
|
117
115
|
|
118
116
|
mkdir_if_not_exist(filename)
|
119
117
|
|
@@ -121,13 +119,7 @@ module NaviClient
|
|
121
119
|
in_filenames.each { |element| f.puts(element) }
|
122
120
|
end
|
123
121
|
|
124
|
-
# this step might not be required as it is done in the prev download step
|
125
|
-
File.open(filename_temp, 'w') do |f|
|
126
|
-
in_filenames.each { |element| f.puts(element) }
|
127
|
-
end
|
128
|
-
|
129
122
|
response = HTTPService::NaviAI.start(filepath: filename, client_type: @client_type, token: @token, email: config['username'])
|
130
|
-
FileUtils.rm_f filename_temp if File.file? filename_temp
|
131
123
|
return response
|
132
124
|
end
|
133
125
|
end
|
@@ -229,13 +221,11 @@ module NaviClient
|
|
229
221
|
|
230
222
|
def parse_prev_failed_emails
|
231
223
|
changes = false
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
changes = true
|
238
|
-
@logger.debug "Complete Ok..."
|
224
|
+
Dir[@download_path + 'inputs/temp*'].each do |file_name|
|
225
|
+
if File.file? file_name
|
226
|
+
HTTPService::NaviAI.start(filepath: file_name, client_type: @client_type, token: @token, email: @current_user_email )
|
227
|
+
changes = true
|
228
|
+
end
|
239
229
|
end
|
240
230
|
return changes
|
241
231
|
end
|
data/lib/navi_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sujit
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-05-
|
13
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- bin/.DS_Store
|
117
117
|
- bin/console
|
118
118
|
- bin/setup
|
119
|
+
- config/navi_client.sample.yml
|
119
120
|
- lib/client.rb
|
120
121
|
- lib/cloud/navi_cloud_client.rb
|
121
122
|
- lib/http_service/naviai.rb
|