codin_rep 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/codin_rep.rb +86 -0
- data/lib/codin_rep/add_employee.rb +47 -0
- data/lib/codin_rep/command.rb +113 -0
- data/lib/codin_rep/communication.rb +124 -0
- data/lib/codin_rep/del_employee.rb +38 -0
- data/lib/codin_rep/employee_command.rb +93 -0
- data/lib/codin_rep/get_afd_header.rb +53 -0
- data/lib/codin_rep/get_records.rb +156 -0
- data/lib/codin_rep/get_time.rb +57 -0
- data/lib/codin_rep/set_time.rb +61 -0
- data/lib/codin_rep/time_util.rb +51 -0
- data/lib/codin_rep/version.rb +23 -0
- data/test/coverage/assets/0.10.0/application.css +799 -0
- data/test/coverage/assets/0.10.0/application.js +1707 -0
- data/test/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/test/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/test/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/test/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/test/coverage/assets/0.10.0/loading.gif +0 -0
- data/test/coverage/assets/0.10.0/magnify.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/coverage/index.html +6162 -0
- data/test/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +19 -0
- data/test/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +15 -0
- data/test/coverage/rcov/assets/0.2.3/print.css +12 -0
- data/test/coverage/rcov/assets/0.2.3/rcov.js +42 -0
- data/test/coverage/rcov/assets/0.2.3/screen.css +270 -0
- data/test/coverage/rcov/index.html +280 -0
- data/test/coverage/rcov/lib-codin_rep-add_employee_rb.html +200 -0
- data/test/coverage/rcov/lib-codin_rep-command_rb.html +398 -0
- data/test/coverage/rcov/lib-codin_rep-communication_rb.html +431 -0
- data/test/coverage/rcov/lib-codin_rep-del_employee_rb.html +173 -0
- data/test/coverage/rcov/lib-codin_rep-employee_command_rb.html +338 -0
- data/test/coverage/rcov/lib-codin_rep-get_afd_header_rb.html +218 -0
- data/test/coverage/rcov/lib-codin_rep-get_identification_rb.html +212 -0
- data/test/coverage/rcov/lib-codin_rep-get_records_rb.html +527 -0
- data/test/coverage/rcov/lib-codin_rep-get_time_rb.html +230 -0
- data/test/coverage/rcov/lib-codin_rep-set_employee_rb.html +248 -0
- data/test/coverage/rcov/lib-codin_rep-set_time_rb.html +242 -0
- data/test/coverage/rcov/lib-codin_rep-time_util_rb.html +212 -0
- data/test/coverage/rcov/lib-codin_rep-version_rb.html +128 -0
- data/test/coverage/rcov/lib-codin_rep_rb.html +317 -0
- data/test/mock_time_clock.rb +184 -0
- data/test/reports/TEST-GetTimeTest.xml +5 -0
- data/test/test_helper.rb +25 -0
- data/test/unit/add_employee_test.rb +43 -0
- data/test/unit/del_employee_test.rb +44 -0
- data/test/unit/get_employer_test.rb +48 -0
- data/test/unit/get_records_test.rb +45 -0
- data/test/unit/get_serial_number_test.rb +42 -0
- data/test/unit/get_time_test.rb +40 -0
- data/test/unit/set_time_test.rb +42 -0
- metadata +165 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>lib/codin_rep/version.rb</title>
|
5
|
+
<link href="./assets/0.2.3/screen.css" media="all" rel="stylesheet" type="text/css" />
|
6
|
+
<link href="./assets/0.2.3/print.css" media="print" rel="stylesheet" type="text/css" />
|
7
|
+
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
8
|
+
<script type="text/javascript" src="./assets/0.2.3/rcov.js"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Src C0 Coverage Information - Simploco - RCov</h1>
|
12
|
+
<h2>lib/codin_rep/version.rb</h2>
|
13
|
+
|
14
|
+
<div class="report_table_wrapper">
|
15
|
+
<table class='report' id='report_table'>
|
16
|
+
<thead>
|
17
|
+
<tr>
|
18
|
+
<th class="left_align">Name</th>
|
19
|
+
<th class="right_align">Total Lines</th>
|
20
|
+
<th class="right_align">Lines of Code</th>
|
21
|
+
<th class="left_align">Total Coverage</th>
|
22
|
+
<th class="left_align">Code Coverage</th>
|
23
|
+
</tr>
|
24
|
+
</thead>
|
25
|
+
<tbody>
|
26
|
+
<tr>
|
27
|
+
<td class="left_align"><a href="lib-codin_rep-version_rb.html">lib/codin_rep/version.rb</a></td>
|
28
|
+
<td class='right_align'><tt>23</tt></td>
|
29
|
+
<td class='right_align'><tt>2</tt></td>
|
30
|
+
<td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
|
31
|
+
<div class="percent_graph">
|
32
|
+
<div class="covered" style="width:100px"></div>
|
33
|
+
<div class="uncovered" style="width:0px"></div>
|
34
|
+
</div></td>
|
35
|
+
<td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
|
36
|
+
<div class="percent_graph">
|
37
|
+
<div class="covered" style="width:100px"></div>
|
38
|
+
<div class="uncovered" style="width:0px"></div>
|
39
|
+
</div></td>
|
40
|
+
</tr>
|
41
|
+
</tbody>
|
42
|
+
</table>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<h3>Key</h3>
|
46
|
+
|
47
|
+
<div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>
|
48
|
+
|
49
|
+
<h3>Coverage Details</h3>
|
50
|
+
|
51
|
+
<table class="details">
|
52
|
+
<tbody>
|
53
|
+
<tr class="inferred">
|
54
|
+
<td><pre><a name="line2">2</a> # -*- coding: utf-8 -*-</pre></td>
|
55
|
+
</tr>
|
56
|
+
<tr class="inferred">
|
57
|
+
<td><pre><a name="line3">3</a> # codin_rep - Gem para acesso de REPs da Telebyte</pre></td>
|
58
|
+
</tr>
|
59
|
+
<tr class="inferred">
|
60
|
+
<td><pre><a name="line4">4</a> # Copyright (C) 2016 O.S. Systems Softwares Ltda.</pre></td>
|
61
|
+
</tr>
|
62
|
+
<tr class="inferred">
|
63
|
+
<td><pre><a name="line5">5</a> </pre></td>
|
64
|
+
</tr>
|
65
|
+
<tr class="inferred">
|
66
|
+
<td><pre><a name="line6">6</a> # This program is free software: you can redistribute it and/or modify</pre></td>
|
67
|
+
</tr>
|
68
|
+
<tr class="inferred">
|
69
|
+
<td><pre><a name="line7">7</a> # it under the terms of the GNU Affero General Public License as</pre></td>
|
70
|
+
</tr>
|
71
|
+
<tr class="inferred">
|
72
|
+
<td><pre><a name="line8">8</a> # published by the Free Software Foundation, either version 3 of the</pre></td>
|
73
|
+
</tr>
|
74
|
+
<tr class="inferred">
|
75
|
+
<td><pre><a name="line9">9</a> # License, or (at your option) any later version.</pre></td>
|
76
|
+
</tr>
|
77
|
+
<tr class="inferred">
|
78
|
+
<td><pre><a name="line10">10</a> </pre></td>
|
79
|
+
</tr>
|
80
|
+
<tr class="inferred">
|
81
|
+
<td><pre><a name="line11">11</a> # This program is distributed in the hope that it will be useful,</pre></td>
|
82
|
+
</tr>
|
83
|
+
<tr class="inferred">
|
84
|
+
<td><pre><a name="line12">12</a> # but WITHOUT ANY WARRANTY; without even the implied warranty of</pre></td>
|
85
|
+
</tr>
|
86
|
+
<tr class="inferred">
|
87
|
+
<td><pre><a name="line13">13</a> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</pre></td>
|
88
|
+
</tr>
|
89
|
+
<tr class="inferred">
|
90
|
+
<td><pre><a name="line14">14</a> # GNU Affero General Public License for more details.</pre></td>
|
91
|
+
</tr>
|
92
|
+
<tr class="inferred">
|
93
|
+
<td><pre><a name="line15">15</a> </pre></td>
|
94
|
+
</tr>
|
95
|
+
<tr class="inferred">
|
96
|
+
<td><pre><a name="line16">16</a> # You should have received a copy of the GNU Affero General Public License</pre></td>
|
97
|
+
</tr>
|
98
|
+
<tr class="inferred">
|
99
|
+
<td><pre><a name="line17">17</a> # along with this program. If not, see <http://www.gnu.org/licenses/>.</pre></td>
|
100
|
+
</tr>
|
101
|
+
<tr class="inferred">
|
102
|
+
<td><pre><a name="line18">18</a> </pre></td>
|
103
|
+
</tr>
|
104
|
+
<tr class="inferred">
|
105
|
+
<td><pre><a name="line19">19</a> # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.</pre></td>
|
106
|
+
</tr>
|
107
|
+
<tr class="inferred">
|
108
|
+
<td><pre><a name="line20">20</a> # e-mail: contato@ossystems.com.br</pre></td>
|
109
|
+
</tr>
|
110
|
+
<tr class="inferred">
|
111
|
+
<td><pre><a name="line21">21</a> </pre></td>
|
112
|
+
</tr>
|
113
|
+
<tr class="marked">
|
114
|
+
<td><pre><a name="line22">22</a> module CodinRep</pre></td>
|
115
|
+
</tr>
|
116
|
+
<tr class="marked">
|
117
|
+
<td><pre><a name="line23">23</a> VERSION = "0.1.0".freeze</pre></td>
|
118
|
+
</tr>
|
119
|
+
<tr class="inferred">
|
120
|
+
<td><pre><a name="line24">24</a> end</pre></td>
|
121
|
+
</tr>
|
122
|
+
</tbody>
|
123
|
+
</table>
|
124
|
+
|
125
|
+
<p>Generated on 2017-01-19 17:18:28 -0200 with <a href="https://github.com/fguillen/simplecov-rcov">SimpleCov-RCov 0.2.3</a></p>
|
126
|
+
|
127
|
+
</body>
|
128
|
+
</html>
|
@@ -0,0 +1,317 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>lib/codin_rep.rb</title>
|
5
|
+
<link href="./assets/0.2.3/screen.css" media="all" rel="stylesheet" type="text/css" />
|
6
|
+
<link href="./assets/0.2.3/print.css" media="print" rel="stylesheet" type="text/css" />
|
7
|
+
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
8
|
+
<script type="text/javascript" src="./assets/0.2.3/rcov.js"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Src C0 Coverage Information - Simploco - RCov</h1>
|
12
|
+
<h2>lib/codin_rep.rb</h2>
|
13
|
+
|
14
|
+
<div class="report_table_wrapper">
|
15
|
+
<table class='report' id='report_table'>
|
16
|
+
<thead>
|
17
|
+
<tr>
|
18
|
+
<th class="left_align">Name</th>
|
19
|
+
<th class="right_align">Total Lines</th>
|
20
|
+
<th class="right_align">Lines of Code</th>
|
21
|
+
<th class="left_align">Total Coverage</th>
|
22
|
+
<th class="left_align">Code Coverage</th>
|
23
|
+
</tr>
|
24
|
+
</thead>
|
25
|
+
<tbody>
|
26
|
+
<tr>
|
27
|
+
<td class="left_align"><a href="lib-codin_rep_rb.html">lib/codin_rep.rb</a></td>
|
28
|
+
<td class='right_align'><tt>86</tt></td>
|
29
|
+
<td class='right_align'><tt>86</tt></td>
|
30
|
+
<td class="left_align"><div class="percent_graph_legend"><tt class=''>0.00%</tt></div>
|
31
|
+
<div class="percent_graph">
|
32
|
+
<div class="covered" style="width:0px"></div>
|
33
|
+
<div class="uncovered" style="width:100px"></div>
|
34
|
+
</div></td>
|
35
|
+
<td class="left_align"><div class="percent_graph_legend"><tt class=''>0.00%</tt></div>
|
36
|
+
<div class="percent_graph">
|
37
|
+
<div class="covered" style="width:0px"></div>
|
38
|
+
<div class="uncovered" style="width:100px"></div>
|
39
|
+
</div></td>
|
40
|
+
</tr>
|
41
|
+
</tbody>
|
42
|
+
</table>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<h3>Key</h3>
|
46
|
+
|
47
|
+
<div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>
|
48
|
+
|
49
|
+
<h3>Coverage Details</h3>
|
50
|
+
|
51
|
+
<table class="details">
|
52
|
+
<tbody>
|
53
|
+
<tr class="uncovered">
|
54
|
+
<td><pre><a name="line2">2</a> # -*- coding: utf-8 -*-</pre></td>
|
55
|
+
</tr>
|
56
|
+
<tr class="uncovered">
|
57
|
+
<td><pre><a name="line3">3</a> # codinrep - Gem para acesso de REPs da Telebyte</pre></td>
|
58
|
+
</tr>
|
59
|
+
<tr class="uncovered">
|
60
|
+
<td><pre><a name="line4">4</a> # Copyright (C) 2016 O.S. Systems Softwares Ltda.</pre></td>
|
61
|
+
</tr>
|
62
|
+
<tr class="uncovered">
|
63
|
+
<td><pre><a name="line5">5</a> </pre></td>
|
64
|
+
</tr>
|
65
|
+
<tr class="uncovered">
|
66
|
+
<td><pre><a name="line6">6</a> # This program is free software: you can redistribute it and/or modify</pre></td>
|
67
|
+
</tr>
|
68
|
+
<tr class="uncovered">
|
69
|
+
<td><pre><a name="line7">7</a> # it under the terms of the GNU Affero General Public License as</pre></td>
|
70
|
+
</tr>
|
71
|
+
<tr class="uncovered">
|
72
|
+
<td><pre><a name="line8">8</a> # published by the Free Software Foundation, either version 3 of the</pre></td>
|
73
|
+
</tr>
|
74
|
+
<tr class="uncovered">
|
75
|
+
<td><pre><a name="line9">9</a> # License, or (at your option) any later version.</pre></td>
|
76
|
+
</tr>
|
77
|
+
<tr class="uncovered">
|
78
|
+
<td><pre><a name="line10">10</a> </pre></td>
|
79
|
+
</tr>
|
80
|
+
<tr class="uncovered">
|
81
|
+
<td><pre><a name="line11">11</a> # This program is distributed in the hope that it will be useful,</pre></td>
|
82
|
+
</tr>
|
83
|
+
<tr class="uncovered">
|
84
|
+
<td><pre><a name="line12">12</a> # but WITHOUT ANY WARRANTY; without even the implied warranty of</pre></td>
|
85
|
+
</tr>
|
86
|
+
<tr class="uncovered">
|
87
|
+
<td><pre><a name="line13">13</a> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</pre></td>
|
88
|
+
</tr>
|
89
|
+
<tr class="uncovered">
|
90
|
+
<td><pre><a name="line14">14</a> # GNU Affero General Public License for more details.</pre></td>
|
91
|
+
</tr>
|
92
|
+
<tr class="uncovered">
|
93
|
+
<td><pre><a name="line15">15</a> </pre></td>
|
94
|
+
</tr>
|
95
|
+
<tr class="uncovered">
|
96
|
+
<td><pre><a name="line16">16</a> # You should have received a copy of the GNU Affero General Public License</pre></td>
|
97
|
+
</tr>
|
98
|
+
<tr class="uncovered">
|
99
|
+
<td><pre><a name="line17">17</a> # along with this program. If not, see <http://www.gnu.org/licenses/>.</pre></td>
|
100
|
+
</tr>
|
101
|
+
<tr class="uncovered">
|
102
|
+
<td><pre><a name="line18">18</a> </pre></td>
|
103
|
+
</tr>
|
104
|
+
<tr class="uncovered">
|
105
|
+
<td><pre><a name="line19">19</a> # Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.</pre></td>
|
106
|
+
</tr>
|
107
|
+
<tr class="uncovered">
|
108
|
+
<td><pre><a name="line20">20</a> # e-mail: contato@ossystems.com.br</pre></td>
|
109
|
+
</tr>
|
110
|
+
<tr class="uncovered">
|
111
|
+
<td><pre><a name="line21">21</a> </pre></td>
|
112
|
+
</tr>
|
113
|
+
<tr class="uncovered">
|
114
|
+
<td><pre><a name="line22">22</a> require "codin_rep/add_employee"</pre></td>
|
115
|
+
</tr>
|
116
|
+
<tr class="uncovered">
|
117
|
+
<td><pre><a name="line23">23</a> require "codin_rep/employee_command"</pre></td>
|
118
|
+
</tr>
|
119
|
+
<tr class="uncovered">
|
120
|
+
<td><pre><a name="line24">24</a> require "codin_rep/get_time"</pre></td>
|
121
|
+
</tr>
|
122
|
+
<tr class="uncovered">
|
123
|
+
<td><pre><a name="line25">25</a> require "codin_rep/set_time"</pre></td>
|
124
|
+
</tr>
|
125
|
+
<tr class="uncovered">
|
126
|
+
<td><pre><a name="line26">26</a> require "codin_rep/get_records"</pre></td>
|
127
|
+
</tr>
|
128
|
+
<tr class="uncovered">
|
129
|
+
<td><pre><a name="line27">27</a> require "codin_rep/del_employee"</pre></td>
|
130
|
+
</tr>
|
131
|
+
<tr class="uncovered">
|
132
|
+
<td><pre><a name="line28">28</a> </pre></td>
|
133
|
+
</tr>
|
134
|
+
<tr class="uncovered">
|
135
|
+
<td><pre><a name="line29">29</a> module CodinRep</pre></td>
|
136
|
+
</tr>
|
137
|
+
<tr class="uncovered">
|
138
|
+
<td><pre><a name="line30">30</a> class << self</pre></td>
|
139
|
+
</tr>
|
140
|
+
<tr class="uncovered">
|
141
|
+
<td><pre><a name="line31">31</a> def included(base)</pre></td>
|
142
|
+
</tr>
|
143
|
+
<tr class="uncovered">
|
144
|
+
<td><pre><a name="line32">32</a> return if base.included_modules.include?(InstanceMethods)</pre></td>
|
145
|
+
</tr>
|
146
|
+
<tr class="uncovered">
|
147
|
+
<td><pre><a name="line33">33</a> base.send(:include, InstanceMethods)</pre></td>
|
148
|
+
</tr>
|
149
|
+
<tr class="uncovered">
|
150
|
+
<td><pre><a name="line34">34</a> end</pre></td>
|
151
|
+
</tr>
|
152
|
+
<tr class="uncovered">
|
153
|
+
<td><pre><a name="line35">35</a> end</pre></td>
|
154
|
+
</tr>
|
155
|
+
<tr class="uncovered">
|
156
|
+
<td><pre><a name="line36">36</a> </pre></td>
|
157
|
+
</tr>
|
158
|
+
<tr class="uncovered">
|
159
|
+
<td><pre><a name="line37">37</a> module InstanceMethods</pre></td>
|
160
|
+
</tr>
|
161
|
+
<tr class="uncovered">
|
162
|
+
<td><pre><a name="line38">38</a> def get_time</pre></td>
|
163
|
+
</tr>
|
164
|
+
<tr class="uncovered">
|
165
|
+
<td><pre><a name="line39">39</a> command = CodinRep::GetTime.new(self.ip, self.tcp_port)</pre></td>
|
166
|
+
</tr>
|
167
|
+
<tr class="uncovered">
|
168
|
+
<td><pre><a name="line40">40</a> response = command.execute</pre></td>
|
169
|
+
</tr>
|
170
|
+
<tr class="uncovered">
|
171
|
+
<td><pre><a name="line41">41</a> return response</pre></td>
|
172
|
+
</tr>
|
173
|
+
<tr class="uncovered">
|
174
|
+
<td><pre><a name="line42">42</a> end</pre></td>
|
175
|
+
</tr>
|
176
|
+
<tr class="uncovered">
|
177
|
+
<td><pre><a name="line43">43</a> </pre></td>
|
178
|
+
</tr>
|
179
|
+
<tr class="uncovered">
|
180
|
+
<td><pre><a name="line44">44</a> def set_time(time)</pre></td>
|
181
|
+
</tr>
|
182
|
+
<tr class="uncovered">
|
183
|
+
<td><pre><a name="line45">45</a> command = CodinRep::SetTime.new(time, self.ip, self.tcp_port)</pre></td>
|
184
|
+
</tr>
|
185
|
+
<tr class="uncovered">
|
186
|
+
<td><pre><a name="line46">46</a> response = command.execute</pre></td>
|
187
|
+
</tr>
|
188
|
+
<tr class="uncovered">
|
189
|
+
<td><pre><a name="line47">47</a> return response</pre></td>
|
190
|
+
</tr>
|
191
|
+
<tr class="uncovered">
|
192
|
+
<td><pre><a name="line48">48</a> end</pre></td>
|
193
|
+
</tr>
|
194
|
+
<tr class="uncovered">
|
195
|
+
<td><pre><a name="line49">49</a> </pre></td>
|
196
|
+
</tr>
|
197
|
+
<tr class="uncovered">
|
198
|
+
<td><pre><a name="line50">50</a> def get_employer</pre></td>
|
199
|
+
</tr>
|
200
|
+
<tr class="uncovered">
|
201
|
+
<td><pre><a name="line51">51</a> command = CodinRep::GetAfdHeader.new(self.ip, self.tcp_port)</pre></td>
|
202
|
+
</tr>
|
203
|
+
<tr class="uncovered">
|
204
|
+
<td><pre><a name="line52">52</a> response = command.execute</pre></td>
|
205
|
+
</tr>
|
206
|
+
<tr class="uncovered">
|
207
|
+
<td><pre><a name="line53">53</a> </pre></td>
|
208
|
+
</tr>
|
209
|
+
<tr class="uncovered">
|
210
|
+
<td><pre><a name="line54">54</a> hash = {}</pre></td>
|
211
|
+
</tr>
|
212
|
+
<tr class="uncovered">
|
213
|
+
<td><pre><a name="line55">55</a> hash[:document_type] = response.employer_type</pre></td>
|
214
|
+
</tr>
|
215
|
+
<tr class="uncovered">
|
216
|
+
<td><pre><a name="line56">56</a> hash[:document_number] = response.employer_document</pre></td>
|
217
|
+
</tr>
|
218
|
+
<tr class="uncovered">
|
219
|
+
<td><pre><a name="line57">57</a> hash[:cei_document] = response.employer_cei</pre></td>
|
220
|
+
</tr>
|
221
|
+
<tr class="uncovered">
|
222
|
+
<td><pre><a name="line58">58</a> hash[:company_name] = response.employer_name</pre></td>
|
223
|
+
</tr>
|
224
|
+
<tr class="uncovered">
|
225
|
+
<td><pre><a name="line59">59</a> </pre></td>
|
226
|
+
</tr>
|
227
|
+
<tr class="uncovered">
|
228
|
+
<td><pre><a name="line60">60</a> return hash</pre></td>
|
229
|
+
</tr>
|
230
|
+
<tr class="uncovered">
|
231
|
+
<td><pre><a name="line61">61</a> end</pre></td>
|
232
|
+
</tr>
|
233
|
+
<tr class="uncovered">
|
234
|
+
<td><pre><a name="line62">62</a> </pre></td>
|
235
|
+
</tr>
|
236
|
+
<tr class="uncovered">
|
237
|
+
<td><pre><a name="line63">63</a> def get_serial_number</pre></td>
|
238
|
+
</tr>
|
239
|
+
<tr class="uncovered">
|
240
|
+
<td><pre><a name="line64">64</a> command = CodinRep::GetAfdHeader.new(self.ip, self.tcp_port)</pre></td>
|
241
|
+
</tr>
|
242
|
+
<tr class="uncovered">
|
243
|
+
<td><pre><a name="line65">65</a> response = command.execute</pre></td>
|
244
|
+
</tr>
|
245
|
+
<tr class="uncovered">
|
246
|
+
<td><pre><a name="line66">66</a> response.rep_serial_number</pre></td>
|
247
|
+
</tr>
|
248
|
+
<tr class="uncovered">
|
249
|
+
<td><pre><a name="line67">67</a> end</pre></td>
|
250
|
+
</tr>
|
251
|
+
<tr class="uncovered">
|
252
|
+
<td><pre><a name="line68">68</a> </pre></td>
|
253
|
+
</tr>
|
254
|
+
<tr class="uncovered">
|
255
|
+
<td><pre><a name="line69">69</a> def get_records(first_id=nil)</pre></td>
|
256
|
+
</tr>
|
257
|
+
<tr class="uncovered">
|
258
|
+
<td><pre><a name="line70">70</a> command = CodinRep::GetRecords.new(first_id, self.ip, self.tcp_port)</pre></td>
|
259
|
+
</tr>
|
260
|
+
<tr class="uncovered">
|
261
|
+
<td><pre><a name="line71">71</a> response = command.execute</pre></td>
|
262
|
+
</tr>
|
263
|
+
<tr class="uncovered">
|
264
|
+
<td><pre><a name="line72">72</a> response</pre></td>
|
265
|
+
</tr>
|
266
|
+
<tr class="uncovered">
|
267
|
+
<td><pre><a name="line73">73</a> end</pre></td>
|
268
|
+
</tr>
|
269
|
+
<tr class="uncovered">
|
270
|
+
<td><pre><a name="line74">74</a> </pre></td>
|
271
|
+
</tr>
|
272
|
+
<tr class="uncovered">
|
273
|
+
<td><pre><a name="line75">75</a> def set_employee(operation_type, registration, pis_number, name)</pre></td>
|
274
|
+
</tr>
|
275
|
+
<tr class="uncovered">
|
276
|
+
<td><pre><a name="line76">76</a> if [:add, :edit].include? operation_type</pre></td>
|
277
|
+
</tr>
|
278
|
+
<tr class="uncovered">
|
279
|
+
<td><pre><a name="line77">77</a> command = CodinRep::AddEmployee.new(registration, pis_number, name, self.ip, self.tcp_port)</pre></td>
|
280
|
+
</tr>
|
281
|
+
<tr class="uncovered">
|
282
|
+
<td><pre><a name="line78">78</a> elsif operation_type == :remove</pre></td>
|
283
|
+
</tr>
|
284
|
+
<tr class="uncovered">
|
285
|
+
<td><pre><a name="line79">79</a> command = CodinRep::DelEmployee.new(registration, self.ip, self.tcp_port)</pre></td>
|
286
|
+
</tr>
|
287
|
+
<tr class="uncovered">
|
288
|
+
<td><pre><a name="line80">80</a> else</pre></td>
|
289
|
+
</tr>
|
290
|
+
<tr class="uncovered">
|
291
|
+
<td><pre><a name="line81">81</a> raise EmployeeCommand::UnknownEmployeeOperation.new(operation_type)</pre></td>
|
292
|
+
</tr>
|
293
|
+
<tr class="uncovered">
|
294
|
+
<td><pre><a name="line82">82</a> end</pre></td>
|
295
|
+
</tr>
|
296
|
+
<tr class="uncovered">
|
297
|
+
<td><pre><a name="line83">83</a> response = command.execute</pre></td>
|
298
|
+
</tr>
|
299
|
+
<tr class="uncovered">
|
300
|
+
<td><pre><a name="line84">84</a> response</pre></td>
|
301
|
+
</tr>
|
302
|
+
<tr class="uncovered">
|
303
|
+
<td><pre><a name="line85">85</a> end</pre></td>
|
304
|
+
</tr>
|
305
|
+
<tr class="uncovered">
|
306
|
+
<td><pre><a name="line86">86</a> end</pre></td>
|
307
|
+
</tr>
|
308
|
+
<tr class="uncovered">
|
309
|
+
<td><pre><a name="line87">87</a> end</pre></td>
|
310
|
+
</tr>
|
311
|
+
</tbody>
|
312
|
+
</table>
|
313
|
+
|
314
|
+
<p>Generated on 2017-01-19 17:18:28 -0200 with <a href="https://github.com/fguillen/simplecov-rcov">SimpleCov-RCov 0.2.3</a></p>
|
315
|
+
|
316
|
+
</body>
|
317
|
+
</html>
|
@@ -0,0 +1,184 @@
|
|
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'
|
22
|
+
require 'codin_rep/time_util'
|
23
|
+
require 'socket'
|
24
|
+
|
25
|
+
class MockTimeClock
|
26
|
+
include CodinRep
|
27
|
+
|
28
|
+
attr_reader :data, :ip
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@data = OpenStruct.new
|
32
|
+
@ip = '127.0.0.1'
|
33
|
+
@server = TCPServer.new(@ip, 0)
|
34
|
+
@running = false
|
35
|
+
@served_connections = 0
|
36
|
+
@threads = []
|
37
|
+
@threadsMutex = Mutex.new
|
38
|
+
@served_connections = 0
|
39
|
+
@time = true
|
40
|
+
@is_sending_records = false
|
41
|
+
end
|
42
|
+
|
43
|
+
def tcp_port
|
44
|
+
@server.addr[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
def serve(socket)
|
48
|
+
Thread.new do
|
49
|
+
Thread.current.abort_on_exception = true
|
50
|
+
@threadsMutex.synchronize {
|
51
|
+
@threads << Thread.current
|
52
|
+
@served_connections += 1
|
53
|
+
}
|
54
|
+
begin
|
55
|
+
raw_command = []
|
56
|
+
@keep_connected = true
|
57
|
+
@first_connection = true
|
58
|
+
# Read command type
|
59
|
+
while @keep_connected && raw_command = read_from_socket_with_timeout(socket, 9)
|
60
|
+
response = process_command(raw_command, socket)
|
61
|
+
socket.write response
|
62
|
+
@first_connection = false
|
63
|
+
end
|
64
|
+
ensure
|
65
|
+
socket.close unless socket.closed?
|
66
|
+
@threadsMutex.synchronize {
|
67
|
+
@threads.delete(Thread.current)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def start
|
74
|
+
@server_thread = Thread.new do
|
75
|
+
Thread.current.abort_on_exception = true
|
76
|
+
@running = true
|
77
|
+
while @running
|
78
|
+
break if @server.closed?
|
79
|
+
socket = @server.accept
|
80
|
+
serve(socket)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
def stop
|
87
|
+
@threadsMutex.synchronize {
|
88
|
+
@threads.each{|thread| thread.kill}
|
89
|
+
@threads = []
|
90
|
+
}
|
91
|
+
@server_thread.kill if @server_thread
|
92
|
+
@server.close unless @server.closed?
|
93
|
+
@server_thread.join
|
94
|
+
@running = false
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
def running?
|
99
|
+
@running
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
def process_command(raw_command, socket)
|
104
|
+
case raw_command
|
105
|
+
when "PGREP009b" # Get time
|
106
|
+
response = 'REP008b' + get_timeclock_time
|
107
|
+
when "PGREP016A" # Set time
|
108
|
+
payload = read_from_socket_with_timeout(socket, 7)
|
109
|
+
response = 'REP008A' + payload
|
110
|
+
set_timeclock_time(payload)
|
111
|
+
when "PGREP009Z"
|
112
|
+
response = 'REP2359' + @data.afd.header.export + "\r\n"
|
113
|
+
@keep_connected = false
|
114
|
+
when "PGREP0289"
|
115
|
+
@afd_read_start_id = read_from_socket_with_timeout(socket, 9).to_i
|
116
|
+
@afd_read_end_id = read_from_socket_with_timeout(socket, 9).to_i
|
117
|
+
@afd_read_current_id = nil
|
118
|
+
@afd_read_finished = false
|
119
|
+
response = "REP0029["
|
120
|
+
when "PGREP009,"
|
121
|
+
if @afd_read_finished
|
122
|
+
response = "REP0029]"
|
123
|
+
@keep_connected = false
|
124
|
+
else
|
125
|
+
if @afd_read_current_id.nil?
|
126
|
+
@afd_read_current_id = @afd_read_start_id
|
127
|
+
response = 'REP3029'
|
128
|
+
elsif @afd_read_current_id == @afd_read_end_id or @afd_read_current_id >= @data.afd.records.size
|
129
|
+
response = 'REP0909'
|
130
|
+
@afd_read_finished = true
|
131
|
+
else
|
132
|
+
response = 'REP0379'
|
133
|
+
end
|
134
|
+
afd_records = ([@data.afd.header] + @data.afd.records)
|
135
|
+
response += afd_records[@afd_read_current_id].export + "\r\n"
|
136
|
+
end
|
137
|
+
@afd_read_current_id += 1
|
138
|
+
when "PGREP075h"
|
139
|
+
payload = read_from_socket_with_timeout(socket, 66)
|
140
|
+
raw_registration, raw_pis, raw_name = payload.scan(/.(.{6})(.{6})(.+)/).flatten
|
141
|
+
registration = convert_bytes_to_string(raw_registration)
|
142
|
+
pis = convert_bytes_to_string(raw_pis)
|
143
|
+
name = raw_name.strip
|
144
|
+
@data.employees << {name: name, pis: pis, registration: registration}
|
145
|
+
response = "REP003h1\0"
|
146
|
+
when "PGREP016j"
|
147
|
+
payload = read_from_socket_with_timeout(socket, 7)
|
148
|
+
raw_registration = payload.scan(/.(.{6})/).flatten[0]
|
149
|
+
registration = convert_bytes_to_string(raw_registration)
|
150
|
+
@data.employees.delete_if{|employee| employee[:registration] == registration}
|
151
|
+
response = "REP003j1\0"
|
152
|
+
when 'PGREP010h', 'PGREP010j'
|
153
|
+
# Don't care for the result of these comands, just disconnect when
|
154
|
+
# possible.
|
155
|
+
@keep_connected = false
|
156
|
+
response = ""
|
157
|
+
else
|
158
|
+
raise StandardError.new("Unknown command \"#{raw_command}\"!")
|
159
|
+
end
|
160
|
+
response
|
161
|
+
end
|
162
|
+
|
163
|
+
def read_from_socket_with_timeout(socket, bytes_to_be_read, timeout_value=5)
|
164
|
+
data_to_receive = nil
|
165
|
+
timeout_value = 600 if @first_connection # use a large timeout on first connection
|
166
|
+
timeout(timeout_value) { data_to_receive = socket.readpartial( bytes_to_be_read ) }
|
167
|
+
return data_to_receive
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_timeclock_time(current_time=nil)
|
171
|
+
current_time ||= @data.time
|
172
|
+
CodinRep::TimeUtil.pack current_time
|
173
|
+
end
|
174
|
+
|
175
|
+
def set_timeclock_time(payload)
|
176
|
+
time = CodinRep::TimeUtil.unpack payload
|
177
|
+
@data.time = time
|
178
|
+
return time
|
179
|
+
end
|
180
|
+
|
181
|
+
def convert_bytes_to_string(bytes)
|
182
|
+
bytes.unpack('H*')[0]
|
183
|
+
end
|
184
|
+
end
|