codin_rep 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/lib/codin_rep.rb +86 -0
  3. data/lib/codin_rep/add_employee.rb +47 -0
  4. data/lib/codin_rep/command.rb +113 -0
  5. data/lib/codin_rep/communication.rb +124 -0
  6. data/lib/codin_rep/del_employee.rb +38 -0
  7. data/lib/codin_rep/employee_command.rb +93 -0
  8. data/lib/codin_rep/get_afd_header.rb +53 -0
  9. data/lib/codin_rep/get_records.rb +156 -0
  10. data/lib/codin_rep/get_time.rb +57 -0
  11. data/lib/codin_rep/set_time.rb +61 -0
  12. data/lib/codin_rep/time_util.rb +51 -0
  13. data/lib/codin_rep/version.rb +23 -0
  14. data/test/coverage/assets/0.10.0/application.css +799 -0
  15. data/test/coverage/assets/0.10.0/application.js +1707 -0
  16. data/test/coverage/assets/0.10.0/colorbox/border.png +0 -0
  17. data/test/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  18. data/test/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  19. data/test/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  20. data/test/coverage/assets/0.10.0/favicon_green.png +0 -0
  21. data/test/coverage/assets/0.10.0/favicon_red.png +0 -0
  22. data/test/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  23. data/test/coverage/assets/0.10.0/loading.gif +0 -0
  24. data/test/coverage/assets/0.10.0/magnify.png +0 -0
  25. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  26. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  27. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  28. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  29. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  30. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  31. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  32. data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  33. data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  34. data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  35. data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  36. data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  37. data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  38. data/test/coverage/index.html +6162 -0
  39. data/test/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +19 -0
  40. data/test/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +15 -0
  41. data/test/coverage/rcov/assets/0.2.3/print.css +12 -0
  42. data/test/coverage/rcov/assets/0.2.3/rcov.js +42 -0
  43. data/test/coverage/rcov/assets/0.2.3/screen.css +270 -0
  44. data/test/coverage/rcov/index.html +280 -0
  45. data/test/coverage/rcov/lib-codin_rep-add_employee_rb.html +200 -0
  46. data/test/coverage/rcov/lib-codin_rep-command_rb.html +398 -0
  47. data/test/coverage/rcov/lib-codin_rep-communication_rb.html +431 -0
  48. data/test/coverage/rcov/lib-codin_rep-del_employee_rb.html +173 -0
  49. data/test/coverage/rcov/lib-codin_rep-employee_command_rb.html +338 -0
  50. data/test/coverage/rcov/lib-codin_rep-get_afd_header_rb.html +218 -0
  51. data/test/coverage/rcov/lib-codin_rep-get_identification_rb.html +212 -0
  52. data/test/coverage/rcov/lib-codin_rep-get_records_rb.html +527 -0
  53. data/test/coverage/rcov/lib-codin_rep-get_time_rb.html +230 -0
  54. data/test/coverage/rcov/lib-codin_rep-set_employee_rb.html +248 -0
  55. data/test/coverage/rcov/lib-codin_rep-set_time_rb.html +242 -0
  56. data/test/coverage/rcov/lib-codin_rep-time_util_rb.html +212 -0
  57. data/test/coverage/rcov/lib-codin_rep-version_rb.html +128 -0
  58. data/test/coverage/rcov/lib-codin_rep_rb.html +317 -0
  59. data/test/mock_time_clock.rb +184 -0
  60. data/test/reports/TEST-GetTimeTest.xml +5 -0
  61. data/test/test_helper.rb +25 -0
  62. data/test/unit/add_employee_test.rb +43 -0
  63. data/test/unit/del_employee_test.rb +44 -0
  64. data/test/unit/get_employer_test.rb +48 -0
  65. data/test/unit/get_records_test.rb +45 -0
  66. data/test/unit/get_serial_number_test.rb +42 -0
  67. data/test/unit/get_time_test.rb +40 -0
  68. data/test/unit/set_time_test.rb +42 -0
  69. metadata +165 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e40b5d66a9adcd57d0cd46e384142079590cfb38
4
+ data.tar.gz: 9e87fa8364e105e6c8487796127c4a8a135badcd
5
+ SHA512:
6
+ metadata.gz: f34acf2a831190d23c59c4e61761987c9f60dff714c0736f3828c52aebe628a118d47bb17f276041f4b73bfa32fb204e0d41355216d1f366e0ee1daf8c529630
7
+ data.tar.gz: fb37f568f897ee7bf934db130c8727563bcac1990b54aeb7f3cb7131f407add9cdb3d8065b9c14e853d056378b6f065c7bd6d0444170eb1b126d8514606e2847
data/lib/codin_rep.rb ADDED
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codinrep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require "codin_rep/add_employee"
22
+ require "codin_rep/employee_command"
23
+ require "codin_rep/get_time"
24
+ require "codin_rep/set_time"
25
+ require "codin_rep/get_records"
26
+ require "codin_rep/del_employee"
27
+
28
+ module CodinRep
29
+ class << self
30
+ def included(base)
31
+ return if base.included_modules.include?(InstanceMethods)
32
+ base.send(:include, InstanceMethods)
33
+ end
34
+ end
35
+
36
+ module InstanceMethods
37
+ def get_time
38
+ command = CodinRep::GetTime.new(self.ip, self.tcp_port)
39
+ response = command.execute
40
+ return response
41
+ end
42
+
43
+ def set_time(time)
44
+ command = CodinRep::SetTime.new(time, self.ip, self.tcp_port)
45
+ response = command.execute
46
+ return response
47
+ end
48
+
49
+ def get_employer
50
+ command = CodinRep::GetAfdHeader.new(self.ip, self.tcp_port)
51
+ response = command.execute
52
+
53
+ hash = {}
54
+ hash[:document_type] = response.employer_type
55
+ hash[:document_number] = response.employer_document
56
+ hash[:cei_document] = response.employer_cei
57
+ hash[:company_name] = response.employer_name
58
+
59
+ return hash
60
+ end
61
+
62
+ def get_serial_number
63
+ command = CodinRep::GetAfdHeader.new(self.ip, self.tcp_port)
64
+ response = command.execute
65
+ response.rep_serial_number
66
+ end
67
+
68
+ def get_records(first_id=nil)
69
+ command = CodinRep::GetRecords.new(first_id, self.ip, self.tcp_port)
70
+ response = command.execute
71
+ response
72
+ end
73
+
74
+ def set_employee(operation_type, registration, pis_number, name)
75
+ if [:add, :edit].include? operation_type
76
+ command = CodinRep::AddEmployee.new(registration, pis_number, name, self.ip, self.tcp_port)
77
+ elsif operation_type == :remove
78
+ command = CodinRep::DelEmployee.new(registration, self.ip, self.tcp_port)
79
+ else
80
+ raise EmployeeCommand::UnknownEmployeeOperation.new(operation_type)
81
+ end
82
+ response = command.execute
83
+ response
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codin_rep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require "codin_rep/employee_command"
22
+
23
+ module CodinRep
24
+ class AddEmployee < EmployeeCommand
25
+ NAME_MAX_SIZE = 53
26
+ COMMAND_CODE = "075h1".freeze
27
+ EXPECTED_HEADER = "REP003h1\0".freeze
28
+ REGISTRATION_COMPLETED_HEADER = 'PGREP010h1'.freeze
29
+
30
+ def initialize(registration, pis_number, name, *args)
31
+ super(*args)
32
+ @registration = convert_integer_to_byte_string(registration)
33
+ @pis_number = convert_integer_to_byte_string(pis_number)
34
+ @name = convert_employee_name(name)
35
+ end
36
+
37
+ def generate_command_payload
38
+ "#{@registration}#{@pis_number}#{@name}"
39
+ end
40
+
41
+ private
42
+ def convert_employee_name(name)
43
+ name = name.strip[0..(NAME_MAX_SIZE-1)].strip + "\0"
44
+ name.ljust(NAME_MAX_SIZE, "\x20")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,113 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codin_rep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require 'codin_rep/communication'
22
+
23
+ module CodinRep
24
+ class Command
25
+ class UnknownHeader < StandardError
26
+ def initialize(header, command_executed, expected_header=nil)
27
+ @header = header
28
+ @command_executed = command_executed
29
+ @expected_header = expected_header
30
+ end
31
+
32
+ def message
33
+ message = "The REP returned an unknown header '#{@header}' for the command '#{@command_executed}'."
34
+ message += " Expected header was '#{@expected_header}'." if @expected_header
35
+ end
36
+ end
37
+
38
+ class MalformedResponsePayload < StandardError
39
+ def initialize(command_executed)
40
+ @command_executed = command_executed
41
+ end
42
+
43
+ def message
44
+ "Payload response from '#{@command_executed}' command is malformed."
45
+ end
46
+ end
47
+
48
+ COMMAND_PREFIX = "PGREP".freeze
49
+
50
+ def initialize(host_address, tcp_port)
51
+ @host_address = host_address
52
+ @tcp_port = tcp_port
53
+ @communication = Communication.new(@host_address, @tcp_port, get_timeout_time, get_max_attempts)
54
+ end
55
+
56
+ def execute
57
+ @command_data = generate_header
58
+ @command_data += generate_command_payload
59
+ @response = communicate!
60
+ check_response_header
61
+ @payload = get_response_payload
62
+ return get_data_from_response_payload
63
+ rescue
64
+ @communication.close
65
+ raise
66
+ ensure
67
+ @communication.close if should_close_connection?
68
+ end
69
+
70
+ def get_timeout_time
71
+ 3
72
+ end
73
+
74
+ def get_max_attempts
75
+ 3
76
+ end
77
+
78
+ def generate_header
79
+ # COMMAND_CODE should be set on the specific command class:
80
+ COMMAND_PREFIX.dup + self.class::COMMAND_CODE.dup
81
+ end
82
+
83
+ def generate_command_payload
84
+ raise_not_implemented_error
85
+ end
86
+
87
+ def check_response_header
88
+ raise_not_implemented_error
89
+ end
90
+
91
+ def get_data_from_response_payload
92
+ raise_not_implemented_error
93
+ end
94
+
95
+ def get_expected_response_size
96
+ raise_not_implemented_error
97
+ end
98
+
99
+ def should_close_connection?
100
+ !!@response
101
+ end
102
+
103
+ private
104
+ def raise_not_implemented_error
105
+ calling_method = caller[0][/`.*'/][1..-2]
106
+ raise NotImplementedError.new "The method '#{calling_method}' must be overriden by the class #{self.class.to_s}."
107
+ end
108
+
109
+ def communicate!
110
+ @communication.communicate(@command_data, get_expected_response_size)
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,124 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codin_rep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require 'socket'
22
+ require 'timeout'
23
+
24
+ module CodinRep
25
+ class Communication
26
+ READ_SIZE = 4096
27
+
28
+ include Timeout
29
+
30
+ def self.finalize(socket)
31
+ proc { socket.close }
32
+ end
33
+
34
+ def initialize(host_address, port, timeout_time=60, max_attempts=3)
35
+ @host_address = host_address
36
+ @port = port
37
+ @timeout_time = timeout_time
38
+ @max_attempts = max_attempts
39
+ @socket = nil
40
+ end
41
+
42
+ def open_socket
43
+ if @socket
44
+ @socket.close
45
+ @socket = nil
46
+ end
47
+
48
+ @attempt = 0
49
+ while @attempt < @max_attempts do
50
+ begin
51
+ timeout(@timeout_time) {
52
+ @socket = TCPSocket.open(@host_address, @port)
53
+ }
54
+ # Use a finalizer to close the socket if "self" is going to be
55
+ # destroyed.
56
+ ObjectSpace.define_finalizer( self, self.class.finalize(@socket) )
57
+ rescue Timeout::Error
58
+ @socket = nil
59
+ end
60
+ break if @socket
61
+
62
+ @attempt += 1
63
+ end
64
+
65
+ raise "Timeout error" if @attempt >= @max_attempts
66
+ @socket
67
+ end
68
+
69
+ def communicate(payload, expected_response_size)
70
+ open_socket if @socket.nil?
71
+
72
+ @payload = payload
73
+ @expected_response_size = expected_response_size
74
+
75
+ while @attempt < @max_attempts do
76
+ @received_data = nil
77
+
78
+ @received_data = send_receive_data(@payload)
79
+
80
+ break unless @received_data.nil?
81
+ @attempt += 1
82
+ end
83
+
84
+ raise "Timeout error" if @attempt >= @max_attempts
85
+ @received_data
86
+ end
87
+
88
+ def close
89
+ if @socket
90
+ @socket.close
91
+ @socket = nil
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ def send_receive_data(data_to_send)
98
+ @socket.write(data_to_send)
99
+ @socket.flush
100
+ data_to_receive = ""
101
+
102
+ # expected_response_size can be a Fixnum, for fixed responses sizes, or
103
+ # a proc, where the response size comes inside the response itself.
104
+ if @expected_response_size.is_a?(Proc)
105
+ expected_size = @expected_response_size.call(data_to_receive)
106
+ else
107
+ expected_size = @expected_response_size
108
+ end
109
+
110
+ while data_to_receive.size < expected_size
111
+ bytes_to_be_read = expected_size - data_to_receive.size
112
+ bytes_to_be_read = READ_SIZE if bytes_to_be_read > READ_SIZE
113
+
114
+ timeout(@timeout_time) {
115
+ data_to_receive += @socket.readpartial( bytes_to_be_read )
116
+ }
117
+ if @expected_response_size.is_a?(Proc)
118
+ expected_size = @expected_response_size.call(data_to_receive)
119
+ end
120
+ end
121
+ data_to_receive
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codin_rep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require "codin_rep/employee_command"
22
+
23
+ module CodinRep
24
+ class DelEmployee < EmployeeCommand
25
+ COMMAND_CODE = "016j1".freeze
26
+ EXPECTED_HEADER = "REP003j1\0".freeze
27
+ REGISTRATION_COMPLETED_HEADER = 'PGREP010j1'.freeze
28
+
29
+ def initialize(registration, *args)
30
+ super(*args)
31
+ @registration = convert_integer_to_byte_string(registration)
32
+ end
33
+
34
+ def generate_command_payload
35
+ @registration
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*-
2
+ # codin_rep - Gem para acesso de REPs da Telebyte
3
+ # Copyright (C) 2016 O.S. Systems Softwares Ltda.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
19
+ # e-mail: contato@ossystems.com.br
20
+
21
+ require "codin_rep/command"
22
+
23
+ module CodinRep
24
+ class EmployeeCommand < Command
25
+ CODE_MAX_SIZE = 12
26
+
27
+ class UnknownEmployeeOperation < StandardError
28
+ def initialize(operation_type)
29
+ @operation_type = operation_type
30
+ end
31
+
32
+ def message
33
+ message = "Unknown employee operation type '#{@operation_type}'."
34
+ end
35
+ end
36
+
37
+ class InvalidInteger < StandardError
38
+ def initialize(invalid_integer)
39
+ @invalid_integer = invalid_integer
40
+ end
41
+
42
+ def message
43
+ message = "Invalid integer for employee operation '#{@invalid_integer}'. Integer must be only numbers and at most #{CodinRep::EmployeeCommand::CODE_MAX_SIZE} digits."
44
+ end
45
+ end
46
+
47
+ def initialize(*args)
48
+ super(*args)
49
+ @sent_registration = false
50
+ end
51
+
52
+ def execute
53
+ @command_data = generate_header
54
+ @command_data += generate_command_payload
55
+ @response = communicate!
56
+ check_response_header
57
+ @sent_registration = true
58
+ @command_data = self.class::REGISTRATION_COMPLETED_HEADER
59
+ @response = communicate!
60
+ return get_data_from_response_payload
61
+ rescue
62
+ @communication.close
63
+ raise
64
+ ensure
65
+ @communication.close if should_close_connection?
66
+ end
67
+
68
+ def get_expected_response_size
69
+ @sent_registration ? 0 : 9
70
+ end
71
+
72
+ def check_response_header
73
+ unless @response.match(/^#{self.class::EXPECTED_HEADER}/)
74
+ raise UnknownHeader.new @response[0..6], 'get time', self.class::EXPECTED_HEADER
75
+ end
76
+ end
77
+
78
+ def get_response_payload
79
+ @sent_employee_data = true
80
+ end
81
+
82
+ def get_data_from_response_payload
83
+ true
84
+ end
85
+
86
+ private
87
+ def convert_integer_to_byte_string(original_integer)
88
+ integer = original_integer.to_s
89
+ raise InvalidInteger.new(original_integer) if integer.size > CODE_MAX_SIZE
90
+ [integer.to_s.rjust(CODE_MAX_SIZE, '0')].pack('H*')
91
+ end
92
+ end
93
+ end