blackstack-core 1.2.10 → 1.2.12

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 +88 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f9ada61d055548918448b48e7cf02f31226fefb8721d35b381a796f215df7f4
4
- data.tar.gz: a28cc19fc248d0263ab165218003b225cb25311d3e985ccc2ae1523c79049837
3
+ metadata.gz: 798ff1afa2d3be6184ccf879455158097e18427e3eaf0b504637d3c8f3f0568d
4
+ data.tar.gz: 9611aed6efa51f99c1bef9b231f8efb12fd044c12181d592790c93f17e79fe80
5
5
  SHA512:
6
- metadata.gz: 733b6b5f3de03db04524a025b8759f1ed2060bb1bab93f232a4926ea83e352fea8f5fff3c15935c2220bdcb207a7b4cde1877ef26a97042729d431aff96a1e52
7
- data.tar.gz: a9e8dde42397c2364e4b8e74c271adc3d8697481ce79a09c9cc104f519c6383aa864b2d1604cec8028fcb50fca5526214afc30bd0138b8a7097d92d6a5a93d7b
6
+ metadata.gz: d97e4e198a961b9d35502ab9d993f0b524e1c7be4f85c7a696604618bfecb6b977bb7e1b1f07904b98bda4c79705e23a027af70894d26670042531c0bb9b8dfe
7
+ data.tar.gz: b0d537a18baaa2af08d660ec7e96b57058b99ccbcd018ba3460eb8571bb0102f440d3dc510f553a2e7becba3040e229cd418c07880ad44acffbd2d65be01db67
data/lib/functions.rb CHANGED
@@ -1,6 +1,94 @@
1
1
 
2
2
  module BlackStack
3
3
 
4
+ # Return true if there is a .sandbox file in the $RUBYLIB folder.
5
+ def sandbox?
6
+ File.exists?('/$RUBYLIB/.sandbox')
7
+ end
8
+
9
+ module API
10
+ # API connection parameters
11
+ @@api_key = nil # Api-key of the client who will be the owner of a process.
12
+ @@api_protocol = nil # Protocol, HTTP or HTTPS, of the BlackStack server where this process will be registered.
13
+ @@api_domain = nil # Domain of the BlackStack server where this process will be registered.
14
+ @@api_port = nil # Port of the BlackStack server where this process will be registered.
15
+ @@api_less_secure_port = nil # Port of the BlackStack server where this process will be registered.
16
+
17
+ # API connection getters and setters
18
+ def self.api_key()
19
+ @@api_key
20
+ end
21
+ def self.api_protocol
22
+ @@api_protocol
23
+ end
24
+ def self.api_domain
25
+ @@api_domain
26
+ end
27
+ def self.api_port
28
+ @@api_port
29
+ end
30
+ def self.api_less_secure_port
31
+ @@api_less_secure_port
32
+ end
33
+ def self.api_url()
34
+ "#{BlackStack::API.api_protocol}://#{BlackStack::API.api_domain}:#{BlackStack::API.api_port}"
35
+ end
36
+ def self.api_less_secure_url()
37
+ "http://#{BlackStack::API.api_domain}:#{BlackStack::API.api_less_secure_port}"
38
+ end
39
+ def self.set_api_key(s)
40
+ # validate: the parameter s is required
41
+ raise 'The parameter s is required' unless s
42
+
43
+ # validate: the parameter s must be a string
44
+ raise 'The parameter s must be a string' unless s.is_a?(String)
45
+
46
+ # map values
47
+ @@api_key = s
48
+ end
49
+ def self.set_api_url(h)
50
+ # validate: the parameter h is requred
51
+ raise "The parameter h is required." if h.nil?
52
+
53
+ # validate: the parameter h must be a hash
54
+ raise "The parameter h must be a hash" unless h.is_a?(Hash)
55
+
56
+ # validate: the :api_key key is required
57
+ raise 'The key :api_key is required' unless h.has_key?(:api_key)
58
+
59
+ # validate: the :api_protocol key is required
60
+ raise 'The key :api_protocol is required' unless h.has_key?(:api_domain)
61
+
62
+ # validate: the :api_domain key is required
63
+ raise 'The key :api_domain is required' unless h.has_key?(:api_domain)
64
+
65
+ # validate: the :api_port key is required
66
+ raise 'The key :api_port is required' unless h.has_key?(:api_port)
67
+
68
+ # validate: the :api_key key is a string
69
+ raise 'The key :api_key must be a string' unless h[:api_key].is_a?(String)
70
+
71
+ # validate: the :api_protocol key is a string
72
+ raise 'The key :api_protocol must be a string' unless h[:api_protocol].is_a?(String)
73
+
74
+ # validate: the :api_domain key is a string
75
+ raise 'The key :api_domain must be a string' unless h[:api_domain].is_a?(String)
76
+
77
+ # validate: the :api_port key is an integer, or a string that can be converted to an integer
78
+ raise 'The key :api_port must be an integer' unless h[:api_port].is_a?(Integer) || (h[:api_port].is_a?(String) && h[:api_port].to_i.to_s == h[:api_port])
79
+
80
+ # validate: the :api_less_secure_port key is an integer, or a string that can be converted to an integer
81
+ raise 'The key :api_less_secure_port must be an integer' unless h[:api_less_secure_port].is_a?(Integer) || (h[:api_less_secure_port].is_a?(String) && h[:api_less_secure_port].to_i.to_s == h[:api_less_secure_port])
82
+
83
+ # map the values
84
+ @@api_key = h[:api_key]
85
+ @@api_protocol = h[:api_protocol]
86
+ @@api_domain = h[:api_domain]
87
+ @@api_port = h[:api_port].to_i
88
+ @@api_less_secure_port = h[:api_less_secure_port].to_i
89
+ end
90
+ end # module API
91
+
4
92
  # -----------------------------------------------------------------------------------------
5
93
  # PRY Supporting Functions
6
94
  # -----------------------------------------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.2.12
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: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning