avm-tools 0.114.0 → 0.115.0
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.
- checksums.yaml +4 -4
- data/lib/avm/launcher/git/publish_base.rb +2 -0
- data/lib/avm/tools/version.rb +1 -1
- data/sub/avm/lib/avm/instances/base/auto_values/database.rb +2 -2
- data/sub/avm/lib/avm/instances/entry_keys.rb +2 -1
- data/{lib → sub/avm/lib}/avm/launcher/errors/base.rb +0 -0
- data/{lib → sub/avm/lib}/avm/launcher/errors/non_project.rb +0 -0
- data/{lib → sub/avm/lib}/avm/launcher/paths/real.rb +0 -0
- data/{lib → sub/avm/lib}/avm/launcher/publish/check_result.rb +0 -0
- data/sub/avm/lib/avm/self/instance.rb +0 -1
- data/sub/avm/lib/avm/sources/base/instance.rb +28 -0
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/assert.rb +77 -0
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +23 -12
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +1 -1
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/deploy.rb +1 -1
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/data_unit.rb +6 -10
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instance.rb +20 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/rest_api.rb +11 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +3 -3
- data/sub/avm-files/lib/avm/files/formatter/formats/generic_plain.rb +2 -2
- data/sub/avm-files/lib/avm/files/version.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner/context.rb +4 -0
- data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +10 -0
- data/sub/eac_cli/lib/eac_cli/speaker.rb +1 -2
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_fs/lib/eac_fs/cached_download.rb +2 -2
- data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +6 -1
- data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
- data/sub/eac_rest/Gemfile +5 -0
- data/sub/eac_rest/eac_rest.gemspec +18 -0
- data/sub/eac_rest/lib/eac_rest/api.rb +39 -0
- data/sub/eac_rest/lib/eac_rest/entity.rb +16 -0
- data/sub/eac_rest/lib/eac_rest/request.rb +74 -0
- data/sub/eac_rest/lib/eac_rest/response.rb +72 -0
- data/sub/eac_rest/lib/eac_rest/version.rb +5 -0
- data/sub/eac_rest/lib/eac_rest.rb +7 -0
- data/sub/eac_rest/spec/rubocop_spec.rb +3 -0
- data/sub/eac_rest/spec/spec_helper.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +46 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +105 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +21 -3
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +12 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb +15 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
- metadata +35 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf0d93631b14929c6e271ba0dd835f75a9633a961b3f870daa5c64eb467e0ef2
|
4
|
+
data.tar.gz: '0281c164c78506d7fe5ac8f601ce4380661f835a3c4e0ebe7c48c60334419565'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbb490835a6f843cb9179effd073b661e7d4c7d1006ae4a135744d692203425ab8c4f9dbd18d55af1b1744655ec216c3feaf23470c1df691788eb3d94030a9d
|
7
|
+
data.tar.gz: 2e647b2157fe2c3bdf9ea51ebaac0809e4299af1bb13c96b73bae51c68e9876ba37347a9a85f3e15b8eede0c837546edf05079b116abf67081ecbe28062092b3
|
data/lib/avm/tools/version.rb
CHANGED
@@ -37,7 +37,7 @@ module Avm
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def auto_database_password
|
40
|
-
database_auto_common('password')
|
40
|
+
database_auto_common('password') || id
|
41
41
|
end
|
42
42
|
|
43
43
|
def auto_database_port
|
@@ -45,7 +45,7 @@ module Avm
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def auto_database_username
|
48
|
-
database_auto_common('username')
|
48
|
+
database_auto_common('username') || id
|
49
49
|
end
|
50
50
|
|
51
51
|
def auto_database_system
|
@@ -47,7 +47,8 @@ module Avm
|
|
47
47
|
docker: %w[registry],
|
48
48
|
mailer: {
|
49
49
|
'' => %w[id from reply_to],
|
50
|
-
smtp: %w[address port domain username password authentication
|
50
|
+
smtp: %w[address port domain username password authentication openssl_verify_mode
|
51
|
+
starttls_auto tls]
|
51
52
|
},
|
52
53
|
ssh: %w[hostname port url username],
|
53
54
|
web: %w[authority hostname path port scheme url userinfo]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/application'
|
4
|
+
require 'avm/instances/base'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Sources
|
8
|
+
class Base
|
9
|
+
module Instance
|
10
|
+
DEFAULT_INSTANCE_SUFFIX = 'dev'
|
11
|
+
|
12
|
+
def instance_suffix
|
13
|
+
DEFAULT_INSTANCE_SUFFIX
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def application_uncached
|
19
|
+
::Avm::Instances::Application.new(path.basename)
|
20
|
+
end
|
21
|
+
|
22
|
+
def instance_uncached
|
23
|
+
::Avm::Instances::Base.new(application, DEFAULT_INSTANCE_SUFFIX)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/sub/avm/lib/avm/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacPostgresqlBase0
|
7
|
+
class Instance
|
8
|
+
class Assert
|
9
|
+
common_constructor :instance
|
10
|
+
delegate :name, :password, :user, to: :instance
|
11
|
+
|
12
|
+
def perform
|
13
|
+
create_user unless user_exist?
|
14
|
+
change_password unless password_ok?
|
15
|
+
create_database unless database_exist?
|
16
|
+
change_owner unless user_owner?
|
17
|
+
end
|
18
|
+
|
19
|
+
def change_owner
|
20
|
+
root_execute("ALTER DaTABASE \"#{name}\" OWNER TO \"#{user}\"")
|
21
|
+
end
|
22
|
+
|
23
|
+
def change_password
|
24
|
+
root_execute("ALTER USER \"#{user}\" WITH PASSWORD '#{password}'")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_user
|
28
|
+
root_execute("CREATE USER \"#{user}\" WITH PASSWORD '#{password}'")
|
29
|
+
end
|
30
|
+
|
31
|
+
def current_owner
|
32
|
+
root_query(<<~SQL
|
33
|
+
SELECT pg_catalog.pg_get_userbyid(datdba)
|
34
|
+
FROM pg_catalog.pg_database
|
35
|
+
WHERE datname = '#{name}'
|
36
|
+
SQL
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def database_exist?
|
41
|
+
root_boolean_query("FROM pg_database WHERE datname='#{name}'")
|
42
|
+
end
|
43
|
+
|
44
|
+
def password_ok?
|
45
|
+
instance.psql_command_command('SELECT 1', false)
|
46
|
+
.execute!(exit_outputs: { 512 => 'login_failed' }).strip == '1'
|
47
|
+
end
|
48
|
+
|
49
|
+
def user_exist?
|
50
|
+
root_boolean_query("FROM pg_roles WHERE rolname='#{user}'")
|
51
|
+
end
|
52
|
+
|
53
|
+
def user_owner?
|
54
|
+
user == current_owner
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_database
|
58
|
+
root_execute("CREATE DATABASE \"#{name}\" WITH OWNER \"#{user}\"")
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def root_boolean_query(sql_after_projection)
|
64
|
+
root_query("SELECT 1 #{sql_after_projection}") == '1'
|
65
|
+
end
|
66
|
+
|
67
|
+
def root_execute(sql)
|
68
|
+
instance.root_psql_command(sql).execute!
|
69
|
+
end
|
70
|
+
|
71
|
+
def root_query(sql)
|
72
|
+
root_execute(sql).strip
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,13 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'avm/eac_postgresql_base0/instance/data_unit'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module Avm
|
6
7
|
module EacPostgresqlBase0
|
7
8
|
class Instance
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
require_sub __FILE__
|
10
|
+
|
11
|
+
MAINTENANCE_DATABASE = 'postgres'
|
12
|
+
|
13
|
+
common_constructor :env, :connection_params do
|
14
|
+
self.connection_params = connection_params.with_indifferent_access
|
15
|
+
end
|
16
|
+
|
17
|
+
def assert
|
18
|
+
::Avm::EacPostgresqlBase0::Instance::Assert.new(self).perform
|
11
19
|
end
|
12
20
|
|
13
21
|
def data_unit
|
@@ -23,20 +31,23 @@ module Avm
|
|
23
31
|
dump_command.append(['@ESC_|', 'gzip', '-9', '-c'])
|
24
32
|
end
|
25
33
|
|
26
|
-
def psql_command
|
27
|
-
env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args)
|
34
|
+
def psql_command(database = true)
|
35
|
+
env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args(database))
|
28
36
|
end
|
29
37
|
|
30
|
-
def psql_command_command(sql)
|
31
|
-
psql_command.append(['--quiet', '--tuples-only', '--command', sql])
|
38
|
+
def psql_command_command(sql, database = true)
|
39
|
+
psql_command(database).append(['--quiet', '--tuples-only', '--command', sql])
|
32
40
|
end
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
def root_psql_command(sql = nil)
|
43
|
+
args = ['sudo', '-u', 'postgres', 'psql']
|
44
|
+
args += ['--quiet', '--tuples-only', '--command', sql] if sql.present?
|
45
|
+
env.command(*args)
|
46
|
+
end
|
37
47
|
|
38
|
-
def common_command_args
|
39
|
-
['--host', host, '--username', user, '--port', port,
|
48
|
+
def common_command_args(database = true)
|
49
|
+
['--host', host, '--username', user, '--port', port,
|
50
|
+
(database ? name : MAINTENANCE_DATABASE)]
|
40
51
|
end
|
41
52
|
|
42
53
|
def host
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.2'
|
17
17
|
s.add_dependency 'curb', '~> 0.9.10'
|
18
18
|
s.add_dependency 'eac_fs', '~> 0.4'
|
19
|
+
s.add_dependency 'eac_rest', '~> 0.4'
|
19
20
|
s.add_dependency 'eac_ruby_utils', '~> 0.68'
|
20
21
|
|
21
22
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.4'
|
@@ -10,11 +10,13 @@ module Avm
|
|
10
10
|
class DataUnit < ::Avm::Data::Instance::Unit
|
11
11
|
common_constructor :instance
|
12
12
|
|
13
|
+
EXPORT_PATH = '/backup/export'
|
13
14
|
EXTENSION = '.tar'
|
15
|
+
IMPORT_PATH = '/backup/import.json'
|
14
16
|
|
15
17
|
def do_dump(data_path)
|
16
18
|
::File.open(data_path, 'wb') do |file|
|
17
|
-
file <<
|
19
|
+
file << export_request.response.body_data_or_raise
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -37,18 +39,12 @@ module Avm
|
|
37
39
|
true
|
38
40
|
end
|
39
41
|
|
40
|
-
def
|
41
|
-
|
42
|
+
def export_request
|
43
|
+
instance.rest_api.request(EXPORT_PATH)
|
42
44
|
end
|
43
45
|
|
44
46
|
def import_url
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def url(path)
|
49
|
-
uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + path
|
50
|
-
uri.query_values = { key: instance.read_entry('admin.api_key') }
|
51
|
-
uri.to_s
|
47
|
+
instance.rest_api.build_service_url(IMPORT_PATH).to_s
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'addressable/uri'
|
3
4
|
require 'avm/eac_redmine_base0/data_unit'
|
4
5
|
require 'avm/eac_redmine_base0/instances/docker_image'
|
6
|
+
require 'avm/eac_redmine_base0/rest_api'
|
5
7
|
require 'avm/eac_webapp_base0/instance'
|
6
8
|
require 'avm/eac_rails_base1/instance'
|
7
9
|
|
8
10
|
module Avm
|
9
11
|
module EacRedmineBase0
|
10
12
|
class Instance < ::Avm::EacRailsBase1::Instance
|
13
|
+
enable_simple_cache
|
14
|
+
|
11
15
|
FILES_UNITS = { files: 'files' }.freeze
|
12
16
|
|
13
17
|
def docker_image_class
|
@@ -32,6 +36,22 @@ module Avm
|
|
32
36
|
}
|
33
37
|
)
|
34
38
|
end
|
39
|
+
|
40
|
+
# @return [Addressable::URI]
|
41
|
+
def root_url
|
42
|
+
r = ::Addressable::URI.parse(read_entry(::Avm::Instances::EntryKeys::WEB_URL))
|
43
|
+
r.query_values = nil
|
44
|
+
r
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# @return [Avm::EacRedmineBase0::RestApi]
|
50
|
+
def rest_api_uncached
|
51
|
+
url = root_url
|
52
|
+
url.query_values = { key: read_entry('api.key') }
|
53
|
+
::Avm::EacRedmineBase0::RestApi.new(url)
|
54
|
+
end
|
35
55
|
end
|
36
56
|
end
|
37
57
|
end
|
data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template
CHANGED
@@ -18,9 +18,9 @@ export git_repositories_hierarchical_organisation=false
|
|
18
18
|
export smtp_server='%%MAILER.SMTP.ADDRESS%%'
|
19
19
|
export smtp_port='%%MAILER.SMTP.PORT%%'
|
20
20
|
export smtp_domain='%%MAILER.SMTP.DOMAIN%%'
|
21
|
-
export smtp_tls='%%
|
22
|
-
export smtp_enable_starttls_auto='%%
|
23
|
-
export smtp_openssl_verify_mode='%%
|
21
|
+
export smtp_tls='%%MAILER.SMTP.TLS%%'
|
22
|
+
export smtp_enable_starttls_auto='%%MAILER.SMTP.STARTTLS_AUTO%%'
|
23
|
+
export smtp_openssl_verify_mode='%%MAILER.SMTP.OPENSSL_VERIFY_MODE%%'
|
24
24
|
export smtp_authentication='%%MAILER.SMTP.AUTHENTICATION%%'
|
25
25
|
export smtp_username='%%MAILER.SMTP.USERNAME%%'
|
26
26
|
export smtp_password='%%MAILER.SMTP.PASSWORD%%'
|
@@ -7,8 +7,8 @@ module Avm
|
|
7
7
|
class Formatter
|
8
8
|
module Formats
|
9
9
|
class GenericPlain < ::Avm::Files::Formatter::Formats::Base
|
10
|
-
VALID_BASENAMES = %w[*.bat *.css.coffee *.java *.js *.rb *.scss *.sql *.tex
|
11
|
-
*.yaml].freeze
|
10
|
+
VALID_BASENAMES = %w[*.asm *.bat *.css.coffee *.java *.js *.rb *.s *.scss *.sql *.tex
|
11
|
+
*.url *.yml *.yaml].freeze
|
12
12
|
|
13
13
|
VALID_TYPES = %w[plain x-shellscript].freeze
|
14
14
|
|
@@ -23,6 +23,10 @@ module EacCli
|
|
23
23
|
raise ::NameError, "No method \"#{method_name}\" found in #{runner} or in its ancestors"
|
24
24
|
end
|
25
25
|
|
26
|
+
def respond_to_call?((method_name))
|
27
|
+
parent.respond_to?(:runner_context) && parent.runner_context.respond_to_call?(method_name)
|
28
|
+
end
|
29
|
+
|
26
30
|
protected
|
27
31
|
|
28
32
|
def parent_call(method_name, *args)
|
@@ -37,6 +37,16 @@ module EacCli
|
|
37
37
|
def program_name
|
38
38
|
runner_context.if_present(&:program_name) || $PROGRAM_NAME
|
39
39
|
end
|
40
|
+
|
41
|
+
def respond_to_missing?(method, include_all = false)
|
42
|
+
runner_context.respond_to_call?(method) || super
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(method, *args, &block)
|
46
|
+
return super unless runner_context.respond_to_call?(method)
|
47
|
+
|
48
|
+
runner_context.call(method, *args, &block)
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
@@ -3,13 +3,13 @@
|
|
3
3
|
require 'eac_fs/patches'
|
4
4
|
require 'eac_ruby_utils/fs/temp'
|
5
5
|
|
6
|
-
module
|
6
|
+
module EacFs
|
7
7
|
class CachedDownload
|
8
8
|
attr_reader :url, :fs_cache
|
9
9
|
|
10
10
|
def initialize(url, parent_fs_cache = nil)
|
11
11
|
@url = url
|
12
|
-
@fs_cache = (parent_fs_cache || fs_cache).child(url.parameterize)
|
12
|
+
@fs_cache = (parent_fs_cache || fs_cache).child(url.to_s.parameterize)
|
13
13
|
end
|
14
14
|
|
15
15
|
def assert
|
@@ -10,7 +10,12 @@ class Object
|
|
10
10
|
def fs_#{type}
|
11
11
|
oid = fs_object_id_by_type(:'#{type}')
|
12
12
|
oid = [oid.to_s] unless oid.is_a?(::Enumerable)
|
13
|
-
oid.inject(
|
13
|
+
oid.inject(fs_#{type}_parent) { |a, e| a.child(e.to_s) }
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [EacFs::StorageTree]
|
17
|
+
def fs_#{type}_parent
|
18
|
+
self.class.fs_#{type}
|
14
19
|
end
|
15
20
|
CODE
|
16
21
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
|
5
|
+
require 'eac_rest/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'eac_rest'
|
9
|
+
s.version = EacRest::VERSION
|
10
|
+
s.authors = ['Eduardo H. Bogoni']
|
11
|
+
s.summary = 'A REST helper for Ruby.'
|
12
|
+
|
13
|
+
s.files = Dir['{lib}/**/*']
|
14
|
+
|
15
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.70'
|
16
|
+
|
17
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rest/request'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacRest
|
7
|
+
# Abstract methods
|
8
|
+
# * self.issue_get_url_suffix(provider_issue_id)
|
9
|
+
class Api
|
10
|
+
require_sub __FILE__, include_modules: true
|
11
|
+
common_constructor :root_url, :username, :password, default: [nil, nil]
|
12
|
+
|
13
|
+
def request(service_url_suffix, headers = {}, &body_data_proc)
|
14
|
+
r = ::EacRest::Request.new(build_service_url(service_url_suffix),
|
15
|
+
body_data_proc)
|
16
|
+
headers.each { |name, value| r = r.header(name, value) }
|
17
|
+
r = r.autenticate(username, password) if username.present?
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
def request_json(service_url_suffix, headers = {}, &body_data_proc)
|
22
|
+
request(service_url_suffix, headers.merge('Accept' => 'application/json')) do |body_data|
|
23
|
+
r = ::JSON.parse(body_data)
|
24
|
+
r = body_data_proc.call(r) if body_data_proc
|
25
|
+
r
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Addressable::URI]
|
30
|
+
def build_service_url(suffix)
|
31
|
+
s = ::Addressable::URI.parse(suffix)
|
32
|
+
r = ::Addressable::URI.parse(root_url)
|
33
|
+
r.path += s.path
|
34
|
+
r.query_values = r.query_values(::Array).if_present([]) +
|
35
|
+
s.query_values(::Array).if_present([])
|
36
|
+
r
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacRest
|
6
|
+
class Entity
|
7
|
+
enable_simple_cache
|
8
|
+
common_constructor :api, :data
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def from_array_data(api, array_data, *args)
|
12
|
+
array_data.map { |item_data| new(api, item_data, *args) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|