magnet 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/magnet/parser.rb +1 -1
- data/lib/magnet/version.rb +1 -1
- data/test/magnet/parser_test.rb +91 -0
- metadata +15 -7
- checksums.yaml +0 -7
data/lib/magnet/parser.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Magnet
|
2
2
|
class Parser
|
3
3
|
TRACKS = {
|
4
|
-
1 => /\A%(?<format>[A-Z])(?<pan>[0-9 ]{1,19})\^(?<name>[A-Za-z0-9
|
4
|
+
1 => /\A%(?<format>[A-Z])(?<pan>[0-9 ]{1,19})\^(?<name>[A-Za-z0-9.'&_!@#\$\%*\\~,"\-\/ *]{0,26})\^(?<expiration>\d{4}|\^)(?<service_code>\d{3}|\^)(?<discretionary_data>[^\?]*)\?\Z/,
|
5
5
|
2 => /\A;(?<format>[A-Z])(?<pan>[0-9 ]{1,19})=(?<expiration>\d{4}|=)(?<service_code>\d{3}|=)(?<discretionary_data>[^\?]*)\?\Z/
|
6
6
|
}.freeze
|
7
7
|
|
data/lib/magnet/version.rb
CHANGED
data/test/magnet/parser_test.rb
CHANGED
@@ -88,10 +88,101 @@ describe Magnet::Parser do
|
|
88
88
|
assert_equal "HAMMOND/G ", attributes[:name]
|
89
89
|
end
|
90
90
|
|
91
|
+
it "should parse track data with no name" do
|
92
|
+
attributes = @parser.parse("%B4717270000000000^^0000000000000000000000000000000?")
|
93
|
+
|
94
|
+
assert_equal "", attributes[:name]
|
95
|
+
end
|
96
|
+
|
91
97
|
it "should parse track data with numbers in the name" do
|
92
98
|
attributes = @parser.parse("%B4717270000000000^LLC/TESTING SCENTS5^0000000000000000000000000000000?")
|
93
99
|
|
94
100
|
assert_equal "LLC/TESTING SCENTS5", attributes[:name]
|
95
101
|
end
|
102
|
+
|
103
|
+
it "should parse track data with single quotes in the name" do
|
104
|
+
attributes = @parser.parse("%B4717270000000000^JIM/O'CONNOR^0000000000000000000000000000000?")
|
105
|
+
|
106
|
+
assert_equal "JIM/O'CONNOR", attributes[:name]
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should parse track data with double quotes in the name" do
|
110
|
+
attributes = @parser.parse('%B4717270000000000^JIM/O"CONNOR^0000000000000000000000000000000?')
|
111
|
+
|
112
|
+
assert_equal 'JIM/O"CONNOR', attributes[:name]
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should parse track data with backslash in the name" do
|
116
|
+
attributes = @parser.parse('%B4717270000000000^JIM/O\CONNOR^0000000000000000000000000000000?')
|
117
|
+
|
118
|
+
assert_equal 'JIM/O\CONNOR', attributes[:name]
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should parse track data with dashes in the name" do
|
122
|
+
attributes = @parser.parse("%B4717270000000000^ALISON-MAYNE/B^0000000000000000000000000000000?")
|
123
|
+
|
124
|
+
assert_equal "ALISON-MAYNE/B", attributes[:name]
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should parse track data with underscore in the name" do
|
128
|
+
attributes = @parser.parse("%B4717270000000000^ALISON_MAYNE/B^0000000000000000000000000000000?")
|
129
|
+
|
130
|
+
assert_equal "ALISON_MAYNE/B", attributes[:name]
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should parse track data with ampersands in the name" do
|
134
|
+
attributes = @parser.parse("%B4717270000000000^ALISON&MAYNE/B^0000000000000000000000000000000?")
|
135
|
+
|
136
|
+
assert_equal "ALISON&MAYNE/B", attributes[:name]
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should parse track data with exclamation mark in the name" do
|
140
|
+
attributes = @parser.parse("%B4717270000000000^ALISON!MAYNE/B^0000000000000000000000000000000?")
|
141
|
+
|
142
|
+
assert_equal "ALISON!MAYNE/B", attributes[:name]
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should parse track data with at sign in the name" do
|
146
|
+
attributes = @parser.parse("%B4717270000000000^ALISON@MAYNE/B^0000000000000000000000000000000?")
|
147
|
+
|
148
|
+
assert_equal "ALISON@MAYNE/B", attributes[:name]
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should parse track data with pound sign in the name" do
|
152
|
+
attributes = @parser.parse("%B4717270000000000^ALISON#{}MAYNE/B^0000000000000000000000000000000?")
|
153
|
+
|
154
|
+
assert_equal "ALISON#{}MAYNE/B", attributes[:name]
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should parse track data with dollar sign in the name" do
|
158
|
+
attributes = @parser.parse("%B4717270000000000^ALISON$MAYNE/B^0000000000000000000000000000000?")
|
159
|
+
|
160
|
+
assert_equal "ALISON$MAYNE/B", attributes[:name]
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should parse track data with percent in the name" do
|
164
|
+
attributes = @parser.parse("%B4717270000000000^ALISON%MAYNE/B^0000000000000000000000000000000?")
|
165
|
+
|
166
|
+
assert_equal "ALISON%MAYNE/B", attributes[:name]
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should parse track data with star in the name" do
|
170
|
+
attributes = @parser.parse("%B4717270000000000^ALISON*MAYNE/B^0000000000000000000000000000000?")
|
171
|
+
|
172
|
+
assert_equal "ALISON*MAYNE/B", attributes[:name]
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should parse track data with tilda in the name" do
|
176
|
+
attributes = @parser.parse("%B4717270000000000^ALISON~MAYNE/B^0000000000000000000000000000000?")
|
177
|
+
|
178
|
+
assert_equal "ALISON~MAYNE/B", attributes[:name]
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should parse track data with comma in the name" do
|
182
|
+
attributes = @parser.parse("%B4717270000000000^ALISON,MAYNE/B^0000000000000000000000000000000?")
|
183
|
+
|
184
|
+
assert_equal "ALISON,MAYNE/B", attributes[:name]
|
185
|
+
end
|
186
|
+
|
96
187
|
end
|
97
188
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magnet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Samuel Kadolph
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: minitest
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: mocha
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -68,26 +75,27 @@ files:
|
|
68
75
|
- test/magnet/parser_test.rb
|
69
76
|
homepage: http://samuelkadolph.github.com/magnet/
|
70
77
|
licenses: []
|
71
|
-
metadata: {}
|
72
78
|
post_install_message:
|
73
79
|
rdoc_options: []
|
74
80
|
require_paths:
|
75
81
|
- lib
|
76
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
77
84
|
requirements:
|
78
|
-
- - '>='
|
85
|
+
- - ! '>='
|
79
86
|
- !ruby/object:Gem::Version
|
80
87
|
version: 1.9.2
|
81
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
82
90
|
requirements:
|
83
|
-
- - '>='
|
91
|
+
- - ! '>='
|
84
92
|
- !ruby/object:Gem::Version
|
85
93
|
version: '0'
|
86
94
|
requirements: []
|
87
95
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
96
|
+
rubygems_version: 1.8.23
|
89
97
|
signing_key:
|
90
|
-
specification_version:
|
98
|
+
specification_version: 3
|
91
99
|
summary: magnet is a library for decoding the track data on magnetic stripe cards.
|
92
100
|
test_files:
|
93
101
|
- test/magnet/card_test.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 06cd197b08c088af98022b59c01defacb98d6ebb
|
4
|
-
data.tar.gz: 2cede75781b0f8294cfd392019653a6e0f74bead
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 077fe3412f76cb26975809d547b09b7af80543553ec7c715f267b2929884f3cf0ba8255290b4bf14c9c6f652ce9b77e02195f81e98222ef32b66a3dc8651ff59
|
7
|
-
data.tar.gz: e6b72e3b91464bda0969317c37daca4a15e773b8744d77fa5d8bb8c660af4a04d0e4ef6b06ca9e7fd0de2bc71544c1c1526e6464252a8b6b6d8d1b8407dde976
|