squared 0.4.13 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bc10e49a42c1eda78b4ff20f734efffd74eda16bc8dae742d2a0f29c0f34851
4
- data.tar.gz: 64b5e88317ba5208cc7824f40b9a4ff810a63197bc0b27813906a2293bbe1388
3
+ metadata.gz: 46ea608e0b2d67acb3d15eaf67d7c70fc4c301c1c7ebf0dbfa9fba2e9ccabe0b
4
+ data.tar.gz: 806aeee453718e1ff75f1f83c3f2ac763fd989cdddeca18b570a1d383c90484c
5
5
  SHA512:
6
- metadata.gz: f34a4d13854343d0713e34bf964feda5206f1c9a60ec2781fca611e74f7257753e01a895e081663b0c2d154a4c4834c39fa478e4665c58982eea053b53fd9529
7
- data.tar.gz: ff549d38162731add0bbb6dd8bd7566f2200d6006f92c268aa0af4271e4f6a60a5a407b6a3a48fbeeee035c0ede41c135f760eb907582ede90020a1c61c7d890
6
+ metadata.gz: bcde780730f2426af5561183d7d33d172f7dc7a096f9b21b3098593e18758a6a5bdb26e40ccabfaf7e0cf2e6963f067289c304e2e7626b85c15dd2c589e907e0
7
+ data.tar.gz: efcae50c9cfd39b72c013035df135533fee434e7985c3896d409a3d2d1850f16c2c7d2dd811e89431ddc46e2fbc64f752ece5bc8f1205d79d052bcec59fb7749
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.0] - 2025-06-16
4
+
5
+ ### Added
6
+
7
+ - Node command exec through NVM was implemented.
8
+ - Git command options were updated to version 2.49.
9
+
10
+ ### Changed
11
+
12
+ - Gem specification required Ruby version set to 2.5.
13
+ - Docker build options from ENV do not require dashes.
14
+ - Unused task descriptions are not generated.
15
+ - Class object shapes were declared in initialize.
16
+ - Project outdated interactive uses a more compact prompt.
17
+ - Workspace banner configuration uses a struct.
18
+
19
+ ### Removed
20
+
21
+ - Git commit hash identifier uses only a colon for a prefix.
22
+ - Common module for classes was delegated to support namespaces.
23
+
24
+ ### Fixed
25
+
26
+ - Project private variables external modification was revised.
27
+
3
28
  ## [0.4.13] - 2025-06-16
4
29
 
5
30
  ### Added
@@ -736,6 +761,7 @@
736
761
 
737
762
  - Changelog was created.
738
763
 
764
+ [0.5.0]: https://github.com/anpham6/squared/releases/tag/v0.5.0-ruby
739
765
  [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
740
766
  [0.4.12]: https://github.com/anpham6/squared/releases/tag/v0.4.12-ruby
741
767
  [0.4.11]: https://github.com/anpham6/squared/releases/tag/v0.4.11-ruby
data/README.md CHANGED
@@ -140,13 +140,13 @@ rake clone # node + docs
140
140
  # PIPE_FAIL={0,1}
141
141
  # PORT=3000
142
142
  docker build -t squared --build-arg MANIFEST=prod --build-arg NODE_ENV=production .
143
- docker build -t node --build-arg NODE_TAG=22 --build-arg NODE_INSTALL=pnpm -f slim.Dockerfile .
143
+ docker build -t node --build-arg NODE_TAG=22 --build-arg NODE_INSTALL=pnpm -f Dockerfile.slim .
144
144
  NODE=22 docker buildx bake node
145
145
  # OR
146
- docker build -t ruby --build-arg RUBY_TAG=3.4.0 --build-arg NODE_VERSION=22 --build-arg PIPE_FAIL=0 -f ruby.Dockerfile .
146
+ docker build -t ruby --build-arg RUBY_TAG=3.4.0 --build-arg NODE_VERSION=22 --build-arg PIPE_FAIL=0 -f Dockerfile.ruby .
147
147
  RUBY=3.4.0 docker buildx bake ruby
148
148
  # OR
149
- docker build -t nginx --build-arg NGINX_VERSION=1.27 --build-arg PORT=3000 --build-arg NODE_VERSION=20 -f nginx.Dockerfile .
149
+ docker build -t nginx --build-arg NGINX_VERSION=1.27 --build-arg PORT=3000 --build-arg NODE_VERSION=20 -f Dockerfile.nginx .
150
150
  NGINX=1.27 docker buildx bake nginx
151
151
 
152
152
  # Express
@@ -1359,4 +1359,4 @@ NOTE: Defining an element "**id**" will prevent it from being removed during the
1359
1359
 
1360
1360
  ## LICENSE
1361
1361
 
1362
- BSD 3-Clause
1362
+ BSD 3-Clause
data/README.ruby.md CHANGED
@@ -1,16 +1,17 @@
1
- # squared 0.4
1
+ # squared 0.5
2
2
 
3
3
  * [source](https://github.com/anpham6/squared)
4
4
  * [docs](https://squared.readthedocs.io)
5
5
 
6
6
  ## Version Compatibility
7
7
 
8
- | Date | squared | Min | Max | Git |
9
- | :--------: | ------: | -----: | -----: | -----: |
10
- | 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 | 2.39 |
11
- | 2025-01-07 | 0.2.0 | 2.4.0 | 3.4.0 | 2.39 |
12
- | 2025-02-07 | 0.3.0 | 2.4.0 | 3.4.1 | 2.39 |
13
- | 2025-03-06 | 0.4.0 | 2.4.0 | 3.4.2 | 2.39 |
8
+ | Date | squared | Min | Max |
9
+ | :--------: | ------: | -----: | -----: |
10
+ | 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 |
11
+ | 2025-01-07 | 0.2.0 | | 3.4.0 |
12
+ | 2025-02-07 | 0.3.0 | | 3.4.1 |
13
+ | 2025-03-06 | 0.4.0 | | 3.4.2 |
14
+ | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.3 |
14
15
 
15
16
  The range chart indicates the latest Ruby tested against at the time of release.
16
17
 
@@ -263,7 +264,7 @@ Workspace::Application
263
264
  add("squared") do
264
265
  revbuild(include: %w[src/ framework/ types/]) # Git revision build command (optional)
265
266
  chain "all", "revbuild", after: "express:build" # step: 4
266
- chain "publish", "bump:patch", "publish:latest", step: 0, sync: true # rake publish -> squared:bump:patch -> squared:publish:latest
267
+ chain "publish", "bump:patch", "publish:latest", step: 0, sync: true # rake publish
267
268
  end
268
269
  end
269
270
  .with(:python) do
@@ -275,12 +276,12 @@ Workspace::Application
275
276
  chain "all", "doc", with: "squared", before: "squared:revbuild" # Same
276
277
  end
277
278
  end
278
- .chain "all", "status", with: "squared", after: "android-docs" # Global tasks (e.g. without ":")
279
+ .chain("all", "status", with: "squared", after: "android-docs") # Global tasks (e.g. without ":")
279
280
  .build
280
281
  ```
281
282
 
282
283
  ```sh
283
- rake all # all[1-3-4]
284
+ rake all # all[1-3-4]
284
285
  rake all:print
285
286
  ```
286
287
 
@@ -537,7 +538,6 @@ Commands which use commit hashes are parsed using a ":" prefix as to not be conf
537
538
 
538
539
  ```sh
539
540
  rake squared:log:view[:af012345] # git log af012345
540
- rake squared:log:view[#{af012345}] # deprecated
541
541
  rake squared:log:view[H1,HEAD^5,all,lib,./H12345] # git log --all @~1 @^5 -- 'lib' 'H12345'
542
542
  ```
543
543
 
@@ -683,6 +683,9 @@ DOCKER_TAG=latest # all
683
683
  DOCKER_TAG_${NAME}=v0.1.0 # project only (override)
684
684
  DOCKER_ALL=1 # list every image/container
685
685
  DOCKER_Y=1 # confirm all
686
+
687
+ BUILD_SQUARED_OPTS="NODE_TAG=24 RUBY_VERSION=3.4.0" DOCKER_SQUARED_OPTS="--no-cache --label=v1" rake squared:build
688
+ docker build --no-cache --label=v1 --build-arg='NODE_TAG=24' --build-arg='RUBY_VERSION=3.4.0' .
686
689
  ```
687
690
 
688
691
  | Command | Flag | ENV |
@@ -99,7 +99,7 @@ module Squared
99
99
 
100
100
  module_function
101
101
 
102
- def as_a(obj, meth = nil, flat: nil, compact: false, &blk)
102
+ def as_a(obj, *meth, flat: nil, compact: false, &blk)
103
103
  return [] if obj.nil?
104
104
 
105
105
  unless obj.is_a?(::Array)
@@ -111,8 +111,10 @@ module Squared
111
111
  end
112
112
  obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
113
113
  obj = obj.compact if compact
114
- obj = obj.map(&meth) if meth
115
- block_given? ? obj.select(&blk) : obj
114
+ obj = obj.map(&meth.shift) until meth.empty?
115
+ return obj unless block_given?
116
+
117
+ obj.select(&blk)
116
118
  end
117
119
  end
118
120
  end
@@ -35,7 +35,7 @@ module Squared
35
35
 
36
36
  def enable_aixterm
37
37
  unless (colors = __get__(:colors)).frozen?
38
- colors.merge!(AIX_TERM)
38
+ colors.update(AIX_TERM)
39
39
  end
40
40
  self
41
41
  end
@@ -11,24 +11,22 @@ module Squared
11
11
  agree = /^#{Regexp.escape(agree)}$/i if agree.is_a?(::String)
12
12
  cancel = /^#{Regexp.escape(cancel)}$/i if cancel.is_a?(::String)
13
13
  Timeout.timeout(timeout) do
14
- begin
15
- while (ch = Readline.readline(msg))
16
- ch = ch.chomp
17
- case (ch.empty? ? default : ch)
18
- when agree
19
- return true
20
- when cancel
21
- return false
22
- end
23
- attempts -= 1
24
- exit 1 unless attempts > 0
14
+ while (ch = Readline.readline(msg))
15
+ ch = ch.chomp
16
+ case (ch.empty? ? default : ch)
17
+ when agree
18
+ return true
19
+ when cancel
20
+ return false
25
21
  end
26
- rescue Interrupt
27
- puts
28
- exit 0
29
- else
30
- false
22
+ attempts -= 1
23
+ exit 1 unless attempts > 0
31
24
  end
25
+ rescue Interrupt
26
+ puts
27
+ exit 0
28
+ else
29
+ false
32
30
  end
33
31
  end
34
32
 
@@ -56,33 +54,31 @@ module Squared
56
54
  end
57
55
  valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max) }
58
56
  Timeout.timeout(timeout) do
59
- begin
60
- while (ch = Readline.readline(msg))
61
- unless (ch = ch.strip).empty?
62
- if multiple
63
- a = ch.split(/\s*,\s*/)
64
- b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
65
- next unless a.size == b.size
66
- return b unless items
67
- next if multiple.is_a?(::Numeric) && multiple != b.size
57
+ while (ch = Readline.readline(msg))
58
+ unless (ch = ch.strip).empty?
59
+ if multiple
60
+ a = ch.split(/\s*,\s*/)
61
+ b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
62
+ next unless a.size == b.size
63
+ return b unless items
64
+ next if multiple.is_a?(::Numeric) && multiple != b.size
68
65
 
69
- return b.map! { |i| items[i - 1] }
70
- elsif valid.call(ch)
71
- return items ? items[ch.to_i - 1] : ch.to_i
72
- end
66
+ return b.map! { |i| items[i - 1] }
67
+ elsif valid.call(ch)
68
+ return items ? items[ch.to_i - 1] : ch.to_i
73
69
  end
74
- attempts -= 1
75
- next if attempts > 0
76
- break unless force
77
-
78
- exit 1
79
70
  end
80
- rescue Interrupt
81
- puts
82
- exit 0
83
- else
84
- multiple ? [] : nil
71
+ attempts -= 1
72
+ next if attempts > 0
73
+ break unless force
74
+
75
+ exit 1
85
76
  end
77
+ rescue Interrupt
78
+ puts
79
+ exit 0
80
+ else
81
+ multiple ? [] : nil
86
82
  end
87
83
  end
88
84
 
@@ -85,26 +85,31 @@ module Squared
85
85
  end}"
86
86
  end
87
87
 
88
- def shell_split(val, quote: false, force: false, join: nil)
88
+ def shell_split(val, join: nil, **kwargs)
89
89
  ret = val.shellsplit
90
- ret.map! { |opt| shell_escape(opt, quote: quote, force: force, double: true, option: true) }
90
+ ret.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
91
91
  return ret unless join
92
92
 
93
93
  ret.join(join.is_a?(::String) ? join : ' ')
94
94
  end
95
95
 
96
- def fill_option(val, double: false)
96
+ def line_width(lines)
97
+ ret = [lines.max_by(&:size).size, 80].max
98
+ [ret, Rake.application.terminal_width].min
99
+ end
100
+
101
+ def fill_option(val, **kwargs)
97
102
  return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
98
103
 
99
- shell_escape(val.start_with?('-') ? val : "--#{val}", double: double)
104
+ shell_escape(val.start_with?('-') ? val : "--#{val}", **kwargs)
100
105
  end
101
106
 
102
- def quote_option(flag, val, option: true, double: false, merge: false)
103
- shell_option(flag, val, escape: false, option: option, double: double, merge: merge)
107
+ def quote_option(flag, val, **kwargs)
108
+ shell_option(flag, val, escape: false, **kwargs)
104
109
  end
105
110
 
106
- def basic_option(flag, val, merge: false)
107
- shell_option(flag, val, escape: false, force: false, merge: merge)
111
+ def basic_option(flag, val, **kwargs)
112
+ shell_option(flag, val, escape: false, force: false, **kwargs)
108
113
  end
109
114
  end
110
115
  end
@@ -20,28 +20,30 @@ module Squared
20
20
  end
21
21
  end
22
22
 
23
- def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, verbose: true)
24
- src = Pathname.new(src)
25
- dest = Pathname.new(dest)
26
- raise "#{dest.cleanpath} (not found)" if !create && !dest.parent.exist?
23
+ def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, hidden: false,
24
+ verbose: true)
25
+ base = Pathname.new(src)
26
+ target = Pathname.new(dest)
27
+ raise "#{target.cleanpath} (not found)" if !create && !target.parent.exist?
27
28
 
28
29
  subdir = {}
29
- dest.mkpath if create
30
+ target.mkpath if create
31
+ flags = hidden ? [File::FNM_DOTMATCH] : []
30
32
  if pass
31
33
  exclude = []
32
- pass = [pass] unless pass.is_a?(::Enumerable)
33
- pass.each { |val| exclude.concat(Dir.glob(src + val)) }
34
+ pass = [pass] unless pass.is_a?(::Array)
35
+ pass.each { |val| exclude.concat(Dir.glob(val, *flags, base: base)) }
34
36
  end
35
37
  (glob.is_a?(::Enumerable) ? glob : [glob]).each do |val|
36
- Dir.glob(src + val) do |path|
37
- next if exclude&.include?(path) || (path = Pathname.new(path)).directory?
38
+ Dir.glob(val, *flags, base: base) do |file|
39
+ next if exclude&.include?(file) || (entry = base + file).directory?
38
40
 
39
- dir = dest.join(path.relative_path_from(src)).dirname
41
+ dir = target.join(file).dirname
40
42
  if (data = subdir[dir.to_s])
41
- data << path
43
+ data << entry
42
44
  else
43
45
  dir.mkpath
44
- subdir[dir.to_s] = [path]
46
+ subdir[dir.to_s] = [entry]
45
47
  end
46
48
  end
47
49
  end
@@ -49,23 +51,24 @@ module Squared
49
51
  soft = 0
50
52
  subdir.each do |dir, files|
51
53
  if link
52
- items = files.dup
53
- files.clear
54
- items.each do |file|
55
- if file.exist?
56
- if file.symlink?
57
- next unless force
54
+ files.dup.yield_self do |items|
55
+ files.clear
56
+ items.each do |file|
57
+ if file.exist?
58
+ if file.symlink?
59
+ next unless force
60
+ else
61
+ files << file
62
+ next
63
+ end
64
+ end
65
+ if link == 'hard'
66
+ FileUtils.ln(file, dir, force: force, verbose: false)
58
67
  else
59
- files << file
60
- next
68
+ FileUtils.ln_s(file, dir, force: force, verbose: false)
61
69
  end
70
+ soft += 1
62
71
  end
63
- if link == 'hard'
64
- FileUtils.ln(file, dir, force: force, verbose: false)
65
- else
66
- FileUtils.ln_s(file, dir, force: force, verbose: false)
67
- end
68
- soft += 1
69
72
  end
70
73
  end
71
74
  next if files.empty?
@@ -73,16 +76,17 @@ module Squared
73
76
  out = FileUtils.cp(files, dir, verbose: false)
74
77
  count += out.size
75
78
  end
76
- puts [dest.realpath, subdir.size, soft > 0 ? "#{count}+#{soft}" : count].join(' => ') if verbose
79
+ puts [target.realpath, subdir.size, soft > 0 ? "#{count}+#{soft}" : count].join(' => ') if verbose
77
80
  end
78
81
 
79
82
  def copy_guard(src, dest, link: nil, force: false, verbose: true)
80
83
  unless force
81
- if (path = Pathname.new(dest)).directory?
84
+ target = Pathname.new(dest)
85
+ if target.directory?
82
86
  src = [src] unless src.is_a?(::Enumerable)
83
- src = src.reject { |val| path.join(File.basename(val)).exist? }
87
+ src = src.reject { |val| target.join(File.basename(val)).exist? }
84
88
  return if src.empty?
85
- elsif path.exist?
89
+ elsif target.exist?
86
90
  return
87
91
  end
88
92
  end
@@ -88,18 +88,6 @@ module Squared
88
88
  end
89
89
  end
90
90
 
91
- def time_offset(val = nil)
92
- val = DateTime.parse(val) if val.is_a?(::String)
93
- cur = DateTime.now
94
- ret = 0
95
- if (r = /^([+-])(\d+):(\d+):(\d+)$/.match((val || cur).strftime('%::z')))
96
- ret += (r[1] == '+' ? -1 : 1) * ((r[2].to_i * 60 * 60) + (r[3].to_i * 60) + r[4].to_i) * 1000
97
- end
98
- return ret unless val
99
-
100
- (cur.strftime('%Q').to_i + time_offset) - (val.strftime('%Q').to_i + ret)
101
- end
102
-
103
91
  def time_since(val, ms: true)
104
92
  s = ms ? '%s%L' : '%s'
105
93
  Time.now.utc.strftime(s).to_i - Time.parse(val).utc.strftime(s).to_i
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  require_relative 'common/base'
4
- require_relative 'common/class'
5
6
  require_relative 'common/format'
6
7
  require_relative 'common/prompt'
7
8
  require_relative 'common/shell'
@@ -27,7 +27,7 @@ module Squared
27
27
  def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
28
28
  return unless project.enabled?
29
29
 
30
- ret = Viewer.new(main, name, project: project, **kwargs)
30
+ ret = new(main, name, project: project, **kwargs)
31
31
  ret.instance_eval(&blk) if block_given?
32
32
  ret
33
33
  end
@@ -170,7 +170,7 @@ module Squared
170
170
  end
171
171
 
172
172
  def style(name, *args)
173
- apply_style(theme, name, args)
173
+ apply_style theme, name, args
174
174
  self
175
175
  end
176
176
 
@@ -213,7 +213,7 @@ module Squared
213
213
  file = nil
214
214
  ext[0] = mime
215
215
  elsif file
216
- keys.unshift(file)
216
+ keys.prepend(file)
217
217
  alt = basepath("#{main}.{#{ext.join(',')}}")
218
218
  file = Dir[alt].first
219
219
  else
@@ -243,13 +243,14 @@ module Squared
243
243
  [
244
244
  { pat: /\A((?:[^:]|(?<! ):(?! ))+)\z/, styles: theme[:banner] },
245
245
  { pat: /\A(.*?)(<[^>]+>)(.+)\z/m, styles: theme[:undefined], index: 2 },
246
- { pat: /\A(.+)( : (?!undefined).+)\z/m, styles: theme[:key] },
247
- { pat: /\A(.+ : )(-?[\d.]+)(\s*)\z/m, styles: theme[:number],
246
+ { pat: /\A((?~ : ))( : (?!undefined).+)\z/m, styles: theme[:key] },
247
+ { pat: /\A((?~: ): )(-?[\d.]+)(\s*)\z/m, styles: theme[:number],
248
248
  index: 2 },
249
- { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
250
- { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
251
- { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
252
- { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
249
+ { pat: /\A((?~: ): ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
250
+ { pat: /\A((?~: ): \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
251
+ { pat: /\A((?~: ): \[)(.+)(\]\s*)\z/m, styles: theme[:array],
252
+ index: 2 },
253
+ { pat: /\A((?~: ): (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
253
254
  index: 2 }
254
255
  ]
255
256
  end, border: theme[:border])
@@ -308,7 +309,7 @@ module Squared
308
309
  return unless Rake::TaskManager.record_task_metadata
309
310
 
310
311
  val = "#{ext.first}[#{target ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
311
- args = *name.split(':').push(command, val)
312
+ args = *name.split(':').append(command, val)
312
313
  if project
313
314
  project.workspace.task_desc(*args)
314
315
  else
@@ -346,7 +347,7 @@ module Squared
346
347
  end
347
348
 
348
349
  def basepath(file)
349
- project ? project.basepath(file) : Pathname.new(file).realdirpath
350
+ project ? project.basepath(file) : Pathname.pwd + file
350
351
  end
351
352
  end
352
353
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.13'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -29,7 +29,7 @@ module Squared
29
29
  @impl_project = obj
30
30
  impl_series.base_set(obj)
31
31
  else
32
- kind_project.unshift(obj)
32
+ kind_project.prepend(obj)
33
33
  obj.tasks&.each { |task| impl_series.add(task, obj) }
34
34
  end
35
35
  if (args = obj.batchargs)
@@ -73,7 +73,7 @@ module Squared
73
73
  end
74
74
 
75
75
  @kind_project = []
76
- @task_exclude = SymSet.new
76
+ @task_exclude = Set.new
77
77
 
78
78
  attr_reader :root, :home, :main, :prefix, :exception, :warning, :pipe, :verbose, :theme, :series, :closed
79
79
 
@@ -220,7 +220,7 @@ module Squared
220
220
  if arg.include?(':') || (keys && !keys.include?(arg))
221
221
  task_name(arg)
222
222
  else
223
- /\A#{Regexp.escape(task_name(arg))}:/
223
+ /#{Regexp.escape(arg)}:/
224
224
  end
225
225
  end
226
226
  end
@@ -278,7 +278,7 @@ module Squared
278
278
  end
279
279
 
280
280
  def banner(*args, command: true, styles: nil, border: nil, group: @group, ref: @ref)
281
- data = { command: command, order: [], styles: check_style(styles, empty: false), border: check_style(border) }
281
+ data = Support::BannerData.new(command, [], check_style(styles, empty: false), check_style(border))
282
282
  args.each do |meth|
283
283
  if meth.is_a?(Array)
284
284
  found = false
@@ -301,9 +301,8 @@ module Squared
301
301
  elsif !Application.attr_banner.include?(meth = meth.to_sym)
302
302
  next
303
303
  end
304
- data[:order] << meth
304
+ data.order << meth
305
305
  end
306
- data = {} if !command && data[:order].empty?
307
306
  if group
308
307
  label = :group
309
308
  items = as_a group
@@ -316,11 +315,7 @@ module Squared
316
315
  end
317
316
 
318
317
  def add(path, project = nil, **kwargs, &blk)
319
- if @withargs
320
- data = @withargs.dup
321
- data.merge!(kwargs)
322
- kwargs = data
323
- end
318
+ kwargs = @withargs.yield_self { |data| data.dup.update(kwargs) } if @withargs
324
319
  ref = if kwargs.key?(:ref)
325
320
  kwargs = kwargs.dup unless @withargs
326
321
  kwargs.delete(:ref)
@@ -360,7 +355,7 @@ module Squared
360
355
  end
361
356
  .each do |dir, basename, opts|
362
357
  args = kwargs.dup
363
- args.merge!(opts) if opts
358
+ args.update(opts) if opts
364
359
  add(dir, basename, group: val, **args, &blk)
365
360
  end
366
361
  self
@@ -399,7 +394,7 @@ module Squared
399
394
  }
400
395
  data.each do |key, val|
401
396
  key = key.to_s
402
- if key.match?(/\A(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
397
+ if key.start_with?(/(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
403
398
  @describe[:replace] << [Regexp.new(key), val]
404
399
  else
405
400
  @describe[val.is_a?(Regexp) ? :pattern : :alias][key.to_s] = val
@@ -417,7 +412,7 @@ module Squared
417
412
  if ret.empty?
418
413
  ret = @project.select { |_, item| item.ref?(ref) }.map(&:last) if ref
419
414
  if ret.empty? && (path || name)
420
- path &&= rootpath(path)
415
+ path &&= rootpath path
421
416
  name &&= name.to_s
422
417
  proj = @project.find { |_, item| (path && item.path == path) || (name && item.name == name) }&.last
423
418
  ret << proj if proj
@@ -517,7 +512,7 @@ module Squared
517
512
  obj.allref.each do |ref|
518
513
  next unless obj.has?(key, ref) && (alt = data[ref])
519
514
 
520
- ret = task_resolve(obj, alt)
515
+ ret = task_resolve obj, alt
521
516
  break unless ret.empty?
522
517
  end
523
518
  else
@@ -537,7 +532,7 @@ module Squared
537
532
  end
538
533
 
539
534
  def format_desc(val, opts = nil, arg: 'opts*', before: nil, after: nil, out: false)
540
- return unless TASK_METADATA || out
535
+ return unless TASK_METADATA
541
536
 
542
537
  val = val.split(':') if val.is_a?(String)
543
538
  if before || after || opts
@@ -703,7 +698,7 @@ module Squared
703
698
  else
704
699
  step = 0
705
700
  catch :found do
706
- has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.match?(e) : d == e } }
701
+ has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.start_with?(e) : d == e } }
707
702
  w = data.with
708
703
  a = data.after
709
704
  b = data.before
@@ -762,7 +757,7 @@ module Squared
762
757
  end
763
758
  end
764
759
  if step == -1
765
- level.unshift(data.action)
760
+ level.prepend(data.action)
766
761
  step = 0
767
762
  elsif step > 0
768
763
  (level[step -= 1] ||= []).concat(data.action)
@@ -852,7 +847,7 @@ module Squared
852
847
  def root?(path, pass: [])
853
848
  return false unless path.directory?
854
849
 
855
- path.children.each do |c|
850
+ path.each_child do |c|
856
851
  name = c.basename.to_s
857
852
  next if c.to_s == __FILE__ || (@main == name && c.directory? && c.empty?) || pass.any? { |val| val == name }
858
853
 
@@ -862,14 +857,14 @@ module Squared
862
857
  end
863
858
 
864
859
  def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false)
865
- data = script_find(ref, group)
860
+ data = script_find ref, group
866
861
  if global
867
862
  target = data[:script] || data[:run] if target.nil?
868
863
  pat = data[state] if pat.nil?
869
864
  end
870
865
  return false if state == :prod && data[:dev] == true && data[:global]
871
866
 
872
- target && pat.is_a?(Regexp) ? as_a(target).any? { |val| val.match?(pat) } : pat == true
867
+ target && pat.is_a?(Regexp) ? as_a(target).any?(pat) : pat == true
873
868
  end
874
869
 
875
870
  def scriptobj