char_detector 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: bee172d7cfc38714ed519dfa6f709ddf52d1ffdc0c40bc23cf0480b545d865e7
4
- data.tar.gz: 636ba79305d27b11734a4e10644cf226364f0464423a4c4be9b6f75e50829426
3
+ metadata.gz: 812bbf7902155754e4632629400a6d6c1ce2e8c20ee33057c70fa0093d2b58b2
4
+ data.tar.gz: 32de51f941e5603a2d339641125d68a891c3b3c2dd22b33948e88b22a751277f
5
5
  SHA512:
6
- metadata.gz: 9566d3608f20d782b16e5abc63252c98efebae4436371a730fa47a4417f6dac4e91781f7287febff42793b7ffb5771a0a0f19b2d2bd55437a78e7077527b5182
7
- data.tar.gz: c16121f0a6b0ec8fc277d718bee151ff34901870a6506c9226fd71231513bbd8e9ac68d6f1834180cd7209d0686fd3b6842bd02ecd1e2d3a45867888b70c922e
6
+ metadata.gz: fb1bf08eb9984f91f17ef1e08a8fb1c02d362c54bf9a418c121613ef37b62a65b5cae4c9e243f5b57beba1a3755da97e5b5923ec6dbee42a2d2d14d9197c8b31
7
+ data.tar.gz: 703e38057ceb2a41faa3afca1d65dd13c636a5f393ac3c7286936714ffa33aed7bc3cce0cad3e7c41e51d24a24f18d78a32dd46bf4fe840b607e6bb4083d40fa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- char_detector (0.1.1)
4
+ char_detector (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- info = {}
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
@@ -1,3 +1,3 @@
1
1
  module CharDetector
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/char_detector.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "char_detector/version"
2
2
  require "char_detector/engine"
3
+ require "char_detector/cli"
3
4
 
4
5
  module CharDetector
5
6
  class Error < StandardError; end
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.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