lyracyst 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/bin/lyracyst +170 -267
- data/lib/lyracyst.rb +170 -267
- data/lib/lyracyst/onelook.rb +61 -0
- data/lib/lyracyst/rhymebrain.rb +0 -1
- data/lib/lyracyst/rhymebrain/combine.rb +8 -13
- data/lib/lyracyst/rhymebrain/info.rb +18 -29
- data/lib/lyracyst/rhymebrain/rhyme.rb +6 -11
- data/lib/lyracyst/rhymebrain/word.rb +3 -3
- data/lib/lyracyst/urban.rb +18 -24
- data/lib/lyracyst/version.rb +1 -1
- data/lib/lyracyst/wordnik.rb +0 -2
- data/lib/lyracyst/wordnik/define.rb +15 -18
- data/lib/lyracyst/wordnik/example.rb +10 -13
- data/lib/lyracyst/wordnik/hyphen.rb +10 -19
- data/lib/lyracyst/wordnik/origin.rb +14 -20
- data/lib/lyracyst/wordnik/phrase.rb +8 -13
- data/lib/lyracyst/wordnik/pronounce.rb +9 -14
- data/lib/lyracyst/wordnik/relate.rb +12 -17
- data/lib/lyracyst/wordnik/word.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7751d12d85b26befa84563c35152c9275f2603e3
|
4
|
+
data.tar.gz: 719eead3fb8cf83e71643931abf11155ab8d657b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d43324ff46751095c76d121dfd47956659826c03bae613df1692cd5db92dd5f74a7a3efab892ffba905843999821b8e0f867f7d7a215fc92deaf7e32441e48
|
7
|
+
data.tar.gz: 4113d612eb6cb24ba000e0e23023b15956c46cfc2f059c7a0fa5ea2233e17c4ff27324f44395ab851159bf87d9e744e2f1d9d856aa1eba99fb7c0d99f7a2dd91
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
Changelog
|
2
2
|
===
|
3
3
|
|
4
|
+
Version **1.0.0** - Subcommands, More options, Onelook
|
5
|
+
- Added word info from [Onelook.com](http://www.onelook.com/?c=faq)
|
6
|
+
- Added more CLI options
|
7
|
+
- Shortened command names and added subcommands
|
8
|
+
|
9
|
+
Version 0.0.9 - File export, Urban Dictionary, Code Climate
|
10
|
+
- Added definitions from Urban Dictionary
|
11
|
+
- Added JSON & XML export
|
12
|
+
- Restructured code to improve climate
|
13
|
+
|
4
14
|
Version 0.0.8 - Major Improvements
|
5
15
|
- The biggest milestone yet!
|
6
16
|
- Most Wordnik search functions now work
|
data/bin/lyracyst
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
# %w(curb em-synchrony em-http eventmachine excon httpclient httpi net/http/persistent rainbow).map { |lib| require lib }
|
4
|
+
# %w(json/ext json/pure multi_json oj yajl).map { |lib| require lib }
|
5
|
+
# %w(libxml multi_xml ox rexml/document).map { |lib| require lib }
|
6
6
|
require 'gli'
|
7
|
+
require 'lyracyst/onelook'
|
7
8
|
require 'lyracyst/rhymebrain'
|
8
9
|
require 'lyracyst/urban'
|
9
10
|
require 'lyracyst/version'
|
10
11
|
require 'lyracyst/wordnik'
|
11
12
|
require 'xml-fu'
|
12
|
-
module Lyracyst
|
13
13
|
|
14
|
+
# The Lyracyst module handles base functionality.
|
15
|
+
module Lyracyst
|
14
16
|
HTTPI.log = false
|
15
17
|
|
16
18
|
# Optionally sets HTTP adapter with httpi. Supports [:httpclient,
|
17
19
|
# :curb, :em_http, :net_http_persistent, :excon, :rack]
|
18
20
|
#
|
19
21
|
# @param http [Symbol] The http adapter to use. Smart defaults.
|
20
|
-
def self.
|
22
|
+
def self.http(http)
|
21
23
|
HTTPI.adapter = http
|
22
24
|
end
|
23
25
|
|
@@ -25,7 +27,7 @@ module Lyracyst
|
|
25
27
|
# :yajl, :json_gem, :json_pure]
|
26
28
|
#
|
27
29
|
# @param mj [Symbol] The JSON adapter to use. Smart defaults.
|
28
|
-
def self.
|
30
|
+
def self.json(mj)
|
29
31
|
MultiJson.use(mj)
|
30
32
|
end
|
31
33
|
|
@@ -33,7 +35,7 @@ module Lyracyst
|
|
33
35
|
# :libxml, :nokogiri, :rexml]
|
34
36
|
#
|
35
37
|
# @param mx [Symbol] The XML adapter to use. Smart defaults.
|
36
|
-
def self.
|
38
|
+
def self.xml(mx)
|
37
39
|
MultiXml.parser = mx
|
38
40
|
end
|
39
41
|
|
@@ -46,6 +48,15 @@ module Lyracyst
|
|
46
48
|
print Rainbow(']').blue.bright
|
47
49
|
print Rainbow('|').bright
|
48
50
|
end
|
51
|
+
|
52
|
+
# Adds an object to the outfile array.
|
53
|
+
#
|
54
|
+
# @param obj [String] The item to add
|
55
|
+
def self.tofile(obj)
|
56
|
+
if $fmt != nil
|
57
|
+
$tofile.push obj
|
58
|
+
end
|
59
|
+
end
|
49
60
|
end
|
50
61
|
|
51
62
|
include GLI::App
|
@@ -53,268 +64,162 @@ program_desc 'A powerful word search tool that fetches definitions, related word
|
|
53
64
|
config_file '.lyracyst.yml'
|
54
65
|
version Lyracyst::VERSION
|
55
66
|
|
56
|
-
desc '
|
57
|
-
long_desc '
|
58
|
-
|
59
|
-
|
60
|
-
desc '
|
61
|
-
|
62
|
-
default_value :
|
63
|
-
arg_name 'http'
|
64
|
-
flag [:h,:http]
|
65
|
-
|
66
|
-
desc 'JSON adapter'
|
67
|
-
long_desc 'oj, yajl, json_gem, json_pure'
|
68
|
-
default_value :oj
|
69
|
-
arg_name 'json'
|
70
|
-
flag [:j,:json]
|
67
|
+
flag [:f, :format], :default_value => nil, :arg_name => 'fmt', :desc => 'File format', :long_desc => 'json or xml'
|
68
|
+
flag [:h, :http], :default_value => :net_http_persistent, :arg_name => 'http', :desc => 'HTTP adapter', :long_desc => 'httpclient, curb, em_http, net_http_persistent, excon, rack'
|
69
|
+
flag [:j, :json], :default_value => :oj, :arg_name => 'json', :desc => 'JSON adapter', :long_desc => 'oj, yajl, json_gem, json_pure'
|
70
|
+
flag [:o, :out], :default_value => nil, :arg_name => 'outfile', :desc => 'Output file', :long_desc => 'filename.json or filename.xml'
|
71
|
+
flag [:x, :xml], :default_value => :rexml, :arg_name => 'xml', :desc => 'XML adapter', :long_desc => 'ox, libxml, nokogiri, rexml'
|
72
|
+
switch [:fo, :force], :default_value => false, :desc => 'Force overwrite', :long_desc => 'Overwrites existing JSON & XML files'
|
73
|
+
switch [:v, :verbose], :default_value => false, :desc => 'Prints parameters and options'
|
71
74
|
|
72
|
-
desc '
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
flag
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
default_value :
|
81
|
-
arg_name '
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
c.default_value nil
|
89
|
-
c.arg_name 'part'
|
90
|
-
c.flag [:p,:part]
|
91
|
-
c.desc "Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet"
|
92
|
-
c.default_value 'all'
|
93
|
-
c.arg_name 'defdict'
|
94
|
-
c.flag [:defdict]
|
95
|
-
c.action do |global_options,options,args|
|
96
|
-
# If you have any errors, just raise them
|
97
|
-
# raise "that command made no sense"
|
98
|
-
search = args[0]
|
99
|
-
part = options[:p]
|
100
|
-
params = {limit: 10, increl: false, canon: false, inctags: false}
|
101
|
-
params[:defdict] = options[:defdict]
|
102
|
-
df = Lyracyst::Wordnik::Define.new
|
103
|
-
df.get_def(search, part, params)
|
75
|
+
desc 'Wordnik operations'
|
76
|
+
arg_name 'wordnik'
|
77
|
+
command :wn do |nik|
|
78
|
+
nik.switch :canon, :default_value => false, :desc => 'Use canonical', :long_desc => "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
|
79
|
+
nik.flag :limit, :default_value => 5, :arg_name => 'limit', :desc => 'Maximum number of results to return'
|
80
|
+
nik.desc 'Fetch definitions from Wordnik'
|
81
|
+
nik.arg_name 'define'
|
82
|
+
nik.command :def do |define|
|
83
|
+
define.flag :defdict, :default_value => 'all', :arg_name => 'defdict', :desc => "CSV list. Source dictionaries to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet"
|
84
|
+
define.flag [:p, :part], :default_value => nil, :arg_name => 'part', :desc => 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
|
85
|
+
define.action do |global_options, options, args|
|
86
|
+
search = args[0]
|
87
|
+
params = { canon: options[:canon], defdict: options[:defdict], increl: false, inctags: false, limit: options[:limit] }
|
88
|
+
df = Lyracyst::Wordnik::Define.new
|
89
|
+
df.get_def(search, options[:p], params)
|
90
|
+
end
|
104
91
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
arg_name '
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
c.arg_name 'limit'
|
117
|
-
c.flag [:limit]
|
118
|
-
c.action do |global_options,options,args|
|
119
|
-
search = args[0]
|
120
|
-
skip = options[:s]
|
121
|
-
limit = options[:limit]
|
122
|
-
params = {incdups: false, canon: false}
|
123
|
-
params[:skip] = skip
|
124
|
-
params[:limit] = limit
|
125
|
-
ex = Lyracyst::Wordnik::Example.new
|
126
|
-
ex.get_ex(search, params)
|
92
|
+
nik.desc 'Fetch examples from Wordnik'
|
93
|
+
nik.arg_name 'example'
|
94
|
+
nik.command :ex do |example|
|
95
|
+
example.flag [:s, :skip], :default_value => 0, :arg_name => 'skip', :desc => 'Results to skip'
|
96
|
+
example.switch :incdups, :default_value => false, :desc => 'Show duplicate examples from different sources'
|
97
|
+
example.action do |global_options, options, args|
|
98
|
+
search = args[0]
|
99
|
+
params = { canon: options[:canon], incdups: options[:incdups], limit: options[:limit], skip: options[:s] }
|
100
|
+
ex = Lyracyst::Wordnik::Example.new
|
101
|
+
ex.get_ex(search, params)
|
102
|
+
end
|
127
103
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
arg_name '
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
c.arg_name 'rell'
|
140
|
-
c.flag [:rell]
|
141
|
-
c.action do |global_options,options,args|
|
142
|
-
search = args[0]
|
143
|
-
reltypes = options[:relt]
|
144
|
-
rellimit = options[:rell]
|
145
|
-
params = {canon: false}
|
146
|
-
params[:rellimit] = rellimit
|
147
|
-
ex = Lyracyst::Wordnik::Relate.new
|
148
|
-
ex.get_rel(search, params, reltypes)
|
104
|
+
nik.desc 'Fetches related words from Wordnik'
|
105
|
+
nik.arg_name 'relate'
|
106
|
+
nik.command :rel do |relate|
|
107
|
+
relate.flag :relt, :default_value => nil, :arg_name => 'reltypes', :desc => 'Limits the total results per type of relationship type'
|
108
|
+
relate.flag :rell, :default_value => 10, :arg_name => 'rell', :desc => 'Restrict to the supplied relationship types'
|
109
|
+
relate.action do |global_options, options, args|
|
110
|
+
search = args[0]
|
111
|
+
params = { canon: options[:canon], rellimit: options[:rell] }
|
112
|
+
ex = Lyracyst::Wordnik::Relate.new
|
113
|
+
ex.get_rel(search, params, options[:relt])
|
114
|
+
end
|
149
115
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
arg_name '
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
c.default_value nil
|
162
|
-
c.arg_name 'ptype'
|
163
|
-
c.flag [:pt]
|
164
|
-
c.desc 'Maximum number of results to return'
|
165
|
-
c.default_value 5
|
166
|
-
c.arg_name 'limit'
|
167
|
-
c.flag [:limit]
|
168
|
-
c.action do |global_options,options,args|
|
169
|
-
search = args[0]
|
170
|
-
source = options[:src]
|
171
|
-
ptype = options[:pt]
|
172
|
-
limit = options[:limit]
|
173
|
-
params = {canon: false}
|
174
|
-
params[:source] = source
|
175
|
-
params[:limit] = limit
|
176
|
-
pr = Lyracyst::Wordnik::Pronounce.new
|
177
|
-
pr.get_pro(search, params, ptype)
|
116
|
+
nik.desc 'Fetches pronunciations from Wordnik'
|
117
|
+
nik.arg_name 'pronounce'
|
118
|
+
nik.command :pro do |pronounce|
|
119
|
+
pronounce.flag :src, :default_value => nil, :arg_name => 'source', :desc =>'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
|
120
|
+
pronounce.flag :pt, :default_value => nil, :arg_name => 'ptype', :desc => 'Text pronunciation type', :long_desc => 'ahd, arpabet, gcide-diacritical, IPA'
|
121
|
+
pronounce.action do |global_options, options, args|
|
122
|
+
search = args[0]
|
123
|
+
params = { canon: options[:canon], limit: options[:limit], source: options[:src] }
|
124
|
+
pr = Lyracyst::Wordnik::Pronounce.new
|
125
|
+
pr.get_pro(search, params, options[:pt])
|
126
|
+
end
|
178
127
|
end
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
arg_name '
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
c.arg_name 'limit'
|
191
|
-
c.flag [:limit]
|
192
|
-
c.action do |global_options,options,args|
|
193
|
-
search = args[0]
|
194
|
-
source = options[:src]
|
195
|
-
limit = options[:limit]
|
196
|
-
params = {canon: false}
|
197
|
-
if source != nil then params[:source] = source; end
|
198
|
-
params[:limit] = limit
|
199
|
-
hyph = Lyracyst::Wordnik::Hyphen.new
|
200
|
-
hyph.get_hyph(search, params)
|
128
|
+
nik.desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
|
129
|
+
nik.arg_name 'hyphen'
|
130
|
+
nik.command :hyph do |hyphen|
|
131
|
+
hyphen.flag :source, :default_value => nil, :arg_name => 'source', :desc => "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
|
132
|
+
hyphen.action do |global_options, options, args|
|
133
|
+
search = args[0]
|
134
|
+
params = { canon: options[:canon], limit: options[:limit] }
|
135
|
+
if options[:source] != nil then params[:source] = options[:source]; end
|
136
|
+
hyph = Lyracyst::Wordnik::Hyphen.new
|
137
|
+
hyph.get_hyph(search, params)
|
138
|
+
end
|
201
139
|
end
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
arg_name '
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
c.default_value 13
|
213
|
-
c.arg_name 'wlmi'
|
214
|
-
c.flag [:wlmi]
|
215
|
-
c.action do |global_options,options,args|
|
216
|
-
search = args[0]
|
217
|
-
limit = options[:limit]
|
218
|
-
wlmi = options[:wlmi]
|
219
|
-
params = {canon: false}
|
220
|
-
params[:limit] = limit
|
221
|
-
params[:wlmi] = wlmi
|
222
|
-
phra = Lyracyst::Wordnik::Phrase.new
|
223
|
-
phra.get_phr(search, params)
|
140
|
+
nik.desc 'Fetches bi-gram phrases from Wordnik'
|
141
|
+
nik.arg_name 'phrase'
|
142
|
+
nik.command :phr do |phrase|
|
143
|
+
phrase.flag :wlmi, :default_value => 13, :arg_name => 'wlmi', :desc => 'Minimum WLMI(weighted mutual info) for the phrase.'
|
144
|
+
phrase.action do |global_options, options, args|
|
145
|
+
search = args[0]
|
146
|
+
params = { canon: options[:canon], limit: options[:limit], wlmi: options[:wlmi] }
|
147
|
+
phra = Lyracyst::Wordnik::Phrase.new
|
148
|
+
phra.get_phr(search, params)
|
149
|
+
end
|
224
150
|
end
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
orig.get_et(search, params)
|
151
|
+
nik.desc 'Fetches etymologies from Wordnik'
|
152
|
+
nik.arg_name 'origin'
|
153
|
+
nik.command :ori do |origin|
|
154
|
+
origin.action do |global_options, options, args|
|
155
|
+
search = args[0]
|
156
|
+
params = { canon: options[:canon] }
|
157
|
+
orig = Lyracyst::Wordnik::Origin.new
|
158
|
+
orig.get_et(search, params)
|
159
|
+
end
|
235
160
|
end
|
236
161
|
end
|
237
162
|
|
238
|
-
desc '
|
239
|
-
arg_name '
|
240
|
-
command :
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
max = options[:max]
|
253
|
-
params = {}
|
254
|
-
params[:lang] = lang
|
255
|
-
params[:max] = max
|
256
|
-
rhym = Lyracyst::Rhymebrain::Rhyme.new
|
257
|
-
rhym.get_rhyme(search, params)
|
163
|
+
desc 'Rhymebrain operations'
|
164
|
+
arg_name 'rhymebrain'
|
165
|
+
command :rb do |rb|
|
166
|
+
rb.flag :lang, :default_value => 'en', :arg_name => 'lang', :desc => 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
167
|
+
rb.flag :max, :default_value => nil, :arg_name => 'max', :desc => '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
168
|
+
rb.desc 'Fetches rhymes from Rhymebrain.com'
|
169
|
+
rb.arg_name 'rhyme'
|
170
|
+
rb.command :rhy do |rhyme|
|
171
|
+
rhyme.action do |global_options, options, args|
|
172
|
+
search = args[0]
|
173
|
+
params = { lang: options[:lang], max: options[:max] }
|
174
|
+
rhym = Lyracyst::Rhymebrain::Rhyme.new
|
175
|
+
rhym.get_rhyme(search, params)
|
176
|
+
end
|
258
177
|
end
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
params[:max] = max
|
279
|
-
info = Lyracyst::Rhymebrain::Info.new
|
280
|
-
info.get_info(search, params)
|
178
|
+
rb.desc 'Fetches word info from Rhymebrain.com'
|
179
|
+
rb.arg_name 'info'
|
180
|
+
rb.command :inf do |info|
|
181
|
+
info.action do |global_options, options, args|
|
182
|
+
search = args[0]
|
183
|
+
params = { lang: options[:lang], max: options[:max] }
|
184
|
+
info = Lyracyst::Rhymebrain::Info.new
|
185
|
+
info.get_info(search, params)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
rb.desc 'Fetches combined words (portmanteaus) from Rhymebrain.com'
|
189
|
+
rb.arg_name 'combine'
|
190
|
+
rb.command :comb do |combine|
|
191
|
+
combine.action do |global_options, options, args|
|
192
|
+
search = args[0]
|
193
|
+
params = { lang: options[:lang], max: options[:max] }
|
194
|
+
port = Lyracyst::Rhymebrain::Combine.new
|
195
|
+
port.get_port(search, params)
|
196
|
+
end
|
281
197
|
end
|
282
198
|
end
|
283
199
|
|
284
|
-
desc 'Fetches
|
200
|
+
desc 'Fetches definitions from Urban Dictionary'
|
285
201
|
arg_name 'word'
|
286
|
-
|
287
|
-
c.
|
288
|
-
c.default_value 'en'
|
289
|
-
c.arg_name 'lang'
|
290
|
-
c.flag [:lang]
|
291
|
-
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
292
|
-
c.default_value nil
|
293
|
-
c.arg_name 'max'
|
294
|
-
c.flag [:max]
|
295
|
-
c.action do |global_options,options,args|
|
202
|
+
command :urb do |c|
|
203
|
+
c.action do |global_options, options, args|
|
296
204
|
search = args[0]
|
297
|
-
|
298
|
-
|
299
|
-
params = {}
|
300
|
-
params[:lang] = lang
|
301
|
-
params[:max] = max
|
302
|
-
port = Lyracyst::Rhymebrain::Combine.new
|
303
|
-
port.get_port(search, params)
|
205
|
+
ur = Lyracyst::Urban::Define.new
|
206
|
+
ur.get_def(search)
|
304
207
|
end
|
305
208
|
end
|
306
209
|
|
307
|
-
desc 'Fetches
|
210
|
+
desc 'Fetches word info from Onelook'
|
308
211
|
arg_name 'word'
|
309
|
-
command :
|
310
|
-
c.
|
212
|
+
command :look do |c|
|
213
|
+
c.switch :source, :default_value => false, :desc => 'Fetches resource links (verbose)'
|
214
|
+
c.action do |global_options, options, args|
|
311
215
|
search = args[0]
|
312
|
-
|
313
|
-
|
216
|
+
source = options[:source]
|
217
|
+
fe = Lyracyst::Onelook::Fetch.new
|
218
|
+
fe.fetch(search, source)
|
314
219
|
end
|
315
220
|
end
|
316
221
|
|
317
|
-
pre do |global,command,options,args|
|
222
|
+
pre do |global, command, options, args|
|
318
223
|
# Pre logic here
|
319
224
|
# Return true to proceed; false to abort and not call the
|
320
225
|
# chosen command
|
@@ -335,30 +240,27 @@ pre do |global,command,options,args|
|
|
335
240
|
json = global[:j]
|
336
241
|
xml = global[:x]
|
337
242
|
if http.class != Symbol then http = http.to_sym; end
|
338
|
-
Lyracyst.
|
243
|
+
Lyracyst.http(http)
|
339
244
|
if json.class != Symbol then json = json.to_sym; end
|
340
|
-
Lyracyst.
|
245
|
+
Lyracyst.json(json)
|
341
246
|
if xml.class != Symbol then xml = xml.to_sym; end
|
342
|
-
Lyracyst.
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
label = 'Bootstrapped'
|
356
|
-
Lyracyst.label(label)
|
357
|
-
puts ''
|
247
|
+
Lyracyst.xml(xml)
|
248
|
+
if global[:v]
|
249
|
+
Lyracyst.label('Global options')
|
250
|
+
print "#{global}"
|
251
|
+
Lyracyst.label('Command')
|
252
|
+
print "#{command.name}"
|
253
|
+
Lyracyst.label('Command options')
|
254
|
+
print "#{options}"
|
255
|
+
Lyracyst.label('Args')
|
256
|
+
print "#{args}"
|
257
|
+
Lyracyst.label('Bootstrapped')
|
258
|
+
puts ''
|
259
|
+
end
|
358
260
|
true
|
359
261
|
end
|
360
262
|
|
361
|
-
post do |global,command,options,args|
|
263
|
+
post do |global, command, options, args|
|
362
264
|
# Post logic here
|
363
265
|
# Use skips_post before a command to skip this
|
364
266
|
# block on that command only
|
@@ -415,9 +317,10 @@ post do |global,command,options,args|
|
|
415
317
|
puts Rainbow("Word search was written to #{outfile}.").bright
|
416
318
|
end
|
417
319
|
end
|
418
|
-
|
419
|
-
|
420
|
-
|
320
|
+
if global[:v]
|
321
|
+
Lyracyst.label('Shutdown')
|
322
|
+
puts ''
|
323
|
+
end
|
421
324
|
end
|
422
325
|
|
423
326
|
on_error do |exception|
|