codic 0.0.4 → 0.0.5

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.
Files changed (4) hide show
  1. data/bin/codic +2 -5
  2. data/lib/codic.rb +3 -3
  3. data/lib/codic/version.rb +1 -1
  4. metadata +2 -2
data/bin/codic CHANGED
@@ -6,11 +6,8 @@ require 'codic/cli'
6
6
  module Codic
7
7
  class << self
8
8
  def search_or_suggest(word)
9
- begin
10
- Codic.display(Codic.search(word))
11
- rescue CodicError
12
- Codic.display(Codic.suggest(word, suggest_dic(word)))
13
- end
9
+ content = Codic.search(word) || Codic.suggest(word, suggest_dic(word))
10
+ Codic.display(content)
14
11
  end
15
12
 
16
13
  def suggest_dic(word)
@@ -9,8 +9,6 @@ require "json"
9
9
  module Codic
10
10
  URL_ROOT = "http://codic.jp"
11
11
 
12
- class CodicError < StandardError; end
13
-
14
12
  module ContentCushion
15
13
  def content
16
14
  ""
@@ -43,7 +41,7 @@ module Codic
43
41
  def search(word)
44
42
  raise ArgumentError, "word is empty" if word.gsub(/\s/, "") == ""
45
43
  @doc = Nokogiri::HTML(open(URI.encode("#{Codic::URL_ROOT}/search?q=#{word}")))
46
- raise CodicError, "Not Found" unless found?
44
+ return nil unless found?
47
45
 
48
46
  case entry_type
49
47
  when "english"
@@ -54,6 +52,8 @@ module Codic
54
52
  end
55
53
 
56
54
  def display(result)
55
+ return unless result
56
+
57
57
  case result[:type]
58
58
  when "english"
59
59
  unless result[:flections] == ""
@@ -1,3 +1,3 @@
1
1
  module Codic
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
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.4
4
+ version: 0.0.5
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-22 00:00:00.000000000 Z
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri