wordwiki 0.2.0 → 0.2.3

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: 9495d04ebb634a952d767ce4bf34c95d635f37a1ae43b83d644c45c571aeb545
4
- data.tar.gz: 53e99fa5b036274aebdbc45b0960fe432a1005be5829ce9264504f1956afb5eb
3
+ metadata.gz: 23e00b98e49c86813af27f09ee880604c688b732a917dc47e0ac436061782028
4
+ data.tar.gz: 7f8da14d5fe1a54118069899c2074a2c3973438fbbcb6155c4f98cc7d71b20eb
5
5
  SHA512:
6
- metadata.gz: 3fab08cebd11119ee4f922be0a629c886c8aa46dac01b32eee8bb424dcd62e361b81cc61fd398433586c792deb670a82d670ed5c5d2916adce7c319cd76a94c5
7
- data.tar.gz: cec4d61cac4dce2a8e33e8ac88a1137c7c404dfb6fb3124fa432dfe0dac17db9f4f874c94ad4e6afb2dc176ea3a20acf13d6f16d46fdb3a369ce666cd75c62dd
6
+ metadata.gz: 63eb5c27170e8a8476ce91e9bf1a322efb7e82e4dd32e05658909178f70774d342cd73620c33df0e79ca3018cc1d6ab66f53190417908c7b0fa0db04c5371c9f
7
+ data.tar.gz: 3fc28cfea8e28fcd0794201c25f8959ce7c4a37bce4c72f5bdb2f4d25d411d24382950d9a0203f43392439b57fcca995867375ce5b69d3f1b32f3161dda79391
data/README.md CHANGED
@@ -19,13 +19,21 @@ Simple commandline based dictionary and wiki. Definitions and answers at your fi
19
19
  $ gem install wordwiki
20
20
  ```
21
21
 
22
- ```ruby
23
- require "wordwiki"
22
+ ## Basic Usage
23
+
24
+ To get a word definition, simply do:
25
+ ```
26
+ $ wordwiki define <word>
27
+ ```
28
+
29
+ For Help:
30
+ ```
31
+ $ wordwiki help
24
32
  ```
25
33
 
26
34
  ## Support
27
35
 
28
- If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/lovepreetkaul/wordwiki/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
36
+ If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/lovepreetkaul/wordwiki/issues/new) and I will do my best to provide a helpful answer.
29
37
 
30
38
  ## License
31
39
 
@@ -37,4 +45,4 @@ Everyone interacting in this project’s codebases, issue trackers, chat rooms a
37
45
 
38
46
  ## Contribution guide
39
47
 
40
- Pull requests are welcome!
48
+ Pull requests are welcome!
data/lib/wordwiki/cli.rb CHANGED
@@ -1,15 +1,19 @@
1
- require 'thor'
1
+ require "thor"
2
2
 
3
3
  module Wordwiki
4
4
  class CLI < Thor
5
5
  include Wordwiki
6
- class_option :verbose, :aliases => "-v"
6
+ class_option :verbose, aliases: "-v"
7
7
 
8
8
  desc "define WORD", "Get the definition for WORD"
9
9
  def define(word)
10
- #TODO Word validation
11
- puts get_definition(word)
10
+ validate(word)
11
+ puts definition(word)
12
+ end
13
+
14
+ desc "version", "Prints the version"
15
+ def version
16
+ puts VERSION
12
17
  end
13
-
14
18
  end
15
19
  end
@@ -1,3 +1,3 @@
1
1
  module Wordwiki
2
- FREE_DICTIONARY_URL = "https://api.dictionaryapi.dev/api/v2/entries/en"
2
+ FREE_DICTIONARY_URL = "https://api.dictionaryapi.dev/api/v2/entries/en/".freeze
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Wordwiki
2
- VERSION = "0.2.0".freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
data/lib/wordwiki.rb CHANGED
@@ -1,35 +1,51 @@
1
- require 'faraday'
2
- require 'json'
3
- require 'colorize'
1
+ require "faraday"
2
+ require "json"
3
+ require "colorize"
4
+ require "erb"
4
5
 
5
- require_relative "wordwiki/cli.rb"
6
- require_relative "wordwiki/version.rb"
7
- require_relative 'wordwiki/constants.rb'
6
+ require_relative 'wordwiki/cli'
7
+ require_relative 'wordwiki/version'
8
+ require_relative 'wordwiki/constants'
8
9
 
9
10
  module Wordwiki
10
- def get_definition(word)
11
- response = Faraday.get("#{FREE_DICTIONARY_URL}/#{word}")
12
- format_definition(response.body)
13
- end
11
+ # Implements define functionality
12
+ def definition(word)
13
+ url = FREE_DICTIONARY_URL + ERB::Util.url_encode(word)
14
+ response = Faraday.get(url)
15
+ return error_response(response) unless response.success?
16
+ format_definition(response.body)
17
+ end
18
+
19
+ private
20
+
21
+ # TODO: Word validation implementation
22
+ def validate(word)
23
+ word.match? /\w/ unless word.nil? or word.empty?
24
+ end
14
25
 
15
- private
26
+ def error_response(response)
27
+ bodyhash = JSON.parse(response.body)
28
+ formatted_output = ''
29
+ formatted_output << ":: ERROR #{response.status}\n"
30
+ formatted_output << ":: #{bodyhash['title']}\n"
31
+ end
16
32
 
17
- def format_definition(body)
18
- #TODO Colorize and format output
19
- #TODO Implement verbose mode
20
- bodyhash = JSON.parse(body)
21
- formatted_output = ""
22
- bodyhash.each do |word|
23
- formatted_output << ":: |- Word: #{word["word"]}\n"
24
- formatted_output << ":: |- Origin: #{word["origin"]}\n"
25
- formatted_output << ":: |- Definitions::>\n"
26
- word["meanings"].each do |meaning|
27
- meaning["definitions"].each do |definition|
28
- formatted_output << ":: |- #{definition["definition"]}\n"
29
- formatted_output << ":: Example: #{definition["example"]}\n"
30
- end
31
- end
33
+ def format_definition(body)
34
+ # TODO: Colorize and format output
35
+ # TODO Implement verbose mode
36
+ bodyhash = JSON.parse(body)
37
+ formatted_output = ""
38
+ bodyhash.each do |word|
39
+ formatted_output << ":: |- Word: #{word['word']}\n"
40
+ formatted_output << ":: |- Origin: #{word['origin']}\n"
41
+ formatted_output << ":: |- Definitions::>\n"
42
+ word["meanings"].each do |meaning|
43
+ meaning["definitions"].each do |definition|
44
+ formatted_output << ":: |- #{definition['definition']}\n"
45
+ formatted_output << ":: Example: #{definition['example']}\n"
32
46
  end
33
- formatted_output
47
+ end
34
48
  end
49
+ formatted_output
50
+ end
35
51
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovepreet
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-01 00:00:00.000000000 Z
11
+ date: 2022-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thor
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: colorize
42
+ name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -52,7 +52,147 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description:
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-ci
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: optparse
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '13.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '13.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.22.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.22.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-minitest
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.15.1
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.15.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-packaging
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.5.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.5.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-performance
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.11.5
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 1.11.5
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 0.6.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.6.0
195
+ description:
56
196
  email:
57
197
  - lovepreetkaul23@gmail.com
58
198
  executables:
@@ -75,7 +215,8 @@ metadata:
75
215
  changelog_uri: https://github.com/lovepreetkaul/wordwiki/releases
76
216
  source_code_uri: https://github.com/lovepreetkaul/wordwiki
77
217
  homepage_uri: https://github.com/lovepreetkaul/wordwiki
78
- post_install_message:
218
+ rubygems_mfa_required: 'true'
219
+ post_install_message:
79
220
  rdoc_options: []
80
221
  require_paths:
81
222
  - lib
@@ -83,15 +224,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
224
  requirements:
84
225
  - - ">="
85
226
  - !ruby/object:Gem::Version
86
- version: 2.6.0
227
+ version: 2.7.0
87
228
  required_rubygems_version: !ruby/object:Gem::Requirement
88
229
  requirements:
89
230
  - - ">="
90
231
  - !ruby/object:Gem::Version
91
232
  version: '0'
92
233
  requirements: []
93
- rubygems_version: 3.2.16
94
- signing_key:
234
+ rubygems_version: 3.2.9
235
+ signing_key:
95
236
  specification_version: 4
96
237
  summary: Commandline based dictionary and wiki.
97
238
  test_files: []