credit-card-sms-parser 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20734c5e150cdf48a2e3fb61d4fbfdfe4881e01f
4
- data.tar.gz: 3230283a766dab34dd66f3fbfbb00029f0e0b90f
3
+ metadata.gz: 39ba2660a8a5b6a4bc71144bf4031939ce420a39
4
+ data.tar.gz: ed5b877f984985f037d9a83ebd63463f699bade1
5
5
  SHA512:
6
- metadata.gz: f3fa1d33552a3769621ed5c61016f67119e25fe5520909879562330a4875c61eaaba69cefc6435a6dae0cbcb042a24a6706811f1974881655181f99eba352db7
7
- data.tar.gz: 440b99c08d7e8aaf1020c188ece9784f65a1be9b793bb4bf5e83e1a79a1c6b4c21c4868bf0998ab6578a085f0bf8deb7d8a17b2c02317a7be529498f6e363b69
6
+ metadata.gz: e3ac1592a8d30faa13d0412c88616bfbf9810e4a2b3b4cba196aaf6f1e5dfdb6db329dbd780f6947738086df08af23b62bf748a3162bd32005973d609d75bc61
7
+ data.tar.gz: 4afa4feb58009d5e4207321f3ccb4ca25f72793911ad88072bf5cffeed3690c982a6a4e97756216e9bd58b1b72fb80465d46c5174fb22404027294bb83b4dacf
data/.gitignore CHANGED
@@ -31,3 +31,6 @@ tmp
31
31
 
32
32
  # Exclude CTags
33
33
  /tags
34
+
35
+ vendor/
36
+ pkg/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- credit-card-sms-parser (0.0.6)
4
+ credit-card-sms-parser (0.1.0)
5
5
  rltk
6
6
 
7
7
  GEM
@@ -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.6'
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
- def parse_sms(phone_number, sms_message)
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
- h.merge(card_name: phone_number)
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 test_parse
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
- puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
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
- puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
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
- puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
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
- "KEB하나 박솔*님 4*6*
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
- puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
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
- puts "SHOP: #{parse_sms('111', s)[:SHOP]}"
93
+ assert_equal('매일식당', parse_sms(s)[:SHOP])
91
94
  end
92
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credit-card-sms-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanson