eac_ruby_utils 0.91.0 → 0.93.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67479e6645bae216dae24b09ff55f7cb5b12d803113963a3990c4c9215b47827
4
- data.tar.gz: d9e542d4e1ba6d39623ce2981da1d3a618946ae483a3822829e3bac92a2fb9cd
3
+ metadata.gz: 2af286c28f13082616eff5ed2d26df52273d28f2de6ee6879d86c99388d3c86a
4
+ data.tar.gz: 3ec4cb86d95b8d17210f376c9a688204fb6885d350fc98d1a1e366f4ccf4eeff
5
5
  SHA512:
6
- metadata.gz: 98b6e459e408b63bdf208d9376829e40dac7bac0e062f872b9313440ccec5e0ac35ba11ff339227578c540a6a8463e8ab531d17f77a3ef4bdcd7874352f1a892
7
- data.tar.gz: 7da0fb8b6fba05183cdb977ab15fd0e8c93c7d3b3b491e0bcb67e66fdd904def1cabf796de0a64a65526f0a0e427bc21455a9d486ada5e711325f43fe45d6a21
6
+ metadata.gz: 3d09e2962b6b68dc8153a75ed47c70b4f5811be9390f2e0d5fa713c26baf07174bdb65429d84e12a67514602a336b39768d9116343af492a9b42f2c2aba5de49
7
+ data.tar.gz: 83a32768b402403f973dafd9dbe55f1711a6b9857dabbe1fd2cb89e93240baf914391e9c3bb82b204003cda07b88a8f8b1038a021ad8834f00492cff7fa0d88d
@@ -27,8 +27,11 @@ module EacRubyUtils
27
27
  push(value)
28
28
  end
29
29
 
30
+ # @return [EacRubyUtils::BitArray] +self+.
30
31
  def push_array(other_bit_array)
31
- @values_array += other_bit_array.values_array
32
+ values_array.push(*other_bit_array.to_a)
33
+
34
+ self
32
35
  end
33
36
 
34
37
  # @param value [EacRubyUtils::Bit]
@@ -6,6 +6,7 @@ require 'eac_ruby_utils/patches/module/compare_by'
6
6
 
7
7
  module EacRubyUtils
8
8
  class Byte
9
+ ASSEMBLY_HEXADECIMAL_PREFIX = '$'
9
10
  BIT_COUNT = 8
10
11
  BIT_INDEX_RANGE = (0..7).freeze
11
12
  VALUE_RANGE = (0..255).freeze
@@ -77,8 +78,9 @@ module EacRubyUtils
77
78
  self.class.new(bit.zero? ? value & ~mask : value | mask)
78
79
  end
79
80
 
80
- def to_bit_array
81
- BIT_INDEX_RANGE.map { |bit_index| self[bit_index] }
81
+ # @return [EacRubyUtils::BitArray]
82
+ def to_bit_array(range = BIT_INDEX_RANGE)
83
+ ::EacRubyUtils::BitArray.new(range.map { |bit_index| self[bit_index] })
82
84
  end
83
85
 
84
86
  # @return [Integer]
@@ -86,6 +88,16 @@ module EacRubyUtils
86
88
  value
87
89
  end
88
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
+
89
101
  private
90
102
 
91
103
  attr_writer :value
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/patches/module/compare_by'
5
5
 
6
6
  module EacRubyUtils
7
7
  class ByteArray
8
- delegate :to_a, :size, :count, :length, :[], :fetch, to: :values_array
8
+ delegate :to_a, :size, :count, :length, :[], :fetch, :map, to: :values_array
9
9
  compare_by :values_array
10
10
 
11
11
  def initialize(values = [])
@@ -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
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Object
4
+ def pretty_debug
5
+ STDERR.write(pretty_inspect)
6
+
7
+ self
8
+ end
9
+
4
10
  def print_debug
5
11
  STDERR.write(to_debug + "\n")
6
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.91.0'
4
+ VERSION = '0.93.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.91.0
4
+ version: 0.93.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport