squared 0.3.14 → 0.4.0

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.
@@ -28,12 +28,16 @@ module Squared
28
28
  bright_cyan!: '106',
29
29
  bright_white!: '107'
30
30
  }.freeze
31
+ AIX_GRAPH = ['│', '─', '├', '└', '┬'].freeze
32
+ AIX_BORDER = ['│', '─', '╭', '╮', '╯', '╰', '├', '┤', '┬', '┴'].freeze
31
33
  TEXT_STYLE = [:bold, :dim, :italic, :underline, :blinking, nil, :inverse, :hidden, :strikethrough].freeze
32
- private_constant :AIX_TERM, :TEXT_STYLE
34
+ private_constant :AIX_TERM, :AIX_GRAPH, :AIX_BORDER, :TEXT_STYLE
33
35
 
34
36
  def enable_aixterm
35
37
  unless (colors = __get__(:colors)).frozen?
36
38
  colors.merge!(AIX_TERM)
39
+ ARG[:GRAPH] = AIX_GRAPH
40
+ ARG[:BORDER] = AIX_BORDER
37
41
  end
38
42
  block_given? ? yield(self) : self
39
43
  end
@@ -53,7 +57,7 @@ module Squared
53
57
  end
54
58
  wrap = ->(s, n) { "\x1B[#{n.join(';')}m#{s}\x1B[0m" }
55
59
  code = []
56
- args.concat(as_a(styles)).flatten.each_with_index do |type, i|
60
+ args.concat(as_a(styles)).each_with_index do |type, i|
57
61
  next unless type
58
62
 
59
63
  if index == -1
@@ -114,7 +118,7 @@ module Squared
114
118
  if !val.is_a?(::Numeric)
115
119
  val = val.to_sym
116
120
  ret << val if colors.key?(val) || TEXT_STYLE.include?(val)
117
- elsif val.between?(0, 256)
121
+ elsif val >= 0 && val <= 256
118
122
  ret << val
119
123
  elsif val < 0 && (b = val.to_s.split('.')[1])
120
124
  b = b[0, 3]
@@ -127,11 +131,11 @@ module Squared
127
131
  def apply_style(data, key, args, empty: true)
128
132
  return if data.is_a?(::Symbol) && (data = __get__(:theme)[data]).nil?
129
133
 
130
- set = ->(k, v) { data[k.to_sym] = check_style(v, empty: empty) }
134
+ set = ->(k, v) { data[k] = check_style(v, empty: empty) }
131
135
  if key.is_a?(::Hash)
132
136
  key.each { |k, v| set.(k, v || args) }
133
137
  else
134
- set.(key, args)
138
+ set.(key.to_sym, args)
135
139
  end
136
140
  end
137
141
 
@@ -166,21 +170,29 @@ module Squared
166
170
  color ? sub_style(ret, *styles) : ret
167
171
  end
168
172
 
169
- def log_message(level, *args, subject: nil, hint: nil, color: ARG[:COLOR])
173
+ def log_message(level, *args, subject: nil, hint: nil, color: ARG[:COLOR], pass: false)
174
+ return false if !pass && level.is_a?(::Numeric) && level < ARG[:LEVEL]
175
+
170
176
  args = args.map(&:to_s)
171
- if args.size > 1
177
+ if args.size > 1 && !hint
172
178
  title = log_title(level, color: false)
173
179
  sub = { pat: /^(#{title})(.+)$/, styles: __get__(:theme)[:logger][log_sym(level)] } if color
174
- emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
180
+ emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub)
175
181
  else
176
182
  msg = [log_title(level, color: color)]
177
- msg << (color ? sub_style(subject, :underline) : subject) if subject
178
- msg << args.shift if msg.size == 1
183
+ if subject
184
+ msg << (color ? sub_style(subject, styles: (@theme && @theme[:subject]) || :bold) : subject)
185
+ else
186
+ msg += args
187
+ args.clear
188
+ end
179
189
  message(msg.join(' '), *args, hint: hint)
180
190
  end
181
191
  end
182
192
 
183
193
  def puts_oe(*args, pipe: 1)
194
+ return if args.first == false && args.size == 1
195
+
184
196
  if pipe.is_a?(Pathname)
185
197
  begin
186
198
  File.open(pipe, 'a') do |f|
@@ -222,27 +234,31 @@ module Squared
222
234
  require 'io/console'
223
235
  (n = [n, $stdout.winsize[1] - 4].min) rescue nil
224
236
  end
237
+ b0, b1, b2, b3, b4, b5, b6, b7 = ARG[:BORDER]
225
238
  out = []
226
- bord = '-' * (n + 4)
227
- bord = sub_style(bord, styles: border) if border
239
+ draw = lambda do |a, b|
240
+ ret = a + (b1 * (n + 2)) + b
241
+ ret = sub_style(ret, styles: border) if border
242
+ ret
243
+ end
228
244
  sub = as_a(sub)
229
245
  pr = lambda do |line|
230
246
  s = line.ljust(n)
231
247
  sub.each { |h| s = sub_style(s, **h) }
232
- s = "| #{s} |"
248
+ s = "#{b0} #{s} #{b0}"
233
249
  if border
234
- s = sub_style(s, pat: /\A(\|)(.+)\z/m, styles: border)
235
- s = sub_style(s, pat: /\A(.+)(\|)\z/m, styles: border, index: 2)
250
+ s = sub_style(s, pat: /\A(#{Regexp.escape(b0)})(.+)\z/m, styles: border)
251
+ s = sub_style(s, pat: /\A(.+)(#{Regexp.escape(b0)})\z/m, styles: border, index: 2)
236
252
  end
237
253
  s
238
254
  end
239
- out << bord
255
+ out << draw.(b2, b3)
240
256
  if title
241
257
  out += title.map { |t| pr.(t) }
242
- out << bord
258
+ out << draw.(b6, b7)
243
259
  end
244
260
  lines.each { |line| out << pr.(line) }
245
- out << bord
261
+ out << draw.(b5, b4)
246
262
  if footer
247
263
  unless sub.empty? && !right
248
264
  footer.map! do |s|
@@ -257,8 +273,6 @@ module Squared
257
273
  yield out
258
274
  elsif pipe
259
275
  case pipe
260
- when -1
261
- return out
262
276
  when 0
263
277
  pipe = $stdin
264
278
  when 2
@@ -276,10 +290,6 @@ module Squared
276
290
  val.gsub(/\x1B\[(\d+;?)+m/, '')
277
291
  end
278
292
 
279
- def stripext(val)
280
- File.basename(val, File.extname(val))
281
- end
282
-
283
293
  def raise_error(*args, hint: nil, kind: ArgumentError)
284
294
  raise kind, message(*args, hint: hint, empty: true), caller_locations(1).map(&:to_s)
285
295
  end
@@ -8,8 +8,8 @@ module Squared
8
8
  def confirm(msg, default = nil, agree: 'Y', cancel: 'N', attempts: 5, timeout: 15)
9
9
  require 'readline'
10
10
  require 'timeout'
11
- agree = /\A#{agree}\z/i if agree.is_a?(::String)
12
- cancel = /\A#{cancel}\z/i if cancel.is_a?(::String)
11
+ agree = /^#{agree}$/i if agree.is_a?(::String)
12
+ cancel = /^#{cancel}$/i if cancel.is_a?(::String)
13
13
  Timeout.timeout(timeout) do
14
14
  begin
15
15
  while (ch = Readline.readline(msg, true))
@@ -21,7 +21,7 @@ module Squared
21
21
  return false
22
22
  end
23
23
  attempts -= 1
24
- exit 1 unless attempts > 0
24
+ exit 1 unless attempts >= 0
25
25
  end
26
26
  rescue Interrupt
27
27
  puts
@@ -8,79 +8,91 @@ module Squared
8
8
  module Shell
9
9
  module_function
10
10
 
11
- def shell_escape(val, quote: false, force: false)
12
- if (data = /\A(--?[^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val if !data[2] || (!data[4] && !data[5].match?(/\s/))
14
-
15
- join = ->(opt) { data[1] + data[3] + shell_quote(opt) }
16
- if data[4] == data[6]
17
- data[4] ? val : join.(data[5])
11
+ def shell_escape(val, quote: false, force: false, double: false, override: false)
12
+ if (r = /\A(--?)([^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
+ return val if !r[3] || (!r[5] && r[6].match?(/\s/))
14
+
15
+ combine = lambda do |opt|
16
+ if r[2] =~ /^(["'])(.+)\1$/
17
+ double = $1 == '"'
18
+ r[2] = $2
19
+ override = true
20
+ end
21
+ r[1] + r[2] + r[4] + shell_quote(opt, double: double, force: force, override: override)
22
+ end
23
+ if r[5] == r[7]
24
+ r[5] ? val : combine.(r[6])
18
25
  else
19
- join.(data[4] + data[5] + data[6])
26
+ force = true
27
+ combine.(r[5] + r[6] + r[7])
20
28
  end
21
29
  elsif Rake::Win32.windows?
22
- quote ? shell_quote(val, force: force) : val
30
+ quote ? shell_quote(val, double: double, force: force) : val
23
31
  else
24
- val.empty? ? '' : Shellwords.escape(val)
32
+ Shellwords.escape(val)
25
33
  end
26
34
  end
27
35
 
28
- def shell_quote(val, force: true)
36
+ def shell_quote(val, option: true, force: true, double: false, override: false)
29
37
  val = val.to_s
30
- return val if !force && !val.include?(' ')
31
- return val if option && val =~ /(?:^|\S=|[^=]\s+|#{Rake::Win32.windows? ? '[\\\/]' : '\/'})(["']).+\1\z/m
32
-
33
- Rake::Win32.windows? || ARG[:QUOTE] == '"' ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
34
- end
35
-
36
- def shell_split(val, escape: true, quote: false, join: nil)
37
- val = Shellwords.split(val)
38
- val = val.map { |opt| shell_escape(opt, quote: quote) } if escape
39
- return val unless join
38
+ return val if (!force && !val.include?(' ')) || (option && val.match?(/(?:^|\S=|[^=]\s+)(["']).+\1\z/m))
40
39
 
41
- val.join(join.is_a?(::String) ? join : ' ')
40
+ if double || Rake::Win32.windows? || (ARG[:QUOTE] == '"' && !override)
41
+ "\"#{val.gsub(/(?<!\\)"/, '\\"')}\""
42
+ else
43
+ "'#{val.gsub("'", "'\\\\''")}'"
44
+ end
42
45
  end
43
46
 
44
- def shell_option(flag, val = nil, escape: true, quote: true, force: true)
47
+ def shell_option(flag, val = nil, escape: true, quote: true, force: true, double: false, override: false,
48
+ merge: false)
45
49
  flag = flag.to_s
50
+ if flag =~ /^(["'])(.+)\1$/
51
+ double = $1 == '"'
52
+ flag = $2
53
+ escape = false
54
+ override = true
55
+ end
46
56
  if flag[0] == '-'
47
57
  b = flag[1] == '-' ? '=' : ' '
58
+ elsif flag.size == 1
59
+ a = '-'
60
+ b = merge ? '' : ' '
48
61
  else
49
- a, b = flag.size == 1 ? ['-', ' '] : ['--', '=']
62
+ a = '--'
63
+ b = '='
50
64
  end
51
65
  "#{a}#{flag}#{if val
52
66
  "#{b}#{if escape
53
- shell_escape(val, quote: quote)
67
+ shell_escape(val, quote: quote, double: double, override: override)
54
68
  else
55
- quote ? shell_quote(val, force: force) : val
69
+ quote ? shell_quote(val, force: force, double: double, override: override) : val
56
70
  end}"
57
71
  end}"
58
72
  end
59
73
 
60
- def fill_option(val)
61
- return "-#{val}" if val =~ /\A[a-z](?:\d*)\z/i
74
+ def shell_split(val, escape: true, quote: false, join: nil)
75
+ ret = Shellwords.split(val)
76
+ return ret if join == false
62
77
 
63
- shell_escape(val.start_with?('-') ? val : "--#{val}")
64
- end
78
+ ret = ret.map { |opt| shell_escape(opt, quote: quote) } if escape
79
+ return ret unless join
65
80
 
66
- def quote_option(flag, val)
67
- shell_option(flag, val, escape: false)
81
+ ret.join(join.is_a?(::String) ? join : ' ')
68
82
  end
69
83
 
70
- def basic_option(flag, val)
71
- shell_option(flag, val, escape: false, force: false)
72
- end
84
+ def fill_option(val, double: false)
85
+ return "-#{val}" if val.match?(/^[a-z]\d*$/i)
73
86
 
74
- def single_quote(val)
75
- val.gsub("'", "'\\\\''")
87
+ shell_escape(val.start_with?('-') ? val : "--#{val}", double: double)
76
88
  end
77
89
 
78
- def double_quote(val)
79
- val.gsub(/(?<!\\)"/, '\\"')
90
+ def quote_option(flag, val, double: false)
91
+ shell_option(flag, val, escape: false, double: double)
80
92
  end
81
93
 
82
- def split_escape(val, char: ',')
83
- val.split(/\s*(?<!\\)#{char}\s*/)
94
+ def basic_option(flag, val, merge: false)
95
+ shell_option(flag, val, escape: false, force: false, merge: merge)
84
96
  end
85
97
  end
86
98
  end
@@ -1,32 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pathname'
4
- require 'rake'
4
+ require 'fileutils'
5
5
 
6
6
  module Squared
7
7
  module Common
8
8
  module System
9
9
  module_function
10
10
 
11
- def shell(*args, name: :system, **kwargs)
12
- if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
13
- e = kwargs[:exception]
14
- if (dir = kwargs[:chdir]) && ((pwd = Dir.pwd) != dir)
15
- Dir.chdir(dir)
16
- ret = Kernel.send(name, *args)
17
- Dir.chdir(pwd)
18
- else
19
- ret = Kernel.send(name, *args)
20
- end
21
- elsif RUBY_VERSION < '2.6'
22
- e = kwargs.delete(:exception)
23
- ret = Kernel.send(name, *args, **kwargs)
11
+ def shell(*args, **kwargs)
12
+ if RUBY_VERSION < '2.6'
13
+ exception = kwargs.delete(:exception)
14
+ ret = system(*args, **kwargs)
15
+ return ret if ret || !exception
16
+
17
+ raise $?.to_s
24
18
  else
25
- return Kernel.send(name, *args, **kwargs)
19
+ system(*args, **kwargs)
26
20
  end
27
- return ret unless e && !ret && name == :system
28
-
29
- raise $?.to_s
30
21
  end
31
22
 
32
23
  def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, verbose: true)
@@ -38,9 +29,10 @@ module Squared
38
29
  dest.mkpath if create
39
30
  if pass
40
31
  exclude = []
41
- Array(pass).each { |val| exclude += Dir.glob(src.join(val)) }
32
+ pass = [pass] unless pass.is_a?(::Array)
33
+ pass.each { |val| exclude += Dir.glob(src.join(val)) }
42
34
  end
43
- Array(glob).each do |val|
35
+ (glob.is_a?(::Array) ? glob : [glob]).each do |val|
44
36
  Dir.glob(src.join(val)) do |path|
45
37
  next if exclude&.include?(path) || (path = Pathname.new(path)).directory?
46
38
 
@@ -87,7 +79,8 @@ module Squared
87
79
  def copy_guard(src, dest, link: nil, force: false, verbose: true)
88
80
  unless force
89
81
  if (path = Pathname.new(dest)).directory?
90
- src = Array(src).reject { |val| path.join(File.basename(val)).exist? }
82
+ src = [src] unless src.is_a?(::Array)
83
+ src = src.reject { |val| path.join(File.basename(val)).exist? }
91
84
  return if src.empty?
92
85
  elsif path.exist?
93
86
  return
@@ -8,6 +8,10 @@ module Squared
8
8
  module Utils
9
9
  module_function
10
10
 
11
+ def split_escape(val, char: ',')
12
+ val.split(/\s*(?<!\\)#{char}\s*/o)
13
+ end
14
+
11
15
  def task_invoke(*cmd, args: [], exception: true, warning: true)
12
16
  cmd.each { |name| Rake::Task[name].invoke(*args) }
13
17
  rescue StandardError => e
@@ -31,8 +35,57 @@ module Squared
31
35
  Rake::Task.tasks.any? do |obj|
32
36
  next unless obj.already_invoked
33
37
 
34
- args.any? { |val| val.is_a?(::Regexp) ? obj.name =~ val : val == obj.name }
38
+ args.any? { |val| val.is_a?(::Regexp) ? obj.name.match?(val) : val == obj.name }
39
+ end
40
+ end
41
+
42
+ def time_format(epoch, clock: false, pass: [])
43
+ ss = 1000
44
+ mm = 60 * ss
45
+ hh = 60 * mm
46
+ dd = 24 * hh
47
+ hm = pass.include?('s')
48
+ time = []
49
+ if !clock && (d = epoch / dd) > 0
50
+ time << "#{d}d"
51
+ epoch -= d * dd
52
+ end
53
+ if (h = epoch / hh) > 0
54
+ time << (clock ? h.to_s : "#{h}h")
55
+ epoch -= h * hh
35
56
  end
57
+ if (m = epoch / mm) > 0
58
+ time << (clock ? m.to_s.rjust(2, '0') : "#{m}m")
59
+ epoch -= m * mm
60
+ elsif clock
61
+ time << '00'
62
+ end
63
+ unless hm
64
+ if (s = epoch / ss) > 0
65
+ time << (clock ? s.to_s.rjust(2, '0') : "#{s}s")
66
+ epoch -= s * ss
67
+ elsif clock
68
+ time << '00'
69
+ end
70
+ end
71
+ if clock
72
+ time.join(':')
73
+ else
74
+ time << "#{epoch}ms" unless hm || pass.include?('ms')
75
+ time.join(' ')
76
+ end
77
+ end
78
+
79
+ def time_offset(val = nil)
80
+ val = DateTime.parse(val) if val.is_a?(::String)
81
+ cur = DateTime.now
82
+ ret = 0
83
+ if (r = /^([+-])(\d+):(\d+):(\d+)$/.match((val || cur).strftime('%::z')))
84
+ ret += (r[1] == '+' ? -1 : 1) * ((r[2].to_i * 60 * 60) + (r[3].to_i * 60) + r[4].to_i) * 1000
85
+ end
86
+ return ret unless val
87
+
88
+ (cur.strftime('%Q').to_i + time_offset) - (val.strftime('%Q').to_i + ret)
36
89
  end
37
90
 
38
91
  def env(key, default = nil, suffix: nil, strict: false, equals: nil, ignore: nil)
@@ -88,7 +141,7 @@ module Squared
88
141
  return ret.to_i
89
142
  end
90
143
  when ::Numeric
91
- return key if key.between?(0, 2)
144
+ return key if key >= 0 && key <= 2
92
145
  end
93
146
  default
94
147
  end
@@ -90,7 +90,7 @@ module Squared
90
90
  @required = true
91
91
  project ? [project, 'not found'] : ['name', 'missing']
92
92
  end
93
- warn log_message(Logger::WARN, msg, subject: self.class, hint: hint)
93
+ warn log_message(Logger::WARN, msg, subject: self.class, hint: hint, pass: true)
94
94
  end
95
95
 
96
96
  def build
@@ -250,8 +250,6 @@ module Squared
250
250
  { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
251
251
  { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
252
252
  { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
253
- { pat: /\A(.+ : )(true|false)(\s*)\z/m, styles: theme[:boolean],
254
- index: 2 },
255
253
  { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
256
254
  index: 2 }
257
255
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.14'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -173,7 +173,7 @@ module Squared
173
173
  when Symbol
174
174
  @ref = val
175
175
  else
176
- raise_error('group{Symbol} | ref{String}', hint: 'missing') if block_given?
176
+ raise_error 'missing group or ref' if block_given?
177
177
  end
178
178
  if block_given?
179
179
  instance_eval(&blk)
@@ -296,7 +296,7 @@ module Squared
296
296
  index = 0
297
297
  while @project[name]
298
298
  index += 1
299
- name = task_name "#{project}-#{index}"
299
+ name = "#{project}-#{index}"
300
300
  end
301
301
  proj = ((if !ref.is_a?(Class)
302
302
  Application.find(ref, path: path)
@@ -350,14 +350,14 @@ module Squared
350
350
  end
351
351
 
352
352
  def describe(data)
353
- @describe ||= {
353
+ @describe = {
354
354
  alias: {},
355
355
  replace: [],
356
356
  pattern: {}
357
357
  }
358
358
  data.each do |key, val|
359
359
  key = key.to_s
360
- if /\A(\\A|\^)/ =~ key || /(\\z|\$)\z/ =~ key
360
+ if key.match?(/\A(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
361
361
  @describe[:replace] << [Regexp.new(key), val]
362
362
  else
363
363
  @describe[val.is_a?(Regexp) ? :pattern : :alias][key.to_s] = val
@@ -404,7 +404,7 @@ module Squared
404
404
  end
405
405
 
406
406
  def task_localname(val)
407
- prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/, '') : val.to_s
407
+ prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/o, '') : val.to_s
408
408
  end
409
409
 
410
410
  def task_desc(*args, **kwargs)
@@ -415,15 +415,14 @@ module Squared
415
415
  val = name || task_join(*args)
416
416
  found = false
417
417
  replace = lambda do |data, out|
418
- if (index = data.size) > 0
419
- data.to_a.reverse_each { |group| out.sub!("%#{index -= 1}", group) }
420
- end
418
+ index = data.size
419
+ data.to_a.reverse_each { |group| out.sub!("%#{index -= 1}", group) }
421
420
  out
422
421
  end
423
- @describe[:replace].each do |pat, key|
424
- next unless (data = pat.match(val))
422
+ @describe[:replace].each do |pat, tmpl|
423
+ next unless val =~ pat
425
424
 
426
- val = replace.(data, key.dup)
425
+ val = replace.($~, tmpl.dup)
427
426
  found = true
428
427
  end
429
428
  if (out = @describe[:alias][val])
@@ -431,14 +430,14 @@ module Squared
431
430
  found = true
432
431
  else
433
432
  @describe[:pattern].each do |key, pat|
434
- next unless (data = pat.match(val))
433
+ next unless val =~ pat
435
434
 
436
- val = replace.(data, key.dup)
435
+ val = replace.($~, key.dup)
437
436
  found = true
438
437
  break
439
438
  end
440
439
  end
441
- args = Shell.split_escape(val, char: ':').map! { |s| s.gsub('\\:', ':') } if found
440
+ args = split_escape(val, char: ':').map! { |s| s.gsub('\\:', ':') } if found
442
441
  end
443
442
  desc message(*args, **kwargs)
444
443
  end
@@ -455,7 +454,7 @@ module Squared
455
454
  tasks << key if obj.has?(key, baseref)
456
455
  elsif (batch = series.batch_get(key))
457
456
  obj.allref.each do |ref|
458
- next unless obj.has?(key, ref) && (data = batch[ref])
457
+ next unless (data = batch[ref])
459
458
 
460
459
  data.each do |val|
461
460
  if (items = task_resolve(obj, val)).empty?
@@ -474,7 +473,7 @@ module Squared
474
473
  return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
475
474
 
476
475
  obj.allref.each do |ref|
477
- next unless obj.has?(key, ref) && (alt = data[ref])
476
+ next unless (alt = data[ref])
478
477
 
479
478
  ret = task_resolve(obj, alt)
480
479
  break unless ret.empty?
@@ -564,7 +563,7 @@ module Squared
564
563
 
565
564
  key = task_join(task_localname(obj.name), key)
566
565
  end
567
- @pass[:pattern].any? { |item| item.is_a?(Regexp) ? key =~ item : key == item }
566
+ @pass[:pattern].any? { |item| item.is_a?(Regexp) ? key.to_s.match?(item) : key == item }
568
567
  end
569
568
 
570
569
  def task_defined?(*key)
@@ -587,12 +586,8 @@ module Squared
587
586
  Rake::Win32.windows?
588
587
  end
589
588
 
590
- def jruby?
591
- RUBY_ENGINE == 'jruby'
592
- end
593
-
594
- def jruby_win?
595
- jruby? && windows?
589
+ def docker?
590
+ File.exist?('/.dockerenv')
596
591
  end
597
592
 
598
593
  def rootpath(*args)
@@ -628,14 +623,9 @@ module Squared
628
623
  private
629
624
 
630
625
  def __build__(default: nil, **)
631
- unless task_defined?('squared:version')
632
- task 'squared:version' do
633
- puts Squared::VERSION
634
- end
635
- end
636
- if default && task_defined?(out = task_name(default))
637
- task Rake.application.default_task_name => out
638
- end
626
+ return unless default && task_defined?(out = task_name(default))
627
+
628
+ task Rake.application.default_task_name => out
639
629
  end
640
630
 
641
631
  def puts(*args)
@@ -669,19 +659,20 @@ module Squared
669
659
  end
670
660
 
671
661
  def data_get(*args, group: nil, ref: nil, target: nil)
672
- if group && (ret = target[:group][group.to_sym])
673
- ret
674
- elsif ref
675
- if ref.is_a?(Enumerable)
676
- ref.each do |key|
677
- next unless (ret = target[:ref][key])
662
+ if group
663
+ target[:group][group.to_sym]
664
+ elsif ref.is_a?(Array)
665
+ ref = ref.each
666
+ end
667
+ if ref.instance_of?(Enumerator)
668
+ ref.each do |key|
669
+ next unless (ret = target[:ref][key])
678
670
 
679
- return ret if args.empty? || args.any? { |val| ret.key?(val) }
680
- end
681
- nil
682
- else
683
- target[:ref][ref]
671
+ return ret if args.empty? || args.any? { |val| ret.key?(val) }
684
672
  end
673
+ nil
674
+ elsif ref
675
+ target[:ref][ref]
685
676
  end
686
677
  end
687
678
 
@@ -705,7 +696,7 @@ module Squared
705
696
  end
706
697
  return false if state == :prod && data[:dev] == true && data[:global]
707
698
 
708
- target && pat.is_a?(Regexp) ? as_a(target).any? { |val| val =~ pat } : pat == true
699
+ target && pat.is_a?(Regexp) ? as_a(target).any? { |val| val.match?(pat) } : pat == true
709
700
  end
710
701
 
711
702
  def scriptobj