squared 0.4.38 → 0.4.40

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: dc06fd43c026c03e1a4ef6b082967f726f0a6a75dd3ab2ecca128198f8f51985
4
- data.tar.gz: 6547492956431f6272a7f1165b2cb3a24f0e8b20787969837dabf13560c11815
3
+ metadata.gz: 9274835227b6d4541e223612c12730e6b87af9cd0b8f60e73ce2821301ce2fb3
4
+ data.tar.gz: 13049d3adf02a7114a72ded6b73a6d0375fef29a8db43c43ba1e823f92863b42
5
5
  SHA512:
6
- metadata.gz: 8982c15e41b7de8e786b7d10515ff44b23e15c8e3e0b403f82db79067b792119b1df6a2b62756314f065fc21f7322c8c27e68edc5f1530fa098747272a703abb
7
- data.tar.gz: eb886ff5f4d5d15afb15c84f1f739d410a53b7fd5aa22ac5b15112e3e5438b2ed7f590d2fd2b3601579212309565be9c51f65c1978b49cf1f78dc11ffeb0ed2c
6
+ metadata.gz: 634e4c43b25ba777a5009b419276df8c1018dcba79da96f8c8bd7f3499a8f17185de6361b0631e6c9514c0421db3f1005e35b968d94ada0618a1f061f5650e93
7
+ data.tar.gz: 74657c33d825ccaec2e6249227a31679f5d6a16aa83e00a0969875f60cd9f90943e40aed095e65baf927197e4c001e828f1f2cd1e2c56efd8c98ee5d23359c8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.40] - 2026-08-06
4
+
5
+ ### Changed
6
+
7
+ - Series method exclude? was made compatible with v0.8 signature.
8
+
9
+ ## [0.4.39] - 2026-07-04
10
+
11
+ ### Changed
12
+
13
+ - Common global argument OUT with a file separator overrides PIPE.
14
+
15
+ ### Fixed
16
+
17
+ - Git output list results did not hide footer when banner was disabled.
18
+ - Project banners which were empty were being printed.
19
+
3
20
  ## [0.4.38] - 2026-06-14
4
21
 
5
22
  ### Added
@@ -1229,6 +1246,8 @@
1229
1246
 
1230
1247
  - Changelog was created.
1231
1248
 
1249
+ [0.4.40]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.40
1250
+ [0.4.39]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.39
1232
1251
  [0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
1233
1252
  [0.4.37]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.37
1234
1253
  [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
@@ -90,6 +90,13 @@ module Squared
90
90
  VAR[key.is_a?(::String) ? key.to_sym : key] = val
91
91
  end
92
92
 
93
+ def __arg__(key, name = nil, &blk)
94
+ ret = ARG[key.to_sym]
95
+ return ret unless name && ret.is_a?(::Hash)
96
+
97
+ ret[name = name.downcase] || (block_given? ? ret.fetch(name.to_sym, &blk) : ret[name.to_sym])
98
+ end
99
+
93
100
  def __freeze__
94
101
  PATH.freeze
95
102
  ARG.freeze
@@ -54,7 +54,7 @@ module Squared
54
54
  end}] "
55
55
  end
56
56
  end
57
- valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max) }
57
+ valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max <= min ? Float::INFINITY : max) }
58
58
  Timeout.timeout(timeout) do
59
59
  begin
60
60
  while (ch = Readline.readline(msg))
@@ -159,11 +159,19 @@ module Squared
159
159
  end
160
160
 
161
161
  def env_pipe(key, default = 1, suffix: nil, strict: false, root: nil)
162
+ out = 1
162
163
  case key
163
164
  when ::String
164
165
  case (ret = env_value(key, suffix: suffix, strict: strict))
165
166
  when '0', '1', '2'
166
167
  return ret.to_i
168
+ else
169
+ out = default if default.is_a?(::Numeric)
170
+ if ret.include?(File::SEPARATOR)
171
+ default = ret
172
+ elsif key.include?(File::SEPARATOR)
173
+ default = key
174
+ end
167
175
  end
168
176
  when ::Numeric
169
177
  return key if key.between?(0, 2)
@@ -174,7 +182,7 @@ module Squared
174
182
  (root ? Pathname.new(root) + default : Pathname.new(default)).realdirpath
175
183
  rescue StandardError => e
176
184
  warn e
177
- 1
185
+ out
178
186
  end
179
187
  end
180
188
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.38'
4
+ VERSION = '0.4.40'
5
5
  end
@@ -95,7 +95,13 @@ module Squared
95
95
  @kind = Support.hashlist
96
96
  @extensions = []
97
97
  @envname = env_key(@main).freeze
98
- @pipe = $DEBUG ? 2 : env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
98
+ @pipe = if $DEBUG
99
+ 2
100
+ elsif (out = ARG[:OUT]) && out.include?(File::SEPARATOR)
101
+ env_pipe(out, pipe, root: home)
102
+ else
103
+ env_pipe(pipe, (out && env(out)) || 1, root: home)
104
+ end
99
105
  @exception = env_bool exception
100
106
  @verbose = if $VERBOSE.nil?
101
107
  false
@@ -1232,7 +1232,7 @@ module Squared
1232
1232
  def env(key, default = nil, suffix: nil, equals: nil, ignore: nil, strict: false)
1233
1233
  a = "#{key}_#{@envname}"
1234
1234
  ret = if suffix
1235
- ENV.fetch("#{a}_#{suffix}", '')
1235
+ ENV["#{a}_#{suffix}"] || (ignore == false && ENV["#{key}_#{suffix}"]) || ''
1236
1236
  elsif strict
1237
1237
  ENV[a].to_s
1238
1238
  else
@@ -1312,7 +1312,7 @@ module Squared
1312
1312
  def print_item(*val)
1313
1313
  puts unless printfirst?
1314
1314
  printsucc
1315
- puts val unless val.empty? || (val.size == 1 && val.first.nil?)
1315
+ puts val unless val.empty? || (val.size == 1 && (!val.first || val.first.empty?))
1316
1316
  end
1317
1317
 
1318
1318
  def print_banner(*lines, client: false, styles: theme[:banner], border: borderstyle, **)
@@ -1465,7 +1465,7 @@ module Squared
1465
1465
  end
1466
1466
 
1467
1467
  def append_hash(data, target: @session || [], build: false)
1468
- if build && (type = env('BUILD', suffix: 'TYPE') || ENV['BUILD_TYPE'])
1468
+ if build && (type = env('BUILD', suffix: 'TYPE', ignore: false))
1469
1469
  type = "__#{type}__"
1470
1470
  if (extra = data[type] || data[type.to_sym]).is_a?(Hash)
1471
1471
  data = data.merge(extra)
@@ -1757,12 +1757,16 @@ module Squared
1757
1757
 
1758
1758
  def matchmap(list, prefix = nil)
1759
1759
  list.map do |val|
1760
- if val.is_a?(Regexp)
1761
- val
1762
- else
1763
- val = ".*#{val}" if prefix && !val.sub!(/\A(\^|\\A)/, '')
1764
- Regexp.new("#{prefix}#{val == '*' ? '.+' : val}")
1760
+ next val if val.is_a?(Regexp)
1761
+
1762
+ if prefix
1763
+ a = nil
1764
+ (val = val.dup).sub!(/\A(\^|\\A)/) do |s|
1765
+ a = s
1766
+ nil
1767
+ end
1765
1768
  end
1769
+ Regexp.new("#{a}#{prefix}#{val == '*' ? '.+' : val}")
1766
1770
  end
1767
1771
  end
1768
1772
 
@@ -207,7 +207,7 @@ module Squared
207
207
  end
208
208
  end
209
209
  else
210
- format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
210
+ format_desc action, flag, "opts*,id/name#{flag == :update || flag == :inspect ? '+' : '*'}"
211
211
  task flag do |_, args|
212
212
  container flag, args.to_a
213
213
  end
@@ -405,7 +405,7 @@ module Squared
405
405
  end
406
406
  end
407
407
  append_command(flag, id || tagmain, op.extras)
408
- when :update
408
+ when :update, :inspect
409
409
  raise_error('missing container', hint: flag) if op.empty?
410
410
  op.append(escape: true, strip: /^:/)
411
411
  when :commit
@@ -133,7 +133,6 @@ module Squared
133
133
  end
134
134
  File.write(@revfile, JSON.pretty_generate(@revdoc))
135
135
  rescue StandardError => e
136
- log&.debug e
137
136
  warn log_message(Logger::WARN, e, pass: true) if warning
138
137
  ensure
139
138
  @revlock = false
@@ -1133,7 +1132,7 @@ module Squared
1133
1132
  op.clear
1134
1133
  out, banner, from = source(io: true)
1135
1134
  print_item banner
1136
- list_result(write_lines(out), 'objects', from: from)
1135
+ list_result(write_lines(out), 'objects', banner: banner, from: from)
1137
1136
  return
1138
1137
  end
1139
1138
  else
@@ -1182,7 +1181,7 @@ module Squared
1182
1181
  end
1183
1182
  out, banner, from = source(io: true)
1184
1183
  ret = write_lines(out, banner: banner, sub: sub)
1185
- list_result(ret, 'files', from: from, action: 'modified')
1184
+ list_result(ret, 'files', action: 'modified', banner: banner, from: from)
1186
1185
  end
1187
1186
 
1188
1187
  def revbuild(flag = nil, opts = [], sync: nil, **kwargs)
@@ -1334,7 +1333,7 @@ module Squared
1334
1333
  out, banner, from = source(io: true)
1335
1334
  print_item banner
1336
1335
  ret = write_lines(out, grep: op.extras)
1337
- list_result(ret, 'tags', from: from, grep: op.extras)
1336
+ list_result(ret, 'tags', grep: op.extras, banner: banner, from: from)
1338
1337
  return
1339
1338
  end
1340
1339
  remote ||= option('remote')
@@ -1565,7 +1564,7 @@ module Squared
1565
1564
  { pat: /^(\*\s+)(\S+)(.*)$/, styles: color(:green), index: 2 },
1566
1565
  { pat: %r{^(\s*)(remotes/\S+)(.*)$}, styles: color(:red), index: 2 }
1567
1566
  ])
1568
- list_result(ret, 'branches', from: from)
1567
+ list_result(ret, 'branches', banner: banner, from: from)
1569
1568
  return
1570
1569
  else
1571
1570
  if (head = git_spawn('rev-parse --abbrev-ref HEAD').chomp).empty?
@@ -1719,7 +1718,7 @@ module Squared
1719
1718
  out, banner, from = source(io: true)
1720
1719
  print_item banner
1721
1720
  ret = write_lines(out, grep: op.extras, prefix: "refs/#{flag}/")
1722
- list_result(ret, flag.to_s, from: from, grep: op.extras)
1721
+ list_result(ret, flag.to_s, grep: op.extras, banner: banner, from: from)
1723
1722
  end
1724
1723
 
1725
1724
  def ls_files(flag, opts = [])
@@ -1729,7 +1728,7 @@ module Squared
1729
1728
  out, banner, from = source(io: true)
1730
1729
  print_item banner
1731
1730
  ret = write_lines(out, grep: op.extras)
1732
- list_result(ret, 'files', from: from, grep: op.extras)
1731
+ list_result(ret, 'files', grep: op.extras, banner: banner, from: from)
1733
1732
  end
1734
1733
 
1735
1734
  def git(flag, opts = [])
@@ -1895,14 +1894,20 @@ module Squared
1895
1894
  ret += 1
1896
1895
  break if first
1897
1896
  end
1898
- print_item banner, out if banner && (ret > 0 || (!pass && !first))
1897
+ if banner && (ret > 0 || (!pass && !first))
1898
+ if banner.empty?
1899
+ print_item(*out)
1900
+ else
1901
+ print_item(banner, *out)
1902
+ end
1903
+ end
1899
1904
  ret
1900
1905
  end
1901
1906
 
1902
- def list_result(size, type, grep: [], action: 'found', from: nil)
1907
+ def list_result(size, type, action: 'found', grep: [], banner: nil, from: nil)
1903
1908
  if size == 0
1904
1909
  puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
1905
- elsif stdout?
1910
+ elsif stdout? && (banner.nil? || (banner.is_a?(String) && !banner.empty?))
1906
1911
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1907
1912
  styles << :bold if styles.size <= 1
1908
1913
  puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
@@ -159,7 +159,7 @@ module Squared
159
159
  log.warn "run script #{n} of #{list.size} (out of range)"
160
160
  end
161
161
  else
162
- case index
162
+ case (index > 1 && poetry? : 0 : index)
163
163
  when 0
164
164
  found |= 1
165
165
  run(session_output('poetry', 'run', val), from: :run)
@@ -235,8 +235,9 @@ module Squared
235
235
  already_invoked? parallel, val
236
236
  end
237
237
 
238
- def exclude?(key, empty = false)
239
- @exclude.include?(key) || (empty && (!@data.key?(key) || @data[key].empty?))
238
+ def exclude?(key, fallback = false, empty: nil)
239
+ fallback = empty unless empty.nil?
240
+ @exclude.include?(key) || (fallback && (!@data.key?(key) || @data[key].empty?))
240
241
  end
241
242
 
242
243
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.38
4
+ version: 0.4.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 4.0.10
128
+ rubygems_version: 4.0.15
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []