wordwiki 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/wordwiki +1 -1
- data/lib/wordwiki/cli.rb +5 -5
- data/lib/wordwiki/constants.rb +1 -1
- data/lib/wordwiki/version.rb +1 -1
- data/lib/wordwiki.rb +43 -27
- metadata +151 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3013bf00dfbcbb1b01f4600a5a3307d01edb76de0d6342309a3dc3e04123e97c
|
4
|
+
data.tar.gz: ea09e798336d9a0501602c4f9e65781aec75c0bace24d3afa86898a0d3c90a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7474b60e47729a45b1cd8e5cf8bde386634f960873778d78de0d7c6530487c27d8935ff962965849651f04986d084ff05b926f21b74d21c95f1d7d6634347e
|
7
|
+
data.tar.gz: 46d6d068f85eb792d76adc31597e4387a6c75e27f2711df75566aeef28b500c6df550a4825596682adc3a66413e23689788138fd9a26a28f05251472aa44a641
|
data/exe/wordwiki
CHANGED
data/lib/wordwiki/cli.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "thor"
|
2
2
|
|
3
3
|
module Wordwiki
|
4
4
|
class CLI < Thor
|
5
5
|
include Wordwiki
|
6
|
-
class_option :verbose, :
|
6
|
+
class_option :verbose, aliases: "-v"
|
7
|
+
class_option :version, aliases: "-V", type: :boolean, desc: "Prints the version"
|
7
8
|
|
8
9
|
desc "define WORD", "Get the definition for WORD"
|
9
10
|
def define(word)
|
10
|
-
|
11
|
-
puts
|
11
|
+
validate(word)
|
12
|
+
puts definition(word)
|
12
13
|
end
|
13
|
-
|
14
14
|
end
|
15
15
|
end
|
data/lib/wordwiki/constants.rb
CHANGED
data/lib/wordwiki/version.rb
CHANGED
data/lib/wordwiki.rb
CHANGED
@@ -1,35 +1,51 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "faraday"
|
2
|
+
require "json"
|
3
|
+
require "colorize"
|
4
|
+
require "erb"
|
4
5
|
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative 'wordwiki/constants
|
6
|
+
require_relative 'wordwiki/cli'
|
7
|
+
require_relative 'wordwiki/version'
|
8
|
+
require_relative 'wordwiki/constants'
|
8
9
|
|
9
10
|
module Wordwiki
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovepreet
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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
|
-
|
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
|
-
|
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.
|
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.
|
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: []
|