ehbrs-tools 0.16.2 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +25 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/track.rb +1 -19
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +8 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
- data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +28 -4
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -1
- data/vendor/eac_docker/lib/eac_docker/container.rb +24 -0
- data/vendor/eac_docker/lib/eac_docker/images/coded.rb +39 -0
- data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +26 -0
- data/vendor/eac_docker/lib/eac_docker/registry.rb +17 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec.rb +12 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +1 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +17 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +1 -0
- data/vendor/eac_ruby_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +41 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +6 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +38 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +40 -17
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +96 -8
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
- metadata +101 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Envs
|
5
|
+
class Command
|
6
|
+
module Envvars
|
7
|
+
def envvar(name, value)
|
8
|
+
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def append_envvars(command)
|
14
|
+
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
15
|
+
e.present? ? "#{e} #{command}" : command
|
16
|
+
end
|
17
|
+
|
18
|
+
def envvars
|
19
|
+
extra_options[:envvars] ||= {}.with_indifferent_access
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -12,39 +12,18 @@ module EacRubyUtils
|
|
12
12
|
duplicate_by_extra_options(chdir: dir)
|
13
13
|
end
|
14
14
|
|
15
|
-
def envvar(name, value)
|
16
|
-
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
17
|
-
end
|
18
|
-
|
19
15
|
def status_result(status_code, result)
|
20
16
|
duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
|
21
17
|
end
|
22
18
|
|
23
|
-
def pipe(other_command)
|
24
|
-
duplicate_by_extra_options(pipe: other_command)
|
25
|
-
end
|
26
|
-
|
27
19
|
private
|
28
20
|
|
29
21
|
attr_reader :extra_options
|
30
22
|
|
31
|
-
def envvars
|
32
|
-
extra_options[:envvars] ||= {}.with_indifferent_access
|
33
|
-
end
|
34
|
-
|
35
23
|
def status_results
|
36
24
|
extra_options[:status_results] ||= {}.with_indifferent_access
|
37
25
|
end
|
38
26
|
|
39
|
-
def append_envvars(command)
|
40
|
-
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
41
|
-
e.present? ? "#{e} #{command}" : command
|
42
|
-
end
|
43
|
-
|
44
|
-
def append_pipe(command)
|
45
|
-
extra_options[:pipe].present? ? "#{command} | #{extra_options[:pipe].command}" : command
|
46
|
-
end
|
47
|
-
|
48
27
|
def append_chdir(command)
|
49
28
|
extra_options[:chdir].present? ? "(cd '#{extra_options[:chdir]}' ; #{command} )" : command
|
50
29
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/inflector'
|
4
|
+
|
3
5
|
module EacRubyUtils
|
4
6
|
class Inflector
|
5
7
|
class << self
|
6
8
|
VARIABLE_NAME_PATTERN = /[_a-z][_a-z0-9]*/i.freeze
|
7
9
|
|
8
10
|
def variableize(string)
|
9
|
-
r = string.gsub(/[^_a-z0-9]/i, '_')
|
11
|
+
r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_')
|
12
|
+
.gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase
|
10
13
|
m = VARIABLE_NAME_PATTERN.match(r)
|
11
14
|
return r if m
|
12
15
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'active_support/values/time_zone'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module LocalTimeZone
|
8
|
+
DEBIAN_CONFIG_PATH = '/etc/timezone'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
|
12
|
+
|
13
|
+
def auto
|
14
|
+
%w[tz_env debian_config offset].lazy.map { |s| send("by_#{s}") }.find(&:present?)
|
15
|
+
end
|
16
|
+
|
17
|
+
def by_debian_config
|
18
|
+
path = ::Pathname.new(DEBIAN_CONFIG_PATH)
|
19
|
+
path.exist? ? path.read.strip.presence : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def by_offset
|
23
|
+
::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
|
24
|
+
end
|
25
|
+
|
26
|
+
def by_timedatectl
|
27
|
+
executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
|
28
|
+
return nil unless executable.exist?
|
29
|
+
|
30
|
+
TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def by_tz_env
|
34
|
+
ENV['TZ'].presence
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'eac_ruby_utils/templates/searcher'
|
5
|
+
|
6
|
+
class Module
|
7
|
+
def template
|
8
|
+
@template ||= ::EacRubyUtils::Templates::Searcher.default.template(name.underscore)
|
9
|
+
end
|
10
|
+
end
|
@@ -1,15 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/templates/searcher'
|
3
|
+
require 'eac_ruby_utils/patches/module/template'
|
5
4
|
|
6
5
|
class Object
|
7
|
-
class << self
|
8
|
-
def template
|
9
|
-
@template ||= ::EacRubyUtils::Templates::Searcher.default.template(name.underscore)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
6
|
def template
|
14
7
|
self.class.template
|
15
8
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'active_support/core_ext/time/zones'
|
4
|
+
require 'eac_ruby_utils/local_time_zone'
|
4
5
|
|
5
|
-
::Time.zone = ::
|
6
|
+
::Time.zone = ::EacRubyUtils::LocalTimeZone.auto
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'active_support/core_ext/module/delegation'
|
4
5
|
require 'active_support/core_ext/object/blank'
|
5
6
|
|
6
7
|
module EacRubyUtils
|
7
8
|
class Struct
|
8
9
|
def initialize(initial_data = {})
|
9
|
-
self.data =
|
10
|
+
self.data = initial_data.symbolize_keys
|
10
11
|
end
|
11
12
|
|
12
13
|
def [](key)
|
@@ -19,6 +20,11 @@ module EacRubyUtils
|
|
19
20
|
bool ? fetch(key).present? : data.fetch(key)
|
20
21
|
end
|
21
22
|
|
23
|
+
def merge(other)
|
24
|
+
other = self.class.new(other) unless other.is_a?(self.class)
|
25
|
+
self.class.new(to_h.merge(other.to_h))
|
26
|
+
end
|
27
|
+
|
22
28
|
def method_missing(method_name, *arguments, &block)
|
23
29
|
property_method?(method_name) ? fetch(method_name) : super
|
24
30
|
end
|
@@ -14,10 +14,18 @@ module EacRubyUtils
|
|
14
14
|
::YAML.dump(sanitize(object))
|
15
15
|
end
|
16
16
|
|
17
|
+
def dump_file(path, object)
|
18
|
+
::File.write(path.to_s, dump(object))
|
19
|
+
end
|
20
|
+
|
17
21
|
def load(string)
|
18
22
|
::YAML.safe_load(string, permitted_classes)
|
19
23
|
end
|
20
24
|
|
25
|
+
def load_file(path)
|
26
|
+
load(::File.read(path.to_s))
|
27
|
+
end
|
28
|
+
|
21
29
|
def permitted_classes
|
22
30
|
DEFAULT_PERMITTED_CLASSES
|
23
31
|
end
|
@@ -9,34 +9,57 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
let(:stub_module) do
|
13
|
+
::Module.new do
|
14
|
+
module ClassMethods # rubocop:disable RSpec/LeakyConstantDeclaration
|
15
|
+
def my_class_method
|
16
|
+
'class'
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
module InstanceMethods # rubocop:disable RSpec/LeakyConstantDeclaration
|
21
|
+
def my_instance_method
|
22
|
+
'from_module'
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
let(:stub_class) do
|
29
|
+
::Class.new do
|
30
|
+
class << self
|
31
|
+
attr_accessor :valor
|
32
|
+
end
|
33
|
+
|
34
|
+
def my_instance_method
|
35
|
+
'from_class'
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
|
-
let(:
|
40
|
+
let(:stub_class_instance) { stub_class.new }
|
33
41
|
|
34
42
|
before do
|
35
|
-
instance.setup(
|
36
|
-
MyClass.include MyModule
|
43
|
+
instance.setup(stub_module)
|
37
44
|
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
context 'when included' do
|
47
|
+
before do
|
48
|
+
stub_class.include stub_module
|
49
|
+
end
|
50
|
+
|
51
|
+
it { expect(stub_class_instance.my_instance_method).to eq('from_class') }
|
52
|
+
it { expect(stub_class_instance.class.my_class_method).to eq('class') }
|
53
|
+
it { expect(stub_class_instance.class.valor).to eq('changed') }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when prepended' do
|
57
|
+
before do
|
58
|
+
stub_class.prepend stub_module
|
59
|
+
end
|
60
|
+
|
61
|
+
it { expect(stub_class_instance.my_instance_method).to eq('from_module') }
|
62
|
+
it { expect(stub_class_instance.class.my_class_method).to eq('class') }
|
63
|
+
it { expect(stub_class_instance.class.valor).to eq('changed') }
|
64
|
+
end
|
42
65
|
end
|
@@ -3,34 +3,122 @@
|
|
3
3
|
require 'eac_ruby_utils/common_constructor'
|
4
4
|
|
5
5
|
RSpec.describe ::EacRubyUtils::CommonConstructor do
|
6
|
-
ARG_LIST = %i[a b c d].freeze
|
6
|
+
ARG_LIST = %i[a b c d].freeze # rubocop:disable RSpec/LeakyConstantDeclaration
|
7
|
+
|
7
8
|
let(:instance) do
|
8
9
|
described_class.new(*ARG_LIST, default: %w[Vcc Vd]) do
|
9
10
|
@z = 'Vz'
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
let(:a_class) do
|
15
|
+
::Class.new do
|
16
|
+
attr_reader :z
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
|
-
let(:
|
20
|
+
let(:a_class_instance) { a_class.new('Va', 'Vb', 'Vc') }
|
18
21
|
|
19
22
|
before do
|
20
|
-
instance.setup_class(
|
23
|
+
instance.setup_class(a_class)
|
21
24
|
end
|
22
25
|
|
23
|
-
it { expect(
|
26
|
+
it { expect(a_class_instance.z).to eq('Vz') }
|
24
27
|
|
25
28
|
ARG_LIST.each do |attr|
|
26
29
|
expected_value = "V#{attr}"
|
27
30
|
it "attribute \"#{attr}\" equal to \"#{expected_value}\"" do
|
28
|
-
expect(
|
31
|
+
expect(a_class_instance.send(attr)).to eq(expected_value)
|
29
32
|
end
|
30
33
|
|
31
34
|
[false, true].each do |include_all|
|
32
35
|
it "respond_to?('#{attr}', #{include_all}) == #{include_all}" do
|
33
|
-
expect(
|
36
|
+
expect(a_class_instance.respond_to?("#{attr}=", include_all)).to eq(include_all)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with super class' do
|
42
|
+
let(:super_class) do
|
43
|
+
::Class.new do
|
44
|
+
attr_reader :super_a, :super_b
|
45
|
+
|
46
|
+
def initialize(a, b) # rubocop:disable Naming/MethodParameterName
|
47
|
+
@super_a = a
|
48
|
+
@super_b = b
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
let(:sub_class) do
|
54
|
+
sub_constructor.setup_class(::Class.new(super_class))
|
55
|
+
end
|
56
|
+
|
57
|
+
let(:sub_object) { sub_class.new(1, 2, 3, 4) }
|
58
|
+
|
59
|
+
context 'with super_args parameter' do
|
60
|
+
let(:sub_constructor) do
|
61
|
+
described_class.new(:c, :a, :b, :d, super_args: -> { [c, a] })
|
62
|
+
end
|
63
|
+
|
64
|
+
it { expect(sub_object.a).to eq(2) }
|
65
|
+
it { expect(sub_object.b).to eq(3) }
|
66
|
+
it { expect(sub_object.c).to eq(1) }
|
67
|
+
it { expect(sub_object.d).to eq(4) }
|
68
|
+
it { expect(sub_object.super_a).to eq(1) }
|
69
|
+
it { expect(sub_object.super_b).to eq(2) }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'without super_args parameter' do
|
73
|
+
let(:sub_constructor) do
|
74
|
+
described_class.new(:c, :a, :b, :d)
|
75
|
+
end
|
76
|
+
|
77
|
+
it { expect(sub_object.a).to eq(2) }
|
78
|
+
it { expect(sub_object.b).to eq(3) }
|
79
|
+
it { expect(sub_object.c).to eq(1) }
|
80
|
+
it { expect(sub_object.d).to eq(4) }
|
81
|
+
it { expect(sub_object.super_a).to eq(2) }
|
82
|
+
it { expect(sub_object.super_b).to eq(3) }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with undefined super arguments' do
|
86
|
+
let(:sub_constructor) do
|
87
|
+
described_class.new(:x, :y, :w, :a)
|
88
|
+
end
|
89
|
+
|
90
|
+
it do
|
91
|
+
expect { sub_object }.to raise_error(::ArgumentError)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'with class hierarchy mixed with and without common_constructor' do
|
97
|
+
let(:klass_0) do
|
98
|
+
described_class.new(:a_param).setup_class(::Class.new)
|
99
|
+
end
|
100
|
+
|
101
|
+
let(:klass_1) do
|
102
|
+
::Class.new(klass_0) do
|
103
|
+
def initialize(a_param)
|
104
|
+
super(a_param)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
let(:klass_2) do
|
110
|
+
::Class.new(klass_1)
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:klass_3) do
|
114
|
+
described_class.new(:a_param).setup_class(::Class.new(klass_2))
|
115
|
+
end
|
116
|
+
|
117
|
+
4.times.each do |i|
|
118
|
+
context "wit #{i}-th class" do
|
119
|
+
let(:class_instance) { send("klass_#{i}").new(:a) }
|
120
|
+
|
121
|
+
it { expect(class_instance.a_param).to eq(:a) }
|
34
122
|
end
|
35
123
|
end
|
36
124
|
end
|