jieshun-parking 0.6.0 → 0.6.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/jieshun/parking/data_center_client.rb +16 -1
- data/lib/jieshun/parking/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35a77584f90c94349799eb8ba1489c2d567a4f394cb11bd05f321c2b881593c7
|
4
|
+
data.tar.gz: f0ad2a2811a35bc67f6b4804bd30a9014e31bc4881d9256002b4c52b66b7b2b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89783f0a838b668dc8849ef997d9fe03a59c45479970a786f9a9a59432c1020279952cfe32510c9dad19fab3f61a60b33e318b096e23ff2486a145d3dd3eb381
|
7
|
+
data.tar.gz: 6f650550391e3bb33a523de19c8ca5828d4eb5548ad1e06a3638c06f4ee2329b2cc8d1916beb1ca41d32e3bf517475c10b5214286470c07ff7be1a62a83e99bf
|
@@ -34,10 +34,25 @@ module Jieshun
|
|
34
34
|
data_items = []
|
35
35
|
data_items << { filePath: file_path }
|
36
36
|
unify_call("/api/pic/picSearch", data_items.to_json) do |result|
|
37
|
-
|
37
|
+
image = result.body['dataItems'].first['image']
|
38
|
+
mime_type = detect_mime_type(image)
|
39
|
+
yield( { mime_type_prefix: "data:#{mime_type};base64,", content: image } )
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
def detect_mime_type(base64_content)
|
44
|
+
return "application/pdf" if content_matches?(base64_content, ['JVBERi0'])
|
45
|
+
return "image/gif" if content_matches?(base64_content, ['R0lGODdh', 'R0lGODlh'])
|
46
|
+
return "image/png" if content_matches?(base64_content, ['iVBORw0KGgo'])
|
47
|
+
return "image/jpg" if content_matches?(base64_content, ['/9j/'])
|
48
|
+
return "image/bmp" if content_matches?(base64_content, ['Qk'])
|
49
|
+
"application/octet-stream"
|
50
|
+
end
|
51
|
+
|
52
|
+
def content_matches?(base64_content, prefixes)
|
53
|
+
prefixes.any? { |prefix| base64_content.start_with?(prefix) }
|
54
|
+
end
|
55
|
+
|
41
56
|
def unify_call(api_path, data_items)
|
42
57
|
login_if_required do |auth_token|
|
43
58
|
ts = Time.now.strftime("%Y%m%d%H%M%S%L")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jieshun-parking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LCola
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|