pd1_tools 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +12 -0
- data/exe/pd1 +8 -0
- data/lib/avmtrf1/active_directory/user.rb +28 -0
- data/lib/avmtrf1/active_directory.rb +8 -0
- data/lib/avmtrf1/ad_user.rb +11 -0
- data/lib/avmtrf1/check_point/session/login.rb +57 -0
- data/lib/avmtrf1/check_point/session.rb +60 -0
- data/lib/avmtrf1/check_point.rb +3 -0
- data/lib/avmtrf1/default_esosti.rb +20 -0
- data/lib/avmtrf1/default_jira.rb +18 -0
- data/lib/avmtrf1/default_redmine.rb +16 -0
- data/lib/avmtrf1/docker/image.rb +49 -0
- data/lib/avmtrf1/docker/image_runner.rb +83 -0
- data/lib/avmtrf1/docker.rb +9 -0
- data/lib/avmtrf1/esosti/entities/issue.rb +24 -0
- data/lib/avmtrf1/esosti/entities.rb +9 -0
- data/lib/avmtrf1/esosti/instance/changed.rb +33 -0
- data/lib/avmtrf1/esosti/instance.rb +22 -0
- data/lib/avmtrf1/esosti/raw_data_sanitizer.rb +47 -0
- data/lib/avmtrf1/esosti/session/action_base.rb +34 -0
- data/lib/avmtrf1/esosti/session/atividades.rb +35 -0
- data/lib/avmtrf1/esosti/session/login.rb +47 -0
- data/lib/avmtrf1/esosti/session/solicitacao/main.rb +49 -0
- data/lib/avmtrf1/esosti/session/solicitacao.rb +81 -0
- data/lib/avmtrf1/esosti/session.rb +36 -0
- data/lib/avmtrf1/esosti.rb +8 -0
- data/lib/avmtrf1/executables.rb +23 -0
- data/lib/avmtrf1/forponto/parsers/day_registers.rb +19 -0
- data/lib/avmtrf1/forponto/parsers/espelho/day_node.rb +50 -0
- data/lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb +21 -0
- data/lib/avmtrf1/forponto/parsers/espelho/row_node.rb +34 -0
- data/lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb +71 -0
- data/lib/avmtrf1/forponto/parsers/espelho/sub_node.rb +20 -0
- data/lib/avmtrf1/forponto/parsers/espelho/summary_node.rb +55 -0
- data/lib/avmtrf1/forponto/parsers/espelho/utils.rb +32 -0
- data/lib/avmtrf1/forponto/parsers/espelho.rb +26 -0
- data/lib/avmtrf1/forponto/session/day_registers.rb +39 -0
- data/lib/avmtrf1/forponto/session/interval.rb +27 -0
- data/lib/avmtrf1/forponto/session/login.rb +45 -0
- data/lib/avmtrf1/forponto/session.rb +32 -0
- data/lib/avmtrf1/forponto/user/balance.rb +155 -0
- data/lib/avmtrf1/forponto/user/day_registers.rb +32 -0
- data/lib/avmtrf1/forponto/user/month.rb +141 -0
- data/lib/avmtrf1/forponto/user.rb +22 -0
- data/lib/avmtrf1/git/cached_repository.rb +27 -0
- data/lib/avmtrf1/git/gitlab.rb +11 -0
- data/lib/avmtrf1/git/issue_on_repository.rb +100 -0
- data/lib/avmtrf1/git/push_large/_utils.rb +16 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +21 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/checkout_previous_revision.rb +35 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/commit_changes.rb +48 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/helpers.rb +29 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/pick_source_revision.rb +103 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/push.rb +90 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/track_large_files.rb +53 -0
- data/lib/avmtrf1/git/push_large/lfs_commit.rb +47 -0
- data/lib/avmtrf1/git/push_large/source_commit/push.rb +42 -0
- data/lib/avmtrf1/git/push_large/source_commit.rb +58 -0
- data/lib/avmtrf1/git/push_large.rb +69 -0
- data/lib/avmtrf1/git/reference.rb +34 -0
- data/lib/avmtrf1/git.rb +10 -0
- data/lib/avmtrf1/gitlab/commit.rb +37 -0
- data/lib/avmtrf1/gitlab/repository.rb +41 -0
- data/lib/avmtrf1/ini/profile.rb +42 -0
- data/lib/avmtrf1/ini.rb +55 -0
- data/lib/avmtrf1/inventario_sistemas/parser/body.rb +27 -0
- data/lib/avmtrf1/inventario_sistemas/parser/body_row.rb +12 -0
- data/lib/avmtrf1/inventario_sistemas/parser/header.rb +38 -0
- data/lib/avmtrf1/inventario_sistemas/parser/header_column.rb +27 -0
- data/lib/avmtrf1/inventario_sistemas/parser.rb +40 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/elements.rb +54 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/layout.rb +55 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/stylesheet.css +57 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +41 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/index.rb +20 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/sistema.rb +62 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/sistemas_index.rb +31 -0
- data/lib/avmtrf1/inventario_sistemas/site_build.rb +71 -0
- data/lib/avmtrf1/inventario_sistemas.rb +38 -0
- data/lib/avmtrf1/issues/factory.rb +22 -0
- data/lib/avmtrf1/issues.rb +7 -0
- data/lib/avmtrf1/jira/entities/issue.rb +30 -0
- data/lib/avmtrf1/jira/entities.rb +9 -0
- data/lib/avmtrf1/jira/instance.rb +28 -0
- data/lib/avmtrf1/jira.rb +8 -0
- data/lib/avmtrf1/node_js/docker_image.rb +14 -0
- data/lib/avmtrf1/node_js.rb +9 -0
- data/lib/avmtrf1/openvpn/config/builder.rb +59 -0
- data/lib/avmtrf1/openvpn/config/parser/builder.rb +62 -0
- data/lib/avmtrf1/openvpn/config/parser/line.rb +47 -0
- data/lib/avmtrf1/openvpn/config/parser/simple.rb +27 -0
- data/lib/avmtrf1/openvpn/config/parser/tag.rb +39 -0
- data/lib/avmtrf1/openvpn/config/parser.rb +20 -0
- data/lib/avmtrf1/oracle/connection/base.rb +66 -0
- data/lib/avmtrf1/oracle/connection/string_builder.rb +44 -0
- data/lib/avmtrf1/oracle/connection.rb +12 -0
- data/lib/avmtrf1/oracle/object/base.rb +39 -0
- data/lib/avmtrf1/oracle/object/table.rb +15 -0
- data/lib/avmtrf1/oracle/object/user.rb +15 -0
- data/lib/avmtrf1/oracle/object/view.rb +15 -0
- data/lib/avmtrf1/oracle/object.rb +25 -0
- data/lib/avmtrf1/oracle/objects/relation.rb +23 -0
- data/lib/avmtrf1/oracle/objects/sql_builder.rb +64 -0
- data/lib/avmtrf1/oracle/objects.rb +53 -0
- data/lib/avmtrf1/oracle/oci8.rb +29 -0
- data/lib/avmtrf1/oracle.rb +10 -0
- data/lib/avmtrf1/patches/avm/git/issue/complete.rb +50 -0
- data/lib/avmtrf1/patches/avm/git/issue.rb +4 -0
- data/lib/avmtrf1/patches/avm/git/launcher/base.rb +46 -0
- data/lib/avmtrf1/patches/avm/git/launcher.rb +4 -0
- data/lib/avmtrf1/patches/avm/git.rb +4 -0
- data/lib/avmtrf1/patches/avm.rb +4 -0
- data/lib/avmtrf1/patches/inifile.rb +13 -0
- data/lib/avmtrf1/patches.rb +4 -0
- data/lib/avmtrf1/php/docker_images/base.rb +49 -0
- data/lib/avmtrf1/php/docker_images/factory.rb +37 -0
- data/lib/avmtrf1/php/docker_images/v5.rb +47 -0
- data/lib/avmtrf1/php/docker_images/v7.rb +27 -0
- data/lib/avmtrf1/php/docker_images/v7_v4.rb +30 -0
- data/lib/avmtrf1/php/docker_images/v8.rb +19 -0
- data/lib/avmtrf1/php/docker_images.rb +11 -0
- data/lib/avmtrf1/php.rb +9 -0
- data/lib/avmtrf1/red/client/authorization.xml.erb +4 -0
- data/lib/avmtrf1/red/client.rb +38 -0
- data/lib/avmtrf1/red/helper.rb +35 -0
- data/lib/avmtrf1/red/profile/put_file.xml.erb +19 -0
- data/lib/avmtrf1/red/profile.rb +58 -0
- data/lib/avmtrf1/red/server.rb +33 -0
- data/lib/avmtrf1/red.rb +5 -0
- data/lib/avmtrf1/redmine/entities/issue.rb +29 -0
- data/lib/avmtrf1/redmine/entities/issue_status.rb +23 -0
- data/lib/avmtrf1/redmine/entities.rb +10 -0
- data/lib/avmtrf1/redmine/instance.rb +41 -0
- data/lib/avmtrf1/redmine.rb +7 -0
- data/lib/avmtrf1/rest_provider/entity.rb +18 -0
- data/lib/avmtrf1/rest_provider/instance/issues.rb +30 -0
- data/lib/avmtrf1/rest_provider/instance.rb +30 -0
- data/lib/avmtrf1/rest_provider/request.rb +44 -0
- data/lib/avmtrf1/rest_provider/response.rb +73 -0
- data/lib/avmtrf1/rest_provider.rb +7 -0
- data/lib/avmtrf1/result.rb +44 -0
- data/lib/avmtrf1/ruby.rb +9 -0
- data/lib/avmtrf1/tools/application.rb +13 -0
- data/lib/avmtrf1/tools/core_ext.rb +4 -0
- data/lib/avmtrf1/tools/msgraph/api/entity.rb +35 -0
- data/lib/avmtrf1/tools/msgraph/api/member.rb +31 -0
- data/lib/avmtrf1/tools/msgraph/api/root.rb +27 -0
- data/lib/avmtrf1/tools/msgraph/api/team/member_add.rb +36 -0
- data/lib/avmtrf1/tools/msgraph/api/team.rb +40 -0
- data/lib/avmtrf1/tools/msgraph/api.rb +55 -0
- data/lib/avmtrf1/tools/msgraph/error.rb +31 -0
- data/lib/avmtrf1/tools/msgraph/request_mixin.rb +18 -0
- data/lib/avmtrf1/tools/msgraph/response_mixin.rb +23 -0
- data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
- data/lib/avmtrf1/tools/msgraph.rb +11 -0
- data/lib/avmtrf1/tools/rubygems/dependency.rb +20 -0
- data/lib/avmtrf1/tools/rubygems/not_found_error.rb +17 -0
- data/lib/avmtrf1/tools/rubygems.rb +11 -0
- data/lib/avmtrf1/tools/runner/check_point/login.rb +33 -0
- data/lib/avmtrf1/tools/runner/check_point.rb +17 -0
- data/lib/avmtrf1/tools/runner/esosti/changed.rb +39 -0
- data/lib/avmtrf1/tools/runner/esosti/fetch.rb +39 -0
- data/lib/avmtrf1/tools/runner/esosti/request.rb +76 -0
- data/lib/avmtrf1/tools/runner/esosti.rb +27 -0
- data/lib/avmtrf1/tools/runner/forponto/espelho.rb +47 -0
- data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +32 -0
- data/lib/avmtrf1/tools/runner/forponto/resumos.rb +87 -0
- data/lib/avmtrf1/tools/runner/forponto/saldo.rb +91 -0
- data/lib/avmtrf1/tools/runner/forponto.rb +70 -0
- data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +81 -0
- data/lib/avmtrf1/tools/runner/git/gitlab.rb +20 -0
- data/lib/avmtrf1/tools/runner/git/issues_check.rb +59 -0
- data/lib/avmtrf1/tools/runner/git/push_large.rb +46 -0
- data/lib/avmtrf1/tools/runner/git.rb +14 -0
- data/lib/avmtrf1/tools/runner/inventario_sistemas.rb +71 -0
- data/lib/avmtrf1/tools/runner/msgraph/joined_teams.rb +39 -0
- data/lib/avmtrf1/tools/runner/msgraph/request.rb +45 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/member/add.rb +48 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/member.rb +25 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/members.rb +38 -0
- data/lib/avmtrf1/tools/runner/msgraph/team.rb +27 -0
- data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
- data/lib/avmtrf1/tools/runner/msgraph.rb +43 -0
- data/lib/avmtrf1/tools/runner/node_js/docker.rb +15 -0
- data/lib/avmtrf1/tools/runner/node_js.rb +18 -0
- data/lib/avmtrf1/tools/runner/openvpn.rb +91 -0
- data/lib/avmtrf1/tools/runner/oracle/query.rb +71 -0
- data/lib/avmtrf1/tools/runner/oracle/source_get.rb +51 -0
- data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +59 -0
- data/lib/avmtrf1/tools/runner/oracle.rb +37 -0
- data/lib/avmtrf1/tools/runner/php/docker.rb +20 -0
- data/lib/avmtrf1/tools/runner/php.rb +18 -0
- data/lib/avmtrf1/tools/runner/red.rb +83 -0
- data/lib/avmtrf1/tools/runner/source.rb +14 -0
- data/lib/avmtrf1/tools/runner.rb +43 -0
- data/lib/avmtrf1/tools.rb +4 -0
- data/lib/pd1_tools/version.rb +5 -0
- data/lib/pd1_tools.rb +7 -0
- data/template/avmtrf1/node_js/docker_image/Dockerfile.template +25 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/config_banner.sh +15 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/init.sh +18 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/lib.sh +30 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/ng_serve.sh +16 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/npm_install.sh +21 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/start.sh +17 -0
- data/template/avmtrf1/php/docker_images/base/Dockerfile.template +104 -0
- data/template/avmtrf1/php/docker_images/base/aux/apache_foreground.sh +16 -0
- data/template/avmtrf1/php/docker_images/base/aux/apache_user.sh +54 -0
- data/template/avmtrf1/php/docker_images/base/aux/app_user_run.sh +17 -0
- data/template/avmtrf1/php/docker_images/base/aux/config_banner.sh +20 -0
- data/template/avmtrf1/php/docker_images/base/aux/init.sh +39 -0
- data/template/avmtrf1/php/docker_images/base/aux/laravel.sh +58 -0
- data/template/avmtrf1/php/docker_images/base/aux/lib.sh +70 -0
- data/template/avmtrf1/php/docker_images/base/aux/pear.sh +35 -0
- data/template/avmtrf1/php/docker_images/base/aux/php_composer.sh +31 -0
- data/template/avmtrf1/php/docker_images/base/aux/php_values.sh +41 -0
- data/template/avmtrf1/php/docker_images/base/aux/setup_apache_site.sh +16 -0
- data/template/avmtrf1/php/docker_images/base/aux/start.sh +26 -0
- data/template/avmtrf1/php/docker_images/base/aux/templates/apache_site.conf +12 -0
- data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
- metadata +460 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/docker/image'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module NodeJs
|
7
|
+
class DockerImage < ::Avmtrf1::Docker::Image
|
8
|
+
# @return [String]
|
9
|
+
def apt_setup
|
10
|
+
debian_stretch_apt_setup.gsub('-y dist-upgrade', '-y --allow-unauthenticated dist-upgrade')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/openvpn/config/parser'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/fs/temp'
|
6
|
+
|
7
|
+
module Avmtrf1
|
8
|
+
module Openvpn
|
9
|
+
module Config
|
10
|
+
class Builder
|
11
|
+
common_constructor :source_data do
|
12
|
+
unless source_data.is_a?(::Hash)
|
13
|
+
self.source_data = ::Avmtrf1::Openvpn::Config::Parser.new(source_data.to_s).data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def data
|
18
|
+
[simple, tags].reject(&:blank?).join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_data_file
|
22
|
+
::EacRubyUtils::Fs::Temp.on_file do |file|
|
23
|
+
file.write(data)
|
24
|
+
yield(file)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def simple
|
29
|
+
source_data.fetch(:simple)
|
30
|
+
.map { |s| ::Shellwords.join([s.fetch(:attribute)] + s.fetch(:args)) }
|
31
|
+
.map { |s| "#{s}\n" }.join
|
32
|
+
end
|
33
|
+
|
34
|
+
def simple_add_or_update(name, args)
|
35
|
+
new_data = { attribute: name, args: args }
|
36
|
+
s = simple_find(name)
|
37
|
+
if s
|
38
|
+
s.merge!(new_data)
|
39
|
+
else
|
40
|
+
source_data.fetch(:simple) << new_data
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def tags
|
45
|
+
source_data.fetch(:tags).map { |t| tag_to_data(t) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def tag_to_data(tag)
|
49
|
+
["<#{tag.fetch(:name)}>", tag.fetch(:content), "</#{tag.fetch(:name)}>"]
|
50
|
+
.map { |v| "#{v}\n" }.join
|
51
|
+
end
|
52
|
+
|
53
|
+
def simple_find(name)
|
54
|
+
source_data.fetch(:simple).find { |s| s.fetch(:attribute) == name }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/openvpn/config/parser/line'
|
4
|
+
require 'avmtrf1/openvpn/config/parser/simple'
|
5
|
+
require 'avmtrf1/openvpn/config/parser/tag'
|
6
|
+
|
7
|
+
module Avmtrf1
|
8
|
+
module Openvpn
|
9
|
+
module Config
|
10
|
+
class Parser < ::Aranha::Parsers::Base
|
11
|
+
class Builder
|
12
|
+
attr_reader :simple, :tags
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@simple = []
|
16
|
+
@tags = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_line(line_text)
|
20
|
+
line = ::Avmtrf1::Openvpn::Config::Parser::Line.new(line_text)
|
21
|
+
if on_tag?
|
22
|
+
add_line_on_tag(line)
|
23
|
+
else
|
24
|
+
add_line_not_on_tag(line)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_line_on_tag(line)
|
29
|
+
if line.close_tag?
|
30
|
+
if line.tag_name != current_tag.name
|
31
|
+
raise("Closing tag \"#{line.tag_name}\" does not match current tag " \
|
32
|
+
"\"#{current_tag}\"")
|
33
|
+
end
|
34
|
+
|
35
|
+
current_tag.close
|
36
|
+
else
|
37
|
+
current_tag.add_line(line.text)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_line_not_on_tag(line)
|
42
|
+
return if line.blank_text?
|
43
|
+
|
44
|
+
if line.open_tag?
|
45
|
+
tags << ::Avmtrf1::Openvpn::Config::Parser::Tag.new(line.tag_name)
|
46
|
+
else
|
47
|
+
simple << ::Avmtrf1::Openvpn::Config::Parser::Simple.new(line.simple_parts)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_tag
|
52
|
+
tags.last
|
53
|
+
end
|
54
|
+
|
55
|
+
def on_tag?
|
56
|
+
tags.last.if_present(false, &:open?)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Openvpn
|
7
|
+
module Config
|
8
|
+
class Parser < ::Aranha::Parsers::Base
|
9
|
+
class Line
|
10
|
+
OPEN_TAG_PATTERN = /\A<(.+)>\z/.freeze
|
11
|
+
CLOSE_TAG_PATTERN = %r{\A</(.+)>\z}.freeze
|
12
|
+
SIMPLE_PATTERN = /\A(\S+)(?:\s+(\S.*))\z/.freeze
|
13
|
+
|
14
|
+
common_constructor :text do
|
15
|
+
self.text = text.rstrip
|
16
|
+
end
|
17
|
+
|
18
|
+
def simple_parts
|
19
|
+
::Shellwords.split(text)
|
20
|
+
end
|
21
|
+
|
22
|
+
def blank_text?
|
23
|
+
text.blank?
|
24
|
+
end
|
25
|
+
|
26
|
+
def open_tag?
|
27
|
+
OPEN_TAG_PATTERN.match?(text)
|
28
|
+
end
|
29
|
+
|
30
|
+
def close_tag?
|
31
|
+
CLOSE_TAG_PATTERN.match?(text)
|
32
|
+
end
|
33
|
+
|
34
|
+
def tag_name
|
35
|
+
if close_tag?
|
36
|
+
CLOSE_TAG_PATTERN.if_match(text) { |m| m[1] }
|
37
|
+
elsif open_tag?
|
38
|
+
OPEN_TAG_PATTERN.if_match(text) { |m| m[1] }
|
39
|
+
else
|
40
|
+
raise "Unmapped branch in #{__method__}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Openvpn
|
7
|
+
module Config
|
8
|
+
class Parser < ::Aranha::Parsers::Base
|
9
|
+
class Simple
|
10
|
+
common_constructor :parts
|
11
|
+
|
12
|
+
def data
|
13
|
+
{ attribute: attribute, args: args }
|
14
|
+
end
|
15
|
+
|
16
|
+
def attribute
|
17
|
+
parts.first
|
18
|
+
end
|
19
|
+
|
20
|
+
def args
|
21
|
+
parts[1..-1] # rubocop:disable Style/SlicingWithRange
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Openvpn
|
7
|
+
module Config
|
8
|
+
class Parser < ::Aranha::Parsers::Base
|
9
|
+
class Tag
|
10
|
+
common_constructor :name do
|
11
|
+
@open = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_line(text)
|
15
|
+
lines << text
|
16
|
+
end
|
17
|
+
|
18
|
+
def data
|
19
|
+
{ name: name, content: lines.join("\n") }
|
20
|
+
end
|
21
|
+
|
22
|
+
def open?
|
23
|
+
@open
|
24
|
+
end
|
25
|
+
|
26
|
+
def close
|
27
|
+
@open = false
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def lines
|
33
|
+
@lines ||= []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Openvpn
|
8
|
+
module Config
|
9
|
+
class Parser < ::Aranha::Parsers::Base
|
10
|
+
require_sub __FILE__
|
11
|
+
|
12
|
+
def data
|
13
|
+
builder = ::Avmtrf1::Openvpn::Config::Parser::Builder.new
|
14
|
+
content.each_line { |line| builder.add_line(line) }
|
15
|
+
{ simple: builder.simple.map(&:data), tags: builder.tags.map(&:data) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/oracle/objects'
|
4
|
+
require 'avmtrf1/oracle/oci8'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Oracle
|
8
|
+
module Connection
|
9
|
+
class Base
|
10
|
+
DEFAULT_PORT = 1521
|
11
|
+
|
12
|
+
delegate :exec, to: :connection
|
13
|
+
|
14
|
+
def initialize(connection_string)
|
15
|
+
::Avmtrf1::Oracle::Oci8.require_lib
|
16
|
+
@connection = OCI8.new(connection_string)
|
17
|
+
end
|
18
|
+
|
19
|
+
def first_row(sql)
|
20
|
+
connection.exec(sql) { |row| return row }
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def first_row_hash(sql)
|
25
|
+
connection.exec(sql).fetch_hash { |row| return row }
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def unique_value(sql)
|
30
|
+
first_row(sql).if_present(&:first)
|
31
|
+
end
|
32
|
+
|
33
|
+
def query(sql, &block)
|
34
|
+
if block
|
35
|
+
query_with_block(sql, block)
|
36
|
+
else
|
37
|
+
query_without_block(sql)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def objects
|
42
|
+
@objects ||= ::Avmtrf1::Oracle::Objects.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
attr_reader :connection
|
48
|
+
|
49
|
+
def query_without_block(sql)
|
50
|
+
connection.exec(sql)
|
51
|
+
end
|
52
|
+
|
53
|
+
def query_with_block(sql, block)
|
54
|
+
cursor = query_without_block(sql)
|
55
|
+
begin
|
56
|
+
while (row = cursor.fetch_hash)
|
57
|
+
block.call(row)
|
58
|
+
end
|
59
|
+
ensure
|
60
|
+
cursor.close
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Oracle
|
5
|
+
module Connection
|
6
|
+
class StringBuilder
|
7
|
+
DEFAULT_PORT = 1521
|
8
|
+
|
9
|
+
FIELDS = %w[user password host port service_name].freeze
|
10
|
+
|
11
|
+
attr_accessor(*FIELDS, :string)
|
12
|
+
|
13
|
+
def initialize(options = nil)
|
14
|
+
if options.is_a?(String)
|
15
|
+
self.string = options
|
16
|
+
elsif options.is_a?(Hash)
|
17
|
+
options.each do |k, v|
|
18
|
+
send("#{k}=", v)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def port
|
24
|
+
@port || DEFAULT_PORT
|
25
|
+
end
|
26
|
+
|
27
|
+
def build
|
28
|
+
if string
|
29
|
+
string
|
30
|
+
else
|
31
|
+
validate_fields
|
32
|
+
"#{user}/#{password}@//#{host}:#{port}/#{service_name}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def validate_fields
|
39
|
+
FIELDS.each { |f| raise "\"#{f}\" is blank" if send(f).blank? }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/listable'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Oracle
|
8
|
+
class Object
|
9
|
+
class Base
|
10
|
+
include ::EacRubyUtils::Listable
|
11
|
+
|
12
|
+
lists.add_string :attributes, :id, :name, :owner, :type
|
13
|
+
common_constructor :connection, :attributes
|
14
|
+
|
15
|
+
lists.attributes.values.each do |attribute| # rubocop:disable Style/HashEachMethods
|
16
|
+
define_method(attribute) do
|
17
|
+
attributes.fetch(attribute.to_sym)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def drop
|
22
|
+
connection.exec(drop_ddl)
|
23
|
+
end
|
24
|
+
|
25
|
+
def fullname
|
26
|
+
(owner.present? ? "#{owner}." : '') + name
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
"#{type}/#{fullname}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def drop_ddl
|
34
|
+
"drop #{type} #{fullname}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/oracle/object/base'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Object
|
8
|
+
class Table < ::Avmtrf1::Oracle::Object::Base
|
9
|
+
def drop_ddl
|
10
|
+
"#{super} cascade constraints"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/oracle/object/base'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Object
|
8
|
+
class User < ::Avmtrf1::Oracle::Object::Base
|
9
|
+
def objects(search_attributes = {})
|
10
|
+
connection.objects.list(search_attributes.merge(owner: name))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/oracle/object/base'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Object
|
8
|
+
class View < ::Avmtrf1::Oracle::Object::Base
|
9
|
+
def drop_ddl
|
10
|
+
"#{super} cascade constraints"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Object
|
8
|
+
require_sub __FILE__
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def factory_get(connection, attributes)
|
12
|
+
return nil if attributes.blank?
|
13
|
+
|
14
|
+
type_class(attributes.fetch(:type)).new(connection, attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
def type_class(type)
|
18
|
+
const_get(type.to_s.humanize.camelize)
|
19
|
+
rescue NameError
|
20
|
+
::Avmtrf1::Oracle::Object::Base
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Objects
|
8
|
+
class Relation
|
9
|
+
common_constructor :connection, :sql
|
10
|
+
|
11
|
+
def each
|
12
|
+
connection.query(sql).fetch_hash do |row|
|
13
|
+
yield(::Avmtrf1::Oracle::Objects.row_to_object(connection, row))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def count
|
18
|
+
connection.unique_value("select * from (#{sql})").to_i
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Objects
|
8
|
+
class SqlBuilder
|
9
|
+
COLUMNS = {
|
10
|
+
type: :type_name, name: :name, owner: :owner_name, table: :table_name
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
enable_simple_cache
|
14
|
+
common_constructor :options
|
15
|
+
|
16
|
+
def sql
|
17
|
+
"SELECT * FROM (\n" + # rubocop:disable Style/StringConcatenation
|
18
|
+
[all_objects_sql, all_users_sql].map { |sub_sql| "\t(#{with_where_sql(sub_sql)})\n" }
|
19
|
+
.join("\tUNION ALL\n") +
|
20
|
+
") order by object_type, owner, object_name\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
def all_objects_sql
|
24
|
+
"SELECT #{COLUMNS_TO_ATTRIBUTES.keys.join(', ')} FROM #{TABLE_NAME}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_users_sql
|
28
|
+
'SELECT user_id as object_id, username as object_name, \'USER\' as object_type' \
|
29
|
+
', null as owner FROM all_users'
|
30
|
+
end
|
31
|
+
|
32
|
+
def with_where_sql(sql)
|
33
|
+
r = "select * from (#{sql}) WHERE 1=1"
|
34
|
+
COLUMNS_TO_ATTRIBUTES.each_value do |search_key|
|
35
|
+
search_option_condition(search_key).if_present do |v|
|
36
|
+
r += " and (#{v})"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
r
|
40
|
+
end
|
41
|
+
|
42
|
+
def column_by_search_key(search_key)
|
43
|
+
COLUMNS_TO_ATTRIBUTES.key(search_key) || raise("Search key not found: #{search_key}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def search_option_condition(search_key)
|
47
|
+
values = search_option(search_key)
|
48
|
+
return nil unless values.any?
|
49
|
+
|
50
|
+
column = column_by_search_key(search_key)
|
51
|
+
values.map { |v| "(LOWER(#{column}) LIKE LOWER('#{v}'))" }.join(' or ')
|
52
|
+
end
|
53
|
+
|
54
|
+
def search_option(search_key)
|
55
|
+
[search_key.to_s, search_key.to_sym].each do |k|
|
56
|
+
v = options[k]
|
57
|
+
return Array(v) if v.present?
|
58
|
+
end
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
class Objects
|
8
|
+
require_sub __FILE__
|
9
|
+
|
10
|
+
COLUMNS_TO_ATTRIBUTES = {
|
11
|
+
object_id: :id,
|
12
|
+
object_name: :name,
|
13
|
+
object_type: :type,
|
14
|
+
owner: :owner
|
15
|
+
}.freeze
|
16
|
+
TABLE_NAME = 'all_objects'
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def row_to_object(connection, row)
|
20
|
+
::Avmtrf1::Oracle::Object.factory_get(
|
21
|
+
connection,
|
22
|
+
row_to_attributes(row)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def row_to_attributes(row)
|
27
|
+
return nil if row.blank?
|
28
|
+
|
29
|
+
COLUMNS_TO_ATTRIBUTES.map do |column, attribute| # rubocop:disable Style/MapToHash
|
30
|
+
[attribute, row.fetch(column.to_s.upcase)]
|
31
|
+
end.to_h
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
common_constructor :connection
|
36
|
+
|
37
|
+
def list(options = {})
|
38
|
+
::Avmtrf1::Oracle::Objects::Relation.new(connection, sql(options))
|
39
|
+
end
|
40
|
+
|
41
|
+
def first(options = {})
|
42
|
+
self.class.row_to_object(
|
43
|
+
connection,
|
44
|
+
connection.first_row_hash(sql(options))
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def sql(options)
|
49
|
+
::Avmtrf1::Oracle::Objects::SqlBuilder.new(options).sql
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/tools/rubygems/dependency'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Oracle
|
7
|
+
module Oci8
|
8
|
+
NLS_LANG_DEFAULT_VALUE = 'BRAZILIAN PORTUGUESE_BRAZIL.UTF8'
|
9
|
+
NLS_LANG_ENVIRONMENT_KEY = 'NLS_LANG'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def dependency
|
13
|
+
@dependency ||= ::Avmtrf1::Tools::Rubygems::Dependency.new('ruby-oci8', 'oci8')
|
14
|
+
end
|
15
|
+
|
16
|
+
def require_lib
|
17
|
+
nls_lang_set
|
18
|
+
dependency.require_lib
|
19
|
+
end
|
20
|
+
|
21
|
+
def nls_lang_set
|
22
|
+
return if ENV.key?(NLS_LANG_ENVIRONMENT_KEY)
|
23
|
+
|
24
|
+
ENV[NLS_LANG_ENVIRONMENT_KEY] = NLS_LANG_DEFAULT_VALUE
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|