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 +4 -4
- data/lib/easycard/color_string.rb +5 -6
- data/lib/easycard/response.rb +4 -6
- data/lib/easycard/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e699f5c33a733444e21d720b923daa12ea09bd5
|
4
|
+
data.tar.gz: 7b2f2c8b21a5a2c76f6966b1ac1169b06ca256cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d8fd29ba4dd7a1db76a17e36f0b7c2706eaf4ac66ee48e3616c664119e210199e923f005b908ac98c7b5c4ed5f891dcd47a72974eb070d29b5902fa92fc768
|
7
|
+
data.tar.gz: 8f6e9596dc352f99915f5489520bd6c9c912fa5c1bbbc9fb47bd57e92d11c0e91d1f367000edf2da23a9911a91e29663dc8ea76a6d818e29617da239df11345b
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module EasyCard
|
2
2
|
module ColorString
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
data/lib/easycard/response.rb
CHANGED
@@ -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 '扣款'
|
30
|
-
when :deposit then '儲值'
|
31
|
-
when :fine then '罰款'
|
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
|
|
data/lib/easycard/version.rb
CHANGED
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.
|
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: '
|
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: '
|
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.
|