orion6_rep 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/orion6_rep/change_ip.rb +54 -0
- data/lib/orion6_rep/clock_time/get.rb +98 -0
- data/lib/orion6_rep/clock_time/set.rb +96 -0
- data/lib/orion6_rep/clock_time.rb +31 -0
- data/lib/orion6_rep/command.rb +176 -0
- data/lib/orion6_rep/communication.rb +89 -0
- data/lib/orion6_rep/detect_reps.rb +86 -0
- data/lib/orion6_rep/employee_get.rb +112 -0
- data/lib/orion6_rep/employee_quantity_get.rb +81 -0
- data/lib/orion6_rep/employee_set.rb +104 -0
- data/lib/orion6_rep/employer_get.rb +84 -0
- data/lib/orion6_rep/employer_set.rb +90 -0
- data/lib/orion6_rep/get_serial_number.rb +64 -0
- data/lib/orion6_rep/interface.rb +55 -0
- data/lib/orion6_rep/mockup.rb +118 -0
- data/lib/orion6_rep/multi_message_command.rb +113 -0
- data/lib/orion6_rep/record_id_get.rb +79 -0
- data/lib/orion6_rep/records_get.rb +89 -0
- data/lib/orion6_rep/version.rb +3 -0
- data/lib/orion6_rep.rb +199 -0
- data/test/afd_file +11 -0
- data/test/external/detect_reps_test.rb +28 -0
- data/test/external/employee_test.rb +100 -0
- data/test/external/employer_test.rb +57 -0
- data/test/external/get_serial_test.rb +31 -0
- data/test/external/record_get_test.rb +32 -0
- data/test/external/time_test.rb +84 -0
- data/test/test_helper.rb +25 -0
- data/test/time_clock.rb +13 -0
- data/test/unit/mockup_test.rb +154 -0
- metadata +125 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
2
|
+
# Copyright (C) 2009 O.S. Systems Softwares Ltda.
|
3
|
+
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as
|
6
|
+
# published by the Free Software Foundation, either version 3 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
|
18
|
+
# e-mail: contato@ossystems.com.br
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
21
|
+
|
22
|
+
class EmployeeTest < Test::Unit::TestCase
|
23
|
+
def test_get_employees_quantity
|
24
|
+
ip = ENV["IP"]
|
25
|
+
t = TimeClock.new(ip, 3000, 1)
|
26
|
+
|
27
|
+
puts "Retrieving employees quantity from '#{ip}'..."
|
28
|
+
payload = t.get_employees_quantity
|
29
|
+
puts "Received: " + payload.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_employees
|
33
|
+
ip = ENV["IP"]
|
34
|
+
t = TimeClock.new(ip, 3000, 1)
|
35
|
+
|
36
|
+
puts "Retrieving employees from '#{ip}'..."
|
37
|
+
data = t.get_employees
|
38
|
+
puts "Received: " + data.inspect
|
39
|
+
data.each do |employee_data|
|
40
|
+
assert_equal(20, employee_data[:registration].size)
|
41
|
+
assert_equal(12, employee_data[:pis_number].size)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_set_employee
|
46
|
+
test_values = {:registration => "12345678901234567890",
|
47
|
+
:name => "Test User",
|
48
|
+
:pis_number => "123456789012"}
|
49
|
+
|
50
|
+
ip = ENV["IP"]
|
51
|
+
t = TimeClock.new(ip, 3000, 1)
|
52
|
+
|
53
|
+
print "Retrieving employees from '#{ip}'... "
|
54
|
+
all_employees = t.get_employees
|
55
|
+
puts "OK!"
|
56
|
+
|
57
|
+
test_user = all_employees.detect do |e|
|
58
|
+
test_values.any?{|key, value| e[key] == value}
|
59
|
+
end
|
60
|
+
|
61
|
+
if test_user
|
62
|
+
print "Test user already exists, removing it for testing... "
|
63
|
+
assert t.set_employee(:remove, test_user[:registration], test_user[:pis_number], test_user[:name])
|
64
|
+
puts "OK!"
|
65
|
+
|
66
|
+
print "Checking if user was removed... "
|
67
|
+
all_employees = t.get_employees
|
68
|
+
test_user = all_employees.detect do |e|
|
69
|
+
test_values.any?{|key, value| e[key] == value}
|
70
|
+
end
|
71
|
+
assert_nil test_user
|
72
|
+
puts "OK!"
|
73
|
+
end
|
74
|
+
|
75
|
+
print "Adding test user... "
|
76
|
+
assert t.set_employee(:add, test_values[:registration], test_values[:pis_number], test_values[:name])
|
77
|
+
puts "OK!"
|
78
|
+
|
79
|
+
print "Checking if user was added... "
|
80
|
+
all_employees = t.get_employees
|
81
|
+
|
82
|
+
test_user = all_employees.detect do |e|
|
83
|
+
test_values.all?{|key, value| e[key] == value}
|
84
|
+
end
|
85
|
+
assert !test_user.nil?
|
86
|
+
puts "OK!"
|
87
|
+
|
88
|
+
print "Removing test user... "
|
89
|
+
assert t.set_employee(:remove, test_user[:registration], test_user[:pis_number], test_user[:name])
|
90
|
+
puts "OK!"
|
91
|
+
|
92
|
+
print "Checking if user was removed... "
|
93
|
+
all_employees = t.get_employees
|
94
|
+
test_user = all_employees.detect do |e|
|
95
|
+
test_values.any?{|key, value| e[key] == value}
|
96
|
+
end
|
97
|
+
assert_nil test_user
|
98
|
+
puts "OK!"
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
2
|
+
# Copyright (C) 2009 O.S. Systems Softwares Ltda.
|
3
|
+
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as
|
6
|
+
# published by the Free Software Foundation, either version 3 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
|
18
|
+
# e-mail: contato@ossystems.com.br
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
21
|
+
|
22
|
+
class EmployerTest < Test::Unit::TestCase
|
23
|
+
def test_get_employer
|
24
|
+
ip = ENV["IP"]
|
25
|
+
t = TimeClock.new(ip, 3000, 1)
|
26
|
+
|
27
|
+
puts "Retrieving employer from '#{ip}'..."
|
28
|
+
payload = t.get_employer
|
29
|
+
puts "Received: " + payload.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_set_employer
|
33
|
+
ip = ENV["IP"]
|
34
|
+
t = TimeClock.new(ip, 3000, 1)
|
35
|
+
|
36
|
+
print "Retrieve the original employer on '#{ip}'... "
|
37
|
+
original_employer = t.get_employer
|
38
|
+
puts "OK!"
|
39
|
+
|
40
|
+
print "Set a new employer... "
|
41
|
+
t.set_employer("RAZAO_SOCIAL_TEST", "LOCATION_TEST", :cnpj, "12345", "54321")
|
42
|
+
print "OK!\nReceive the new employer data to check... "
|
43
|
+
new_employer = t.get_employer
|
44
|
+
|
45
|
+
print "OK!\nSet a different employer... "
|
46
|
+
t.set_employer("RAZAO_SOCIAL", "LOCATION", :cnpj, "67890", "09876")
|
47
|
+
print "OK!\nReceive the different employer data to check... "
|
48
|
+
different_employer = t.get_employer
|
49
|
+
assert_not_equal new_employer, different_employer
|
50
|
+
|
51
|
+
print "OK!\nRestore the original employer... "
|
52
|
+
t.set_employer(original_employer[:company_name], original_employer[:company_location], original_employer[:document_type], original_employer[:document_number], original_employer[:cei_document])
|
53
|
+
print "OK!\nReceive the employer data to check if it is the original... "
|
54
|
+
assert_equal original_employer, t.get_employer
|
55
|
+
puts "OK!"
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
2
|
+
# Copyright (C) 2009 O.S. Systems Softwares Ltda.
|
3
|
+
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as
|
6
|
+
# published by the Free Software Foundation, either version 3 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
|
18
|
+
# e-mail: contato@ossystems.com.br
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
21
|
+
|
22
|
+
class GetSerialTest < Test::Unit::TestCase
|
23
|
+
def test_get_REP_serial_number
|
24
|
+
ip = ENV["IP"]
|
25
|
+
t = TimeClock.new(ip, 3000, 1)
|
26
|
+
|
27
|
+
puts "Retrieving serial number from '#{ip}'..."
|
28
|
+
serial = t.get_serial_number
|
29
|
+
puts "Received: " + serial.inspect
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
2
|
+
# Copyright (C) 2009 O.S. Systems Softwares Ltda.
|
3
|
+
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as
|
6
|
+
# published by the Free Software Foundation, either version 3 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
|
18
|
+
# e-mail: contato@ossystems.com.br
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
21
|
+
|
22
|
+
class RecordGetTest < Test::Unit::TestCase
|
23
|
+
def test_get_record_id
|
24
|
+
ip = ENV["IP"]
|
25
|
+
t = TimeClock.new(ip, 3000, 1)
|
26
|
+
|
27
|
+
time = DateTime.civil(2011,2,15,9)
|
28
|
+
puts "Retrieving data from '#{ip}'..."
|
29
|
+
payload = t.get_record_id(time)
|
30
|
+
puts "Received: " + payload.inspect
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
2
|
+
# Copyright (C) 2009 O.S. Systems Softwares Ltda.
|
3
|
+
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as
|
6
|
+
# published by the Free Software Foundation, either version 3 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Rua Clóvis Gularte Candiota 132, Pelotas-RS, Brasil.
|
18
|
+
# e-mail: contato@ossystems.com.br
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
21
|
+
|
22
|
+
class TimeTest < Test::Unit::TestCase
|
23
|
+
def test_get_set_time
|
24
|
+
ip = ENV["IP"]
|
25
|
+
t = TimeClock.new(ip, 3000, 1)
|
26
|
+
|
27
|
+
puts "Retrieving time from '#{ip}'..."
|
28
|
+
original_time_array = t.get_time
|
29
|
+
original_time = original_time_array[0]
|
30
|
+
difference = (Time.now - original_time).truncate
|
31
|
+
puts "Received: "
|
32
|
+
puts " Time: " + original_time_array[0].to_s
|
33
|
+
puts " DST Start: " + original_time_array[1].to_s
|
34
|
+
puts " DST End: " + original_time_array[2].to_s
|
35
|
+
|
36
|
+
puts "\nSetting time to tomorrow..."
|
37
|
+
new_time = change_time(original_time_array[0], :day, 1)
|
38
|
+
t.set_time(new_time).to_s
|
39
|
+
new_array = t.get_time
|
40
|
+
puts "Received: "
|
41
|
+
puts " Time: " + new_array[0].to_s
|
42
|
+
puts " DST Start: " + new_array[1].to_s
|
43
|
+
puts " DST End: " + new_array[2].to_s
|
44
|
+
|
45
|
+
puts "\nSetting time to tomorrow and with DST starting one month earlier and ending one month after..."
|
46
|
+
new_time = change_time(original_time_array[0], :day, 1)
|
47
|
+
dst_start = change_time(original_time_array[0], :month, 1)
|
48
|
+
dst_end = change_time(original_time_array[0], :month, 1)
|
49
|
+
t.set_time(new_time, dst_start, dst_end).to_s
|
50
|
+
new_array = t.get_time
|
51
|
+
puts "Received: "
|
52
|
+
puts " Time: " + new_array[0].to_s
|
53
|
+
puts " DST Start: " + new_array[1].to_s
|
54
|
+
puts " DST End: " + new_array[2].to_s
|
55
|
+
|
56
|
+
puts "\nRestoring time..."
|
57
|
+
new_time = Time.now
|
58
|
+
dst_start = original_time_array[1]
|
59
|
+
dst_end = original_time_array[2]
|
60
|
+
puts "Received: " + t.set_time(new_time, dst_start, dst_end).to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def change_time(time, time_part, difference)
|
65
|
+
year, month, day, hour, minute, second = [time.year, time.month, time.day, time.hour, time.min, time.sec]
|
66
|
+
case time_part
|
67
|
+
when :year
|
68
|
+
year += difference.to_i
|
69
|
+
when :month
|
70
|
+
month += difference.to_i
|
71
|
+
when :day
|
72
|
+
day += difference.to_i
|
73
|
+
when :hour
|
74
|
+
hour += difference.to_i
|
75
|
+
when :minute
|
76
|
+
minute += difference.to_i
|
77
|
+
when :second
|
78
|
+
second += difference.to_i
|
79
|
+
else
|
80
|
+
raise "unknow time part '#{time_part}'"
|
81
|
+
end
|
82
|
+
Time.local(year,month,day,hour,minute)
|
83
|
+
end
|
84
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
3
|
+
# Copyright (C) 2009 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
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'test/unit'
|
25
|
+
require 'time_clock'
|
data/test/time_clock.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Controle de Horas - Sistema para gestão de horas trabalhadas
|
3
|
+
# Copyright (C) 2009 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 File.dirname(__FILE__) + '/../test_helper'
|
22
|
+
|
23
|
+
class MockupTest < Test::Unit::TestCase
|
24
|
+
# load the mockup
|
25
|
+
def setup
|
26
|
+
load 'orion6_rep/mockup.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
# unload the mockup
|
30
|
+
def teardown
|
31
|
+
load 'orion6_rep.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_set_time
|
35
|
+
time = Time.now
|
36
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
37
|
+
tc.set_time time
|
38
|
+
assert_equal [time, nil, nil], tc.get_time
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_get_set_employer
|
42
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
43
|
+
company_name = "Super Company"
|
44
|
+
company_location = "FOOBAR St."
|
45
|
+
document_type = :cnpj
|
46
|
+
document_number = 12345678901234
|
47
|
+
cei_number = 12345
|
48
|
+
tc.set_employer company_name, company_location, document_type, document_number, cei_number
|
49
|
+
assert_equal({:company_name => company_name, :company_location => company_location, :document_type => document_type, :document_number => document_number, :cei_number => cei_number}, tc.get_employer)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_get_set_employees
|
53
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
54
|
+
assert_equal 0, tc.get_employees_quantity
|
55
|
+
assert tc.get_employees.empty?
|
56
|
+
assert tc.get_employees(0).empty?
|
57
|
+
assert tc.get_employees(1).empty?
|
58
|
+
assert tc.get_employees(1000).empty?
|
59
|
+
tc.set_employee(:add, 1234, 12345678, "Fulano de Tal")
|
60
|
+
assert_equal 1, tc.get_employees_quantity
|
61
|
+
assert_equal([{:registration => 1234, :pis_number => 12345678, :name => "Fulano de Tal"}], tc.get_employees)
|
62
|
+
tc.set_employee(:edit, 1234, 123456789, "Fulano de Tel")
|
63
|
+
assert_equal 1, tc.get_employees_quantity
|
64
|
+
assert_equal([{:registration => 1234, :pis_number => 123456789, :name => "Fulano de Tel"}], tc.get_employees)
|
65
|
+
tc.set_employee(:add, 12345, 1234567, "Ciclano de Tal")
|
66
|
+
assert_equal 2, tc.get_employees_quantity
|
67
|
+
assert_equal([{:registration => 1234, :pis_number => 123456789, :name => "Fulano de Tel"}, {:registration => 12345, :pis_number => 1234567, :name => "Ciclano de Tal"}], tc.get_employees)
|
68
|
+
assert_equal([{:registration => 1234, :pis_number => 123456789, :name => "Fulano de Tel"}, {:registration => 12345, :pis_number => 1234567, :name => "Ciclano de Tal"}], tc.get_employees(1000))
|
69
|
+
tc.set_employee(:remove, 12345, 1234567, "Ciclano de Tal")
|
70
|
+
assert_equal 1, tc.get_employees_quantity
|
71
|
+
assert_equal([{:registration => 1234, :pis_number => 123456789, :name => "Fulano de Tel"}], tc.get_employees)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_get_set_ip
|
75
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
76
|
+
tc.change_ip("0.0.0.1")
|
77
|
+
assert_equal "0.0.0.1", Orion6Rep::Mockup.mock_ip
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_get_set_ip
|
81
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
82
|
+
tc.change_ip("0.0.0.1")
|
83
|
+
assert_equal "0.0.0.1", Orion6Rep::Mockup.mock_ip
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_get_record_id
|
87
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
88
|
+
parser = load_afd_file_fixture
|
89
|
+
tc.set_records parser
|
90
|
+
assert_equal 6, tc.get_record_id(Time.local 2011,2,11,17,22)
|
91
|
+
assert_equal 6, tc.get_record_id(Time.local 2011,2,11,17,23)
|
92
|
+
assert_equal 7, tc.get_record_id(Time.local 2011,2,11,17,24)
|
93
|
+
assert_nil tc.get_record_id(Time.local 2035,2,11,17,23)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_get_records
|
97
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
98
|
+
parser = load_afd_file_fixture
|
99
|
+
tc.set_records parser
|
100
|
+
tc.set_employer "Super Company", "FOOBAR St.", :cnpj, 12345678901234, 12345
|
101
|
+
parser = tc.get_records
|
102
|
+
assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9],
|
103
|
+
parser.records.collect{|t| t.line_id})
|
104
|
+
assert !parser.header.nil?
|
105
|
+
assert !parser.trailer.nil?
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_get_records_specifing_id
|
109
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
110
|
+
parser = load_afd_file_fixture
|
111
|
+
tc.set_records parser
|
112
|
+
tc.set_employer "Super Company", "FOOBAR St.", :cnpj, 12345678901234, 12345
|
113
|
+
parser = tc.get_records(5)
|
114
|
+
assert_equal([5, 6, 7, 8, 9],
|
115
|
+
parser.records.collect{|t| t.line_id})
|
116
|
+
assert !parser.header.nil?
|
117
|
+
assert !parser.trailer.nil?
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_detect_reps
|
121
|
+
assert_equal({}, TimeClock.detect_reps)
|
122
|
+
detection_data = {"eth0" => {"123.123.123.123" => {:port => 12345, :rep_data => "abcdata"}}}
|
123
|
+
Orion6Rep::Mockup.mock_detection_data = detection_data
|
124
|
+
assert_equal detection_data, TimeClock.detect_reps
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_on_communication_success
|
128
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
129
|
+
assert !TimeClock.instance_methods(false).include?(:on_communication_success)
|
130
|
+
tc.set_employer "Super Company", "FOOBAR St.", :cnpj, 12345678901234, 12345
|
131
|
+
|
132
|
+
TimeClock.class_eval do
|
133
|
+
attr_reader :last_communication_method
|
134
|
+
def on_communication_success(method)
|
135
|
+
@last_communication_method = method
|
136
|
+
end
|
137
|
+
end
|
138
|
+
assert TimeClock.instance_methods(false).include?(:on_communication_success)
|
139
|
+
tc = TimeClock.new "0.0.0.0", 0, 1
|
140
|
+
tc.set_employer "Super Company", "FOOBAR St.", :cnpj, 12345678901234, 12345
|
141
|
+
assert_equal :set_employer, tc.last_communication_method
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
def load_afd_file_fixture
|
146
|
+
parser = AfdParser.new(true)
|
147
|
+
file = File.open("test/afd_file", "r")
|
148
|
+
file.readlines.each_with_index do |line, index|
|
149
|
+
parser.parse_line(line, index)
|
150
|
+
end
|
151
|
+
file.close
|
152
|
+
return parser
|
153
|
+
end
|
154
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orion6_rep
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- O.S. Systems Softwares Ltda.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: afd_parser
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: system-getifaddrs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Use this gem to manage several features of the Henry Orion 6 eletronic
|
56
|
+
timeclocks, like report creation, user management, configuration etc.
|
57
|
+
email: contato@ossystems.com.br
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/orion6_rep.rb
|
63
|
+
- lib/orion6_rep/change_ip.rb
|
64
|
+
- lib/orion6_rep/clock_time.rb
|
65
|
+
- lib/orion6_rep/clock_time/get.rb
|
66
|
+
- lib/orion6_rep/clock_time/set.rb
|
67
|
+
- lib/orion6_rep/command.rb
|
68
|
+
- lib/orion6_rep/communication.rb
|
69
|
+
- lib/orion6_rep/detect_reps.rb
|
70
|
+
- lib/orion6_rep/employee_get.rb
|
71
|
+
- lib/orion6_rep/employee_quantity_get.rb
|
72
|
+
- lib/orion6_rep/employee_set.rb
|
73
|
+
- lib/orion6_rep/employer_get.rb
|
74
|
+
- lib/orion6_rep/employer_set.rb
|
75
|
+
- lib/orion6_rep/get_serial_number.rb
|
76
|
+
- lib/orion6_rep/interface.rb
|
77
|
+
- lib/orion6_rep/mockup.rb
|
78
|
+
- lib/orion6_rep/multi_message_command.rb
|
79
|
+
- lib/orion6_rep/record_id_get.rb
|
80
|
+
- lib/orion6_rep/records_get.rb
|
81
|
+
- lib/orion6_rep/version.rb
|
82
|
+
- test/afd_file
|
83
|
+
- test/external/detect_reps_test.rb
|
84
|
+
- test/external/employee_test.rb
|
85
|
+
- test/external/employer_test.rb
|
86
|
+
- test/external/get_serial_test.rb
|
87
|
+
- test/external/record_get_test.rb
|
88
|
+
- test/external/time_test.rb
|
89
|
+
- test/test_helper.rb
|
90
|
+
- test/time_clock.rb
|
91
|
+
- test/unit/mockup_test.rb
|
92
|
+
homepage: http://www.ossystems.com.br/
|
93
|
+
licenses: []
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.11
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Gem to manage Henry Orion 6 eletronic timeclocks
|
115
|
+
test_files:
|
116
|
+
- test/test_helper.rb
|
117
|
+
- test/unit/mockup_test.rb
|
118
|
+
- test/time_clock.rb
|
119
|
+
- test/external/record_get_test.rb
|
120
|
+
- test/external/detect_reps_test.rb
|
121
|
+
- test/external/employer_test.rb
|
122
|
+
- test/external/get_serial_test.rb
|
123
|
+
- test/external/time_test.rb
|
124
|
+
- test/external/employee_test.rb
|
125
|
+
- test/afd_file
|