blackstack_commons 1.1.26 → 1.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/functions.rb +29 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57115faaf3a00b4a0cc954244de3d33fa9b00fa
|
4
|
+
data.tar.gz: 58107d6e5250b684e336d02bac25e8790599ac60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc986a230a3bd4bc56c59c5240349ecb887cf4ed84656dab07b4cc2196a859eccf66f5bdb513727bc806627f63cb515f345aa42a53c369c4d3f95087f385993
|
7
|
+
data.tar.gz: 1f9ddbcc4429c33a55643a8379f60f169379343b2841f06c3b1abfa634b5ea2496ea28a8458c88e0e7fd988e6658c4b626fef9e5ef88eee143fb5aa4167938ad
|
data/lib/functions.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
|
+
|
1
2
|
module BlackStack
|
2
3
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
# -----------------------------------------------------------------------------------------
|
5
|
+
# OCRA Supporting Functions
|
6
|
+
# -----------------------------------------------------------------------------------------
|
7
|
+
module OCRA
|
8
|
+
# OCRA files run into a temp folder, where the script is unpacked.
|
9
|
+
#
|
10
|
+
# This function is useful to require a configuration file when the
|
11
|
+
# script is running inside an OCRA temp folder, since the local folder
|
12
|
+
# of the running command is not the filder where the exe file is hosted.
|
13
|
+
#
|
14
|
+
# More information: https://stackoverflow.com/questions/1937743/how-to-get-the-current-working-directorys-absolute-path-from-irb
|
15
|
+
#
|
16
|
+
def self.require_in_working_path(filename, show_path_info=false)
|
17
|
+
puts '' if show_path_info
|
18
|
+
path = File.expand_path File.dirname(__FILE__)
|
19
|
+
puts "require_in_working_path.path:#{path}:." if show_path_info
|
20
|
+
file = "#{path}/#{filename}"
|
21
|
+
puts "require_in_working_path.file:#{file}:." if show_path_info
|
22
|
+
require file
|
23
|
+
end
|
24
|
+
end # module OCRA
|
18
25
|
|
19
26
|
# -----------------------------------------------------------------------------------------
|
20
27
|
# DateTime Functions
|
@@ -523,18 +530,18 @@ module BlackStack
|
|
523
530
|
# ssl_verify_mode: you can disabele SSL verification here.
|
524
531
|
# 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.
|
525
532
|
# TODO: setup max_simultaneus_calls in the configurtion file.
|
526
|
-
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, use_lockfile=true
|
533
|
+
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, use_lockfile=true)
|
527
534
|
# build the lockfile name
|
528
535
|
x = 0
|
529
|
-
|
530
536
|
if BlackStack::Netting.max_api_call_channels.to_i > 0
|
531
537
|
raise "Max Channels cannot be higher than #{BlackStack::Netting.lockfiles.size.to_s}" if BlackStack::Netting.max_api_call_channels > BlackStack::Netting.lockfiles.size
|
532
538
|
x = rand(BlackStack::Netting.max_api_call_channels)
|
533
539
|
# lock the file
|
534
540
|
BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
|
535
541
|
end
|
536
|
-
|
542
|
+
|
537
543
|
begin
|
544
|
+
|
538
545
|
# do the call
|
539
546
|
uri = URI(url)
|
540
547
|
ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
|
@@ -545,23 +552,25 @@ module BlackStack
|
|
545
552
|
res = http.request req
|
546
553
|
case res
|
547
554
|
when Net::HTTPSuccess then res
|
548
|
-
when Net::HTTPRedirection then
|
549
|
-
BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false, false) if allow_redirection
|
555
|
+
when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false)
|
550
556
|
else
|
551
557
|
res.error!
|
552
558
|
end
|
553
559
|
end
|
560
|
+
|
554
561
|
# release the file
|
555
562
|
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
|
556
563
|
rescue => e
|
557
564
|
# release the file
|
558
565
|
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
|
566
|
+
|
559
567
|
# elevo la excepcion
|
560
568
|
raise e
|
561
569
|
ensure
|
562
570
|
# release the file
|
563
571
|
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
|
564
572
|
end
|
573
|
+
|
565
574
|
# return
|
566
575
|
ret
|
567
576
|
end
|
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.
|
4
|
+
version: 1.1.28
|
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-
|
11
|
+
date: 2020-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|