ojad 0.0.1 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9bd49fd888f3b51311edb1024c3ac1214157467236ebf97bfb693a886622216
4
- data.tar.gz: a3c0c676cb31c63e606023258d3b6b31a494195d2ed5d6379aa61b9b1aadf9ce
3
+ metadata.gz: f60eabada133af27007812427975c8dcc7eac8f0f1c74ee0e42dff5b968c20ee
4
+ data.tar.gz: d409aa62676e1603fc437eeca502ea6bbc98673dc09c48d57f81bd0ad6aa9d6c
5
5
  SHA512:
6
- metadata.gz: 7f6cff41db7d42e6d3d48925a279763e578eff4526b0838a0e1255cd4b93d4bf2938e1254cb4637199267495a61dc5c1c0c6c26a8ea20780b88abe244fa1bd21
7
- data.tar.gz: f517b184df1cf232c049e8d288794f8e1416c3bb32afffc4a0e523de7cb5c236be2c7027ba0955ef94cf8b28bb9f19100029edb5499d279bca480e08b334577e
6
+ metadata.gz: c87627a5d3772cb2fd370d45db729f8ec7b67cb6169e0e071e6a945a1dc5be1466d7e06131faa55aed865fba90642ca244b1b60722f38916b9e8cdc052bd4db1
7
+ data.tar.gz: adc0d0c23b2fde8a5135b82afa48349e6880aee730ab1e6f71a31a96d4ff8b6d18b343a367dc9172606857fc744134257589ee10b12b28f7d0e57018ca6c0c0a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.2
4
+
5
+ - Improve output
6
+ - Fix nokogiri require in wrong place
7
+
3
8
  ## 0.0.1
4
9
 
5
10
  First release.
data/README.md CHANGED
@@ -7,7 +7,7 @@ A Ruby Client to interact with [OJAD][ojad].
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'ojad'
10
+ gem "ojad"
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -21,9 +21,20 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```
24
- ojad search くる
25
-
26
- 来る・来ます くる きます きて きた こない こなかった くれば こさせる こられる こい こられる こよう
24
+ $ ojad くる
25
+ Group: 来る・来ます
26
+ Dictionary: くる
27
+ Polite: きます
28
+ Te: きて
29
+ Ta: きた
30
+ Negative: こない
31
+ Past negative: こなかった
32
+ Ba: くれば
33
+ Causative: こさせる
34
+ Passive: こられる
35
+ Imperative: こい
36
+ Potential: こられる
37
+ Volitional: こよう
27
38
  ```
28
39
 
29
40
  ## Development
data/lib/ojad/cli.rb CHANGED
@@ -14,13 +14,17 @@ module OJAD
14
14
  end
15
15
 
16
16
  def start
17
- Result.new(response).to_human
17
+ $stdout.puts(result_for_human)
18
18
  end
19
19
 
20
20
  private
21
21
 
22
22
  attr_reader :arguments
23
23
 
24
+ def result_for_human
25
+ Result.new(response).to_human
26
+ end
27
+
24
28
  def response
25
29
  Client.call(arguments.first)
26
30
  end
data/lib/ojad/result.rb CHANGED
@@ -10,10 +10,7 @@ module OJAD
10
10
 
11
11
  def to_human
12
12
  if response.success?
13
- verbs.each do |verb|
14
- verb.to_human
15
- puts "-"*80
16
- end
13
+ verbs_for_human
17
14
  else
18
15
  error_message
19
16
  end
@@ -23,17 +20,23 @@ module OJAD
23
20
 
24
21
  attr_reader :response
25
22
 
23
+ LINE = "-"*80
24
+
26
25
  def html
27
26
  @_response_string ||= response.body.to_s
28
27
  end
29
28
 
29
+ def verbs_for_human
30
+ verbs.map(&:to_human).join(LINE)
31
+ end
32
+
30
33
  def verbs
31
34
  Verbs.new(html).to_a
32
35
  end
33
36
 
34
37
  def error_message
35
38
  "An error occurred. Please try again later.\n\n" \
36
- "Response body:\n\n#{response.body.to_s}" \
39
+ "Response body:\n\n#{response.body.to_s}"
37
40
  end
38
41
  end
39
42
  end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
4
-
5
3
  module OJAD
6
- class VerbPresenter
4
+ class Verb
7
5
  def initialize(document)
8
6
  @document = document
9
7
  end
10
8
 
11
9
  def to_human
12
- puts "Group: #{group}"
13
- puts "Dictionary: #{dictionary}"
14
- puts "Polite: #{polite}"
15
- puts "Te: #{te}"
16
- puts "Ta: #{ta}"
17
- puts "Negative: #{negative}"
18
- puts "Past negative: #{past_negative}"
19
- puts "Ba: #{ba}"
20
- puts "Causative: #{causative}"
21
- puts "Passive: #{passive}"
22
- puts "Imperative: #{imperative}"
23
- puts "Potential: #{potential}"
24
- puts "Volitional: #{volitional}"
10
+ "Group: #{group}\n" \
11
+ "Dictionary: #{dictionary}\n" \
12
+ "Polite: #{polite}\n" \
13
+ "Te: #{te}\n" \
14
+ "Ta: #{ta}\n" \
15
+ "Negative: #{negative}\n" \
16
+ "Past negative: #{past_negative}\n" \
17
+ "Ba: #{ba}\n" \
18
+ "Causative: #{causative}\n" \
19
+ "Passive: #{passive}\n" \
20
+ "Imperative: #{imperative}\n" \
21
+ "Potential: #{potential}\n" \
22
+ "Volitional: #{volitional}\n"
25
23
  end
26
24
 
27
25
  private
data/lib/ojad/verbs.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "verb_presenter"
3
+ require "nokogiri"
4
+
5
+ require_relative "verb"
4
6
 
5
7
  module OJAD
6
8
  class Verbs
@@ -10,7 +12,7 @@ module OJAD
10
12
 
11
13
  def to_a
12
14
  verbs.map do |verb_document|
13
- VerbPresenter.new(verb_document)
15
+ Verb.new(verb_document)
14
16
  end
15
17
  end
16
18
 
data/lib/ojad/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OJAD
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ojad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito Fatas
@@ -119,7 +119,7 @@ files:
119
119
  - lib/ojad/client.rb
120
120
  - lib/ojad/response.rb
121
121
  - lib/ojad/result.rb
122
- - lib/ojad/verb_presenter.rb
122
+ - lib/ojad/verb.rb
123
123
  - lib/ojad/verbs.rb
124
124
  - lib/ojad/version.rb
125
125
  - ojad.gemspec