blackstack_commons 1.1.23 → 1.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/functions.rb +24 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 345922a44893caebb3f49941d727caeaec60b5cb
4
- data.tar.gz: 7273fc7489470e892f5c6acabbaf01de6400d059
3
+ metadata.gz: 3c06dd76bc3936b16355aba14d4ea7dccd1b6323
4
+ data.tar.gz: 13b8b273c05e6912528d973b41eb245e524de699
5
5
  SHA512:
6
- metadata.gz: f67ecc32793dc0d973afde9f79ebfca57a0119dafcd9f37a9c75bc72e858f014adb137356f0482f65ff0bd5c304c5e4c5e18a5c1800ca6eef1f3f2f5fa07e4fd
7
- data.tar.gz: 9cd3982e6265e59c742e02a44165d8d78cef80747512c5700d57818b887878ed0c11d8f49043e22dd339faed61666936cef795e630440b6039e8b21b9b4620f0
6
+ metadata.gz: cbbeaf250f1fd2dd8d1e48fc09f9c65b5d470a45ad332804754823acd451e9a4e0379feb124fbbbc6d6f4dc67c50948eab0ce83388807270e4299151c31c7092
7
+ data.tar.gz: 1bc256b596063aebea05a7211ea6ced437ac71adf36d1269471040feefb81de902906780f104429f16baca85e93a7ee9fd84c366b4ab6e27b1ef28098dbb7d7b
data/lib/functions.rb CHANGED
@@ -1,4 +1,24 @@
1
1
  module BlackStack
2
+
3
+ # This method does a require of the config.rb that must then then
4
+ # ruby script that is running, or where an .exe file genrated by
5
+ # OCRA is running.
6
+ #
7
+ # When you run an OCRA .exe file, such .exe will unpackage the ruby
8
+ # script in a temporal folder. So any require will look for conf.rb
9
+ # into the temporal folder.
10
+ #
11
+ # This function resolves that problem, by forcing the require to look
12
+ # into the folder where the .exe command is hosted.
13
+ #
14
+ def self.require_local(filename='config.rb')
15
+ current_dir = ($0) || __FILE__
16
+ current_dir = File.expand_path('..', current_dir)
17
+ source_dir = ENV["OCRA_EXECUTABLE"] || __FILE__
18
+ source_dir = File.expand_path('..', source_dir)
19
+ require File.expand_path('config', source_dir)
20
+ end
21
+
2
22
  # -----------------------------------------------------------------------------------------
3
23
  # DateTime Functions
4
24
  # -----------------------------------------------------------------------------------------
@@ -508,21 +528,16 @@ module BlackStack
508
528
  # TODO: setup max_simultaneus_calls in the configurtion file.
509
529
  def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, use_lockfile=true, allow_redirection=true)
510
530
  # build the lockfile name
511
- #puts ''
512
- #puts "call_post.url:#{url}:."
513
- =begin
514
531
  x = 0
515
532
 
516
533
  if BlackStack::Netting.max_api_call_channels.to_i > 0
517
- puts "call_post.url.1:."
518
534
  raise "Max Channels cannot be higher than #{BlackStack::Netting.lockfiles.size.to_s}" if BlackStack::Netting.max_api_call_channels > BlackStack::Netting.lockfiles.size
519
535
  x = rand(BlackStack::Netting.max_api_call_channels)
520
536
  # lock the file
521
537
  BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
522
538
  end
523
- =end
539
+
524
540
  begin
525
- #puts "call_post.url.2:."
526
541
  # do the call
527
542
  uri = URI(url)
528
543
  ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -539,24 +554,17 @@ puts "call_post.url.1:."
539
554
  res.error!
540
555
  end
541
556
  end
542
- #puts "call_post.url.3:."
543
557
  # release the file
544
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
545
- #puts "call_post.url.4:."
558
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
546
559
  rescue => e
547
560
  # release the file
548
- #puts "call_post.url.5:."
549
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
550
- #puts "call_post.url.6:."
561
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
551
562
  # elevo la excepcion
552
563
  raise e
553
564
  ensure
554
565
  # release the file
555
- #puts "call_post.url.7:."
556
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
557
- #puts "call_post.url.8:."
566
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
558
567
  end
559
- #puts "call_post.url.9:."
560
568
  # return
561
569
  ret
562
570
  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.23
4
+ version: 1.1.25
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-01 00:00:00.000000000 Z
11
+ date: 2020-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning