blackstack_commons 1.1.32 → 1.1.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/functions.rb +15 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf2a3706d12af1ed68a4fe8ee11fab224a47859d
4
- data.tar.gz: 6d7bd517914e50690ff504a4431311294d5a7b5d
3
+ metadata.gz: 199db793bb9c9280c62317c5b51e0da27464a728
4
+ data.tar.gz: 45541c5c9d023f34edd95b8af1b152b1d519a22d
5
5
  SHA512:
6
- metadata.gz: e66f18f3903ad218d5241ca74c8b9e074c3a2689d81f8e3421d68ac7d8a9801038e424b6206f752b35e87ffac0de815d391a395a17e63498577929995771237f
7
- data.tar.gz: 82b5657efed2447d1bd7ac7095882378117221c23b7fb1bcb19e88a4506be777c9f822c9eda853b38b0fca1c2c6679c5c2dca127e56ed60d3d9ca219f3098c63
6
+ metadata.gz: 1818dcf6bf275b0640d3a93d22a3a680fb85a0f470aa5cfc849eb3e1a0d0b06bed185ae71c649bbb20ec823be3a83f63e30757014fa447d02e52084d40065567
7
+ data.tar.gz: db6156e7f22d49667ebfe85609ece58caadf90176ff80490cf28f64be6e94a6ba7a929d5faa87f585db4851e10b0e757682e37839ab7cccd9767a17a71daa848
@@ -16,10 +16,10 @@ module BlackStack
16
16
  # * https://stackoverflow.com/questions/8577223/ruby-get-the-file-being-executed
17
17
  # * https://stackoverflow.com/questions/7399882/ruby-getting-path-from-pathfilename/7400057
18
18
  #
19
- def self.require_in_working_path(filename, path,show_path_info=false)
19
+ def self.require_in_working_path(filename, path, show_path_info=false)
20
20
  puts '' if show_path_info
21
- #path = File.expand_path File.dirname(path)
22
- path = Dir.pwd
21
+ path = File.expand_path File.dirname(path)
22
+ #path = Dir.pwd
23
23
  puts "require_in_working_path.path:#{path}:." if show_path_info
24
24
  file = "#{path}/#{filename}"
25
25
  puts "require_in_working_path.file:#{file}:." if show_path_info
@@ -246,7 +246,7 @@ module BlackStack
246
246
  # units: it is a positive integer
247
247
  def self.encode_period(period, units)
248
248
  s = "Last "
249
- s += units.to_s + " " if units.to_i > 1
249
+ s += units.to_i.to_s + " " if units.to_i > 1
250
250
  s += "Hours" if period.upcase == "H" && units.to_i != 1
251
251
  s += "Days" if period.upcase == "D" && units.to_i != 1
252
252
  s += "Weeks" if period.upcase == "W" && units.to_i != 1
@@ -512,7 +512,7 @@ module BlackStack
512
512
  end
513
513
 
514
514
  # New call_get
515
- def self.call_get(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
515
+ def self.call_get(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, support_redirections=true)
516
516
  uri = URI(url)
517
517
  uri.query = URI.encode_www_form(params)
518
518
  Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -521,7 +521,7 @@ module BlackStack
521
521
  res = http.request req
522
522
  case res
523
523
  when Net::HTTPSuccess then res
524
- when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params)
524
+ when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params, false) if support_redirections
525
525
  else
526
526
  res.error!
527
527
  end
@@ -534,7 +534,8 @@ module BlackStack
534
534
  # ssl_verify_mode: you can disabele SSL verification here.
535
535
  # max_channels: this method use lockfiles to prevent an excesive number of API calls from each datacenter. There is not allowed more simultaneous calls than max_channels.
536
536
  # TODO: setup max_simultaneus_calls in the configurtion file.
537
- def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, use_lockfile=true)
537
+ def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, support_redirections=true)
538
+ =begin
538
539
  # build the lockfile name
539
540
  x = 0
540
541
  if BlackStack::Netting.max_api_call_channels.to_i > 0
@@ -543,9 +544,10 @@ module BlackStack
543
544
  # lock the file
544
545
  BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
545
546
  end
546
-
547
+ =end
547
548
  begin
548
-
549
+ #puts
550
+ #puts "call_post:#{url}:."
549
551
  # do the call
550
552
  uri = URI(url)
551
553
  ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -556,23 +558,23 @@ module BlackStack
556
558
  res = http.request req
557
559
  case res
558
560
  when Net::HTTPSuccess then res
559
- when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false)
561
+ when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false) if support_redirections
560
562
  else
561
563
  res.error!
562
564
  end
563
565
  end
564
566
 
565
567
  # release the file
566
- BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
568
+ # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
567
569
  rescue => e
568
570
  # release the file
569
- BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
571
+ # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
570
572
 
571
573
  # elevo la excepcion
572
574
  raise e
573
575
  ensure
574
576
  # release the file
575
- BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
577
+ # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
576
578
  end
577
579
 
578
580
  # return
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.32
4
+ version: 1.1.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-24 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning