easycard 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de65d5a1fa9046e9b85a468ce23da1c259b968cf
4
- data.tar.gz: c0c60ef9ea374f6957fa657dd4092dc7ee70565b
3
+ metadata.gz: 1e699f5c33a733444e21d720b923daa12ea09bd5
4
+ data.tar.gz: 7b2f2c8b21a5a2c76f6966b1ac1169b06ca256cc
5
5
  SHA512:
6
- metadata.gz: 602fdb29058772249ab6eb56b19bf43a21025f8b1ee6d8608ddb72f8ab89e0d1ec168fb6e0cbd742e8d9fec4e544f9089b45f393e71a2b079060bbc258cc7e54
7
- data.tar.gz: 5257b248199a25b517710f2421c5fd86f2e0bf1352457aa2c26556da2529fd3f218097d8ab5a6095b5d40cda859c10a75ea296642b1039a1ef80a6566f8f25fb
6
+ metadata.gz: 33d8fd29ba4dd7a1db76a17e36f0b7c2706eaf4ac66ee48e3616c664119e210199e923f005b908ac98c7b5c4ed5f891dcd47a72974eb070d29b5902fa92fc768
7
+ data.tar.gz: 8f6e9596dc352f99915f5489520bd6c9c912fa5c1bbbc9fb47bd57e92d11c0e91d1f367000edf2da23a9911a91e29663dc8ea76a6d818e29617da239df11345b
@@ -1,10 +1,9 @@
1
1
  module EasyCard
2
2
  module ColorString
3
- refine String do
4
- def bold; "\033[1m#{self}\033[22m" end
5
- def red; "\033[31m#{self}\033[0m" end
6
- def green; "\033[32m#{self}\033[0m" end
7
- def yellow; "\033[33m#{self}\033[0m" end
8
- end
3
+ module_function
4
+ def bold(str); "\033[1m#{str}\033[22m" end
5
+ def red(str); bold("\033[31m#{str}\033[0m") end
6
+ def green(str); bold("\033[32m#{str}\033[0m") end
7
+ def yellow(str); bold("\033[33m#{str}\033[0m") end
9
8
  end
10
9
  end
@@ -10,15 +10,13 @@ module EasyCard
10
10
  attr_reader :data, :raw_data, :parsed_data, :balance
11
11
  def_delegators :@data, :to_json, :to_yaml, :to_a
12
12
 
13
- using ColorString
14
-
15
13
  def self.normalize_record record
16
14
  type = case record[?T]
17
15
  when ?D then :withdrawal
18
16
  when ?U then :deposit
19
17
  when '罰款' then :fine
20
18
  when '查無交易資料' then raise EasyCard::NotFound, record[?T]
21
- else raise EasyCard::Error, "未知類型: #{record[?T]}"
19
+ else raise EasyCard::Error, "未知類型: #{record[?T]},#{record}"
22
20
  end
23
21
  record[?L].gsub!('<BR>', ?-)
24
22
  {type: type, datetime: record[?D], location: record[?L], balance: record[?A], amount: record[?Q]}
@@ -26,9 +24,9 @@ module EasyCard
26
24
 
27
25
  def self.type_text type
28
26
  case type
29
- when :withdrawal then '扣款'.red.bold
30
- when :deposit then '儲值'.green.bold
31
- when :fine then '罰款'.yellow.bold
27
+ when :withdrawal then EasyCard::ColorString.red('扣款')
28
+ when :deposit then EasyCard::ColorString.green('儲值')
29
+ when :fine then EasyCard::ColorString.yellow('罰款')
32
30
  end
33
31
  end
34
32
 
@@ -1,3 +1,3 @@
1
1
  module EasyCard
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easycard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jian Weihang
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '10.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '10.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.6'
27
41
  description: |
28
42
  台灣悠遊卡交易紀錄查詢工具,支援指令模式。
29
43
  A search tool for Taiwan EasyCard, supporting CLI mode.