codic 0.0.2 → 0.0.3

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.
data/bin/codic CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'codic'
4
+ require 'codic/cli'
4
5
 
5
6
  module Codic
6
7
  class << self
@@ -23,13 +24,15 @@ module Codic
23
24
  end
24
25
 
25
26
  if ARGV.empty?
26
- while word = STDIN.gets
27
- Codic.search_or_suggest(word.chomp)
28
- puts "-"*60
29
- end
30
- elsif ARGV.size == 2 && ARGV[0] == "suggest"
27
+ Codic::CLI.start
28
+ elsif ARGV.size == 2
31
29
  word = ARGV[1].chomp
32
- Codic.display(Codic.suggest(word, Codic.suggest_dic(word)))
30
+ case word
31
+ when "search"
32
+ Codic.display(Codic.search(word))
33
+ when "suggest"
34
+ Codic.display(Codic.suggest(word, Codic.suggest_dic(word)))
35
+ end
33
36
  else
34
37
  Codic.search_or_suggest(ARGV[0])
35
38
  end
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_runtime_dependency 'nokogiri'
21
+ gem.add_runtime_dependency 'prompt'
21
22
  end
@@ -0,0 +1,25 @@
1
+ require 'prompt'
2
+
3
+ module Codic
4
+ class CLI
5
+ extend Prompt::DSL
6
+
7
+ command "suggest :word" do |word|
8
+ Codic.display(Codic.suggest(word, Codic.suggest_dic(word)))
9
+ end
10
+
11
+ command "search :word" do |word|
12
+ Codic.display(Codic.search(word))
13
+ end
14
+
15
+ command ":word" do |word|
16
+ Codic.search_or_suggest(word.chomp)
17
+ end
18
+
19
+ class << self
20
+ def start
21
+ Prompt::Console.start
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Codic
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: prompt
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: simple access codic via terminal
31
47
  email:
32
48
  - kei.kita2501@gmail.com
@@ -43,6 +59,7 @@ files:
43
59
  - bin/codic
44
60
  - codic.gemspec
45
61
  - lib/codic.rb
62
+ - lib/codic/cli.rb
46
63
  - lib/codic/version.rb
47
64
  homepage: https://github.com/kitak/codic
48
65
  licenses: []