squared 0.4.32 → 0.4.33

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: 913d20d3c4a6de7260752fb6603305cee9af765f2885ae74a57d145abe0c2e4e
4
- data.tar.gz: 4c07a15fb013d871a8ebf0f93343146b4366a127ca1f1c18467648d9f7c4ca44
3
+ metadata.gz: cc4c3610fd67d9cf3afa29add2ea865f0fbe13e075c384cb746f5074c473f7ef
4
+ data.tar.gz: 6328ffe0d303b321d8663a53c6d0c59b3b758bfb881d693c2d7ac5b322961db4
5
5
  SHA512:
6
- metadata.gz: 13a87e14e520b801a71e00c5012eb06e8a557b1f6c7d14cf30702e0a4b2ed0d87bb5535d8ffc970275da0f7a65958562e4ca586cebca847c886a80a6df438d5b
7
- data.tar.gz: 48626887ad8b660747dc389e321c2b179b9855cba8ddc9c98d3e48416b87d3ab5899de9f416db068ce47e983f56ce27174057ebed38b148b5331cc4088e12e9c
6
+ metadata.gz: 5e7c0fdee86fd208433ed3736383a1cd0bac10792fdbdb1e8e3c4829b9d77e78e02d603a79efe81b1b4c5944159bfd464aad9ccc834aeeea1431508554c0fc14
7
+ data.tar.gz: cfb6cc7335731677c8643ef3667dcb03707c6d3f9c7c1285f1ecf89c7f75ec827083c687a57449bd94d75d5881bf542031d430325035f594ba3300caa21faf64
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.33] - 2025-12-07
4
+
5
+ ### Added
6
+
7
+ - Ruby attribute setter gemdir for copy method was created.
8
+ - Project inline run executables binary path are replaced with global alias.
9
+
10
+ ### Fixed
11
+
12
+ - Workspace class Series created non-existent keys when queried.
13
+ - Application class did not support changing base Project class.
14
+ - Git command rev action build did not check build? method.
15
+ - Python command build action python did not use outdir option.
16
+
3
17
  ## [0.4.32] - 2025-11-25
4
18
 
5
19
  ### Fixed
@@ -1130,6 +1144,8 @@
1130
1144
 
1131
1145
  - Changelog was created.
1132
1146
 
1147
+ [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1148
+ [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
1133
1149
  [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
1134
1150
  [0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
1135
1151
  [0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.32'
4
+ VERSION = '0.4.33'
5
5
  end
@@ -336,9 +336,9 @@ module Squared
336
336
  end
337
337
  proj = ((if !ref.is_a?(Class)
338
338
  Application.find(ref, path: path)
339
- elsif ref < Project::Base
339
+ elsif ref < Application.impl_project
340
340
  ref
341
- end) || @kind[name]&.last || Project::Base).new(self, path, name, **kwargs)
341
+ end) || @kind[name]&.last || Application.impl_project).new(self, path, name, **kwargs)
342
342
  proj.__send__(:index_set, @project.size)
343
343
  @project[name] = proj
344
344
  __get__(:project)[name] = proj unless kwargs[:private]
@@ -471,7 +471,7 @@ module Squared
471
471
  end
472
472
  d = append_hash(d, target: []).join(' ') if d.is_a?(Hash)
473
473
  if a
474
- cmd << [a, d, b].compact.join(' ')
474
+ cmd << [replace_bin(a), d, b].compact.join(' ')
475
475
  else
476
476
  next unless respond_to?(:compose)
477
477
 
@@ -485,7 +485,7 @@ module Squared
485
485
  if cmd
486
486
  return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
487
487
 
488
- cmd = as_get(cmd, from)
488
+ cmd = replace_bin as_get(cmd, from)
489
489
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
490
490
  flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
491
491
  case opts
@@ -1595,6 +1595,13 @@ module Squared
1595
1595
  ret
1596
1596
  end
1597
1597
 
1598
+ def replace_bin(val)
1599
+ a, b = val.split(' ', 2)
1600
+ return val if val.start_with?(/["']/) || a.include?(File::Separator)
1601
+
1602
+ [shell_bin(a), b].compact.join(' ')
1603
+ end
1604
+
1598
1605
  def parse_json(val, kind: Hash, hint: nil)
1599
1606
  ret = JSON.parse(val)
1600
1607
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
@@ -13,7 +13,7 @@ module Squared
13
13
  buildx: {
14
14
  common: %w[builder=b D|debug],
15
15
  build: %w[add-host=q annotation=q attest=q build-arg=qq build-context=qq cache-from=q cache-to=q
16
- cgroup-parent=b iidfile=p label=q a-file=p network=b no-cache-filter=b o|output=q platform=b
16
+ cgroup-parent=b iidfile=p label=q network=b no-cache-filter=b o|output=q platform=q
17
17
  q|quiet secret=qq shm-size=b ssh=qq t|tag=b target=b ulimit=q].freeze,
18
18
  bake: %w[print list=q set=q].freeze,
19
19
  shared: %w[check load no-cache pull push allow=q call=b? f|file=p metadata-file=p progress=b provenance=q
@@ -41,14 +41,14 @@ module Squared
41
41
  device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
42
42
  disable-content-trust=b? dns=q dns-option=q dns-search=q domainname=b entrypoint=q e|env=qq
43
43
  env-file=p expose=q gpus=q group-add=b health-cmd=q health-interval=b health-retries=i
44
- health-start-interval=q health-start-period=q health-timeout=q io-maxbandwidth=b io-maxiops=b
45
- ip=b ip6=q ipc=b isolation=b kernel-memory=b l|label=q label-file=q link=b link-local-ip=q
46
- log-driver=b log-opt=q mac-address=q m|memory=b memory-reservation=b memory-swap=n
47
- memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b pid=b pids-limit=n
48
- platform=b p|publish=q pull=b restart=b runtime=b security-opt=q shm-size=b stop-signal=b
49
- stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b v|volume=q
50
- volume-driver=b volumes-from=b w|workdir=q].freeze,
51
- run: %w[d|detach detach-keys=q hostname=q sig-proxy=b?].freeze,
44
+ health-start-interval=q health-start-period=q health-timeout=q hostname=q io-maxbandwidth=b
45
+ io-maxiops=b ip=b ip6=q ipc=b isolation=b kernel-memory=b l|label=q label-file=q link=b
46
+ link-local-ip=q log-driver=b log-opt=q mac-address=q m|memory=b memory-reservation=b
47
+ memory-swap=n memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b
48
+ pid=b pids-limit=n platform=q p|publish=q pull=b restart=b runtime=b security-opt=q shm-size=b
49
+ stop-signal=b stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b
50
+ v|volume=q volume-driver=b volumes-from=b w|workdir=q].freeze,
51
+ run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
52
52
  update: %w[blkio-weight=i cpu-period=i cpu-quota=i cpu-rt-period=i cpu-rt-runtime=i c|cpu-shares=i cpus=f
53
53
  cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=b pids-limit=n
54
54
  restart=q].freeze,
@@ -64,9 +64,9 @@ module Squared
64
64
  }.freeze,
65
65
  image: {
66
66
  list: %w[a|all q|quiet digests no-trunc tree f|filter=q format=q].freeze,
67
- push: %w[a|all-tags disable-content-trust=b? platform=b q|quiet].freeze,
68
- rm: %w[f|force no-prune platform=b].freeze,
69
- save: %w[o|output=p platform=b].freeze
67
+ push: %w[a|all-tags disable-content-trust=b? platform=q q|quiet].freeze,
68
+ rm: %w[f|force no-prune platform=q].freeze,
69
+ save: %w[o|output=p platform=q].freeze
70
70
  }.freeze,
71
71
  network: {
72
72
  connect: %w[alias=b driver-opt=q gw-priority=n ip=b ip6=q link=b link-local-ip=q].freeze,
@@ -863,6 +863,8 @@ module Squared
863
863
  rev_parse(flag, ref: ref, size: size)
864
864
  end
865
865
  when :build
866
+ next unless build?
867
+
866
868
  format_desc action, flag, 'opts*'
867
869
  task flag do |_, args|
868
870
  revbuild flag, args.to_a
@@ -1114,7 +1116,7 @@ module Squared
1114
1116
  end
1115
1117
  end
1116
1118
  out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
1117
- values: values, column: /^[^@]+@\{(\d+)\}/, force: true)
1119
+ values: values, column: /^[^@]+@\{(\d+)\}/)
1118
1120
  if values
1119
1121
  op.merge(out.reverse)
1120
1122
  else
@@ -1766,7 +1768,7 @@ module Squared
1766
1768
  files << "#{sub_style(b, styles: color(:red))} #{a}"
1767
1769
  end
1768
1770
  unless files.empty?
1769
- files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
1771
+ files = choice_index('Select files', files, multiple: true, trim: /^\S+\s/,
1770
1772
  accept: [['Add?', false, true]])
1771
1773
  end
1772
1774
  op.swap(list + files)
@@ -78,7 +78,7 @@ module Squared
78
78
 
79
79
  attr_reader :venv, :editable
80
80
 
81
- def initialize(*, editable: '.', verbose: nil, **kwargs)
81
+ def initialize(*, editable: '.', **kwargs)
82
82
  super
83
83
  if @pass.include?(Python.ref)
84
84
  initialize_ref Python.ref
@@ -307,10 +307,10 @@ module Squared
307
307
  next unless build_backend == 'hatchling.build'
308
308
  end
309
309
  format_desc(action, flag, 'opts*', after: case flag
310
- when :python then 'srcdir?'
311
310
  when :poetry then 'output?'
312
311
  when :pdm then 'dest?'
313
312
  when :hatch then 'location?'
313
+ else 'outdir?'
314
314
  end)
315
315
  task flag do |_, args|
316
316
  build! flag, args.to_a
@@ -478,9 +478,6 @@ module Squared
478
478
 
479
479
  def build!(flag, opts = [])
480
480
  case flag
481
- when :python
482
- cmd, opts = python_session('-m build', opts: opts)
483
- list = OPT_PYTHON[:build]
484
481
  when :poetry
485
482
  cmd = poetry_session 'build'
486
483
  list = OPT_POETRY[:build] + OPT_POETRY[:common]
@@ -490,37 +487,32 @@ module Squared
490
487
  when :hatch
491
488
  cmd, opts = hatch_session('build', opts: opts)
492
489
  list = OPT_HATCH[:build]
490
+ else
491
+ cmd, opts = python_session('-m build', opts: opts)
492
+ list = OPT_PYTHON[:build]
493
493
  end
494
- srcdir = nil
495
494
  op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
496
- op.each do |opt|
497
- if !srcdir && basepath(opt.chomp('*')).exist? && projectpath?(opt.chomp('*'))
498
- srcdir = opt
499
- else
500
- op.found << opt
501
- end
502
- end
503
- op.swap
504
495
  case flag
505
- when :poetry, :pdm
506
- if srcdir
507
- args = flag == :pdm ? ['d', 'dest'] : ['o', 'output']
508
- if op.arg?(*args)
509
- op.push(srcdir)
510
- else
511
- op << quote_option(args.last, basepath(srcdir))
512
- end
513
- srcdir = nil
514
- end
515
496
  when :hatch
516
- if ENV['HATCH_BUILD_LOCATION']
517
- srcdir = nil
518
- else
519
- srcdir ||= path
497
+ if !ENV['HATCH_BUILD_LOCATION'] && (outdir ||= op.shift)
498
+ op.add_path(outdir)
520
499
  end
521
500
  op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
501
+ else
502
+ unless op.empty?
503
+ args = case flag
504
+ when :poetry
505
+ %w[o output]
506
+ when :pdm
507
+ %w[d dest]
508
+ else
509
+ srcdir = true
510
+ %w[o outdir]
511
+ end
512
+ op << quote_option(args.last, basepath(op.shift)) unless op.arg?(*args)
513
+ end
522
514
  end
523
- op.add_path(srcdir) if srcdir
515
+ op.exist?(add: true, first: true) if srcdir
524
516
  op.clear
525
517
  run(from: :"#{flag}:build")
526
518
  end
@@ -24,10 +24,10 @@ module Squared
24
24
  common: %w[no-color V|verbose r|retry=i].freeze,
25
25
  install: %w[frozen no-cache no-prune system binstubs=p? path=p standalone=q? target-rbconfig=p trust-policy=b
26
26
  with=q without=q].freeze,
27
- install_base: %w[force full-index quiet redownload gemfile=p j|jobs=i].freeze,
27
+ install_base: %w[force full-index local quiet redownload gemfile=p j|jobs=i].freeze,
28
28
  update: %w[all conservative local major minor patch pre ruby strict bundler=b? g|group=q source=b].freeze,
29
- outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
30
- update-strict group=q source=b].freeze,
29
+ outdated: %w[filter-major filter-minor filter-patch filter-strict groups local parseable porcelain pre
30
+ only-explicit strict update-strict group=q source=b].freeze,
31
31
  exec: %w[gemfile=p].freeze,
32
32
  cache: %w[all all-platforms frozen no-all no-install no-prune quiet cache-path=p gemfile=p path=p].freeze,
33
33
  check: %w[dry-run gemfile=p path=p].freeze
@@ -38,7 +38,7 @@ module Squared
38
38
  install_base: %w[E f w b|both clear-sources conservative default development development-all explain
39
39
  ignore-dependencies l|local N|no-document r|remote vendor n|bindir=p build-root=p
40
40
  B|bulk-threshold=i document=b? g|file=p? p|http-proxy=q? i|install-dir=p platform=q
41
- s|source=q target-rbconfig=p? P|trust-policy=b without=b].freeze,
41
+ s|source=q target-rbconfig=p? P|trust-policy=b without=q].freeze,
42
42
  update: %w[system=b?].freeze,
43
43
  uninstall: %w[a D I x vendor n|bindir=p i|install-dir=p platform=b v|version=q].freeze,
44
44
  outdated: %w[b|both clear-sources l|local r|remote B|bulk-threshold=i p|http-proxy=q? platform=q
@@ -69,7 +69,7 @@ module Squared
69
69
  end
70
70
 
71
71
  def bannerargs
72
- %i[dependfile gemname].freeze
72
+ %i[dependfile gemname gemdir].freeze
73
73
  end
74
74
 
75
75
  def config?(val)
@@ -93,6 +93,8 @@ module Squared
93
93
  'irb' => nil
94
94
  })
95
95
 
96
+ attr_reader :gemdir
97
+
96
98
  def initialize(*, autodetect: false, gemspec: nil, **kwargs)
97
99
  super
98
100
  if @pass.include?(Ruby.ref)
@@ -126,6 +128,14 @@ module Squared
126
128
  end
127
129
  end
128
130
 
131
+ def gemdir=(val)
132
+ @gemdir = if val.is_a?(Pathname)
133
+ val
134
+ else
135
+ Pathname.new(val).realdirpath rescue nil
136
+ end
137
+ end
138
+
129
139
  def ref
130
140
  Ruby.ref
131
141
  end
@@ -241,7 +251,7 @@ module Squared
241
251
  else
242
252
  a, b, c = choice_index('Select a file', Dir.glob(file || path.join('*.rb')),
243
253
  values: (file ? [] : ['Options']).push('Arguments'),
244
- force: true, series: true)
254
+ series: true)
245
255
  if file
246
256
  file = a
247
257
  b
@@ -287,7 +297,7 @@ module Squared
287
297
  end
288
298
  end
289
299
 
290
- def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
300
+ def copy(from: gemlib, into: gemdir, override: false, **kwargs)
291
301
  return if @copy == false
292
302
 
293
303
  glob = kwargs[:include]
@@ -716,7 +726,7 @@ module Squared
716
726
  "#{spec.name}-#{spec.version}.gem"
717
727
  else
718
728
  gems = Dir.glob(basepath('*.gem')).map { |val| File.basename(val) }
719
- choice_index('Select a file', gems, force: true)
729
+ choice_index 'Select a file', gems
720
730
  end)
721
731
  else
722
732
  file = op.shift
@@ -844,27 +854,25 @@ module Squared
844
854
 
845
855
  def copy?
846
856
  return true if @copy.is_a?(Hash) ? copy[:into] : super
847
- return gemdir? if @gemdir
857
+ return gemdir? if gemdir
848
858
 
849
859
  if version
850
860
  begin
851
861
  case @autodetect
852
862
  when 'rvm'
853
- @gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
863
+ self.gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
854
864
  when 'rbenv'
855
865
  if pwd_set { `rbenv which ruby` } =~ %r{^(.+[\\/]versions[\\/](\d\.\d)\.[^\\/]+)[\\/]bin[\\/]ruby$}
856
- @gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
866
+ self.gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
857
867
  end
858
868
  when 'asdf'
859
- @gemdir = pwd_set { `asdf where ruby` }
860
- @gemdir = @gemdir =~ /(\d\.\d)\.[^.]+$/ && File.join(@gemdir, 'lib/ruby/gems', "#{$1}.0")
869
+ val = pwd_set { `asdf where ruby` }
870
+ self.gemdir = File.join(val, 'lib/ruby/gems', "#{$1}.0") if val =~ /(\d\.\d)\.[^.]+$/
861
871
  when /bundler?/
862
- @gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
872
+ self.gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
863
873
  end
864
874
  rescue StandardError => e
865
875
  log.debug e
866
- else
867
- @gemdir = Pathname.new(@gemdir) if @gemdir
868
876
  end
869
877
  return true if gemdir?
870
878
  end
@@ -875,7 +883,7 @@ module Squared
875
883
  log.warn "using version #{val} (given #{ver})"
876
884
  end
877
885
  self.version = val
878
- @gemdir = Pathname.new(path.strip) + gempath
886
+ self.gemdir = Pathname.new(path.strip) + gempath
879
887
  end
880
888
  if version
881
889
  opt = gempwd
@@ -889,17 +897,17 @@ module Squared
889
897
  next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
890
898
 
891
899
  set.call(val, $1)
892
- return gemdir? if @gemdir
900
+ return gemdir? if gemdir
893
901
  end
894
902
  end
895
903
  end
896
- @gemdir = Pathname.new(Gem.dir) + gempath
904
+ self.gemdir = Pathname.new(Gem.dir) + gempath
897
905
  else
898
906
  parse = lambda do |path|
899
907
  next unless path
900
908
 
901
909
  lib = Regexp.new(['', 'gems', "#{gemname}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
902
- if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
910
+ if (ver = path[lib, 1]) && (val = path[/\A(.+)#{Regexp.escape(gempath(ver))}/, 1])
903
911
  set.call(ver, val)
904
912
  end
905
913
  end
@@ -907,7 +915,7 @@ module Squared
907
915
  target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
908
916
  parse.call(target.resolve_feature_path(gemname)&.last)
909
917
  end
910
- if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
918
+ if !gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
911
919
  raise_error 'gems directory not found'
912
920
  end
913
921
  end
@@ -1047,9 +1055,9 @@ module Squared
1047
1055
  end
1048
1056
 
1049
1057
  def gemdir?
1050
- return false unless @gemdir
1058
+ return false unless gemdir
1051
1059
 
1052
- @gemdir.exist? && !@gemdir.empty?
1060
+ gemdir.exist? && !gemdir.empty?
1053
1061
  end
1054
1062
 
1055
1063
  alias read_rakefile raketasks
@@ -114,7 +114,7 @@ module Squared
114
114
 
115
115
  def matchopts(list, value = false)
116
116
  a, b = Array(list).partition { |val| val.size == 1 || val.match?(OPT_SINGLE) }
117
- return /\A#{shortopt(*a)}}/ if b.empty?
117
+ return /\A#{shortopt(*a)}/ if b.empty?
118
118
  return /\A#{longopt(*b, value)}/ if a.empty?
119
119
 
120
120
  /\A(?:#{shortopt(*a)}|#{longopt(*b, value)})/
@@ -309,6 +309,7 @@ module Squared
309
309
  else
310
310
  add val
311
311
  end
312
+ found << val if args.empty?
312
313
  end
313
314
  self
314
315
  end
@@ -405,26 +406,26 @@ module Squared
405
406
  end
406
407
 
407
408
  def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
408
- found, other = if block_given?
409
- partition(&blk)
410
- elsif exclude.first.is_a?(Symbol)
411
- partition(&exclude.first)
412
- else
413
- partition do |val|
414
- next false if pattern && OptionPartition.pattern?(val)
415
-
416
- exclude.none? { |pat| val.match?(Regexp.new(pat)) }
417
- end
418
- end
419
- unless found.empty?
409
+ temp, other = if block_given?
410
+ partition(&blk)
411
+ elsif exclude.first.is_a?(Symbol)
412
+ partition(&exclude.first)
413
+ else
414
+ partition do |val|
415
+ next false if pattern && OptionPartition.pattern?(val)
416
+
417
+ exclude.none? { |pat| val.match?(Regexp.new(pat)) }
418
+ end
419
+ end
420
+ unless temp.empty?
420
421
  add '--' if delim
421
422
  extras.clear
422
423
  concat other
423
424
  if path
424
- found.each { |val| add_path(val) }
425
+ temp.each { |val| add_path(val) }
425
426
  else
426
- found.map! { |val| shell_quote(val) } if quote
427
- merge found
427
+ temp.map! { |val| shell_quote(val) } if quote
428
+ merge temp
428
429
  end
429
430
  end
430
431
  self
@@ -38,8 +38,8 @@ module Squared
38
38
  def alias(ref, obj)
39
39
  if obj.is_a?(Hash)
40
40
  obj.each { |key, val| TASK_ALIAS[key][ref] = val }
41
- else
42
- TASK_ALIAS[obj]&.delete(ref)
41
+ elsif TASK_ALIAS.key?(obj)
42
+ TASK_ALIAS[obj].delete(ref)
43
43
  end
44
44
  end
45
45
 
@@ -165,6 +165,8 @@ module Squared
165
165
  end
166
166
 
167
167
  def alias_get(key)
168
+ return unless TASK_ALIAS.key?(key)
169
+
168
170
  TASK_ALIAS[key]
169
171
  end
170
172
 
@@ -182,11 +184,13 @@ module Squared
182
184
  end
183
185
 
184
186
  def extend?(obj, key)
185
- return false unless (items = TASK_EXTEND[key]) && !(items = items.select { |kind| obj.is_a?(kind) }).empty?
187
+ return false unless TASK_EXTEND.key?(key)
186
188
 
187
189
  meth = :"#{key}?"
188
190
  ret = false
189
- items.each do |kind|
191
+ TASK_EXTEND[key].each do |kind|
192
+ next unless obj.is_a?(kind)
193
+
190
194
  if kind.instance_methods.include?(meth)
191
195
  out = obj.__send__(meth)
192
196
  return true if out == 1
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.32
4
+ version: 0.4.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham