squared 0.6.3 → 0.6.4

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.
@@ -11,10 +11,11 @@ module Squared
11
11
  TASK_BASE = []
12
12
  TASK_BATCH = {}
13
13
  TASK_EXTEND = Support.hashlist
14
+ TASK_METHODS = {}
14
15
  TASK_KEYS = []
15
16
  TASK_ALIAS = Support.hashobj
16
17
  TASK_NAME = {}
17
- private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
18
+ private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_METHODS, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
18
19
 
19
20
  class << self
20
21
  def add(task, obj)
@@ -52,6 +53,11 @@ module Squared
52
53
  TASK_BASE.concat(obj.tasks.reject { |val| TASK_KEYS.include?(val) })
53
54
  end
54
55
 
56
+ def extend_set(obj)
57
+ obj.tasks&.each { |task| add(task, obj) }
58
+ TASK_METHODS[obj] = obj.instance_methods(false)
59
+ end
60
+
55
61
  private
56
62
 
57
63
  def key_set(val)
@@ -64,7 +70,8 @@ module Squared
64
70
 
65
71
  attr_reader :sync, :multiple, :parallel
66
72
 
67
- def_delegators :@data, :[], :each, :each_key, :keys, :key?, :fetch, :update, :merge!, :to_a, :to_s, :inspect
73
+ def_delegators :@data, :[], :each, :each_key, :keys, :key?, :include?, :fetch, :update, :merge!, :any?, :none?,
74
+ :delete, :delete_if, :find, :find_all, :to_a, :to_s, :inspect
68
75
  def_delegators :@workspace, :task_desc, :task_name, :task_namespace, :task_join, :format_desc
69
76
 
70
77
  def initialize(workspace, exclude: [])
@@ -184,12 +191,14 @@ module Squared
184
191
  end
185
192
 
186
193
  def extend?(obj, key)
187
- return false unless (items = TASK_EXTEND[key]) && !(items = items.select { |kind| obj.is_a?(kind) }).empty?
194
+ return false unless (items = TASK_EXTEND[key])
188
195
 
189
- meth = :"#{key}?"
190
196
  ret = false
191
197
  items.each do |kind|
192
- if kind.instance_methods.include?(meth)
198
+ next unless obj.is_a?(kind)
199
+
200
+ meth = :"#{key}?"
201
+ if TASK_METHODS[kind].include?(meth)
193
202
  out = obj.__send__(meth)
194
203
  return true if out == 1
195
204
  return out if obj.ref?(kind.ref)
@@ -201,7 +210,9 @@ module Squared
201
210
  end
202
211
 
203
212
  def batch?(obj, key)
204
- (data = batch_get(key)) ? data.keys.any? { |ref| obj.ref?(ref) } : false
213
+ return false unless (data = batch_get(key))
214
+
215
+ data.keys.any? { |ref| obj.ref?(ref) }
205
216
  end
206
217
 
207
218
  def chain?(val)
@@ -5,12 +5,14 @@ module Squared
5
5
  class << self
6
6
  include Common
7
7
 
8
- def resolve(*args)
9
- ret = args.map! do |id|
8
+ def resolve(*args, base: '..')
9
+ values = __get__(:project).values
10
+ ret = args.map do |id|
10
11
  if id.is_a?(Symbol)
11
12
  project id
12
13
  else
13
- __get__(:project).find { |_, val| File.expand_path(val.path) == File.expand_path(id, __dir__) }
14
+ values.find { |proj| proj.name == id } || values.find { |proj| proj.project == id } ||
15
+ values.find { |proj| proj.path.to_s == File.expand_path(id, base) }
14
16
  end
15
17
  end
16
18
  ret.size == 1 ? ret.first : ret
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.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.7.2
127
+ rubygems_version: 3.6.9
128
128
  specification_version: 4
129
129
  summary: Rake task generator for managing multi-language workspaces.
130
130
  test_files: []