squared 0.4.8 → 0.4.10

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.
@@ -8,12 +8,12 @@ module Squared
8
8
  module Shell
9
9
  module_function
10
10
 
11
- def shell_escape(val, quote: false, force: false, double: false, override: false)
11
+ def shell_escape(val, quote: false, force: false, double: false, option: false, override: false)
12
12
  if (r = /\A(--?)([^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val if !r[3] || (!r[5] && r[6].match?(/\s/))
13
+ return val if !r[3] || (!r[5] && !r[6].match?(/\s/))
14
14
 
15
15
  combine = lambda do |opt|
16
- if r[2] =~ /\A(["'])(.+)\1\z/
16
+ if r[2] =~ /\A(["'])(.+)\1\z/m
17
17
  double = $1 == '"'
18
18
  r[2] = $2
19
19
  override = true
@@ -26,19 +26,28 @@ module Squared
26
26
  force = true
27
27
  combine.call(r[5] + r[6] + r[7])
28
28
  end
29
- elsif val.empty?
30
- ''
29
+ elsif option && val =~ /\A([^=]+)=(.+)\z/m
30
+ return val if $2.match?(/\A(["']).+\1\z/m)
31
+
32
+ "#{$1}=%s" % if $2.include?(' ')
33
+ shell_quote($2, option: false)
34
+ else
35
+ Rake::Win32.windows? ? $2 : Shellwords.escape($2)
36
+ end
31
37
  elsif Rake::Win32.windows?
32
38
  quote ? shell_quote(val, double: double, force: force) : val
33
39
  else
34
- Shellwords.escape(val)
40
+ val.empty? ? '' : Shellwords.escape(val)
35
41
  end
36
42
  end
37
43
 
38
44
  def shell_quote(val, option: true, force: true, double: false, override: false)
39
45
  val = val.to_s
40
- return val if val.empty? || (!force && !val.include?(' '))
41
- return val if option && val.match?(/(?:\A|\S=|[^=]\s+|#{Rake::Win32.windows? ? '[\\\/]' : '\/'})(["']).+\1\z/m)
46
+ return val if (!force && !val.include?(' ')) || val.empty?
47
+
48
+ if option && val.match?(/(?:\A|\A[^=\s]+(?:=|\s+)|#{Rake::Win32.windows? ? '[\\\/]' : '\/'})(["']).+\1\z/m)
49
+ return val
50
+ end
42
51
 
43
52
  if double || Rake::Win32.windows? || (ARG[:QUOTE] == '"' && !override)
44
53
  "\"#{val.gsub(/(?<!\\)"/, '\\"')}\""
@@ -76,18 +85,16 @@ module Squared
76
85
  end}"
77
86
  end
78
87
 
79
- def shell_split(val, escape: true, quote: false, join: nil)
80
- ret = Shellwords.split(val)
81
- return ret if join == false
82
-
83
- ret.map! { |opt| shell_escape(opt, quote: quote) } if escape
88
+ def shell_split(val, quote: false, force: false, join: nil)
89
+ ret = val.shellsplit
90
+ ret.map! { |opt| shell_escape(opt, quote: quote, force: force, double: true, option: true) }
84
91
  return ret unless join
85
92
 
86
93
  ret.join(join.is_a?(::String) ? join : ' ')
87
94
  end
88
95
 
89
96
  def fill_option(val, double: false)
90
- return "-#{val}" if val.match?(/^[a-z]\d*$/i)
97
+ return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
91
98
 
92
99
  shell_escape(val.start_with?('-') ? val : "--#{val}", double: double)
93
100
  end
@@ -29,11 +29,11 @@ module Squared
29
29
  dest.mkpath if create
30
30
  if pass
31
31
  exclude = []
32
- pass = [pass] unless pass.is_a?(::Array)
33
- pass.each { |val| exclude.concat(Dir.glob(src.join(val))) }
32
+ pass = [pass] unless pass.is_a?(::Enumerable)
33
+ pass.each { |val| exclude.concat(Dir.glob(src + val)) }
34
34
  end
35
- (glob.is_a?(::Array) ? glob : [glob]).each do |val|
36
- Dir.glob(src.join(val)) do |path|
35
+ (glob.is_a?(::Enumerable) ? glob : [glob]).each do |val|
36
+ Dir.glob(src + val) do |path|
37
37
  next if exclude&.include?(path) || (path = Pathname.new(path)).directory?
38
38
 
39
39
  dir = dest.join(path.relative_path_from(src)).dirname
@@ -79,7 +79,7 @@ module Squared
79
79
  def copy_guard(src, dest, link: nil, force: false, verbose: true)
80
80
  unless force
81
81
  if (path = Pathname.new(dest)).directory?
82
- src = [src] unless src.is_a?(::Array)
82
+ src = [src] unless src.is_a?(::Enumerable)
83
83
  src = src.reject { |val| path.join(File.basename(val)).exist? }
84
84
  return if src.empty?
85
85
  elsif path.exist?
@@ -89,7 +89,7 @@ module Squared
89
89
  case link
90
90
  when 'hard', 1
91
91
  FileUtils.ln(src, dest, force: force, verbose: verbose)
92
- when TrueClass, 'soft', 0
92
+ when ::TrueClass, 'soft', 0
93
93
  FileUtils.ln_s(src, dest, force: force, verbose: verbose)
94
94
  else
95
95
  FileUtils.cp(src, dest, verbose: verbose)
@@ -159,7 +159,7 @@ module Squared
159
159
  end
160
160
  begin
161
161
  if default.is_a?(::String)
162
- default = (root ? Pathname.new(root).join(default) : Pathname.new(default)).realdirpath
162
+ default = (root ? Pathname.new(root) + default : Pathname.new(default)).realdirpath
163
163
  end
164
164
  rescue StandardError => e
165
165
  warn e
@@ -14,7 +14,7 @@ module Squared
14
14
  class << self
15
15
  def parse(gem, namespace, ext = [pkg])
16
16
  require gem
17
- obj = eval(namespace)
17
+ obj = eval namespace
18
18
  ext = [ext] unless ext.is_a?(Array)
19
19
  ext.each { |val| @@mime_obj[val] = [obj, ext] }
20
20
  rescue LoadError, NameError => e
@@ -127,7 +127,7 @@ module Squared
127
127
  if enabled?
128
128
  if namespace
129
129
  require(gem || type)
130
- obj = eval(namespace)
130
+ obj = eval namespace
131
131
  else
132
132
  as_a(ext).each do |val|
133
133
  next unless (data = @@mime_obj[val])
@@ -163,7 +163,7 @@ module Squared
163
163
  def also(path, type = nil, name: nil, **kwargs)
164
164
  return self if @mime.frozen? || !(file = basepath(path)).exist?
165
165
 
166
- ext = mimetype(file)
166
+ ext = mimetype file
167
167
  type ||= ext
168
168
  name ||= file.basename.to_s.chomp(File.extname(file))
169
169
  add(type, ext: ext, command: name, file: file, **kwargs)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.8'
4
+ VERSION = '0.4.10'
5
5
  end
@@ -83,7 +83,7 @@ module Squared
83
83
  basename = @home.basename.to_s
84
84
  if main
85
85
  @main = main.to_s.freeze
86
- @home = @home.join(@main) unless @main == basename || (windows? && @main.downcase == basename.downcase)
86
+ @home += @main unless @main == basename || (windows? && @main.downcase == basename.downcase)
87
87
  else
88
88
  @main = basename.freeze
89
89
  end
@@ -96,7 +96,7 @@ module Squared
96
96
  @extensions = []
97
97
  @envname = @main.gsub(/[^\w]+/, '_').upcase.freeze
98
98
  @pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
99
- @exception = env_bool(exception)
99
+ @exception = env_bool exception
100
100
  @verbose = env_bool(verbose, verbose.nil? || verbose.is_a?(String) ? @pipe != 0 : verbose, index: true)
101
101
  @warning = @verbose != false
102
102
  @closed = false
@@ -274,7 +274,7 @@ module Squared
274
274
  data = {} if !command && data[:order].empty?
275
275
  if group
276
276
  label = :group
277
- items = as_a(group)
277
+ items = as_a group
278
278
  else
279
279
  label = :ref
280
280
  items = ref ? as_a(ref) : [:_]
@@ -299,9 +299,9 @@ module Squared
299
299
  kwargs = kwargs.dup unless @withargs
300
300
  kwargs[:group] = @group
301
301
  end
302
- path = rootpath(path)
302
+ path = root + path
303
303
  project = (project || path.basename).to_s
304
- name = task_name(project)
304
+ name = task_name project
305
305
  index = 0
306
306
  while @project[name]
307
307
  index += 1
@@ -463,7 +463,7 @@ module Squared
463
463
  tasks << key if obj.has?(key, baseref)
464
464
  elsif (batch = series.batch_get(key))
465
465
  obj.allref.each do |ref|
466
- next unless (data = batch[ref])
466
+ next unless obj.has?(key, ref) && (data = batch[ref])
467
467
 
468
468
  data.each do |val|
469
469
  if (items = task_resolve(obj, val)).empty?
@@ -482,7 +482,7 @@ module Squared
482
482
  return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
483
483
 
484
484
  obj.allref.each do |ref|
485
- next unless (alt = data[ref])
485
+ next unless obj.has?(key, ref) && (alt = data[ref])
486
486
 
487
487
  ret = task_resolve(obj, alt)
488
488
  break unless ret.empty?
@@ -499,7 +499,7 @@ module Squared
499
499
  end
500
500
 
501
501
  def task_sync(key)
502
- key = task_name(key)
502
+ key = task_name key
503
503
  task_defined?(ret = task_join(key, 'sync')) ? ret : key
504
504
  end
505
505
 
@@ -561,7 +561,7 @@ module Squared
561
561
  end
562
562
 
563
563
  def task_include?(obj, key, ref = nil)
564
- return false if @series.exclude.include?(key)
564
+ return false if @series.exclude?(key)
565
565
 
566
566
  task_base?(key) ? obj.has?(key, ref || baseref) : task_extend?(obj, key)
567
567
  end
@@ -598,7 +598,7 @@ module Squared
598
598
  end
599
599
 
600
600
  def docker?
601
- File.exist?('/.dockerenv')
601
+ !Dir['/.dockerenv', '/docker-*.{sh,d}'].empty?
602
602
  end
603
603
 
604
604
  def powershell?
@@ -608,7 +608,7 @@ module Squared
608
608
  when 'powershell.exe', 'vscode'
609
609
  true
610
610
  else
611
- ENV.fetch('PSModulePath', '').split(';').size > 1
611
+ ENV.fetch('PSModulePath', '').split(';', 2).size > 1
612
612
  end
613
613
  end
614
614
 
@@ -686,12 +686,8 @@ module Squared
686
686
  end
687
687
 
688
688
  def data_get(*args, group: nil, ref: nil, target: nil)
689
- if group
690
- target[:group][group.to_sym]
691
- elsif ref.is_a?(Array)
692
- ref = ref.each
693
- end
694
- if ref.instance_of?(Enumerator)
689
+ target[:group][group.to_sym] if group
690
+ if ref.is_a?(Enumerable)
695
691
  ref.each do |key|
696
692
  next unless (ret = target[:ref][key])
697
693
 
@@ -213,7 +213,7 @@ module Squared
213
213
  file = val.is_a?(String) ? Time.now.strftime(val) : "#{@name}-#{Date.today}.log"
214
214
  end
215
215
  if file
216
- file = (val = env('LOG_DIR')) ? @workspace.home.join(val, file) : @workspace.home.join(file)
216
+ file = (val = env('LOG_DIR')) ? @workspace.home.join(val, file) : @workspace.home + file
217
217
  begin
218
218
  file = file.realdirpath
219
219
  rescue StandardError => e
@@ -225,7 +225,7 @@ module Squared
225
225
  end
226
226
  log[:progname] ||= @name
227
227
  if (val = env('LOG_LEVEL', ignore: false))
228
- log[:level] = val.match?(/^\d$/) ? log_sym(val.to_i) : val
228
+ log[:level] = val.match?(/\d/) ? log_sym(val.to_i) : val
229
229
  end
230
230
  log.delete(:file)
231
231
  @log = [file, log]
@@ -240,10 +240,10 @@ module Squared
240
240
  unless @output[0] == false || @output[0].is_a?(Array)
241
241
  if (val = env('BUILD', suffix: 'OPTS'))
242
242
  n = @output[0] ? 1 : 3
243
- @output[n] = merge_opts(@output[n], shell_split(val, escape: false))
243
+ @output[n] = merge_opts(@output[n], shell_split(val))
244
244
  end
245
245
  if (val = env(ref.to_s.upcase, suffix: 'OPTS'))
246
- @output[4] = merge_opts(@output[4], shell_split(val, escape: false))
246
+ @output[4] = merge_opts(@output[4], shell_split(val))
247
247
  end
248
248
  end
249
249
  @version = val if (val = env('BUILD', suffix: 'VERSION'))
@@ -324,7 +324,7 @@ module Squared
324
324
  else
325
325
  force = args.fetch(:force, false)
326
326
  end
327
- unpack(basepath(dir), uri: tag, digest: digest, ext: ext, force: force)
327
+ unpack(path + dir, uri: tag, digest: digest, ext: ext, force: force)
328
328
  end
329
329
  end
330
330
  end
@@ -401,10 +401,10 @@ module Squared
401
401
  self
402
402
  end
403
403
 
404
- def build(*args, sync: invoked_sync?('build'), from: @buildtype || :build, **)
404
+ def build(*args, sync: invoked_sync?('build'), from: :run, **)
405
405
  banner = verbose
406
406
  if args.empty?
407
- return unless from == (@buildtype || :build)
407
+ return unless from == :run
408
408
 
409
409
  run_b(@run, sync: sync, from: from) if series?(@run)
410
410
  args = @output
@@ -443,7 +443,7 @@ module Squared
443
443
  cmd, opts, var, flags, extra = args
444
444
  end
445
445
  if cmd
446
- cmd = as_get(cmd)
446
+ cmd = as_get cmd
447
447
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
448
448
  flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
449
449
  case opts
@@ -461,6 +461,7 @@ module Squared
461
461
  return unless (opts || extra) && respond_to?(:compose)
462
462
 
463
463
  cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
464
+ from = :script if from == :run && script?
464
465
  end
465
466
  run(cmd, var, from: from, banner: banner, sync: sync)
466
467
  end
@@ -516,13 +517,13 @@ module Squared
516
517
  else
517
518
  if @clean.is_a?(Enumerable) && !series?(@clean)
518
519
  @clean.each do |val|
519
- path = basepath(val = val.to_s)
520
- if path.directory? && val.match?(%r{[\\/]$})
521
- log&.warn "rm -rf #{path}"
522
- rm_rf(path, verbose: verbose)
520
+ entry = path + (val = val.to_s)
521
+ if entry.directory? && val.match?(%r{[\\/]$})
522
+ log&.warn "rm -rf #{entry}"
523
+ rm_rf(entry, verbose: verbose)
523
524
  else
524
- log&.warn "rm #{path}"
525
- (val.include?('*') ? Dir[path] : [path]).each do |file|
525
+ log&.warn "rm #{entry}"
526
+ (val.include?('*') ? Dir[entry] : [entry]).each do |file|
526
527
  next unless File.file?(file)
527
528
 
528
529
  begin
@@ -571,7 +572,7 @@ module Squared
571
572
  end
572
573
  end
573
574
 
574
- def unpack(target, sync: true, uri: nil, digest: nil, ext: nil, force: false, depth: 1, headers: {},
575
+ def unpack(target, uri:, sync: true, digest: nil, ext: nil, force: false, depth: 1, headers: {},
575
576
  from: :unpack)
576
577
  if !target.exist?
577
578
  target.mkpath
@@ -685,7 +686,7 @@ module Squared
685
686
  break unless entry.directory?
686
687
 
687
688
  i = 0
688
- while (dest = target.join("#{File.basename(file.path)}-#{i}")).exist?
689
+ while (dest = target + "#{File.basename(file.path)}-#{i}").exist?
689
690
  i += 1
690
691
  end
691
692
  FileUtils.mv(entry, dest)
@@ -915,7 +916,7 @@ module Squared
915
916
  end
916
917
  return
917
918
  end
918
- cmd = session_done(cmd)
919
+ cmd = session_done cmd
919
920
  log&.info cmd
920
921
  on :first, from
921
922
  begin
@@ -1122,7 +1123,7 @@ module Squared
1122
1123
  end
1123
1124
  ret = JoinSet.new(cmd.flatten(1))
1124
1125
  if options && (val = env("#{prefix}_OPTIONS"))
1125
- split_escape(val).each { |opt| ret.last(fill_option(opt), /^(--?[^ =]+)[ =].+$/) }
1126
+ split_escape(val).each { |opt| ret.last(fill_option(opt), /\A(--?[^ =]+)[ =].+\z/m) }
1126
1127
  end
1127
1128
  main ? @session = ret : ret
1128
1129
  end
@@ -1130,7 +1131,7 @@ module Squared
1130
1131
  def session_delete(*args, target: @session)
1131
1132
  ret = []
1132
1133
  args.each do |val|
1133
- pat = /^#{Regexp.escape(shell_option(val))}(?: |=|$)/
1134
+ pat = /\A#{Regexp.escape(shell_option(val))}(?: |=|\z)/
1134
1135
  if (key = target.find { |opt| opt.match?(pat) })
1135
1136
  target.delete(key)
1136
1137
  ret << key
@@ -1172,6 +1173,10 @@ module Squared
1172
1173
  OptionPartition.clear(target, opts, styles: theme[:inline], **kwargs)
1173
1174
  end
1174
1175
 
1176
+ def print_success(*)
1177
+ puts 'Success'
1178
+ end
1179
+
1175
1180
  def print_item(*val)
1176
1181
  puts if @@print_order > 0 && stdout?
1177
1182
  @@print_order += 1
@@ -1204,7 +1209,7 @@ module Squared
1204
1209
 
1205
1210
  def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
1206
1211
  n = Project.max_width(lines)
1207
- sub = as_a(sub)
1212
+ sub = as_a sub
1208
1213
  lines.map! do |val|
1209
1214
  s = right ? val.rjust(n) : val.ljust(n)
1210
1215
  sub.each { |h| s = sub_style(s, **h) }
@@ -1471,7 +1476,7 @@ module Squared
1471
1476
  end
1472
1477
  end
1473
1478
 
1474
- def param_guard(action, flag, args: nil, key: nil, pat: nil, values: nil)
1479
+ def param_guard(action, flag, args:, key: nil, pat: nil, values: nil)
1475
1480
  if args && key
1476
1481
  val = args.fetch(key, nil)
1477
1482
  return val unless val.nil? || (pat && !val.match?(pat)) || (values && !values.include?(val))
@@ -1497,24 +1502,59 @@ module Squared
1497
1502
  b = sub_style("#{pkg} #{ver}", styles: theme[:inline])
1498
1503
  c, d = rev == 1 || lock ? ['y/N', 'N'] : ['Y/n', 'Y']
1499
1504
  e = lock ? " #{sub_style('(locked)', styles: color(:red))}" : ''
1500
- confirm("Upgrade to #{a}? #{b + e} [#{c}] ", d, timeout: 60)
1505
+ confirm("Upgrade to #{a}? #{b + e} [#{c}] ", d)
1501
1506
  end
1502
1507
 
1503
- def choice_index(msg, list, values: nil, multiple: false, accept: nil, trim: nil)
1504
- puts if @@print_order > 0
1505
- raise_error 'user cancelled' unless (ret = choice(msg, list, multiple: multiple))
1508
+ def choice_index(msg, list, values: nil, accept: nil, series: false, trim: nil, column: nil,
1509
+ multiple: false, force: true, **kwargs)
1510
+ puts if !series && @@print_order > 0
1511
+ msg = "#{msg} (optional)" unless force
1512
+ unless (ret = choice(msg, list, multiple: multiple, force: force, **kwargs)) || !force
1513
+ raise_error 'user cancelled'
1514
+ end
1515
+ if ret.nil? || ret.empty?
1516
+ return unless force
1517
+
1518
+ exit 1
1519
+ end
1506
1520
  ret = multiple ? ret.map! { |val| val.sub(trim, '') } : ret.sub(trim, '') if trim
1507
- exit 1 if accept && !confirm("#{accept} [#{ret.join(', ')}] [y/N] ", 'N', timeout: 60)
1521
+ if column
1522
+ a, b = as_a(column)
1523
+ ret = as_a(ret).map! { |val| val[a, b || 1] }
1524
+ ret = ret.first unless multiple
1525
+ end
1526
+ if accept
1527
+ a = as_a(ret).map { |val| sub_style(val, styles: theme[:inline]) }.join(', ')
1528
+ accept = as_a(accept).map { |val| as_a(val) }
1529
+ if accept.any? { |val| val[1] == true }
1530
+ ret = [ret]
1531
+ multiple = -1
1532
+ end
1533
+ loop do
1534
+ c = confirm("#{accept.first[0]}#{a ? " [#{a}]" : ''} [y/N] ", 'N', timeout: 60)
1535
+ if accept.shift[1] == true
1536
+ ret << c
1537
+ elsif !c
1538
+ break
1539
+ end
1540
+ a = nil
1541
+ break if accept.empty?
1542
+ end
1543
+ exit 1 unless accept.empty?
1544
+ end
1508
1545
  if values
1509
- ret = [ret]
1546
+ ret = [ret] unless accept && multiple == -1
1510
1547
  values.each do |val|
1511
- val, req = val if val.is_a?(Array)
1512
- val = Readline.readline("#{val} (#{req ? 'required' : 'optional'}): ", true).strip
1513
- raise_error 'user cancelled' if req && val.empty?
1548
+ if val.is_a?(Array)
1549
+ val, force = val
1550
+ else
1551
+ force = false
1552
+ end
1553
+ val = readline(val, force: force)
1514
1554
  ret << (val.empty? ? nil : val)
1515
1555
  end
1516
1556
  end
1517
- @@print_order += 1
1557
+ @@print_order += 1 unless series
1518
1558
  ret
1519
1559
  end
1520
1560
 
@@ -1547,7 +1587,7 @@ module Squared
1547
1587
  raise_error 'pathspec not within worktree' unless pass || files.size == proj.size
1548
1588
  files = proj
1549
1589
  end
1550
- files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
1590
+ files.map { |val| val == '.' ? '.' : shell_quote(path + val) }
1551
1591
  end
1552
1592
 
1553
1593
  def semver(val)
@@ -1583,7 +1623,7 @@ module Squared
1583
1623
  end
1584
1624
 
1585
1625
  def colormap(val)
1586
- val.compact.map! { |s| color(s) }.flatten
1626
+ val.compact.flat_map { |s| color(s) }
1587
1627
  end
1588
1628
 
1589
1629
  def epochtime
@@ -1592,7 +1632,7 @@ module Squared
1592
1632
 
1593
1633
  def verbosetype
1594
1634
  case verbose
1595
- when TrueClasss
1635
+ when TrueClass
1596
1636
  1
1597
1637
  when Numeric
1598
1638
  verbose.succ
@@ -1627,7 +1667,7 @@ module Squared
1627
1667
  pwd = Pathname.pwd
1628
1668
  if block_given?
1629
1669
  begin
1630
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join >= RUBY_VERSION)
1670
+ if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
1631
1671
  ret = yield
1632
1672
  else
1633
1673
  Dir.chdir(path)
@@ -1794,6 +1834,10 @@ module Squared
1794
1834
  end
1795
1835
  end
1796
1836
 
1837
+ def success?(ret)
1838
+ ret == true && stdout? && banner?
1839
+ end
1840
+
1797
1841
  def banner?
1798
1842
  ARG[:BANNER] && !env('BANNER', equals: '0')
1799
1843
  end
@@ -1811,14 +1855,14 @@ module Squared
1811
1855
  end
1812
1856
 
1813
1857
  def has_value?(data, val)
1814
- return data.value?(val) if data.is_a?(::Hash)
1815
- return data.is_a?(::Enumerable) && data.to_a.include?(val) if !val.is_a?(::Enumerable) || val.is_a?(::Hash)
1858
+ return data.value?(val) if data.is_a?(Hash)
1859
+ return data.is_a?(Enumerable) && data.to_a.include?(val) if !val.is_a?(Enumerable) || val.is_a?(Hash)
1816
1860
 
1817
1861
  val.to_a.any? do |obj|
1818
1862
  case data
1819
- when ::Hash
1863
+ when Hash
1820
1864
  data.value?(obj)
1821
- when ::Enumerable
1865
+ when Enumerable
1822
1866
  data.to_a.include?(obj)
1823
1867
  end
1824
1868
  end