char_detector 0.1.1 → 0.1.2
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/Gemfile.lock +1 -1
- data/README.md +0 -5
- data/bin/char_detector +1 -13
- data/lib/char_detector/cli.rb +37 -0
- data/lib/char_detector/version.rb +1 -1
- data/lib/char_detector.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 812bbf7902155754e4632629400a6d6c1ce2e8c20ee33057c70fa0093d2b58b2
|
4
|
+
data.tar.gz: 32de51f941e5603a2d339641125d68a891c3b3c2dd22b33948e88b22a751277f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb1bf08eb9984f91f17ef1e08a8fb1c02d362c54bf9a418c121613ef37b62a65b5cae4c9e243f5b57beba1a3755da97e5b5923ec6dbee42a2d2d14d9197c8b31
|
7
|
+
data.tar.gz: 703e38057ceb2a41faa3afca1d65dd13c636a5f393ac3c7286936714ffa33aed7bc3cce0cad3e7c41e51d24a24f18d78a32dd46bf4fe840b607e6bb4083d40fa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,11 +31,6 @@ Ref: [ASCII table , ascii codes](https://theasciicode.com.ar/)
|
|
31
31
|
+ bundle gem char_detector
|
32
32
|
+ Test and fix and refactor
|
33
33
|
|
34
|
-
+ TODO refactor
|
35
|
-
+ TODO add features(If I have more requirements)
|
36
|
-
+ TODO [format output(refer to rubocop's output) Thanks Freebird](https://github.com/liijunwei/char_detector/issues/5)
|
37
|
-
+ TODO [Improve compatibility](https://github.com/liijunwei/char_detector/issues/4)
|
38
|
-
|
39
34
|
## Installation(WIP)
|
40
35
|
|
41
36
|
Add this line to your application's Gemfile:
|
data/bin/char_detector
CHANGED
@@ -29,16 +29,4 @@ OptionParser.new do |opts|
|
|
29
29
|
end
|
30
30
|
end.parse!
|
31
31
|
|
32
|
-
|
33
|
-
info[:file] = options[:file]
|
34
|
-
info[:result] = CharDetector::Engine.new(file: options[:file]).scan
|
35
|
-
|
36
|
-
unless info[:result].empty?
|
37
|
-
if options[:pretty]
|
38
|
-
jj info
|
39
|
-
else
|
40
|
-
puts info.to_json
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
exit 0
|
32
|
+
CharDetector::Cli.execute(options)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class CharDetector::Cli
|
2
|
+
def self.execute(options={})
|
3
|
+
new(options).run
|
4
|
+
end
|
5
|
+
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@options = options
|
10
|
+
|
11
|
+
if options[:file] && !File.exist?(options[:file])
|
12
|
+
warn("[fail] Can't find file: #{options[:file]}")
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if options.empty?
|
17
|
+
abort("[info] Pass -h for usage")
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
info = {}
|
24
|
+
info[:file] = options[:file]
|
25
|
+
info[:result] = CharDetector::Engine.new(file: options[:file]).scan
|
26
|
+
|
27
|
+
unless info[:result].empty?
|
28
|
+
if options[:pretty]
|
29
|
+
jj info
|
30
|
+
else
|
31
|
+
puts info.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
end
|
data/lib/char_detector.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: char_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lijunwei
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- image/Xnip2022-05-08_14-10-52.png
|
79
79
|
- image/Xnip2022-05-08_14-11-04.png
|
80
80
|
- lib/char_detector.rb
|
81
|
+
- lib/char_detector/cli.rb
|
81
82
|
- lib/char_detector/engine.rb
|
82
83
|
- lib/char_detector/version.rb
|
83
84
|
homepage: https://github.com/liijunwei/char_detector
|