everyday_thor_util 2.0.1 → 2.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
  SHA1:
3
- metadata.gz: 9e10a18e08aac4d4696245884b5bd3172af25756
4
- data.tar.gz: 05112220ff41221cb49c4675453d189518f0bac9
3
+ metadata.gz: f929d1d0b101083c8b1883c0b912b9a81d47cc84
4
+ data.tar.gz: a89c6e92dea3dda294c4ebaeecc637cb087456a1
5
5
  SHA512:
6
- metadata.gz: 0f5c3975fda2524cb21c65cf09049c0a90ce3376eb63d49fa09cea69153f1066ea0d04eb08780fcb109d2192198d6a2e32719e8e07082b78721951fb8f808159
7
- data.tar.gz: c475d42073e35b4eaade31f2bc72273282cb59db4c96db1d58459572afaa4b03fd0145ddc1f44494a367380044b0e4845fe0d439c4e945d962583031b96011a1
6
+ metadata.gz: 5df372dcaf50ccf8456ff049bb82fc96561d740d09526be61b2febcd66d59d25ebbbf8f7322774b1f547d292a53bc8a327b24acba308f7dfb44f7ca6abaf3f35
7
+ data.tar.gz: 48773e7eb081c6bd52913b6b223187057b632185758b30cf30831fdb58d3253895cd4e53cf96bb4f42bd32394850d43ac7486e14b885843573a9e78d728286b9
@@ -204,11 +204,19 @@ module EverydayThorUtil
204
204
  rc
205
205
  end
206
206
 
207
+ def build_helpers(p, pc)
208
+ self.global.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
209
+ p.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
210
+ end
211
+
212
+ def build_flags(p, pc, has_children)
213
+ p.flags.each { |fn, f| has_children ? pc.class_option(fn.to_sym, f) : pc.option(fn.to_sym, f) }
214
+ end
215
+
207
216
  def build_recurse(p, pc)
208
217
  if p.parent.nil?
209
- p.flags.flags.each { |fn, f| pc.class_option(fn.to_sym, f) }
210
- self.global.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
211
- p.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
218
+ build_flags(p, pc, true)
219
+ build_helpers(p, pc)
212
220
  end
213
221
  p.commands.commands.each { |cn, c|
214
222
  short_desc = c.options[:short_desc]
@@ -218,33 +226,31 @@ module EverydayThorUtil
218
226
  if !c.leaf?
219
227
  cc = Class.new(Thor)
220
228
  cc.namespace cn.to_s
221
- self.global.helpers.helpers.each { |hn, h| cc.no_commands { cc.create_method(hn.to_sym, &h) } }
222
- c.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
223
- c.flags.flags.each { |fn, f| cc.class_option(fn.to_sym, f) }
229
+ build_helpers(c, cc)
230
+ build_flags(c, cc, true)
224
231
  build_recurse(c, cc)
225
- c.flags.flags.each { |fn, f| pc.class_option(fn.to_sym, f) }
232
+ build_flags(c, pc, false)
226
233
  pc.desc short_desc, desc if short_desc && desc
227
234
  pc.long_desc long_desc if long_desc
228
235
  pc.subcommand cn, cc
229
236
  aliases.each { |an|
230
237
  cc2 = Class.new(Thor)
231
238
  cc2.namespace an
232
- self.global.helpers.helpers.each { |hn, h| cc2.no_commands { cc2.create_method(hn.to_sym, &h) } }
233
- c.helpers.helpers.each { |hn, h| pc.no_commands { pc.create_method(hn.to_sym, &h) } }
234
- c.flags.flags.each { |fn, f| cc2.class_option(fn.to_sym, f) }
239
+ build_helpers(c, cc2)
240
+ build_flags(c, cc2, true)
235
241
  build_recurse(c, cc2)
236
- c.flags.flags.each { |fn, f| pc.class_option(fn.to_sym, f) }
242
+ build_flags(c, pc, false)
237
243
  pc.desc short_desc.gsub(/^\S+(?=\s|$)/, an.gsub(/_/, '-')), desc if short_desc && desc
238
244
  pc.long_desc long_desc if long_desc
239
245
  pc.subcommand an, cc2
240
246
  } if aliases && !aliases.empty?
241
247
  elsif c.body
242
- c.flags.flags.each { |fn, f| pc.option(fn.to_sym, f) }
248
+ build_flags(c, pc, false)
243
249
  pc.desc short_desc, desc if short_desc && desc
244
250
  pc.long_desc long_desc if long_desc
245
251
  pc.create_method(cn.to_sym, &c.body)
246
252
  aliases.each { |an|
247
- c.flags.flags.each { |fn, f| pc.option(fn.to_sym, f) }
253
+ build_flags(c, pc, false)
248
254
  pc.desc short_desc.gsub(/^\S+(?=\s|$)/, an.gsub(/_/, '-')), desc if short_desc && desc
249
255
  pc.long_desc long_desc if long_desc
250
256
  pc.dup_method an.to_sym, cn.to_sym
@@ -1,3 +1,3 @@
1
1
  module EverydayThorUtil
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everyday_thor_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler