avm-tools 0.114.2 → 0.116.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/tools/runner/git/deploy.rb +1 -1
  3. data/lib/avm/tools/version.rb +1 -1
  4. data/sub/avm/lib/avm/instances/base/auto_values/database.rb +2 -2
  5. data/sub/avm/lib/avm/instances/entry_keys.rb +4 -1
  6. data/sub/avm/lib/avm/self/instance.rb +0 -1
  7. data/sub/avm/lib/avm/sources/base/instance.rb +28 -0
  8. data/sub/avm/lib/avm/version.rb +1 -1
  9. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/file.rb +1 -1
  10. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build.rb +2 -2
  11. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner/build.rb +1 -1
  12. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner.rb +2 -2
  13. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  14. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/assert.rb +77 -0
  15. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +23 -12
  16. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +1 -1
  17. data/sub/avm-eac_rails_base0/avm-eac_rails_base0.gemspec +1 -1
  18. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/deploy.rb +1 -1
  19. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
  20. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
  21. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb +46 -0
  22. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb +17 -0
  23. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb +70 -0
  24. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb +29 -0
  25. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb +57 -0
  26. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  27. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service +12 -0
  28. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +6 -0
  29. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
  30. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  31. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +3 -3
  32. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/instances/base.rb +6 -0
  33. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/version.rb +1 -1
  34. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +1 -1
  35. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instance.rb +7 -0
  36. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  37. data/sub/eac_cli/lib/eac_cli/runner/context.rb +4 -0
  38. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +10 -0
  39. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  40. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  41. data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +6 -1
  42. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  43. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +46 -0
  44. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
  45. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +105 -0
  46. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
  47. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +12 -4
  48. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +11 -0
  49. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
  50. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
  51. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  52. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
  53. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
  54. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
  55. metadata +38 -14
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'avm', '~> 0.1'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.1'
17
17
  s.add_dependency 'avm-eac_postgresql_base0', '~> 0.1'
18
- s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.2.1'
18
+ s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
19
19
  s.add_dependency 'eac_ruby_utils', '~> 0.68'
20
20
 
21
21
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
@@ -5,12 +5,14 @@ require 'avm/eac_postgresql_base0/instance_with'
5
5
  require 'avm/data/instance/files_unit'
6
6
  require 'avm/data/instance/package'
7
7
  require 'avm/eac_webapp_base0/deploy/file_unit'
8
+ require 'avm/eac_ubuntu_base0/instances/base'
8
9
 
9
10
  module Avm
10
11
  module EacWebappBase0
11
12
  class Instance < ::Avm::Instances::Base
12
13
  require_sub __FILE__
13
14
  include ::Avm::EacPostgresqlBase0::InstanceWith
15
+ enable_simple_cache
14
16
 
15
17
  FILES_UNITS = [].freeze
16
18
 
@@ -45,6 +47,11 @@ module Avm
45
47
 
46
48
  private
47
49
 
50
+ # @return [Avm::EacUbuntuBase0::Instances::Base]
51
+ def platform_instance_uncached
52
+ ::Avm::EacUbuntuBase0::Instances::Base.by_id(id)
53
+ end
54
+
48
55
  def files_units
49
56
  self.class.const_get('FILES_UNITS').transform_values do |fs_path_subpath|
50
57
  ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacWebappBase0
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -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
@@ -95,7 +95,7 @@ module EacCli
95
95
  raise(::EacCli::Parser::Error.new(
96
96
  self.class.runner_definition, runner_context.argv,
97
97
  "Subcommand \"#{subcommand_name}\" not found " \
98
- "(Available: #{available_subcommands.keys}"
98
+ "(Available: #{available_subcommands.keys})"
99
99
  ))
100
100
  end
101
101
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.26.2'
4
+ VERSION = '0.27.2'
5
5
  end
@@ -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(self.class.fs_#{type}) { |a, e| a.child(e.to_s) }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacFs
4
- VERSION = '0.11.1'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/compare_by'
4
+
5
+ module EacRubyUtils
6
+ class Bit
7
+ VALID_VALUES = [0, 1].freeze
8
+
9
+ class << self
10
+ def assert(obj)
11
+ return obj if obj.is_a?(self)
12
+
13
+ new(obj.to_i)
14
+ end
15
+
16
+ def valid_integer?(value)
17
+ value.is_a?(::Integer) && VALID_VALUES.include?(value)
18
+ end
19
+
20
+ def validate_integer(value)
21
+ return value if valid_integer?(value)
22
+
23
+ raise(::ArgumentError, "Invalid bit value: #{value} (Valid: #{VALID_VALUES})")
24
+ end
25
+ end
26
+
27
+ attr_reader :value
28
+ compare_by :value
29
+ delegate :to_s, :zero?, to: :value
30
+
31
+ # @param value [Integer]
32
+ def initialize(value)
33
+ @value = self.class.validate_integer(value)
34
+ end
35
+
36
+ # @return [Boolean]
37
+ def one?
38
+ !zero?
39
+ end
40
+
41
+ # @return [Integer]
42
+ def to_i
43
+ value
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/bit'
4
+ require 'eac_ruby_utils/byte'
5
+ require 'eac_ruby_utils/byte_array'
6
+ require 'eac_ruby_utils/patches/module/compare_by'
7
+
8
+ module EacRubyUtils
9
+ class BitArray
10
+ class << self
11
+ def assert(obj)
12
+ return obj if obj.is_a?(self)
13
+ return new(obj) if obj.is_a?(::Enumerable)
14
+
15
+ raise "Could not convert #{obj} to #{self}"
16
+ end
17
+ end
18
+
19
+ delegate :each, :each_with_index, :to_a, :size, :count, :length, :[], :fetch, to: :values_array
20
+ compare_by :values_array
21
+
22
+ def initialize(values = [])
23
+ values.each { |value| push(value) }
24
+ end
25
+
26
+ def <<(value)
27
+ push(value)
28
+ end
29
+
30
+ # @return [EacRubyUtils::BitArray] +self+.
31
+ def push_array(other_bit_array)
32
+ values_array.push(*other_bit_array.to_a)
33
+
34
+ self
35
+ end
36
+
37
+ # @param value [EacRubyUtils::Bit]
38
+ # @return [EacRubyUtils::Bit]
39
+ def push(value)
40
+ values_array.push(::EacRubyUtils::Bit.assert(value))
41
+ end
42
+
43
+ # @return [EacRubyUtils::BitArray]
44
+ def reverse
45
+ self.class.new(values_array.reverse)
46
+ end
47
+
48
+ # @param big_endian [Boolean]
49
+ # @return [EacRubyUtils::ByteArray]
50
+ def to_byte_array(big_endian = false)
51
+ unless count.modulo(::EacRubyUtils::Byte::BIT_COUNT).zero?
52
+ raise 'Bits returned is not multile of 8'
53
+ end
54
+
55
+ byte_bits_enumerator.each_with_object(::EacRubyUtils::ByteArray.new) do |e, a|
56
+ a << ::EacRubyUtils::Byte.from_bit_array(e, big_endian)
57
+ end
58
+ end
59
+
60
+ # @return [Array<Integer>]
61
+ def to_int_array
62
+ values_array.map(&:to_i)
63
+ end
64
+
65
+ private
66
+
67
+ def byte_bits_enumerator
68
+ ::Enumerator.new do |y|
69
+ offset = 0
70
+ while offset < values_array.count
71
+ y.yield(values_array.slice(offset, ::EacRubyUtils::Byte::BIT_COUNT))
72
+ offset += ::EacRubyUtils::Byte::BIT_COUNT
73
+ end
74
+ end
75
+ end
76
+
77
+ def values_array
78
+ @values_array ||= []
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/bit'
4
+ require 'eac_ruby_utils/bit_array'
5
+ require 'eac_ruby_utils/patches/module/compare_by'
6
+
7
+ module EacRubyUtils
8
+ class Byte
9
+ ASSEMBLY_HEXADECIMAL_PREFIX = '$'
10
+ BIT_COUNT = 8
11
+ BIT_INDEX_RANGE = (0..7).freeze
12
+ VALUE_RANGE = (0..255).freeze
13
+
14
+ class << self
15
+ def assert(obj)
16
+ return obj if obj.is_a?(self)
17
+
18
+ new(obj.to_i)
19
+ end
20
+
21
+ def from_bit_array(bit_array, big_endian = false)
22
+ bit_array = ::EacRubyUtils::BitArray.assert(bit_array)
23
+ raise ::ArgumentError, "Wrong bit array size: #{bit_array.size}" if
24
+ bit_array.size != BIT_COUNT
25
+
26
+ bit_array = bit_array.reverse if big_endian
27
+ bit_array.each_with_index.inject(new(0)) do |a, e|
28
+ a.bit_set(e[1], e[0])
29
+ end
30
+ end
31
+
32
+ def valid_bit_index?(value)
33
+ value.is_a?(::Integer) && BIT_INDEX_RANGE.include?(value)
34
+ end
35
+
36
+ def validate_bit_index(value)
37
+ return value if valid_bit_index?(value)
38
+
39
+ raise(::ArgumentError, "Invalid bit index: #{value} (Range: #{BIT_INDEX_RANGE})")
40
+ end
41
+
42
+ def valid_value?(value)
43
+ value.is_a?(::Integer) && VALUE_RANGE.include?(value)
44
+ end
45
+
46
+ def validate_value(value)
47
+ return value if valid_value?(value)
48
+
49
+ raise(::ArgumentError, "Invalid byte value: #{value} (Range: #{VALUE_RANGE})")
50
+ end
51
+ end
52
+
53
+ attr_reader :value
54
+ compare_by :value
55
+
56
+ def initialize(value)
57
+ self.value = value
58
+ end
59
+
60
+ # @param bit_index [Integer]
61
+ # @return [EacRubyUtils::Bit]
62
+ def [](bit_index)
63
+ bit_get(bit_index)
64
+ end
65
+
66
+ # @param bit_index [Integer]
67
+ # @return [EacRubyUtils::Bit]
68
+ def bit_get(bit_index)
69
+ self.class.validate_bit_index(bit_index)
70
+
71
+ ::EacRubyUtils::Bit.new((value & (1 << bit_index)) >> bit_index)
72
+ end
73
+
74
+ def bit_set(bit_index, bit_value)
75
+ self.class.validate_bit_index(bit_index)
76
+ bit = ::EacRubyUtils::Bit.assert(bit_value)
77
+ mask = (1 << bit_index)
78
+ self.class.new(bit.zero? ? value & ~mask : value | mask)
79
+ end
80
+
81
+ # @return [EacRubyUtils::BitArray]
82
+ def to_bit_array(range = BIT_INDEX_RANGE)
83
+ ::EacRubyUtils::BitArray.new(range.map { |bit_index| self[bit_index] })
84
+ end
85
+
86
+ # @return [Integer]
87
+ def to_i
88
+ value
89
+ end
90
+
91
+ # @return [String]
92
+ def to_asm_hex
93
+ ASSEMBLY_HEXADECIMAL_PREFIX + to_hex
94
+ end
95
+
96
+ # @return [String]
97
+ def to_hex
98
+ value.to_s(16).upcase.rjust(2, '0')
99
+ end
100
+
101
+ private
102
+
103
+ attr_writer :value
104
+ end
105
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/byte'
4
+ require 'eac_ruby_utils/patches/module/compare_by'
5
+
6
+ module EacRubyUtils
7
+ class ByteArray
8
+ delegate :to_a, :size, :count, :length, :[], :fetch, :map, to: :values_array
9
+ compare_by :values_array
10
+
11
+ def initialize(values = [])
12
+ values.each { |value| push(value) }
13
+ end
14
+
15
+ def <<(value)
16
+ push(value)
17
+ end
18
+
19
+ # @param value [EacRubyUtils::Byte]
20
+ # @return [EacRubyUtils::Byte]
21
+ def push(value)
22
+ values_array.push(::EacRubyUtils::Byte.assert(value))
23
+ end
24
+
25
+ # @return [Array<Integer>]
26
+ def to_int_array
27
+ values_array.map(&:to_i)
28
+ end
29
+
30
+ private
31
+
32
+ def values_array
33
+ @values_array ||= []
34
+ end
35
+ end
36
+ end
@@ -5,15 +5,23 @@ require 'open3'
5
5
  module EacRubyUtils
6
6
  module Envs
7
7
  class Process
8
+ EXIT_CODE_KEY = :exit_code
9
+ ERR_KEY = :stderr
10
+ OUT_KEY = :stdout
11
+
8
12
  def initialize(command)
9
- @data = { command: command }
10
- @data[:stdout], @data[:stderr], @data[:exit_code] = Open3.capture3(command)
11
- @data[:exit_code] = @data[:exit_code].to_i
13
+ self.data = { command: command }
14
+ data[OUT_KEY], data[ERR_KEY], data[EXIT_CODE_KEY] = Open3.capture3(command)
15
+ data[EXIT_CODE_KEY] = data[EXIT_CODE_KEY].to_i
12
16
  end
13
17
 
14
18
  def to_h
15
- @data.dup
19
+ data.dup
16
20
  end
21
+
22
+ private
23
+
24
+ attr_accessor :data
17
25
  end
18
26
  end
19
27
  end
@@ -11,4 +11,15 @@ class Object
11
11
  "Argument \"#{argument_name}\" is not a #{klass}" \
12
12
  "(Actual class: #{self.class}, actual value: #{self})"
13
13
  end
14
+
15
+ # Raises a ArgumentError if +self.count+ is not equal to +count+.
16
+ #
17
+ # @return +self+
18
+ def assert_count(count, argument_name = 'unknown_argument_name')
19
+ return self if self.count == count
20
+
21
+ raise ::ArgumentError,
22
+ "Argument \"#{argument_name}\" has wrong elements count" \
23
+ "(Actual: #{self.count}, Required: #{count})"
24
+ end
14
25
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/extname'
4
+ require 'pathname'
5
+
6
+ class Pathname
7
+ def basename_noext(limit = 1)
8
+ basename(::EacRubyUtils::Fs.extname(basename.to_path, limit))
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ class Pathname
6
+ # A .glob that raises a ::RuntimeError if +self+ is not a directory.
7
+ # @return [Pathname]
8
+ def reqdir_glob(*args)
9
+ raise ::RuntimeError, "\"#{self}\" is not a directory" unless directory?
10
+
11
+ glob(*args)
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.87.0'
4
+ VERSION = '0.92.1'
5
5
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/bit_array'
4
+
5
+ RSpec.describe ::EacRubyUtils::BitArray do
6
+ describe '#to_byte_array' do
7
+ let(:instance) { described_class.new([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1]) }
8
+
9
+ {
10
+ false => [0xF0, 0xDC],
11
+ true => [0x0F, 0x3B]
12
+ }.each do |big_endian, expected_bytes|
13
+ context "when big-endian is #{big_endian}" do
14
+ let(:expected_value) { ::EacRubyUtils::ByteArray.new(expected_bytes) }
15
+
16
+ it do
17
+ expect(instance.to_byte_array(big_endian)).to eq(expected_value)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/byte'
4
+
5
+ RSpec.describe ::EacRubyUtils::Byte do
6
+ describe '#[]' do
7
+ let(:instance) { described_class.new(0xDC) }
8
+
9
+ [0, 0, 1, 1, 1, 0, 1, 1].each_with_index do |bit_value, bit_index|
10
+ context "when bit index is #{bit_index}" do
11
+ it { expect(instance[bit_index].value).to eq(bit_value) }
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '#bit_set' do
17
+ let(:instance) { described_class.new(0b11011100) }
18
+
19
+ {
20
+ 0 => [0b11011100, 0b11011100, 0b11011000, 0b11010100,
21
+ 0b11001100, 0b11011100, 0b10011100, 0b01011100],
22
+ 1 => [0b11011101, 0b11011110, 0b11011100, 0b11011100,
23
+ 0b11011100, 0b11111100, 0b11011100, 0b11011100]
24
+ }.each do |bit_value, expected_values|
25
+ expected_values.each_with_index do |expected_value, bit_index|
26
+ context "when bit index is #{bit_index} and bit value is #{bit_value}" do
27
+ it do
28
+ expect(instance.bit_set(bit_index, bit_value))
29
+ .to eq(described_class.new(expected_value))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '#from_bit_array' do
37
+ let(:bit_array) { [0, 0, 1, 1, 1, 0, 1, 1] }
38
+
39
+ { false => 0b11011100, true => 0b00111011 }.each do |big_endian, expected_integer|
40
+ context "when big-endian is #{big_endian}" do
41
+ let(:expected_value) { described_class.new(expected_integer) }
42
+
43
+ it do
44
+ expect(described_class.from_bit_array(bit_array, big_endian)).to eq(expected_value)
45
+ end
46
+ end
47
+ end
48
+
49
+ it do
50
+ expect { described_class.from_bit_array([0, 0, 1, 1, 1, 0, 1]) }
51
+ .to raise_error(::ArgumentError)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/pathname/basename_noext'
4
+
5
+ RSpec.describe ::Pathname do
6
+ describe '#basename_noext' do
7
+ {
8
+ 'After.Life.S01E01.WEBRip.x264-ION10.mp4' =>
9
+ %w[After.Life.S01E01.WEBRip.x264-ION10 After.Life.S01E01.WEBRip.x264-ION10.mp4
10
+ After.Life.S01E01.WEBRip.x264-ION10 After.Life.S01E01.WEBRip.x264-ION10],
11
+ 's01e01.en.srt' => %w[s01e01 s01e01.en.srt s01e01.en s01e01 s01e01],
12
+ 's01e01.srt' => %w[s01e01 s01e01.srt s01e01 s01e01 s01e01],
13
+ '/path/to/file.tar.gz' => %w[file file.tar.gz file.tar file file]
14
+ }.each do |source, expected_values|
15
+ expected_values.each_with_index do |expected_value, index|
16
+ limit = index - 1
17
+ context "when source is \"#{source}\" and limit is \"#{limit}\"" do
18
+ let(:instance) { described_class.new(source) }
19
+ let(:expected_path) { described_class.new(expected_value) }
20
+
21
+ it { expect(instance.basename_noext(limit)).to eq(expected_path) }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end