lyracyst 1.0.2 → 1.1.0

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
  SHA1:
3
- metadata.gz: 04aa0f88e802ebfc29567e7bd4c869217ecccc0b
4
- data.tar.gz: ca44ce70517f1d47ba7a42ebdcc5c0b213362d04
3
+ metadata.gz: c062c9d3baca7f781229f0dcb79fc73af3031a40
4
+ data.tar.gz: f9ee4efb9855d0023d7e4f800d33de0d0b926618
5
5
  SHA512:
6
- metadata.gz: 955927f012089dea86c66eceb908d42913955622a463ddef9b6d3e58741ec3eec287bf840ed13d4447decf93173f6c4e9b9b9764aa686263a9b640c07d0fb915
7
- data.tar.gz: 9db35817730ca71a25601bee00fa94a731c19707bba84db06132ab6bc012dd56e9b303680e7b1228b1613c838af07ef712ce8db60b0c22a9c4fe7b424d3b19bb
6
+ metadata.gz: 5d89ab3574e4cc2cb33d7a3d9db4ecb847dbbb15b0ccf7183a7edf04d905257d06d19b006d26ed45c4c7ba9f0fbd149e71f6b9a394f9d9239c6e9a0aceb137b7
7
+ data.tar.gz: bb69b57eff63a2f02252d6d844ec488dad7314e229bf183292f774656f2d3beb34c7e3d63ebbf2c1ccecd2c7ffe35ca914904985ed285e252f692fec0ee77f25
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  ===
3
3
 
4
+ Version 1.1.0 - Major cleanup
5
+ - Dropped redundant format flag, autodetects format based on file extension.
6
+ - Split up the command blocks into separate files
7
+ - Fixed rhyme outfile
8
+
4
9
  Version 1.0.2 - Code climate & defaults
5
10
  - Methodized more code blocks to improve climate
6
11
  - Now using smart defaults for httpi, multi_json & multi_xml
data/bin/lyracyst CHANGED
@@ -10,9 +10,7 @@ require 'lyracyst/rhymebrain'
10
10
  require 'lyracyst/urban'
11
11
  require 'lyracyst/version'
12
12
  require 'lyracyst/wordnik'
13
- require "rexml/document"
14
13
  require 'xml-fu'
15
- include REXML
16
14
 
17
15
  # The Lyracyst module handles base functionality.
18
16
  module Lyracyst
@@ -67,7 +65,6 @@ program_desc 'A powerful word search tool that fetches definitions, related word
67
65
  config_file '.lyracyst.yml'
68
66
  version Lyracyst::VERSION
69
67
 
70
- flag [:f, :format], :default_value => nil, :arg_name => 'string', :desc => 'File format', :long_desc => 'json or xml'
71
68
  flag [:h, :http], :default_value => nil, :arg_name => 'string', :desc => 'HTTP adapter', :long_desc => 'httpclient, curb, em_http, net_http_persistent, excon, rack'
72
69
  flag [:j, :json], :default_value => nil, :arg_name => 'string', :desc => 'JSON adapter', :long_desc => 'oj, yajl, json_gem, json_pure'
73
70
  flag [:o, :out], :default_value => nil, :arg_name => 'filename', :desc => 'Output file', :long_desc => 'filename.json or filename.xml'
@@ -75,150 +72,10 @@ flag [:x, :xml], :default_value => nil, :arg_name => 'string', :desc => 'XML ada
75
72
  switch [:fo, :force], :default_value => false, :desc => 'Force overwrite', :long_desc => 'Overwrites existing JSON & XML files'
76
73
  switch [:v, :verbose], :default_value => false, :desc => 'Prints parameters and options'
77
74
 
78
- desc 'Wordnik operations'
79
- command :wn do |nik|
80
- 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."
81
- nik.flag :limit, :default_value => 5, :arg_name => 'integer', :desc => 'Maximum number of results to return'
82
- nik.desc 'Fetch definitions from Wordnik'
83
- nik.arg_name 'word'
84
- nik.command :def do |define|
85
- define.flag :defdict, :default_value => 'all', :arg_name => 'string', :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"
86
- define.flag [:p, :part], :default_value => nil, :arg_name => 'csv', :desc => 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
87
- define.action do |global_options, options, args|
88
- search = args[0]
89
- params = { canon: options[:canon], defdict: options[:defdict], increl: false, inctags: false, limit: options[:limit] }
90
- df = Lyracyst::Wordnik::Define.new
91
- df.get_def(search, options[:p], params)
92
- end
93
- end
94
- nik.desc 'Fetch examples from Wordnik'
95
- nik.arg_name 'word'
96
- nik.command :ex do |example|
97
- example.flag [:s, :skip], :default_value => 0, :arg_name => 'integer', :desc => 'Results to skip'
98
- example.switch :incdups, :default_value => false, :desc => 'Show duplicate examples from different sources'
99
- example.action do |global_options, options, args|
100
- search = args[0]
101
- params = { canon: options[:canon], incdups: options[:incdups], limit: options[:limit], skip: options[:s] }
102
- ex = Lyracyst::Wordnik::Example.new
103
- ex.get_ex(search, params)
104
- end
105
- end
106
- nik.desc 'Fetches related words from Wordnik'
107
- nik.arg_name 'word'
108
- nik.command :rel do |relate|
109
- relate.flag :relt, :default_value => nil, :arg_name => 'integer', :desc => 'Limits the total results per type of relationship type'
110
- relate.flag :rell, :default_value => 10, :arg_name => 'integer', :desc => 'Restrict to the supplied relationship types'
111
- relate.action do |global_options, options, args|
112
- search = args[0]
113
- params = { canon: options[:canon], rellimit: options[:rell] }
114
- ex = Lyracyst::Wordnik::Relate.new
115
- ex.get_rel(search, params, options[:relt])
116
- end
117
- end
118
- nik.desc 'Fetches pronunciations from Wordnik'
119
- nik.arg_name 'word'
120
- nik.command :pro do |pronounce|
121
- pronounce.flag :src, :default_value => nil, :arg_name => 'string', :desc =>'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
122
- pronounce.flag :pt, :default_value => nil, :arg_name => 'string', :desc => 'Text pronunciation type', :long_desc => 'ahd, arpabet, gcide-diacritical, IPA'
123
- pronounce.action do |global_options, options, args|
124
- search = args[0]
125
- params = { canon: options[:canon], limit: options[:limit], source: options[:src] }
126
- pr = Lyracyst::Wordnik::Pronounce.new
127
- pr.get_pro(search, params, options[:pt])
128
- end
129
- end
130
- nik.desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
131
- nik.arg_name 'word'
132
- nik.command :hyph do |hyphen|
133
- hyphen.flag :source, :default_value => nil, :arg_name => 'string', :desc => "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
134
- hyphen.action do |global_options, options, args|
135
- search = args[0]
136
- params = { canon: options[:canon], limit: options[:limit] }
137
- if options[:source] != nil then params[:source] = options[:source]; end
138
- hyph = Lyracyst::Wordnik::Hyphen.new
139
- hyph.get_hyph(search, params)
140
- end
141
- end
142
- nik.desc 'Fetches bi-gram phrases from Wordnik'
143
- nik.arg_name 'word'
144
- nik.command :phr do |phrase|
145
- phrase.flag :wlmi, :default_value => 13, :arg_name => 'integer', :desc => 'Minimum WLMI(weighted mutual info) for the phrase.'
146
- phrase.action do |global_options, options, args|
147
- search = args[0]
148
- params = { canon: options[:canon], limit: options[:limit], wlmi: options[:wlmi] }
149
- phra = Lyracyst::Wordnik::Phrase.new
150
- phra.get_phr(search, params)
151
- end
152
- end
153
- nik.desc 'Fetches etymologies from Wordnik'
154
- nik.arg_name 'word'
155
- nik.command :ori do |origin|
156
- origin.action do |global_options, options, args|
157
- search = args[0]
158
- params = { canon: options[:canon] }
159
- orig = Lyracyst::Wordnik::Origin.new
160
- orig.get_et(search, params)
161
- end
162
- end
163
- end
164
-
165
- desc 'Rhymebrain operations'
166
- command :rb do |rb|
167
- rb.flag :lang, :default_value => 'en', :arg_name => 'string', :desc => 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
168
- rb.flag :max, :default_value => nil, :arg_name => 'integer', :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.'
169
- rb.desc 'Fetches rhymes from Rhymebrain.com'
170
- rb.arg_name 'word'
171
- rb.command :rhy do |rhyme|
172
- rhyme.action do |global_options, options, args|
173
- search = args[0]
174
- params = { lang: options[:lang], max: options[:max] }
175
- rhym = Lyracyst::Rhymebrain::Rhyme.new
176
- rhym.get_rhyme(search, params)
177
- end
178
- end
179
- rb.desc 'Fetches word info from Rhymebrain.com'
180
- rb.arg_name 'word'
181
- rb.command :inf do |info|
182
- info.action do |global_options, options, args|
183
- search = args[0]
184
- params = { lang: options[:lang], max: options[:max] }
185
- info = Lyracyst::Rhymebrain::Info.new
186
- info.get_info(search, params)
187
- end
188
- end
189
- rb.desc 'Fetches combined words (portmanteaus) from Rhymebrain.com'
190
- rb.arg_name 'word'
191
- rb.command :comb do |combine|
192
- combine.action do |global_options, options, args|
193
- search = args[0]
194
- params = { lang: options[:lang], max: options[:max] }
195
- port = Lyracyst::Rhymebrain::Combine.new
196
- port.get_port(search, params)
197
- end
198
- end
199
- end
200
-
201
- desc 'Fetches definitions from Urban Dictionary'
202
- arg_name 'word'
203
- command :urb do |c|
204
- c.action do |global_options, options, args|
205
- search = args[0]
206
- ur = Lyracyst::Urban::Define.new
207
- ur.get_def(search)
208
- end
209
- end
210
-
211
- desc 'Fetches word info from Onelook'
212
- arg_name 'word'
213
- command :look do |c|
214
- c.switch :source, :default_value => false, :desc => 'Fetches resource links (verbose)'
215
- c.action do |global_options, options, args|
216
- search = args[0]
217
- source = options[:source]
218
- fe = Lyracyst::Onelook::Fetch.new
219
- fe.fetch(search, source)
220
- end
221
- end
75
+ require 'lyracyst/cli/onelook'
76
+ require 'lyracyst/cli/rhymebrain'
77
+ require 'lyracyst/cli/urban'
78
+ require 'lyracyst/cli/wordnik'
222
79
 
223
80
  pre do |global, command, options, args|
224
81
  # Pre logic here
@@ -273,7 +130,7 @@ post do |global, command, options, args|
273
130
  # block on that command only
274
131
  if $fmt != nil
275
132
  outfile = global[:o]
276
- if File.exist?(outfile) && global[:f] == true
133
+ if File.exist?(outfile) && global[:fo] == true
277
134
  if $fmt == :json
278
135
  fo = File.open(outfile, 'w+')
279
136
  fo.print MultiJson.dump($tofile, :pretty => true)
@@ -289,7 +146,7 @@ post do |global, command, options, args|
289
146
  puts 'Invalid file extension.'
290
147
  end
291
148
  end
292
- if File.exist?(outfile) && global[:f] == false
149
+ if File.exist?(outfile) && global[:fo] == false
293
150
  puts Rainbow("#{outfile} exists. Overwrite? y/n ").bright
294
151
  ans = gets
295
152
  if ans =~ /y/
data/lib/lyracyst.rb CHANGED
@@ -10,9 +10,7 @@ require 'lyracyst/rhymebrain'
10
10
  require 'lyracyst/urban'
11
11
  require 'lyracyst/version'
12
12
  require 'lyracyst/wordnik'
13
- require "rexml/document"
14
13
  require 'xml-fu'
15
- include REXML
16
14
 
17
15
  # The Lyracyst module handles base functionality.
18
16
  module Lyracyst
@@ -67,7 +65,6 @@ program_desc 'A powerful word search tool that fetches definitions, related word
67
65
  config_file '.lyracyst.yml'
68
66
  version Lyracyst::VERSION
69
67
 
70
- flag [:f, :format], :default_value => nil, :arg_name => 'string', :desc => 'File format', :long_desc => 'json or xml'
71
68
  flag [:h, :http], :default_value => nil, :arg_name => 'string', :desc => 'HTTP adapter', :long_desc => 'httpclient, curb, em_http, net_http_persistent, excon, rack'
72
69
  flag [:j, :json], :default_value => nil, :arg_name => 'string', :desc => 'JSON adapter', :long_desc => 'oj, yajl, json_gem, json_pure'
73
70
  flag [:o, :out], :default_value => nil, :arg_name => 'filename', :desc => 'Output file', :long_desc => 'filename.json or filename.xml'
@@ -75,150 +72,10 @@ flag [:x, :xml], :default_value => nil, :arg_name => 'string', :desc => 'XML ada
75
72
  switch [:fo, :force], :default_value => false, :desc => 'Force overwrite', :long_desc => 'Overwrites existing JSON & XML files'
76
73
  switch [:v, :verbose], :default_value => false, :desc => 'Prints parameters and options'
77
74
 
78
- desc 'Wordnik operations'
79
- command :wn do |nik|
80
- 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."
81
- nik.flag :limit, :default_value => 5, :arg_name => 'integer', :desc => 'Maximum number of results to return'
82
- nik.desc 'Fetch definitions from Wordnik'
83
- nik.arg_name 'word'
84
- nik.command :def do |define|
85
- define.flag :defdict, :default_value => 'all', :arg_name => 'string', :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"
86
- define.flag [:p, :part], :default_value => nil, :arg_name => 'csv', :desc => 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
87
- define.action do |global_options, options, args|
88
- search = args[0]
89
- params = { canon: options[:canon], defdict: options[:defdict], increl: false, inctags: false, limit: options[:limit] }
90
- df = Lyracyst::Wordnik::Define.new
91
- df.get_def(search, options[:p], params)
92
- end
93
- end
94
- nik.desc 'Fetch examples from Wordnik'
95
- nik.arg_name 'word'
96
- nik.command :ex do |example|
97
- example.flag [:s, :skip], :default_value => 0, :arg_name => 'integer', :desc => 'Results to skip'
98
- example.switch :incdups, :default_value => false, :desc => 'Show duplicate examples from different sources'
99
- example.action do |global_options, options, args|
100
- search = args[0]
101
- params = { canon: options[:canon], incdups: options[:incdups], limit: options[:limit], skip: options[:s] }
102
- ex = Lyracyst::Wordnik::Example.new
103
- ex.get_ex(search, params)
104
- end
105
- end
106
- nik.desc 'Fetches related words from Wordnik'
107
- nik.arg_name 'word'
108
- nik.command :rel do |relate|
109
- relate.flag :relt, :default_value => nil, :arg_name => 'integer', :desc => 'Limits the total results per type of relationship type'
110
- relate.flag :rell, :default_value => 10, :arg_name => 'integer', :desc => 'Restrict to the supplied relationship types'
111
- relate.action do |global_options, options, args|
112
- search = args[0]
113
- params = { canon: options[:canon], rellimit: options[:rell] }
114
- ex = Lyracyst::Wordnik::Relate.new
115
- ex.get_rel(search, params, options[:relt])
116
- end
117
- end
118
- nik.desc 'Fetches pronunciations from Wordnik'
119
- nik.arg_name 'word'
120
- nik.command :pro do |pronounce|
121
- pronounce.flag :src, :default_value => nil, :arg_name => 'string', :desc =>'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
122
- pronounce.flag :pt, :default_value => nil, :arg_name => 'string', :desc => 'Text pronunciation type', :long_desc => 'ahd, arpabet, gcide-diacritical, IPA'
123
- pronounce.action do |global_options, options, args|
124
- search = args[0]
125
- params = { canon: options[:canon], limit: options[:limit], source: options[:src] }
126
- pr = Lyracyst::Wordnik::Pronounce.new
127
- pr.get_pro(search, params, options[:pt])
128
- end
129
- end
130
- nik.desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
131
- nik.arg_name 'word'
132
- nik.command :hyph do |hyphen|
133
- hyphen.flag :source, :default_value => nil, :arg_name => 'string', :desc => "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
134
- hyphen.action do |global_options, options, args|
135
- search = args[0]
136
- params = { canon: options[:canon], limit: options[:limit] }
137
- if options[:source] != nil then params[:source] = options[:source]; end
138
- hyph = Lyracyst::Wordnik::Hyphen.new
139
- hyph.get_hyph(search, params)
140
- end
141
- end
142
- nik.desc 'Fetches bi-gram phrases from Wordnik'
143
- nik.arg_name 'word'
144
- nik.command :phr do |phrase|
145
- phrase.flag :wlmi, :default_value => 13, :arg_name => 'integer', :desc => 'Minimum WLMI(weighted mutual info) for the phrase.'
146
- phrase.action do |global_options, options, args|
147
- search = args[0]
148
- params = { canon: options[:canon], limit: options[:limit], wlmi: options[:wlmi] }
149
- phra = Lyracyst::Wordnik::Phrase.new
150
- phra.get_phr(search, params)
151
- end
152
- end
153
- nik.desc 'Fetches etymologies from Wordnik'
154
- nik.arg_name 'word'
155
- nik.command :ori do |origin|
156
- origin.action do |global_options, options, args|
157
- search = args[0]
158
- params = { canon: options[:canon] }
159
- orig = Lyracyst::Wordnik::Origin.new
160
- orig.get_et(search, params)
161
- end
162
- end
163
- end
164
-
165
- desc 'Rhymebrain operations'
166
- command :rb do |rb|
167
- rb.flag :lang, :default_value => 'en', :arg_name => 'string', :desc => 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
168
- rb.flag :max, :default_value => nil, :arg_name => 'integer', :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.'
169
- rb.desc 'Fetches rhymes from Rhymebrain.com'
170
- rb.arg_name 'word'
171
- rb.command :rhy do |rhyme|
172
- rhyme.action do |global_options, options, args|
173
- search = args[0]
174
- params = { lang: options[:lang], max: options[:max] }
175
- rhym = Lyracyst::Rhymebrain::Rhyme.new
176
- rhym.get_rhyme(search, params)
177
- end
178
- end
179
- rb.desc 'Fetches word info from Rhymebrain.com'
180
- rb.arg_name 'word'
181
- rb.command :inf do |info|
182
- info.action do |global_options, options, args|
183
- search = args[0]
184
- params = { lang: options[:lang], max: options[:max] }
185
- info = Lyracyst::Rhymebrain::Info.new
186
- info.get_info(search, params)
187
- end
188
- end
189
- rb.desc 'Fetches combined words (portmanteaus) from Rhymebrain.com'
190
- rb.arg_name 'word'
191
- rb.command :comb do |combine|
192
- combine.action do |global_options, options, args|
193
- search = args[0]
194
- params = { lang: options[:lang], max: options[:max] }
195
- port = Lyracyst::Rhymebrain::Combine.new
196
- port.get_port(search, params)
197
- end
198
- end
199
- end
200
-
201
- desc 'Fetches definitions from Urban Dictionary'
202
- arg_name 'word'
203
- command :urb do |c|
204
- c.action do |global_options, options, args|
205
- search = args[0]
206
- ur = Lyracyst::Urban::Define.new
207
- ur.get_def(search)
208
- end
209
- end
210
-
211
- desc 'Fetches word info from Onelook'
212
- arg_name 'word'
213
- command :look do |c|
214
- c.switch :source, :default_value => false, :desc => 'Fetches resource links (verbose)'
215
- c.action do |global_options, options, args|
216
- search = args[0]
217
- source = options[:source]
218
- fe = Lyracyst::Onelook::Fetch.new
219
- fe.fetch(search, source)
220
- end
221
- end
75
+ require 'lyracyst/cli/onelook'
76
+ require 'lyracyst/cli/rhymebrain'
77
+ require 'lyracyst/cli/urban'
78
+ require 'lyracyst/cli/wordnik'
222
79
 
223
80
  pre do |global, command, options, args|
224
81
  # Pre logic here
@@ -273,7 +130,7 @@ post do |global, command, options, args|
273
130
  # block on that command only
274
131
  if $fmt != nil
275
132
  outfile = global[:o]
276
- if File.exist?(outfile) && global[:f] == true
133
+ if File.exist?(outfile) && global[:fo] == true
277
134
  if $fmt == :json
278
135
  fo = File.open(outfile, 'w+')
279
136
  fo.print MultiJson.dump($tofile, :pretty => true)
@@ -289,7 +146,7 @@ post do |global, command, options, args|
289
146
  puts 'Invalid file extension.'
290
147
  end
291
148
  end
292
- if File.exist?(outfile) && global[:f] == false
149
+ if File.exist?(outfile) && global[:fo] == false
293
150
  puts Rainbow("#{outfile} exists. Overwrite? y/n ").bright
294
151
  ans = gets
295
152
  if ans =~ /y/
@@ -0,0 +1,11 @@
1
+ desc 'Fetches word info from Onelook'
2
+ arg_name 'word'
3
+ command :look do |c|
4
+ c.switch :source, :default_value => false, :desc => 'Fetches resource links (verbose)'
5
+ c.action do |global_options, options, args|
6
+ search = args[0]
7
+ source = options[:source]
8
+ fe = Lyracyst::Onelook::Fetch.new
9
+ fe.fetch(search, source)
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ desc 'Rhymebrain operations'
2
+ command :rb do |rb|
3
+ rb.flag :lang, :default_value => 'en', :arg_name => 'string', :desc => 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
4
+ rb.flag :max, :default_value => nil, :arg_name => 'integer', :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.'
5
+ rb.desc 'Fetches rhymes from Rhymebrain.com'
6
+ rb.arg_name 'word'
7
+ rb.command :rhy do |rhyme|
8
+ rhyme.action do |global_options, options, args|
9
+ search = args[0]
10
+ params = { lang: options[:lang], max: options[:max] }
11
+ rhym = Lyracyst::Rhymebrain::Rhyme.new
12
+ rhym.get_rhyme(search, params)
13
+ end
14
+ end
15
+ rb.desc 'Fetches word info from Rhymebrain.com'
16
+ rb.arg_name 'word'
17
+ rb.command :inf do |info|
18
+ info.action do |global_options, options, args|
19
+ search = args[0]
20
+ params = { lang: options[:lang], max: options[:max] }
21
+ info = Lyracyst::Rhymebrain::Info.new
22
+ info.get_info(search, params)
23
+ end
24
+ end
25
+ rb.desc 'Fetches combined words (portmanteaus) from Rhymebrain.com'
26
+ rb.arg_name 'word'
27
+ rb.command :comb do |combine|
28
+ combine.action do |global_options, options, args|
29
+ search = args[0]
30
+ params = { lang: options[:lang], max: options[:max] }
31
+ port = Lyracyst::Rhymebrain::Combine.new
32
+ port.get_port(search, params)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ desc 'Fetches definitions from Urban Dictionary'
2
+ arg_name 'word'
3
+ command :urb do |c|
4
+ c.action do |global_options, options, args|
5
+ search = args[0]
6
+ ur = Lyracyst::Urban::Define.new
7
+ ur.get_def(search)
8
+ end
9
+ end
@@ -0,0 +1,86 @@
1
+ desc 'Wordnik operations'
2
+ command :wn do |nik|
3
+ 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."
4
+ nik.flag :limit, :default_value => 5, :arg_name => 'integer', :desc => 'Maximum number of results to return'
5
+ nik.desc 'Fetch definitions from Wordnik'
6
+ nik.arg_name 'word'
7
+ nik.command :def do |define|
8
+ define.flag :defdict, :default_value => 'all', :arg_name => 'string', :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"
9
+ define.flag [:p, :part], :default_value => nil, :arg_name => 'csv', :desc => 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
10
+ define.action do |global_options, options, args|
11
+ search = args[0]
12
+ params = { canon: options[:canon], defdict: options[:defdict], increl: false, inctags: false, limit: options[:limit] }
13
+ df = Lyracyst::Wordnik::Define.new
14
+ df.get_def(search, options[:p], params)
15
+ end
16
+ end
17
+ nik.desc 'Fetch examples from Wordnik'
18
+ nik.arg_name 'word'
19
+ nik.command :ex do |example|
20
+ example.flag [:s, :skip], :default_value => 0, :arg_name => 'integer', :desc => 'Results to skip'
21
+ example.switch :incdups, :default_value => false, :desc => 'Show duplicate examples from different sources'
22
+ example.action do |global_options, options, args|
23
+ search = args[0]
24
+ params = { canon: options[:canon], incdups: options[:incdups], limit: options[:limit], skip: options[:s] }
25
+ ex = Lyracyst::Wordnik::Example.new
26
+ ex.get_ex(search, params)
27
+ end
28
+ end
29
+ nik.desc 'Fetches related words from Wordnik'
30
+ nik.arg_name 'word'
31
+ nik.command :rel do |relate|
32
+ relate.flag :relt, :default_value => nil, :arg_name => 'integer', :desc => 'Limits the total results per type of relationship type'
33
+ relate.flag :rell, :default_value => 10, :arg_name => 'integer', :desc => 'Restrict to the supplied relationship types'
34
+ relate.action do |global_options, options, args|
35
+ search = args[0]
36
+ params = { canon: options[:canon], rellimit: options[:rell] }
37
+ ex = Lyracyst::Wordnik::Relate.new
38
+ ex.get_rel(search, params, options[:relt])
39
+ end
40
+ end
41
+ nik.desc 'Fetches pronunciations from Wordnik'
42
+ nik.arg_name 'word'
43
+ nik.command :pro do |pronounce|
44
+ pronounce.flag :src, :default_value => nil, :arg_name => 'string', :desc =>'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
45
+ pronounce.flag :pt, :default_value => nil, :arg_name => 'string', :desc => 'Text pronunciation type', :long_desc => 'ahd, arpabet, gcide-diacritical, IPA'
46
+ pronounce.action do |global_options, options, args|
47
+ search = args[0]
48
+ params = { canon: options[:canon], limit: options[:limit], source: options[:src] }
49
+ pr = Lyracyst::Wordnik::Pronounce.new
50
+ pr.get_pro(search, params, options[:pt])
51
+ end
52
+ end
53
+ nik.desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
54
+ nik.arg_name 'word'
55
+ nik.command :hyph do |hyphen|
56
+ hyphen.flag :source, :default_value => nil, :arg_name => 'string', :desc => "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
57
+ hyphen.action do |global_options, options, args|
58
+ search = args[0]
59
+ params = { canon: options[:canon], limit: options[:limit] }
60
+ if options[:source] != nil then params[:source] = options[:source]; end
61
+ hyph = Lyracyst::Wordnik::Hyphen.new
62
+ hyph.get_hyph(search, params)
63
+ end
64
+ end
65
+ nik.desc 'Fetches bi-gram phrases from Wordnik'
66
+ nik.arg_name 'word'
67
+ nik.command :phr do |phrase|
68
+ phrase.flag :wlmi, :default_value => 13, :arg_name => 'integer', :desc => 'Minimum WLMI(weighted mutual info) for the phrase.'
69
+ phrase.action do |global_options, options, args|
70
+ search = args[0]
71
+ params = { canon: options[:canon], limit: options[:limit], wlmi: options[:wlmi] }
72
+ phra = Lyracyst::Wordnik::Phrase.new
73
+ phra.get_phr(search, params)
74
+ end
75
+ end
76
+ nik.desc 'Fetches etymologies from Wordnik'
77
+ nik.arg_name 'word'
78
+ nik.command :ori do |origin|
79
+ origin.action do |global_options, options, args|
80
+ search = args[0]
81
+ params = { canon: options[:canon] }
82
+ orig = Lyracyst::Wordnik::Origin.new
83
+ orig.get_et(search, params)
84
+ end
85
+ end
86
+ end
@@ -32,9 +32,9 @@ module Lyracyst
32
32
  rhyme = match['word']
33
33
  rcont.push rhyme
34
34
  rhyme = { 'rhyme' => rhyme }
35
- Lyracyst.tofile(rhyme)
36
35
  a += 1
37
36
  end
37
+ Lyracyst.tofile("#{rcont.join(',')}")
38
38
  puts rcont.join(Rainbow('|').bright)
39
39
  end
40
40
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
  module Lyracyst
3
3
  # Semantic program version
4
- VERSION = '1.0.2'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyracyst
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Prentice
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -188,6 +188,10 @@ files:
188
188
  - CHANGELOG.md
189
189
  - bin/lyracyst
190
190
  - lib/lyracyst.rb
191
+ - lib/lyracyst/cli/onelook.rb
192
+ - lib/lyracyst/cli/rhymebrain.rb
193
+ - lib/lyracyst/cli/urban.rb
194
+ - lib/lyracyst/cli/wordnik.rb
191
195
  - lib/lyracyst/onelook.rb
192
196
  - lib/lyracyst/rhymebrain.rb
193
197
  - lib/lyracyst/rhymebrain/combine.rb