squared 0.7.7 → 0.8.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: 31bed35054b2a63862e132897fcbe7b6bdc38e034e083f2d05c31faede547105
4
- data.tar.gz: de80005a8d615de8024459d098493fb9a2d2703ddf755be5bfe571ee6b92c759
3
+ metadata.gz: 2452b04f29a57fd7e41177ca45d0699c6cbfcbac259f6cd5d34c7b884e525fa3
4
+ data.tar.gz: 795dbe474a4ad6e72af653fcd0bf8c80929edaa1749c7a7f0343b60e851cd954
5
5
  SHA512:
6
- metadata.gz: 412dc0cee1e2419c9c1ef2e7d5da84c4f3c9e3d87a26f2222913f43e52082481d95b85a573d1e7f58a9bcff7063e418bcf998ac3e1280b5a6c21c3db7a5eeaae
7
- data.tar.gz: 1830bfa1dfdd32b2af0fd2abe037b3e5a54887885c66d54e50c0f5a0c3b48ab9eb40765a0faaf4e3533dfb509b9975ec36ff00f99507e9dd363ca44362eca383
6
+ metadata.gz: be07f3621680097432f4a5f56c825af6e47603c1fbdbaaf37a12c0fbec377fa231ad9d2551ee5a6d2fe1565115dc8e8398cca35cac7f858874a178f920683879
7
+ data.tar.gz: 1743bc51b54ceb5c21a1328bc83b8cb2c2e098378964e1f6bfc623984e551be215c73ef3b16b21e9258d257ba29d950b385364e874a8a6b5485bab24f3c1953c
data/CHANGELOG.md CHANGED
@@ -1,11 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.0] - 2026-06-16
4
+
5
+ ### Added
6
+
7
+ - Application method join for group task invoke was created.
8
+ - Ruby command gem action push can use wildcard paths.
9
+ - Ruby command gem action build can use wildcard paths.
10
+ - Docker command container action attach was implemented.
11
+ - Application method join can be run in parallel.
12
+ - Project base method semver supports bumping prerelease.
13
+ - Node command bump supports incrementing a private workspace.
14
+ - Project base class implemented Enumerable each method.
15
+ - Ruby command gem action outdated can be pinned by semver.
16
+ - Node command publish action stage was implemented.
17
+ - Git command remote was implemented.
18
+
19
+ ### Changed
20
+
21
+ - Node task outdated does not modify without a full semver range.
22
+ - OptionPartition static methods do not support unknown arguments.
23
+ - Readline/Reline is no longer loaded into global namespace.
24
+ - JRuby/TruffleRuby are no longer given any special treatment.
25
+ - Common shell lib does not include PATH when used as module function.
26
+ - Override methods using suffix "!" were renamed to "\_".
27
+ - Common method as_a checks for to_ary after to_a.
28
+ - Node command bump was condensed into one subtask.
29
+ - Git event name revbuild was separated into git:revbuild:[before|after].
30
+ - Git command stash action [branch|clear|list|all|staged|worktree] were grouped.
31
+ - Project methods with prefix parameter were converted into keyword.
32
+ - Project base method accept_b parameters were converted into keyword.
33
+ - Class methods with a ref parameter were converted into keyword.
34
+
35
+ ### Removed
36
+
37
+ - Common format method raise_error was removed.
38
+
3
39
  ## [0.7.7] - 2026-06-15
4
40
 
5
41
  ### Added
6
42
 
7
43
  - Ruby program commands can be run through bundle exec.
8
- - Node task depend can run approve-scripts with NPM_APPROVE_SCRIPTS.
9
44
  - Node command package action [approve|deny] was implemented.
10
45
  - NPM command options were updated to 11.16.
11
46
 
@@ -244,6 +279,7 @@
244
279
  - Application class supports extensions used during build finalization.
245
280
  - Docker command bake action compose to build with defaults was implemented.
246
281
  - Program asdf legacy global installations using ASDF_DIR is supported.
282
+ - Docker command compose action publish was implemented.
247
283
 
248
284
  ### Changed
249
285
 
@@ -271,7 +307,6 @@
271
307
  - Application project classes can only be injected using static methods.
272
308
  - Tasks can only be excluded through Appliction build instance method.
273
309
  - Project base utility methods were relocated to Support namespace.
274
- - Ruby class private method run_rb was removed.
275
310
  - Application attribute exception accept Logger levels to route errors.
276
311
  - Ruby command irb always includes local development require paths.
277
312
  - Bundler tasks are hidden when package is not installed.
@@ -279,7 +314,10 @@
279
314
  - Application method with renamed pass to hide due to conflict with Project.
280
315
  - Node task depend using Yarn no longer sets option ignore-engines by default.
281
316
  - Project base private instance variable events was relocated.
282
- - Docker command compose action publish was implemented.
317
+
318
+ ### Removed
319
+
320
+ - Ruby class private method run_rb was removed.
283
321
 
284
322
  ### Fixed
285
323
 
@@ -654,7 +692,6 @@
654
692
 
655
693
  - Git method source will raise error when checking exit status.
656
694
  - Date gem is no longer globally required.
657
- - Global task git:all was removed.
658
695
  - Common base method as_a was relocated to Utils.
659
696
  - Python command build and publish detects only one backend.
660
697
  - Docker command compose action ps was renamed service.
@@ -662,14 +699,12 @@
662
699
  - Project base method success? conditionally calls print_success method.
663
700
  - Error classes were not specified for invalid operation.
664
701
  - Common format methods stripstyle and stripext are String instance methods.
665
- - Common format method alias puts_oe was removed.
666
702
  - Git commands without a valid action will exit with error status.
667
703
  - Errno exceptions are used in place of SystemCallError.
668
704
  - Common format method raise_error defaults to RuntimeError.
669
705
  - OptionPartition delegator method delete_at was renamed remove_at.
670
706
  - Node event name "publish" was renamed to "npm:publish".
671
707
  - Project task run with a Method passes self as first argument.
672
- - Ruby command check was removed.
673
708
  - Ruby method gem! was renamed gem.
674
709
  - Ruby methods ruby and irb first argument was converted into kwargs.
675
710
  - Ruby method rake executes all tasks in one run command.
@@ -685,12 +720,18 @@
685
720
  - Project base method run_s uses last argument for ENV hash.
686
721
  - Project base method inject does not exit program when raised.
687
722
  - Reline gem is installed only when using at least Ruby 3.0.
688
- - Python method install arguments strategy and user were removed.
689
723
  - Project command outdated does not support threading when interactive.
690
724
  - Project base accessor global was converted into a reader and setter.
691
725
  - Repo build can simultaneously use script and run through REPO_BUILD.
692
726
  - Repo static method read_manifest was made an instance method named repo_manifest.
693
727
 
728
+ ### Removed
729
+
730
+ - Global task git:all was removed.
731
+ - Common format method alias puts_oe was removed.
732
+ - Ruby command check was removed.
733
+ - Python method install arguments strategy and user were removed.
734
+
694
735
  ### Fixed
695
736
 
696
737
  - Node task update did not check equivalent ENV install options.
@@ -1287,6 +1328,10 @@
1287
1328
 
1288
1329
  ## [0.3.10]
1289
1330
 
1331
+ ### Removed
1332
+
1333
+ - Git command files action ignored could not be used alone.
1334
+
1290
1335
  ### Fixed
1291
1336
 
1292
1337
  - Git command reset action commit used invalid delimeter.
@@ -1294,10 +1339,6 @@
1294
1339
  - Project script task did not fire first and last callbacks.
1295
1340
  - Git checkout action commit did not include options.
1296
1341
 
1297
- ### Removed
1298
-
1299
- - Git command files action ignored could not be used alone.
1300
-
1301
1342
  ## [0.2.10]
1302
1343
 
1303
1344
  ### Fixed
@@ -1879,6 +1920,7 @@
1879
1920
 
1880
1921
  - Changelog was created.
1881
1922
 
1923
+ [0.8.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.0
1882
1924
  [0.7.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.7
1883
1925
  [0.7.6]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.6
1884
1926
  [0.7.5]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.5
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # squared 0.7
1
+ # squared 0.8
2
2
 
3
3
  * [source](https://github.com/anpham6/squared-ruby)
4
4
  * [docs](https://squared.readthedocs.io)
@@ -11,11 +11,12 @@
11
11
  | 2025-01-07 | 0.2.0 | | 3.4.0 | |
12
12
  | 2025-02-07 | 0.3.0 | | 3.4.1 | |
13
13
  | 2025-03-06 | 0.4.0 | | 3.4.2 | * |
14
- | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.4 | * |
14
+ | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.4 | |
15
15
  | ---------- | ----- | ----- | ----- | --- |
16
16
  | 2025-08-23 | 0.5.5 | | 3.4.5 | |
17
17
  | 2025-10-31 | 0.6.0 | | 3.4.7 | * |
18
18
  | 2026-01-07 | 0.7.0 | 2.5.0 | 4.0.0 | * |
19
+ | 2026-06-16 | 0.8.0 | | 4.0.5 | * |
19
20
 
20
21
  The range chart indicates the *latest* Ruby tested against at the time of release.
21
22
 
@@ -47,7 +48,6 @@ require "squared/app" # All workspace related modules
47
48
  # log = /workspaces/logger
48
49
  # emc = /workspaces/e-mc
49
50
  # pir = /workspaces/pi-r
50
- # pir2 = /workspaces/pi-r2
51
51
  # squared = /workspaces/squared
52
52
  # cli = /workspaces/squared/publish/sqd-cli
53
53
  # sqd-serve = /workspaces/squared/publish/sqd-serve
@@ -74,7 +74,6 @@ Workspace::Application
74
74
  end
75
75
  .add("e-mc", "emc", copy: { from: "publish", scope: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
76
76
  .add("pi-r", "pir", copy: { from: "publish", scope: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
77
- .add("pi-r2", "pir2", copy: { from: :npm, also: %i[squared express], files: ["LICENSE", ["README.md.ruby", "README.md"]] }) # Uses dist files from NPM package spec
78
77
  .add("squared", init: "pnpm", script: ["build:stage1", "build:stage2"], group: "app") do # Use pnpm/yarn/berry for depend + Copy target (main)
79
78
  # Repo (global)
80
79
  as(:run, "build:dev", "dev") # npm run build:dev -> npm run dev
@@ -179,6 +178,12 @@ Workspace::Application
179
178
  pip("wheel", with: "build:dev") # pip wheel -r "/chrome-docs/requirements.txt" --no-deps
180
179
  }
181
180
  end
181
+
182
+ join("venv", invoke: "venv:remove", args: ["create"]) # rake venv:python => rake android:venv:remove[create] => chrome:venv:remove[create]
183
+ join("venv", "venv:remove", "create", sync: false) # PYTHON_ARGS=depend,dry-run rake venv:python => rake android:venv:remove[depend,dry-run] | chrome:venv:remove[depend,dry-run]
184
+ join("pwd") do # rake pwd:python => "/workspaces/android-docs" => "/workspaces/chrome-docs"
185
+ puts self.path
186
+ end
182
187
  end
183
188
  .style("inline", "bold")
184
189
  .stage("init:project") { puts self.path } # modify attributes before building tasks (init | begin | project:begin/end | populate | extensions | series | finalize | end)
@@ -284,9 +289,6 @@ Workspace::Application
284
289
  add("pi-r", "pir") do
285
290
  chain "all", "build", after: "emc:build" # step: 3
286
291
  end
287
- add("pi-r2", "pir2") do
288
- chain "all", "build", before: "squared" # step: 3
289
- end
290
292
  add("squared-express", "express") do
291
293
  chain "all", "clean", with: "emc" # step: 1
292
294
  chain "all", "build", with: "pir" # step: 3
@@ -547,6 +549,7 @@ Most project classes will inherit from `Git` which enables these tasks:
547
549
  | pull | pull | origin remote all |
548
550
  | range-diff | range-diff | view between contain |
549
551
  | rebase | rebase | branch onto send |
552
+ | remote | remote | add select |
550
553
  | refs | ls-remote --refs | heads tags remote |
551
554
  | reset | reset | commit index patch mode undo |
552
555
  | restore | restore | source staged worktree |
@@ -868,44 +871,44 @@ Features can be enabled through ENV when calling global tasks such as through *C
868
871
 
869
872
  * Prefix: BUNDLE/GEM/RBS
870
873
 
871
- | Command | Flag | ENV |
872
- | :--------- | :-------- | :-------------------------------------------------------- |
873
- | depend | - | BINSTUBS=s JOBS=n |
874
- | depend | update | VERSION=major|minor|patch STRICT CONSERVATIVE |
875
- | outdated | - | U|UPDATE=major|minor|patch ONLY_EXPLICIT DRY_RUN |
876
- | gem | outdated | DOCUMENT=0,1 USER_INSTALL=0,1 |
877
- | rbs | prototype | Y=0,1 |
874
+ | Command | Flag | ENV |
875
+ | :--------- | :-------- | :---------------------------------------------------------- |
876
+ | depend | - | BINSTUBS=s JOBS=n |
877
+ | depend | update | VERSION=major|minor|patch STRICT CONSERVATIVE |
878
+ | outdated | - | U|UPDATE=major|minor|patch ONLY_EXPLICIT DRY_RUN |
879
+ | gem | outdated | DOCUMENT=0,1 USER_INSTALL=0,1 |
880
+ | rbs | prototype | Y=0,1 |
878
881
 
879
882
  #### Node
880
883
 
881
884
  * Prefix: NPM/PNPM/YARN
882
885
 
883
- | Command | Flag | ENV |
884
- | :------------- | :------------- | :----------------------------------------------- |
885
- | depend | - | FORCE CI IGNORE_SCRIPTS |
886
- | outdated | - | U|UPDATE=major|minor|patch DIFF DRY_RUN |
887
- | publish | - | OTP=s TAG=s ACCESS=0,1,s DRY_RUN Y |
888
- | depend package | * | PACAKGE_LOCK|LOCKFILE=0 NO_LOCKFILE=1 Y |
889
- | npm | depend | APPROVE_SCRIPTS=s |
890
- | npm | package | SAVE IGNORE_SCRIPTS STRICT_PEER_DEPS |
891
- | pnpm | depend | PUBLIC_HOIST_PATTERN=s APPROVE_BUILDS |
892
- | pnpm | depend:add | ALLOW_BUILD=s |
893
- | yarn | depend package | IGNORE_ENGINES |
894
- | yarn | depend:add | W|IGNORE_WORKSPACE_ROOT_CHECK=0 |
895
- | npm pnpm | depend package | CPU=s OS=s LIBC=s |
886
+ | Command | Flag | ENV |
887
+ | :------------- | :------------- | :------------------------------------------------- |
888
+ | depend | - | FORCE CI IGNORE_SCRIPTS |
889
+ | outdated | - | U|UPDATE=major|minor|patch SAVE_EXACT DIFF DRY_RUN |
890
+ | publish | - | OTP=s TAG=s ACCESS=0,1,s DRY_RUN Y |
891
+ | depend package | * | PACAKGE_LOCK|LOCKFILE=0 NO_LOCKFILE=1 Y |
892
+ | npm | depend | APPROVE_SCRIPTS=s |
893
+ | npm | package | SAVE IGNORE_SCRIPTS STRICT_PEER_DEPS |
894
+ | pnpm | depend | PUBLIC_HOIST_PATTERN=s APPROVE_BUILDS |
895
+ | pnpm | depend:add | ALLOW_BUILD=s |
896
+ | yarn | depend package | IGNORE_ENGINES |
897
+ | yarn | depend:add | W|IGNORE_WORKSPACE_ROOT_CHECK=0 |
898
+ | npm pnpm | depend package | CPU=s OS=s LIBC=s |
896
899
 
897
900
  #### Python
898
901
 
899
902
  * Prefix: PIP/POETRY
900
903
 
901
- | Command | Flag | ENV |
902
- | :--------- | :-------- | :-------------------------------------------------------- |
903
- | global | * | CACHE_DIR=0,s PROXY=s PYTHON=s COLOR=0 |
904
- | depend | - | E|EDITABLE=0,s BUILD_ISOLATION=0 |
905
- | outdated | - | U|UPDATE=major|minor|patch NOT_REQUIRED=0 L|LOCAL DRY_RUN |
906
- | venv | exec | INTERACTIVE=0 |
907
- | poetry | * | PROJECT=s |
908
- | poetry | depend | NO_ROOT |
904
+ | Command | Flag | ENV |
905
+ | :--------- | :-------- | :---------------------------------------------------------- |
906
+ | global | * | CACHE_DIR=0,s PROXY=s PYTHON=s COLOR=0 |
907
+ | depend | - | E|EDITABLE=0,s BUILD_ISOLATION=0 |
908
+ | outdated | - | U|UPDATE=major|minor|patch NOT_REQUIRED=0 L|LOCAL DRY_RUN |
909
+ | venv | exec | INTERACTIVE=0 |
910
+ | poetry | * | PROJECT=s |
911
+ | poetry | depend | NO_ROOT |
909
912
 
910
913
  ## LICENSE
911
914
 
@@ -18,7 +18,6 @@ module Squared
18
18
  GRAPH: %w[| - | \\ -].freeze,
19
19
  BORDER: %w[| - - - - - | | - -].freeze,
20
20
  VIEW: 'view',
21
- BACKTRACE: $DEBUG || !$VERBOSE.nil?,
22
21
  LEVEL: ENV.fetch('LOG_LEVEL', 0).to_i,
23
22
  COLOR: ENV.fetch('NO_COLOR', '').empty?
24
23
  }
@@ -41,7 +41,7 @@ module Squared
41
41
 
42
42
  String.define_method(:stripstyle) { gsub(/\x1B\[(?:\d+;?)+m/, '') }
43
43
  String.define_method(:stripext) { File.basename(self, '.*') }
44
- String.define_method(:subhint) { |s| s.nil? || (s.is_a?(::String) && s.empty?) ? self : "#{self} (#{s})" }
44
+ String.define_method(:subhint) { |s| s.nil? || (s.respond_to?(:empty?) && s.empty?) ? self : "#{self} (#{s})" }
45
45
 
46
46
  def enable_aixterm
47
47
  unless (colors = __get__(:colors)).frozen?
@@ -62,9 +62,9 @@ module Squared
62
62
  return val unless ARG[:COLOR]
63
63
 
64
64
  ret = if pat && index != 0
65
- return val unless (data = pat.match(val))
65
+ return val unless (md = pat.match(val))
66
66
 
67
- index == -1 ? data.to_a.drop(1) : data[index]
67
+ index == -1 ? md.to_a.drop(1) : md[index]
68
68
  else
69
69
  index = 0
70
70
  val
@@ -110,10 +110,10 @@ module Squared
110
110
  return ret.join if index == -1
111
111
 
112
112
  ret = wrap.call(ret, code) unless code.empty?
113
- return ret unless data
113
+ return ret unless md
114
114
 
115
115
  out = +''
116
- data.to_a.each_with_index do |group, i|
116
+ md.to_a.each_with_index do |group, i|
117
117
  next if i == 0
118
118
 
119
119
  if i == index
@@ -319,15 +319,6 @@ module Squared
319
319
  err ? warn(out) : puts(out)
320
320
  end
321
321
  end
322
-
323
- def raise_error(*args, hint: nil, kind: RuntimeError, start: 0)
324
- kind = args.shift if args.first.is_a?(::Class) && args.first < ::Exception
325
- raise kind, message(*args, hint: hint, empty: true), if ARG[:BACKTRACE]
326
- caller(start.succ)
327
- else
328
- caller_locations(start.succ, 1).first&.base_label
329
- end
330
- end
331
322
  end
332
323
  end
333
324
  end
@@ -1,28 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- unless defined?(Readline)
4
- if RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.7'
5
- require 'readline'
6
- else
7
- begin
8
- require 'reline'
9
- Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
10
- Readline = Reline
11
- rescue LoadError
12
- require 'readline' rescue LoadError
13
- end
14
- end
15
- end
16
-
17
3
  module Squared
18
4
  module Common
19
5
  module Prompt
6
+ def self.reline
7
+ if RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.7'
8
+ require 'readline'
9
+ Readline
10
+ else
11
+ begin
12
+ require 'reline'
13
+ Reline
14
+ rescue LoadError
15
+ require 'readline'
16
+ Readline
17
+ end
18
+ end
19
+ end
20
+
20
21
  module_function
21
22
 
22
- def confirm(msg, default = nil, agree: 'Y', cancel: 'N', force: false, attempts: 3, timeout: 60)
23
+ def confirm(msg, accept = nil, agree: 'Y', cancel: 'N', force: false, attempts: 3, timeout: 60)
23
24
  require 'timeout'
24
- if agree == 'Y' && cancel == 'N' && !msg.match?(%r{\[(?:Yn|nY|Y/n|y/N)\]})
25
- case default
25
+ if agree == 'Y' && cancel == 'N' && !msg.match?(%r{\[(Yn|nY|Y/n|y/N)\]})
26
+ case accept
26
27
  when 'Y'
27
28
  msg = "#{msg} [Y/n] "
28
29
  when 'N'
@@ -32,9 +33,9 @@ module Squared
32
33
  agree = /^#{Regexp.escape(agree)}$/i if agree.is_a?(::String)
33
34
  cancel = /^#{Regexp.escape(cancel)}$/i if cancel.is_a?(::String)
34
35
  Timeout.timeout(timeout) do
35
- while (ch = Readline.readline(msg))
36
+ while (ch = Prompt.reline.readline(msg))
36
37
  ch = ch.chomp
37
- case (ch.empty? ? default : ch)
38
+ case (ch.empty? ? accept : ch)
38
39
  when agree
39
40
  return true
40
41
  when cancel
@@ -82,7 +83,7 @@ module Squared
82
83
  end
83
84
  between = ->(s) { s.match?(/^\d+$/) && s.to_i.between?(min, max) }
84
85
  Timeout.timeout(timeout) do
85
- while (ch = Readline.readline(msg))
86
+ while (ch = Prompt.reline.readline(msg))
86
87
  ch.strip!
87
88
  unless ch.empty?
88
89
  if multiple
@@ -128,14 +129,14 @@ module Squared
128
129
  end
129
130
 
130
131
  def readline(msg, history = false, force: nil, multiline: nil, &blk)
131
- multiline = nil unless Readline.respond_to?(:readmultiline)
132
+ multiline = nil unless Prompt.reline.respond_to?(:readmultiline)
132
133
  read = lambda do
133
134
  if !multiline
134
- Readline.readline(msg, history)
135
+ Prompt.reline.readline(msg, history)
135
136
  elsif block_given?
136
- Readline.readmultiline(msg, history, &blk)
137
+ Prompt.reline.readmultiline(msg, history, &blk)
137
138
  else
138
- Readline.readmultiline(msg, history) do |line|
139
+ Prompt.reline.readmultiline(msg, history) do |line|
139
140
  next if line.strip.empty?
140
141
 
141
142
  Array(multiline).any? { |val| line.split.last.end_with?(val.to_s) }
@@ -18,14 +18,14 @@ module Squared
18
18
 
19
19
  def shell_escape(val, quote: false, option: false, force: false, double: false, override: false)
20
20
  val = val.to_s
21
- if (r = /\A(--?)([^=\s]+)((=|\s+)(["'])?(?(5)(.*)\5|(.*)))?\z/m.match(val))
22
- if (data = r[2].match(QUOTE_VALUE))
23
- double = data[1] == '"'
21
+ if (md = /\A(--?)([^=\s]+)((=|\s+)(["'])?(?(5)(.*)\5|(.*)))?\z/m.match(val))
22
+ if (q = md[2].match(QUOTE_VALUE))
23
+ double = q[1] == '"'
24
24
  override = true
25
- elsif !r[3] || r[6]
25
+ elsif !md[3] || md[6]
26
26
  return val
27
27
  end
28
- ch = r[7]
28
+ ch = md[7]
29
29
  opt = if ch.start_with?('"', "'")
30
30
  "#{ch}#{ch[0]}"
31
31
  elsif ch.end_with?('"', "'")
@@ -35,7 +35,7 @@ module Squared
35
35
 
36
36
  ch
37
37
  end
38
- r[1] + (data ? data[2] : r[2]) + r[4] + shell_quote(opt, force: force, double: double, override: override)
38
+ md[1] + (q ? q[2] : md[2]) + md[4] + shell_quote(opt, force: force, double: double, override: override)
39
39
  elsif option && val =~ /\A(-{0,2}[^=\s-][^=\s]*)=(.+)\z/m
40
40
  return val if $2.match?(QUOTE_VALUE)
41
41
 
@@ -61,7 +61,7 @@ module Squared
61
61
  if val =~ QUOTE_VALUE
62
62
  if pass == '"' || pass == "'"
63
63
  return val if pass == $1
64
- elsif pass || ($1 == '"' && Rake::Win32.windows? && val.match?(/(?:[#{File::SEPARATOR} ]|\\")/o))
64
+ elsif pass || ($1 == '"' && Rake::Win32.windows? && val.match?(/([#{File::SEPARATOR} ]|\\")/o))
65
65
  return val
66
66
  end
67
67
  case preserve
@@ -162,11 +162,11 @@ module Squared
162
162
  end
163
163
 
164
164
  def shell_bin(name, env: true)
165
- require_relative 'base'
165
+ path = defined?(PATH) ? PATH : {}
166
166
  key = name.to_s.upcase
167
167
  key = File.basename(key, '.*') if Rake::Win32.windows?
168
- shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || PATH[key = key.downcase] ||
169
- PATH[key.to_sym] || name, option: false, force: false, double: true)
168
+ shell_quote((env && ENV["PATH_#{key}"]) || path[key] || path[key.to_sym] || path[key = key.downcase] ||
169
+ path[key.to_sym] || name, option: false, force: false, double: true)
170
170
  end
171
171
 
172
172
  def line_width(lines)
@@ -175,7 +175,7 @@ module Squared
175
175
 
176
176
  def fill_option(val, **kwargs)
177
177
  return val unless val.is_a?(::String)
178
- return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
178
+ return "-#{val}" if val.match?(/\A([a-z]\d*|\d)\z/i)
179
179
 
180
180
  shell_escape(val.start_with?('-') ? val : "--#{val}", **kwargs)
181
181
  end
@@ -7,10 +7,8 @@ require 'timeout'
7
7
  module Squared
8
8
  module Common
9
9
  module System
10
- class << self
11
- private
12
-
13
- def parse_link(val)
10
+ module Internal
11
+ def self.parse_link(val)
14
12
  case val
15
13
  when 's', true
16
14
  1
@@ -25,26 +23,18 @@ module Squared
25
23
  end
26
24
  end
27
25
  end
26
+ private_constant :Internal
28
27
 
29
28
  module_function
30
29
 
31
30
  def shell(*args, name: :system, **kwargs)
32
- kwargs.delete(:exception) unless name == :system
33
- if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
34
- ex = kwargs[:exception]
35
- if (dir = kwargs[:chdir]) && Dir.pwd != dir
36
- pwd = Dir.pwd
37
- Dir.chdir(dir)
38
- end
39
- ret = Kernel.send(name, *args)
40
- Dir.chdir(pwd) if pwd
31
+ if name != :system
32
+ kwargs.delete(:exception)
41
33
  elsif RUBY_VERSION < '2.6'
42
34
  ex = kwargs.delete(:exception)
43
- ret = Kernel.send(name, *args, **kwargs)
44
- else
45
- return Kernel.send(name, *args, **kwargs)
46
35
  end
47
- raise $?.to_s if !ret && ex
36
+ ret = Kernel.send(name, *args, **kwargs)
37
+ raise $?.to_s if ex && !ret
48
38
 
49
39
  ret
50
40
  end
@@ -86,7 +76,7 @@ module Squared
86
76
  end
87
77
  count = 0
88
78
  soft = 0
89
- type = System.send :parse_link, link
79
+ type = Internal.parse_link(link)
90
80
  subdir.each do |dir, files|
91
81
  unless type == 0
92
82
  items = files.dup
@@ -133,7 +123,7 @@ module Squared
133
123
  target.map! { |file| [base + file, dir ? dest + File.basename(file) : dest] }
134
124
  return if !force && (target = target.reject { |to| to[1].exist? }).empty?
135
125
 
136
- type = System.send :parse_link, link
126
+ type = Internal.parse_link(link)
137
127
  target.each do |file, to|
138
128
  case type
139
129
  when 0
@@ -11,11 +11,9 @@ module Squared
11
11
 
12
12
  def env_value(key, default = '', name: @envname, suffix: nil, strict: false)
13
13
  if suffix
14
- if (ret = ENV[[key, name, suffix].compact.join('_')])
15
- return ret
16
- elsif strict
17
- return default
18
- end
14
+ ret = ENV[[key, name, suffix].compact.join('_')]
15
+ return ret if ret
16
+ return default if strict
19
17
  end
20
18
  if name
21
19
  return ret if (ret = ENV["#{key}_#{name}"])
@@ -42,10 +40,10 @@ module Squared
42
40
  return [] if obj.nil?
43
41
 
44
42
  unless obj.is_a?(::Array)
45
- obj = if obj.respond_to?(:to_ary)
46
- obj.to_ary
47
- elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
43
+ obj = if obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
48
44
  val
45
+ elsif obj.respond_to?(:to_ary)
46
+ obj.to_ary
49
47
  else
50
48
  [obj]
51
49
  end
@@ -65,12 +63,18 @@ module Squared
65
63
  ret.each_with_index(&blk)
66
64
  end
67
65
 
68
- def task_invoke(*cmd, args: [], exception: true, warning: true)
69
- cmd.each { |name| Rake::Task[name].invoke(*args) }
70
- rescue => e
71
- raise if exception
66
+ def task_invoke(*cmd, args: [], sync: true, exception: true, warning: true)
67
+ cmd.each do |name|
68
+ if sync
69
+ Rake::Task[name].invoke(*args)
70
+ else
71
+ Rake.application.run_with_threads { Rake::Task[name].invoke(*args) }
72
+ end
73
+ rescue => e
74
+ raise if exception
72
75
 
73
- warn e if warning
76
+ warn e if warning
77
+ end
74
78
  end
75
79
 
76
80
  def task_join(*val)
@@ -206,7 +206,7 @@ module Squared
206
206
 
207
207
  def read_keys(reader, type, file, keys, ext: [type], opts: {})
208
208
  if file && (mime = mimetype(file)) && basepath(file).exist?
209
- raise_error file, mime, hint: 'invalid' unless ext.include?(mime)
209
+ raise message(file, mime, hint: 'invalid') unless ext.include?(mime)
210
210
  else
211
211
  if ext.include?(mime)
212
212
  alt = file
@@ -218,12 +218,8 @@ module Squared
218
218
  file = Dir[alt].first
219
219
  else
220
220
  alt = main
221
- args = { hint: 'no keys' }
222
- end
223
- unless file
224
- args ||= { kind: Errno::ENOENT }
225
- raise_error(reader.name, "#{File.basename(alt, '.*')}.#{ext.first}", **args)
226
221
  end
222
+ raise Errno::ENOENT, message(reader.name, "#{File.basename(alt, '.*')}.#{ext.first}") unless file
227
223
  end
228
224
  log&.info "#{Viewer}(#{type}) => #{file} {#{keys.join(', ')}}"
229
225
  return puts File.read(file) if keys.last == '*'
@@ -273,11 +269,7 @@ module Squared
273
269
  val = Regexp.escape($!.message)
274
270
  key = key.sub(/(#{val})\.|\.(#{val})|(#{val})/) do
275
271
  s = "<#{$3 || $2 || $1}>"
276
- if $3
277
- s
278
- else
279
- $2 ? ".#{s}" : "#{s}."
280
- end
272
+ $3 ? s : $2 ? ".#{s}" : "#{s}."
281
273
  end
282
274
  out << [key, stdin? ? JSON.dump(nil) : 'undefined']
283
275
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.7.7'
4
+ VERSION = '0.8.0'
5
5
  end