squared 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ruby.md +20 -7
- data/lib/squared/common/base.rb +9 -9
- data/lib/squared/common/format.rb +1 -1
- data/lib/squared/common/task.rb +2 -2
- data/lib/squared/config.rb +18 -14
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +81 -69
- data/lib/squared/workspace/project/base.rb +36 -20
- data/lib/squared/workspace/project/git.rb +55 -55
- data/lib/squared/workspace/project/node.rb +36 -21
- data/lib/squared/workspace/project/python.rb +43 -21
- data/lib/squared/workspace/project/ruby.rb +35 -51
- data/lib/squared/workspace/repo.rb +27 -18
- data/lib/squared/workspace/series.rb +50 -41
- data/lib/squared/workspace.rb +8 -2
- data/squared.gemspec +1 -0
- metadata +16 -2
@@ -7,9 +7,8 @@ module Squared
|
|
7
7
|
REQUIREMENTS = %w[requirements.txt pyproject.toml setup.py].freeze
|
8
8
|
OPT_USER = %w[pre dry-run].freeze
|
9
9
|
OPT_FORCE = [*OPT_USER, 'user'].freeze
|
10
|
-
OPT_UPGRADE = [*OPT_FORCE, 'eager'].freeze
|
11
10
|
OPT_GENERAL = %w{venv isolated no-cache-dir [v]erbose}.freeze
|
12
|
-
private_constant :REQUIREMENTS, :OPT_USER, :OPT_FORCE, :
|
11
|
+
private_constant :REQUIREMENTS, :OPT_USER, :OPT_FORCE, :OPT_GENERAL
|
13
12
|
|
14
13
|
class << self
|
15
14
|
def populate(*); end
|
@@ -42,12 +41,12 @@ module Squared
|
|
42
41
|
end
|
43
42
|
|
44
43
|
@@tasks[ref] = {
|
45
|
-
install: %i[user upgrade force]
|
44
|
+
install: %i[user target upgrade force]
|
46
45
|
}.freeze
|
47
46
|
|
48
47
|
def populate(*)
|
49
48
|
super
|
50
|
-
return unless outdated? &&
|
49
|
+
return unless outdated? && ref?(Python.ref)
|
51
50
|
|
52
51
|
namespace name do
|
53
52
|
@@tasks[Python.ref].each do |action, flags|
|
@@ -56,16 +55,26 @@ module Squared
|
|
56
55
|
case action
|
57
56
|
when :install
|
58
57
|
list = case flag
|
58
|
+
when :target
|
59
|
+
req = 'dir'
|
60
|
+
OPT_USER + %w[upgrade eager]
|
59
61
|
when :upgrade
|
60
|
-
|
62
|
+
OPT_FORCE + ['eager']
|
61
63
|
when :force
|
62
64
|
OPT_FORCE
|
63
65
|
else
|
64
66
|
OPT_USER
|
65
67
|
end
|
66
|
-
desc format_desc(action, flag, list + OPT_GENERAL)
|
67
|
-
|
68
|
-
|
68
|
+
desc format_desc(action, flag, list + OPT_GENERAL, req: req)
|
69
|
+
if flag == :target
|
70
|
+
task flag, [:dir, :opts] do |_, args|
|
71
|
+
guard_params(action, flag, args: args, key: :dir)
|
72
|
+
depend(flag, dir: args.dir, opts: args.to_a)
|
73
|
+
end
|
74
|
+
else
|
75
|
+
task flag do |_, args|
|
76
|
+
depend(flag, opts: args.to_a)
|
77
|
+
end
|
69
78
|
end
|
70
79
|
end
|
71
80
|
end
|
@@ -74,33 +83,42 @@ module Squared
|
|
74
83
|
end
|
75
84
|
end
|
76
85
|
|
77
|
-
def depend(flag = nil,
|
78
|
-
if @depend && !
|
86
|
+
def depend(flag = nil, dir: nil, opts: [])
|
87
|
+
if @depend && !flag
|
79
88
|
super
|
80
89
|
elsif outdated?
|
90
|
+
sync = invoked_sync?('depend', flag)
|
81
91
|
case (type = install_type)
|
82
92
|
when 1, 2
|
83
93
|
cmd = pip_session 'install'
|
84
94
|
case flag
|
85
95
|
when :user
|
86
96
|
cmd << '--user'
|
87
|
-
|
97
|
+
append_pip opts, OPT_USER
|
98
|
+
when :target
|
99
|
+
cmd << "--target=#{shell_escape(base_path(dir).to_s, quote: true)}"
|
100
|
+
append_pip opts, OPT_USER + ['upgrade']
|
101
|
+
append_eager opts
|
88
102
|
when :upgrade
|
89
103
|
cmd << '--upgrade'
|
90
|
-
|
104
|
+
append_pip opts, OPT_FORCE
|
105
|
+
append_eager opts
|
91
106
|
when :force
|
92
107
|
cmd << '--force-reinstall'
|
93
|
-
|
108
|
+
append_pip opts, OPT_FORCE
|
94
109
|
end
|
95
110
|
cmd << (type == 1 ? '-r requirements.txt' : '.')
|
96
|
-
run(sync:
|
111
|
+
run(sync: sync)
|
97
112
|
when 3
|
98
|
-
run_s("#{@bin} setup.py install", sync:
|
113
|
+
run_s("#{@bin} setup.py install", sync: sync)
|
99
114
|
end
|
100
115
|
end
|
101
116
|
end
|
102
117
|
|
103
|
-
def outdated(*)
|
118
|
+
def outdated(*)
|
119
|
+
pip_session 'list', '--outdated'
|
120
|
+
run
|
121
|
+
end
|
104
122
|
|
105
123
|
def install_type(*)
|
106
124
|
requirements.exist? ? @reqindex + 1 : 0
|
@@ -116,14 +134,11 @@ module Squared
|
|
116
134
|
session('pip', *cmd)
|
117
135
|
end
|
118
136
|
|
119
|
-
def
|
120
|
-
list += OPT_GENERAL
|
137
|
+
def append_pip(opts, list = [])
|
121
138
|
opts.each do |opt|
|
122
|
-
next unless (v = opt.match(/^v+$/))
|
139
|
+
next unless list.include?(opt) || OPT_GENERAL.include?(opt) || (v = opt.match(/^v+$/))
|
123
140
|
|
124
141
|
@session << case opt
|
125
|
-
when 'eager'
|
126
|
-
'--upgrade-strategy=eager'
|
127
142
|
when 'venv'
|
128
143
|
'--require-virtualenv'
|
129
144
|
else
|
@@ -135,8 +150,15 @@ module Squared
|
|
135
150
|
if (val = env('PIP_PROXY'))
|
136
151
|
@session << "--proxy=#{shell_escape(val, quote: true)}"
|
137
152
|
end
|
153
|
+
if (val = env('PIP_LOG'))
|
154
|
+
@session << "--log=#{shell_escape(base_path(val).to_s, quote: true)}"
|
155
|
+
end
|
138
156
|
append_nocolor
|
139
157
|
end
|
158
|
+
|
159
|
+
def append_eager(opts)
|
160
|
+
@session << '--upgrade-strategy=eager' if opts.include?('eager')
|
161
|
+
end
|
140
162
|
end
|
141
163
|
end
|
142
164
|
end
|
@@ -63,7 +63,7 @@ module Squared
|
|
63
63
|
|
64
64
|
def populate(*)
|
65
65
|
super
|
66
|
-
return unless outdated? &&
|
66
|
+
return unless outdated? && ref?(Ruby.ref)
|
67
67
|
|
68
68
|
namespace name do
|
69
69
|
@@tasks[Ruby.ref].each do |action, flags|
|
@@ -93,19 +93,19 @@ module Squared
|
|
93
93
|
task flag, [:name] do |_, args|
|
94
94
|
name = args.to_a
|
95
95
|
guard_params(action, flag, args: name)
|
96
|
-
depend(flag, opts: name
|
96
|
+
depend(flag, opts: name)
|
97
97
|
end
|
98
98
|
when :with, :without
|
99
99
|
desc format_desc(action, flag, 'group+')
|
100
100
|
task flag, [:group] do |_, args|
|
101
101
|
group = args.to_a
|
102
102
|
guard_params(action, flag, args: group)
|
103
|
-
depend(flag, opts: group
|
103
|
+
depend(flag, opts: group)
|
104
104
|
end
|
105
105
|
else
|
106
106
|
desc format_desc(action, flag, OPT_INSTALL)
|
107
107
|
task flag, [:opts] do |_, args|
|
108
|
-
depend(flag, opts: args.to_a
|
108
|
+
depend(flag, opts: args.to_a)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
when :update, :outdated
|
@@ -142,11 +142,17 @@ module Squared
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
def depend(flag = nil, opts: []
|
146
|
-
if @depend && !
|
145
|
+
def depend(flag = nil, opts: [])
|
146
|
+
if @depend && !flag
|
147
147
|
super
|
148
148
|
elsif outdated?
|
149
149
|
case flag
|
150
|
+
when :gem
|
151
|
+
gem_session 'install'
|
152
|
+
append_value opts
|
153
|
+
when :with, :without
|
154
|
+
gem_session 'install'
|
155
|
+
append_repeat flag, opts
|
150
156
|
when :redownload, :local, :'prefer-local'
|
151
157
|
cmd = bundle_session 'install', "--#{flag}"
|
152
158
|
if (val = env('BUNDLE_TRUST_POLICY'))
|
@@ -166,17 +172,11 @@ module Squared
|
|
166
172
|
end}"
|
167
173
|
end
|
168
174
|
append_bundle opts, OPT_INSTALL
|
169
|
-
when :gem
|
170
|
-
gem_session 'install'
|
171
|
-
append_value opts
|
172
|
-
when :with, :without
|
173
|
-
gem_session 'install'
|
174
|
-
append_repeat flag, opts
|
175
175
|
else
|
176
176
|
bundle_session 'install'
|
177
177
|
append_bundle
|
178
178
|
end
|
179
|
-
run_rb
|
179
|
+
run_rb(sync: invoked_sync?('depend', flag))
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -207,7 +207,7 @@ module Squared
|
|
207
207
|
append_bundle opts, OPT_OUTDATED
|
208
208
|
cmd = cmd.done
|
209
209
|
log.info cmd
|
210
|
-
print_item format_banner(cmd) if store_pwd || invoked_sync?("outdated#{rev
|
210
|
+
print_item format_banner(cmd) if store_pwd || invoked_sync?("outdated#{rev && ":#{rev}"}")
|
211
211
|
start = 0
|
212
212
|
found = 0
|
213
213
|
major = 0
|
@@ -224,41 +224,29 @@ module Squared
|
|
224
224
|
l = lat.join
|
225
225
|
styles = []
|
226
226
|
data.each do |val|
|
227
|
-
break unless
|
227
|
+
break unless (req = /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
|
228
228
|
|
229
229
|
v = semver(val).join
|
230
230
|
case req[1]
|
231
231
|
when '>', '>='
|
232
|
-
if
|
233
|
-
styles = nil
|
234
|
-
elsif l < v
|
235
|
-
styles = %i[red underline]
|
236
|
-
break
|
237
|
-
elsif semmajor(cur, lat)
|
238
|
-
styles = %i[green underline]
|
239
|
-
major += 1
|
240
|
-
elsif cur[3] != lat[3]
|
232
|
+
if semmajor(cur, lat)
|
241
233
|
styles = %i[green bold]
|
234
|
+
major += 1
|
242
235
|
else
|
243
|
-
styles[0] = :green
|
236
|
+
styles[0] = cur[2] == lat[2] ? :yellow : :green
|
244
237
|
end
|
245
238
|
when '<', '<='
|
246
239
|
if c <= v
|
247
240
|
if semmajor(cur, lat)
|
248
|
-
styles = %i[green
|
241
|
+
styles = %i[green bold]
|
249
242
|
major += 1
|
250
243
|
else
|
251
244
|
styles[0] = :yellow
|
252
245
|
end
|
253
|
-
elsif l >= v
|
254
|
-
styles = nil
|
255
246
|
end
|
256
247
|
when '!='
|
257
|
-
if c ==
|
258
|
-
styles
|
259
|
-
break
|
260
|
-
elsif l == v
|
261
|
-
styles = nil
|
248
|
+
if c == l
|
249
|
+
styles.clear
|
262
250
|
else
|
263
251
|
styles[1] = :bold
|
264
252
|
end
|
@@ -266,27 +254,23 @@ module Squared
|
|
266
254
|
if c < v && cur[0] == val[0] && !semmajor(cur, val)
|
267
255
|
styles[0] = :yellow
|
268
256
|
elsif semmajor(lat, val)
|
269
|
-
styles = nil
|
270
|
-
else
|
271
|
-
styles[1] = :bold
|
272
|
-
end
|
273
|
-
when '='
|
274
|
-
if c == v
|
275
257
|
styles[1] = :underline
|
276
258
|
else
|
277
|
-
styles[
|
259
|
+
styles[1] = :bold
|
278
260
|
end
|
279
261
|
end
|
280
262
|
end
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
263
|
+
unless styles.empty?
|
264
|
+
case styles[0]
|
265
|
+
when :green
|
266
|
+
line = sub_style(line, pat: /^(\S+)(.+)$/, styles: theme[styles[1] == :bold ? :major : :active])
|
267
|
+
found += 1
|
268
|
+
when :yellow
|
269
|
+
found += 1
|
270
|
+
end
|
271
|
+
line = sub_style(line, pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.+)$/,
|
272
|
+
styles: styles.compact, index: 2)
|
287
273
|
end
|
288
|
-
line = sub_style(line, pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.+)$/,
|
289
|
-
styles: styles.compact, index: 2)
|
290
274
|
end
|
291
275
|
end
|
292
276
|
puts "#{start.to_s.rjust(2)}. #{line}"
|
@@ -393,8 +377,8 @@ module Squared
|
|
393
377
|
|
394
378
|
private
|
395
379
|
|
396
|
-
def run_rb
|
397
|
-
run(banner: !@session.include?('--quiet'))
|
380
|
+
def run_rb(sync: true)
|
381
|
+
run(sync: sync, banner: !@session.include?('--quiet'))
|
398
382
|
end
|
399
383
|
|
400
384
|
def append_bundle(opts = nil, list = nil)
|
@@ -413,7 +397,7 @@ module Squared
|
|
413
397
|
end
|
414
398
|
|
415
399
|
def append_repeat(flag, opts)
|
416
|
-
opts.each { |val| @session << "--#{flag}=#{shell_escape(val)}" }
|
400
|
+
opts.each { |val| @session << "--#{flag}=#{shell_escape(val, quote: true)}" }
|
417
401
|
end
|
418
402
|
|
419
403
|
def append_value(opts)
|
@@ -7,8 +7,6 @@ module Squared
|
|
7
7
|
include Format
|
8
8
|
include System
|
9
9
|
|
10
|
-
attr_accessor :warning
|
11
|
-
|
12
10
|
def repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil, ref: @ref, group: @group)
|
13
11
|
@home = if (val = env('REPO_HOME'))
|
14
12
|
home = Pathname.new(val)
|
@@ -34,11 +32,18 @@ module Squared
|
|
34
32
|
end
|
35
33
|
@root.join(main).realdirpath
|
36
34
|
else
|
37
|
-
install?(pwd =
|
35
|
+
install?(pwd = @home) ? pwd.join(main) : pwd
|
38
36
|
end
|
39
37
|
@root = @home.parent
|
40
38
|
@manifest_url = url
|
41
39
|
@manifest = manifest
|
40
|
+
set_ref = lambda do
|
41
|
+
if group
|
42
|
+
@script[:group][:_] = group.to_s
|
43
|
+
elsif ref
|
44
|
+
@script[:ref][:_] = ref.to_sym
|
45
|
+
end
|
46
|
+
end
|
42
47
|
if repo?
|
43
48
|
@script[:build] = case (val = env('REPO_BUILD'))
|
44
49
|
when 'verbose'
|
@@ -53,8 +58,15 @@ module Squared
|
|
53
58
|
end
|
54
59
|
@script[:dev] = bool_match(env('REPO_DEV'), dev)
|
55
60
|
@script[:prod] = bool_match(env('REPO_PROD'), prod)
|
56
|
-
|
57
|
-
|
61
|
+
if (val = env('REPO_GROUP'))
|
62
|
+
@script[:group][:_] = val.to_s
|
63
|
+
@script[:env] = true
|
64
|
+
elsif (val = env('REPO_REF'))
|
65
|
+
@script[:ref][:_] = val.to_sym
|
66
|
+
@script[:env] = true
|
67
|
+
else
|
68
|
+
set_ref
|
69
|
+
end
|
58
70
|
@warning = case env('REPO_WARN')
|
59
71
|
when '0'
|
60
72
|
false
|
@@ -68,22 +80,11 @@ module Squared
|
|
68
80
|
@script[:build] = run
|
69
81
|
@script[:dev] = dev
|
70
82
|
@script[:prod] = prod
|
71
|
-
|
72
|
-
@script[:group][:_] = group
|
83
|
+
set_ref
|
73
84
|
end
|
74
85
|
self
|
75
86
|
end
|
76
87
|
|
77
|
-
protected
|
78
|
-
|
79
|
-
def repo?
|
80
|
-
!@manifest_url.nil? && (install? || !!@override)
|
81
|
-
end
|
82
|
-
|
83
|
-
def empty?(dir)
|
84
|
-
dir.empty? || (dir.children.size == 1 && dir.join(dir.children.first).to_s == __FILE__)
|
85
|
-
end
|
86
|
-
|
87
88
|
private
|
88
89
|
|
89
90
|
def __repo__(**kwargs)
|
@@ -125,7 +126,7 @@ module Squared
|
|
125
126
|
stage ||= 'all'
|
126
127
|
repo['sync'].invoke
|
127
128
|
@project.select do |_, proj|
|
128
|
-
next unless proj.enabled?
|
129
|
+
next false unless proj.enabled? && proj.ref?(Project::Base.ref)
|
129
130
|
|
130
131
|
proj.depend if proj.depend?
|
131
132
|
proj.build?
|
@@ -192,6 +193,14 @@ module Squared
|
|
192
193
|
end
|
193
194
|
end
|
194
195
|
|
196
|
+
def repo?
|
197
|
+
!@manifest_url.nil? && (install? || !!@override)
|
198
|
+
end
|
199
|
+
|
200
|
+
def empty?(dir)
|
201
|
+
dir.empty? || (dir.children.size == 1 && dir.join(dir.children.first).to_s == __FILE__)
|
202
|
+
end
|
203
|
+
|
195
204
|
def install?(dir = root)
|
196
205
|
return true if empty?(dir) || dir.join('.repo').directory?
|
197
206
|
return false unless dir == root && env('REPO_HOME').nil? && !env('REPO_ROOT').nil?
|
@@ -8,18 +8,22 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
+
TASK_BASE = %i[build refresh depend outdated doc test copy clean].freeze
|
12
|
+
TASK_KEYS = TASK_BASE.dup
|
13
|
+
TASK_EXTEND = {}
|
14
|
+
private_constant :TASK_BASE, :TASK_KEYS, :TASK_EXTEND
|
15
|
+
|
16
|
+
def self.add(task, obj)
|
17
|
+
TASK_KEYS << task unless TASK_KEYS.include?(task)
|
18
|
+
(TASK_EXTEND[task] ||= []).push(obj)
|
19
|
+
end
|
20
|
+
|
11
21
|
attr_reader :sync, :multiple, :parallel
|
12
22
|
|
13
23
|
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key?
|
14
24
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
@data = {}
|
18
|
-
tasks.each { |key| __set__ key }
|
19
|
-
else
|
20
|
-
@data = tasks.dup
|
21
|
-
end
|
22
|
-
@keys = keys
|
25
|
+
def initialize(prefix = nil)
|
26
|
+
@prefix = prefix
|
23
27
|
@sync = []
|
24
28
|
@multiple = []
|
25
29
|
@parallel = []
|
@@ -28,77 +32,80 @@ module Squared
|
|
28
32
|
parent: {},
|
29
33
|
id: []
|
30
34
|
}
|
35
|
+
@data = {}
|
36
|
+
TASK_KEYS.each { |key| @data[key] = [] }
|
31
37
|
end
|
32
38
|
|
33
39
|
def __set__(key)
|
34
40
|
self[key.to_sym] ||= []
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
43
|
+
def __populate__(proj)
|
38
44
|
return unless @session
|
39
45
|
|
40
46
|
group, parent, id = @session.values
|
41
|
-
|
47
|
+
ws = proj.workspace
|
42
48
|
each do |key, items|
|
43
|
-
|
44
|
-
if
|
45
|
-
|
46
|
-
else
|
47
|
-
next unless workspace.task_include?(proj, key)
|
48
|
-
end
|
49
|
-
next unless workspace.task_defined?(target)
|
49
|
+
task = "#{proj.name}:#{key}"
|
50
|
+
next if include?(key) ? !proj.has?(key) && !(task = ws.task_base?(key, task)) : !ws.task_extend?(proj, key)
|
51
|
+
next unless ws.task_defined?(task)
|
50
52
|
|
51
53
|
if (g = proj.group)
|
52
54
|
id << g
|
53
|
-
(group[:"#{key}:#{g}"] ||= []).push(
|
55
|
+
(group[:"#{key}:#{g}"] ||= []).push(task)
|
54
56
|
else
|
55
|
-
items <<
|
57
|
+
items << task
|
56
58
|
end
|
57
|
-
next unless (b = find_base(proj)) && (name = b.ref.to_s) != g
|
59
|
+
next unless (b = ws.find_base(proj)) && (name = b.ref.to_s) != g
|
58
60
|
|
59
61
|
id << name
|
60
|
-
(parent[:"#{key}:#{name}"] ||= []).push(
|
62
|
+
(parent[:"#{key}:#{name}"] ||= []).push(task)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
def
|
65
|
-
thread = kwargs.fetch(:parallel, []).map(&:to_s)
|
66
|
+
def __build__(parallel: [], **)
|
66
67
|
group, parent, id = @session.values
|
67
68
|
merge!(parent) if id.uniq.size > 1
|
68
69
|
merge!(group)
|
69
70
|
each do |key, items|
|
70
71
|
next if items.empty?
|
71
72
|
|
72
|
-
|
73
|
+
name = key.to_s
|
74
|
+
key = @prefix ? "#{@prefix}:#{name}" : name
|
75
|
+
val = key.split(':').join(' => ')
|
73
76
|
if items.size > 1
|
74
|
-
multiple << key
|
75
|
-
if
|
76
|
-
desc "#{
|
77
|
+
@multiple << key
|
78
|
+
if parallel.include?(name) || (name.include?(':') && parallel.include?(name.split(':').first.to_sym))
|
79
|
+
desc "#{val} (thread)"
|
77
80
|
multitask key => items
|
78
|
-
parallel << key
|
81
|
+
@parallel << key
|
79
82
|
|
80
|
-
desc "#{
|
81
|
-
task "#{key}:sync"
|
82
|
-
sync << "#{key}:sync"
|
83
|
-
multiple << "#{key}:sync"
|
83
|
+
desc "#{val} (sync)"
|
84
|
+
task "#{key}:sync" => items
|
85
|
+
@sync << "#{key}:sync"
|
84
86
|
next
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
|
-
desc
|
90
|
+
desc val
|
89
91
|
task key => items
|
90
92
|
end
|
93
|
+
@multiple += sync
|
91
94
|
@session = nil
|
92
95
|
end
|
93
96
|
|
94
|
-
def method_missing(key, *)
|
95
|
-
self[key]
|
96
|
-
end
|
97
|
-
|
98
97
|
def has?(key)
|
99
98
|
!key.nil? && key?(key = key.to_sym) && !self[key].empty?
|
100
99
|
end
|
101
100
|
|
101
|
+
def include?(key)
|
102
|
+
TASK_BASE.include?(key)
|
103
|
+
end
|
104
|
+
|
105
|
+
def extend?(obj, key)
|
106
|
+
TASK_EXTEND.fetch(key, []).any? { |kind| obj.is_a?(kind) && obj.ref?(kind.ref) }
|
107
|
+
end
|
108
|
+
|
102
109
|
def multiple?(val = nil)
|
103
110
|
already_invoked?(multiple, val)
|
104
111
|
end
|
@@ -111,12 +118,14 @@ module Squared
|
|
111
118
|
already_invoked?(parallel, val)
|
112
119
|
end
|
113
120
|
|
114
|
-
def respond_to_missing?(key, *)
|
115
|
-
key?(key)
|
116
|
-
end
|
117
|
-
|
118
121
|
private
|
119
122
|
|
123
|
+
def method_missing(key, *)
|
124
|
+
raise NoMethodError, key unless key?(key)
|
125
|
+
|
126
|
+
self[key]
|
127
|
+
end
|
128
|
+
|
120
129
|
def already_invoked?(list, val)
|
121
130
|
return list.include?(val) && Common::Task.invoked?(val) if val
|
122
131
|
|
data/lib/squared/workspace.rb
CHANGED
@@ -12,7 +12,7 @@ module Squared
|
|
12
12
|
if id.is_a?(::Symbol)
|
13
13
|
project id
|
14
14
|
else
|
15
|
-
|
15
|
+
id = dirpath(id) if id.is_a?(::String)
|
16
16
|
__get__(:project).find { |_, val| val.path.to_s == id.to_s }
|
17
17
|
end
|
18
18
|
end
|
@@ -26,6 +26,12 @@ module Squared
|
|
26
26
|
raise NoMethodError, message('project is not initialized', hint: name)
|
27
27
|
end
|
28
28
|
|
29
|
+
def dirpath(val, absolute: true)
|
30
|
+
Pathname.new(val).realdirpath
|
31
|
+
rescue StandardError
|
32
|
+
absolute ? Pathname.pwd.join(val) : Pathname.new(val)
|
33
|
+
end
|
34
|
+
|
29
35
|
def project?(name)
|
30
36
|
!!project(name)&.enabled?
|
31
37
|
end
|
@@ -39,6 +45,6 @@ module Squared
|
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
require_relative 'workspace/application'
|
43
48
|
require_relative 'workspace/series'
|
49
|
+
require_relative 'workspace/application'
|
44
50
|
require_relative 'workspace/project'
|
data/squared.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rexml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Rake task generator for managing multi-language workspaces.
|
42
56
|
email:
|
43
57
|
- anpham6@gmail.com
|