blackstack_commons 1.1.31 → 1.1.36

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 +16 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c422b39239eaf255aedc0c99080824e8adcd37b6
4
- data.tar.gz: 78274d2f142589e44fca0de63325539063ee24b4
3
+ metadata.gz: 655f2f5de9ac34605dea9510a33abf62f0a92394
4
+ data.tar.gz: ea0ae62678e670306f23ddd19ff8a5fd1a9eb063
5
5
  SHA512:
6
- metadata.gz: d3d6f5a2b41b4c3cc442d5debb6d48a68b4ac59d63d1afe3cccd435eaf5fd176a8cc33637fd94a0458c5b7744f3989a51aa1ef09840e5869798f4c7ae7748451
7
- data.tar.gz: 0877f4c7dd9465320ef64c9d8289aec213866cc6e7dcecbf15fcb93e1c120733ca309dc72ef9fbb0b9429d5498763a80d6c7b4df734d3fc0e0be83cc60456f43
6
+ metadata.gz: 8aaf3a174708159ca6779b349facb50da208004671d0806c27cf031963f7fdd5c9f1396eeed2cff32599e72adfe1cf380088a6e9dba740bf94c1968550108050
7
+ data.tar.gz: 04d07be65bb552f1247b836e0d71cc8df20a6fbf8bf8e00b0436c12839f3063f033a8d0cec58ccdbd9cd3bab64a3200edb75ed6d7c9c47c1aa31ea7c4c554e48
@@ -11,9 +11,12 @@ module BlackStack
11
11
  # script is running inside an OCRA temp folder, since the local folder
12
12
  # of the running command is not the filder where the exe file is hosted.
13
13
  #
14
- # More information: https://stackoverflow.com/questions/1937743/how-to-get-the-current-working-directorys-absolute-path-from-irb
14
+ # More information:
15
+ # * https://stackoverflow.com/questions/1937743/how-to-get-the-current-working-directorys-absolute-path-from-irb
16
+ # * https://stackoverflow.com/questions/8577223/ruby-get-the-file-being-executed
17
+ # * https://stackoverflow.com/questions/7399882/ruby-getting-path-from-pathfilename/7400057
15
18
  #
16
- def self.require_in_working_path(filename, path=__FILE__,show_path_info=false)
19
+ def self.require_in_working_path(filename, path, show_path_info=false)
17
20
  puts '' if show_path_info
18
21
  path = File.expand_path File.dirname(path)
19
22
  #path = Dir.pwd
@@ -509,7 +512,7 @@ module BlackStack
509
512
  end
510
513
 
511
514
  # New call_get
512
- 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)
513
516
  uri = URI(url)
514
517
  uri.query = URI.encode_www_form(params)
515
518
  Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -518,7 +521,7 @@ module BlackStack
518
521
  res = http.request req
519
522
  case res
520
523
  when Net::HTTPSuccess then res
521
- 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
522
525
  else
523
526
  res.error!
524
527
  end
@@ -531,7 +534,8 @@ module BlackStack
531
534
  # ssl_verify_mode: you can disabele SSL verification here.
532
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.
533
536
  # TODO: setup max_simultaneus_calls in the configurtion file.
534
- 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
535
539
  # build the lockfile name
536
540
  x = 0
537
541
  if BlackStack::Netting.max_api_call_channels.to_i > 0
@@ -540,9 +544,10 @@ module BlackStack
540
544
  # lock the file
541
545
  BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
542
546
  end
543
-
547
+ =end
544
548
  begin
545
-
549
+ #puts
550
+ #puts "call_post:#{url}:."
546
551
  # do the call
547
552
  uri = URI(url)
548
553
  ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -553,23 +558,23 @@ module BlackStack
553
558
  res = http.request req
554
559
  case res
555
560
  when Net::HTTPSuccess then res
556
- 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
557
562
  else
558
563
  res.error!
559
564
  end
560
565
  end
561
566
 
562
567
  # release the file
563
- 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
564
569
  rescue => e
565
570
  # release the file
566
- 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
567
572
 
568
573
  # elevo la excepcion
569
574
  raise e
570
575
  ensure
571
576
  # release the file
572
- 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
573
578
  end
574
579
 
575
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.31
4
+ version: 1.1.36
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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning