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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f64a81312f89b39114bd475b0742b210ae09c4ceaeb9f40602339fa1ee19a1e8
4
- data.tar.gz: 89b65764d85e94e09fe00bf5ae890e77673d61ba11ec0d9052e523c887524a18
3
+ metadata.gz: 455132fb8d355d46bb9309a7616d6f293e640674612196f8b814c73924c40ef4
4
+ data.tar.gz: f7be2fcac208fa91cbc865223741a241e4d101d43d750feddd678392cb329f47
5
5
  SHA512:
6
- metadata.gz: 906b815b2d1d63b52192181ce80ae0e073c9f62c18334befe666303d2453a364b5d55daa07140afda9f6b339c83ddcc3db7a966e0cd91d70140ac0420b606100
7
- data.tar.gz: 487934bb4151ca197e6b38a1284189193b756c525b6de0c78462d6306ddd5040644b1afe619de25721d7304863f2edd46897358e27a6fb2c40d1e9c8290d565e
6
+ metadata.gz: 73d9a1109bcb3d6bc2167762e66304ca0189867c79faf9e609de89d935d5f6d78f113416c7323f3383caa8ce09dd2012c6ce09d7e8c863815d3a2a323909a5be
7
+ data.tar.gz: 1b3c23480c58316541d482c36317c7b95b268c3bf602142902d1d04b68cffccc2c46da942904c0ca6692bf8bcaeb9c9148f8d09ca1428eff413b9eb8d6940ebb
@@ -0,0 +1,9 @@
1
+ # Just copy paste the following format in application.yml and configure accordingly
2
+
3
+ development:
4
+ api_url: http://localhost:3020/
5
+ parser_url: http://localhost:9090
6
+
7
+ production:
8
+ parser_url: http://34.214.134.104:9090
9
+
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
- save(meta, "meta/#{uid.to_s + '_' + custom_uid}")
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)
@@ -13,7 +13,7 @@ module NaviClient
13
13
 
14
14
  attr_reader :id
15
15
 
16
- def initialize(sso_web_url = "http://localhost:3008/", env = "development")
16
+ def initialize(sso_web_url = ENV['api_url'], env = Rails.env)
17
17
  super()
18
18
 
19
19
  # client-id used to track the process
@@ -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 = 'http://localhost:9090/v2/metas'
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 = 'http://localhost:3008', client_type = "local", gen_csv_url = "http://localhost:3020/v2/generate_csv_input", debug = true, env = "development")
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'] + '/inputs/temp'
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/" + (Time.now.to_f * 1000).to_s
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
- file = @download_path + 'inputs/temp'
233
- if File.file? file
234
- @logger.debug "Parsing previously fetched emails"
235
- HTTPService::NaviAI.start(filepath: file, client_type: @client_type, token: @token, email: @current_user_email )
236
- FileUtils.rm_f file
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
@@ -1,3 +1,3 @@
1
1
  module NaviClient
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
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.3
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-08 00:00:00.000000000 Z
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