ctapi 0.2.2 → 0.2.3
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.
- data/CHANGES +9 -4
- data/{GPL → COPYING} +7 -7
- data/README +49 -0
- data/Rakefile +76 -57
- data/VERSION +1 -1
- data/{examples → bin}/cardinfo.rb +2 -2
- data/bin/ctsh.rb +21 -0
- data/ctapi.gemspec +31 -0
- data/doc-main.txt +39 -0
- data/ext/ctapicore.c +164 -163
- data/ext/extconf.rb +5 -2
- data/install.rb +9 -5
- data/lib/ctapi.rb +521 -560
- data/lib/ctapi/version.rb +8 -0
- data/tests/test.rb +36 -36
- metadata +68 -45
- data/README.en +0 -31
- data/examples/ctsh.rb +0 -10
- data/make_doc.rb +0 -6
data/tests/test.rb
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
$:.unshift 'lib'
|
5
|
+
$:.unshift '../lib'
|
4
6
|
require 'ctapi'
|
5
7
|
|
6
8
|
class TC_CTAPI < Test::Unit::TestCase
|
7
|
-
|
8
9
|
include CTAPI
|
9
|
-
|
10
|
+
CT = Cardterminal.init(PORT_COM1)
|
10
11
|
|
11
12
|
def test_preconditions
|
12
|
-
assert_instance_of(Cardterminal,
|
13
|
-
assert_instance_of(Cardterminal::Manufacturer,
|
14
|
-
assert(
|
15
|
-
assert_instance_of(Cardterminal::Card,
|
16
|
-
assert(
|
17
|
-
assert(
|
18
|
-
assert(
|
19
|
-
assert(
|
13
|
+
assert_instance_of(Cardterminal, CT)
|
14
|
+
assert_instance_of(Cardterminal::Manufacturer, CT.manufacturer)
|
15
|
+
assert(CT.card_inserted?)
|
16
|
+
assert_instance_of(Cardterminal::Card, CT.card)
|
17
|
+
assert(CT.card.atr_ok?)
|
18
|
+
assert(CT.card.memory_size >= 255) # I hope there is no smaller size
|
19
|
+
assert(CT.card.structure)
|
20
|
+
assert(CT.card.protocol)
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_read
|
23
|
-
assert(
|
24
|
-
assert(
|
25
|
-
assert(
|
26
|
-
assert(
|
27
|
-
old_cs =
|
28
|
-
|
29
|
-
assert(
|
30
|
-
assert(
|
31
|
-
assert(
|
32
|
-
assert(
|
33
|
-
|
24
|
+
assert(!CT.read(0, 0))
|
25
|
+
assert(CT.read(0, 255).size == 255)
|
26
|
+
assert(CT.read.size == CT.card.memory_size)
|
27
|
+
assert(CT.read(100).size == CT.card.memory_size - 100)
|
28
|
+
old_cs = CT.chunk_size
|
29
|
+
CT.chunk_size = 23
|
30
|
+
assert(!CT.read(0, 0))
|
31
|
+
assert(CT.read(0, 255).size == 255)
|
32
|
+
assert(CT.read.size == CT.card.memory_size)
|
33
|
+
assert(CT.read(100).size == CT.card.memory_size - 100)
|
34
|
+
CT.chunk_size = old_cs
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_write
|
37
38
|
data = (1..255).to_a
|
38
|
-
big = "A" *
|
39
|
-
assert(
|
40
|
-
assert(
|
41
|
-
assert_equal(data.pack("C*"),
|
42
|
-
assert(
|
43
|
-
assert_equal(
|
44
|
-
old_cs =
|
45
|
-
|
46
|
-
assert(
|
47
|
-
assert(
|
48
|
-
assert_equal(data.pack("C*"),
|
49
|
-
assert(
|
50
|
-
assert_equal(
|
51
|
-
|
39
|
+
big = "A" * CT.card.memory_size
|
40
|
+
assert(!CT.write(''))
|
41
|
+
assert(CT.write(data))
|
42
|
+
assert_equal(data.pack("C*"), CT.read(0, 255))
|
43
|
+
assert(CT.write(big))
|
44
|
+
assert_equal(CT.read, big)
|
45
|
+
old_cs = CT.chunk_size
|
46
|
+
CT.chunk_size = 23
|
47
|
+
assert(!CT.write(''))
|
48
|
+
assert(CT.write(data))
|
49
|
+
assert_equal(data.pack("C*"), CT.read(0, 255))
|
50
|
+
assert(CT.write(big))
|
51
|
+
assert_equal(CT.read, big)
|
52
|
+
CT.chunk_size = old_cs
|
52
53
|
end
|
53
|
-
|
54
54
|
end
|
55
55
|
# vim: set et sw=2 ts=2:
|
metadata
CHANGED
@@ -1,53 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.1
|
3
|
-
specification_version: 1
|
4
2
|
name: ctapi
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
author: Florian Frank
|
12
|
-
email: flori@ping.de
|
13
|
-
homepage: http://ctapi.rubyforge.org
|
14
|
-
rubyforge_project: ctapi
|
15
|
-
description: "These are Ruby bindings to a library that supports the Cardterminal-API (CTAPI) for chipcards. It should be possible to link this against any carddriver library that supports this standard, but I have actually only tested with libtowitoko."
|
16
|
-
autorequire: ctapi
|
17
|
-
default_executable:
|
4
|
+
version: 0.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florian Frank
|
8
|
+
autorequire:
|
18
9
|
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-26 00:00:00 +02:00
|
13
|
+
default_executable: ctsh.rb
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: |
|
17
|
+
These are Ruby bindings to a library that supports the Cardterminal-API (CTAPI)
|
18
|
+
for chipcards. It should be possible to link this against any carddriver
|
19
|
+
library that supports this standard, but I have actually only tested with
|
20
|
+
libtowitoko.
|
21
|
+
|
22
|
+
email: flori@ping.de
|
23
|
+
executables:
|
24
|
+
- cardinfo.rb
|
25
|
+
- ctsh.rb
|
26
|
+
extensions:
|
27
|
+
- ext/extconf.rb
|
28
|
+
extra_rdoc_files:
|
29
|
+
- doc-main.txt
|
30
|
+
files:
|
31
|
+
- CHANGES
|
32
|
+
- COPYING
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- bin/cardinfo.rb
|
37
|
+
- bin/ctsh.rb
|
38
|
+
- ctapi.gemspec
|
39
|
+
- ext/ctapicore.c
|
40
|
+
- ext/extconf.rb
|
41
|
+
- install.rb
|
42
|
+
- lib/ctapi.rb
|
43
|
+
- lib/ctapi/version.rb
|
44
|
+
- tests/test.rb
|
45
|
+
- doc-main.txt
|
19
46
|
has_rdoc: true
|
20
|
-
|
47
|
+
homepage: http://ctapi.rubyforge.org
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --main
|
53
|
+
- doc-main.txt
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
21
57
|
requirements:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
26
67
|
version:
|
27
|
-
platform: ruby
|
28
|
-
files:
|
29
|
-
- README.en
|
30
|
-
- CHANGES
|
31
|
-
- GPL
|
32
|
-
- examples
|
33
|
-
- Rakefile
|
34
|
-
- VERSION
|
35
|
-
- install.rb
|
36
|
-
- make_doc.rb
|
37
|
-
- ext
|
38
|
-
- lib
|
39
|
-
- tests
|
40
|
-
- examples/cardinfo.rb
|
41
|
-
- examples/ctsh.rb
|
42
|
-
- ext/ctapicore.c
|
43
|
-
- ext/extconf.rb
|
44
|
-
- lib/ctapi.rb
|
45
|
-
- tests/test.rb
|
46
|
-
test_files: []
|
47
|
-
rdoc_options: []
|
48
|
-
extra_rdoc_files: []
|
49
|
-
executables: []
|
50
|
-
extensions:
|
51
|
-
- ext/extconf.rb
|
52
68
|
requirements: []
|
53
|
-
|
69
|
+
|
70
|
+
rubyforge_project: ctapi
|
71
|
+
rubygems_version: 1.3.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Ruby extension for Chipcard Cardterminal-API (CTAPI)
|
75
|
+
test_files:
|
76
|
+
- tests/test.rb
|
data/README.en
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
Installation
|
2
|
-
============
|
3
|
-
|
4
|
-
Just type into the command line as root:
|
5
|
-
|
6
|
-
# ruby install.rb LIBRARYNAME
|
7
|
-
|
8
|
-
where LIBRARYNAME is the name of the ctapi driver library to use. If you want
|
9
|
-
to link against the towitoko library, this would be, e. g.,
|
10
|
-
|
11
|
-
# ruby install.rb towitoko
|
12
|
-
|
13
|
-
Documentation
|
14
|
-
=============
|
15
|
-
|
16
|
-
To generate the documentation in doc/ type:
|
17
|
-
$ ruby make_doc.rb
|
18
|
-
|
19
|
-
There is also an example of how to use this library in the examples
|
20
|
-
subdirectory.
|
21
|
-
|
22
|
-
Author
|
23
|
-
======
|
24
|
-
|
25
|
-
Florian Frank <flori@ping.de>
|
26
|
-
|
27
|
-
License
|
28
|
-
=======
|
29
|
-
|
30
|
-
GNU General Public License (GPL)
|
31
|
-
|
data/examples/ctsh.rb
DELETED