wonder_oracle_database 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/wonder_oracle_database/version.rb +1 -1
- data/lib/wonder_oracle_database.rb +64 -42
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 687f8c858046c82fd21cf982a64172296296da25ae57416d72ada2e9d3fd8a00
|
4
|
+
data.tar.gz: 5bc9e5ba30947223e6c01270e7161b4b1e2849a24c83cc514361c832a631318c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 935ee59d389ed96d8f24632d629b579e1358229479df3dd0ce55024194766f7a1819a5a0a241adcdf5d7cffc012f8e7097df838001887d86a64e8541c5a7b506
|
7
|
+
data.tar.gz: b71536c7244e389393d8b1c12326c98b56a1e4393d082528de3494f3e7e32e19eef20a7797270e6194d31657e84be2d3fea28523803575e96c8fa799dd3aed95
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,58 +1,80 @@
|
|
1
1
|
require 'wonder_oracle_database/version'
|
2
2
|
|
3
3
|
module WonderOracleDatabase
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
def variable_candidates
|
6
|
+
%w[
|
7
|
+
DATABASE_URL
|
8
|
+
W_HOST_DB_SERVER
|
9
|
+
]
|
10
|
+
end
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
def present?
|
13
|
+
!environment.nil?
|
14
|
+
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
def test?
|
17
|
+
ENV['RAILS_ENV'].to_s.upcase.eql?('TEST')
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
def shared?
|
21
|
+
!test? && present? && !load.nil? && load[:shared]
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
def load
|
25
|
+
parsed_env if present?
|
26
|
+
end
|
22
27
|
|
23
|
-
|
28
|
+
def environment
|
29
|
+
result = nil
|
24
30
|
|
25
|
-
|
31
|
+
variable_candidates.each do |e|
|
32
|
+
next if result
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
password: senha,
|
30
|
-
database: banco,
|
31
|
-
adapter: 'oracle_enhanced',
|
32
|
-
shared: true
|
33
|
-
}
|
34
|
-
end
|
34
|
+
result = ENV[e]
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
.reverse # inverte a string
|
39
|
-
.split('') # cria um array de caracteres
|
40
|
-
.collect { |c| (c.chr.ord - 1).chr } # converte a cadeia de caracteres obfuscados pra seus valores verdadeiros
|
41
|
-
.join # junta o array em uma string
|
42
|
-
end
|
37
|
+
result
|
38
|
+
end
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
def parsed_env
|
41
|
+
match = parse_obfuscated_variable.match(/^(\w+)\/(\w+)@(.+)$/)
|
42
|
+
|
43
|
+
return invalid_variable_error unless match
|
44
|
+
|
45
|
+
usuario, senha, banco = match.captures
|
46
|
+
|
47
|
+
{
|
48
|
+
username: usuario,
|
49
|
+
password: senha,
|
50
|
+
database: banco,
|
51
|
+
adapter: 'oracle_enhanced',
|
52
|
+
shared: true,
|
53
|
+
encoding: 'unicode'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse_obfuscated_variable
|
58
|
+
environment =~ /^(\w+)\/(\w+)@(.+)$/ ? environment : [environment].pack('H*') # converte de hex para decimal
|
59
|
+
.reverse # inverte a string
|
60
|
+
.split('') # cria um array de caracteres
|
61
|
+
.collect { |c| (c.chr.ord - 1).chr } # converte a cadeia de caracteres obfuscados pra seus valores verdadeiros
|
62
|
+
.join # junta o array em uma string
|
63
|
+
end
|
64
|
+
|
65
|
+
def obfuscate_variable
|
66
|
+
parse_obfuscated_variable.split('') # cria um array de caracteres
|
67
|
+
.collect { |c| (c.chr.ord + 1).chr } # converte a cadeia de caracteres para seus valores obfuscados
|
68
|
+
.join # junta o array em uma string
|
69
|
+
.reverse # inverte a string
|
70
|
+
.unpack('H*') # converte pra array de hexadecimais
|
71
|
+
.join # junta o array em uma string
|
72
|
+
end
|
52
73
|
|
53
|
-
|
54
|
-
|
74
|
+
def invalid_variable_error
|
75
|
+
puts "W_HOST_DB_SERVER inválida: deve ser usuario/senha@[ip/]banco ou obfuscada, valor da variável: #{environment}."
|
55
76
|
|
56
|
-
|
77
|
+
false
|
78
|
+
end
|
57
79
|
end
|
58
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wonder_oracle_database
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wonder Sistemas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.7.
|
124
|
+
rubygems_version: 2.7.7
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Wonder Sistemas' shared oracle database config for Rails.
|