credit-card-sms-parser 0.0.6 → 0.1.0
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 +4 -4
- data/.gitignore +3 -0
- data/Gemfile.lock +1 -1
- data/credit-card-sms-parser.gemspec +1 -1
- data/lib/credit_card_sms_parser.rb +13 -2
- data/test/test_credit_card_sms_parser.rb +35 -32
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39ba2660a8a5b6a4bc71144bf4031939ce420a39
|
4
|
+
data.tar.gz: ed5b877f984985f037d9a83ebd63463f699bade1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3ac1592a8d30faa13d0412c88616bfbf9810e4a2b3b4cba196aaf6f1e5dfdb6db329dbd780f6947738086df08af23b62bf748a3162bd32005973d609d75bc61
|
7
|
+
data.tar.gz: 4afa4feb58009d5e4207321f3ccb4ca25f72793911ad88072bf5cffeed3690c982a6a4e97756216e9bd58b1b72fb80465d46c5174fb22404027294bb83b4dacf
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'credit-card-sms-parser'
|
7
|
-
gem.version = '0.0
|
7
|
+
gem.version = '0.1.0'
|
8
8
|
gem.licenses = %w(MIT)
|
9
9
|
gem.authors = %w(Hanson Benjamin)
|
10
10
|
gem.email = %w(jehokim@live.com)
|
@@ -35,13 +35,24 @@ class KoreanCreditCardLexer < RLTK::Lexer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
module CreditCardSmsParser
|
38
|
-
|
38
|
+
CARD_MAP = {
|
39
|
+
'15776200' => '현대카드',
|
40
|
+
'18001111' => '하나카드',
|
41
|
+
'16449999' => '국민카드',
|
42
|
+
'15884000' => '농협BC카드',
|
43
|
+
}
|
44
|
+
|
45
|
+
def parse_sms(sms_message, phone_number = nil)
|
39
46
|
tokens = KoreanCreditCardLexer.lex(sms_message)
|
40
47
|
h = tokens.inject({}) do |memo, t|
|
41
48
|
memo[t.type] = t.value
|
42
49
|
memo
|
43
50
|
end
|
44
51
|
|
45
|
-
|
52
|
+
if phone_number
|
53
|
+
h.merge(card_company_name: CARD_MAP[phone_number])
|
54
|
+
end
|
55
|
+
|
56
|
+
h
|
46
57
|
end
|
47
58
|
end
|
@@ -9,7 +9,7 @@ class TestCreditCardSmsParser < Minitest::Test
|
|
9
9
|
# @hana_card = CreditCardSmsParser::HanaCard.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def test_hyundae_card
|
13
13
|
s = <<-eos
|
14
14
|
[Web발신]
|
15
15
|
[현대카드]-승인
|
@@ -18,16 +18,20 @@ class TestCreditCardSmsParser < Minitest::Test
|
|
18
18
|
마노핀익스프레스신림
|
19
19
|
누적:354,220원
|
20
20
|
eos
|
21
|
-
puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
|
22
21
|
|
22
|
+
assert_equal('마노핀익스프레스신림', parse_sms(s)[:SHOP])
|
23
|
+
end
|
23
24
|
|
25
|
+
def test_hana_card
|
24
26
|
s = <<-eos
|
25
27
|
[Web발신]
|
26
28
|
하나(6*8*)김*호님 04/06 15:26 씨유판교 일시불/3,500원/누적-4,645원
|
27
|
-
eos
|
29
|
+
eos
|
28
30
|
|
29
|
-
|
31
|
+
assert_equal('씨유판교', parse_sms(s)[:SHOP])
|
32
|
+
end
|
30
33
|
|
34
|
+
def test_kb_card
|
31
35
|
s = <<-eos
|
32
36
|
[Web발신]
|
33
37
|
KB국민카드 2*5*
|
@@ -36,10 +40,12 @@ KB국민카드 2*5*
|
|
36
40
|
2,200원
|
37
41
|
미니스톱판교점
|
38
42
|
누적 97,440원
|
39
|
-
eos
|
43
|
+
eos
|
40
44
|
|
41
|
-
|
45
|
+
assert_equal('미니스톱판교점', parse_sms(s)[:SHOP])
|
46
|
+
end
|
42
47
|
|
48
|
+
def test_kb_card
|
43
49
|
s = <<-eos
|
44
50
|
[Web발신]
|
45
51
|
삼성가족카드승인9785
|
@@ -47,46 +53,43 @@ eos
|
|
47
53
|
10,000원
|
48
54
|
일시불
|
49
55
|
소문난우동
|
50
|
-
eos
|
56
|
+
eos
|
57
|
+
|
58
|
+
assert_equal('소문난우동', parse_sms(s)[:SHOP])
|
51
59
|
|
52
|
-
|
60
|
+
s = <<-eos
|
61
|
+
[Web발신]
|
62
|
+
[KB]04/08 21:27
|
63
|
+
078501**554
|
64
|
+
주식회사개성
|
65
|
+
체크카드출금
|
66
|
+
13,000
|
67
|
+
eos
|
68
|
+
|
69
|
+
assert_equal('개성', parse_sms(s)[:SHOP])
|
70
|
+
end
|
53
71
|
|
72
|
+
def test_keb_hana_card
|
54
73
|
s = <<-eos
|
55
74
|
[Web발신]
|
56
|
-
|
75
|
+
KEB하나 박솔*님 4*6*
|
57
76
|
일시불 30,000원
|
58
77
|
(주)이니 03/23 09:58
|
59
|
-
누적 2,368,397원
|
60
|
-
eos
|
78
|
+
누적 2,368,397원
|
79
|
+
eos
|
61
80
|
|
62
|
-
|
81
|
+
assert_equal('이니', parse_sms(s)[:SHOP])
|
82
|
+
end
|
63
83
|
|
84
|
+
def test_city_bc_card
|
64
85
|
s = <<-eos
|
65
86
|
[체크.승인]
|
66
87
|
22,000원
|
67
88
|
씨티BC(1*9*)김*정님
|
68
89
|
01/23 12:34
|
69
90
|
매일식당
|
70
|
-
eos
|
71
|
-
|
72
|
-
puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
|
73
|
-
|
74
|
-
s = <<-eos
|
75
|
-
[Web발신]
|
76
|
-
[KB]04/08 21:27
|
77
|
-
078501**554
|
78
|
-
주식회사개성
|
79
|
-
체크카드출금
|
80
|
-
13,000
|
81
|
-
eos
|
82
|
-
|
83
|
-
puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
|
84
|
-
|
85
|
-
s = <<-eos
|
86
|
-
[Web발신]
|
87
|
-
하나(6*8*)김*호님 04/02 19:59 (주)보나 일시불/4,500원/누적-134,049원
|
88
|
-
eos
|
91
|
+
eos
|
89
92
|
|
90
|
-
|
93
|
+
assert_equal('매일식당', parse_sms(s)[:SHOP])
|
91
94
|
end
|
92
95
|
end
|