squared 0.0.6 → 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 +48 -13
- data/lib/squared/common/base.rb +22 -16
- data/lib/squared/common/class.rb +5 -1
- data/lib/squared/common/format.rb +48 -45
- data/lib/squared/common/shell.rb +3 -3
- data/lib/squared/common/system.rb +35 -3
- data/lib/squared/common/task.rb +3 -11
- data/lib/squared/config.rb +21 -18
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +136 -128
- data/lib/squared/workspace/project/base.rb +131 -72
- data/lib/squared/workspace/project/git.rb +73 -73
- data/lib/squared/workspace/project/node.rb +88 -63
- data/lib/squared/workspace/project/python.rb +48 -33
- data/lib/squared/workspace/project/ruby.rb +196 -64
- data/lib/squared/workspace/project.rb +4 -0
- data/lib/squared/workspace/repo.rb +41 -28
- data/lib/squared/workspace/series.rb +54 -43
- data/lib/squared/workspace.rb +11 -3
- data/squared.gemspec +1 -0
- metadata +16 -2
@@ -8,19 +8,22 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
|
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
|
12
20
|
|
13
|
-
|
21
|
+
attr_reader :sync, :multiple, :parallel
|
14
22
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
@data = tasks.dup
|
21
|
-
end
|
22
|
-
@workspace = workspace
|
23
|
-
@keys = keys
|
23
|
+
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key?
|
24
|
+
|
25
|
+
def initialize(prefix = nil)
|
26
|
+
@prefix = prefix
|
24
27
|
@sync = []
|
25
28
|
@multiple = []
|
26
29
|
@parallel = []
|
@@ -29,67 +32,65 @@ module Squared
|
|
29
32
|
parent: {},
|
30
33
|
id: []
|
31
34
|
}
|
35
|
+
@data = {}
|
36
|
+
TASK_KEYS.each { |key| @data[key] = [] }
|
32
37
|
end
|
33
38
|
|
34
39
|
def __set__(key)
|
35
40
|
self[key.to_sym] ||= []
|
36
41
|
end
|
37
42
|
|
38
|
-
def
|
43
|
+
def __populate__(proj)
|
39
44
|
return unless @session
|
40
45
|
|
41
46
|
group, parent, id = @session.values
|
47
|
+
ws = proj.workspace
|
42
48
|
each do |key, items|
|
43
|
-
|
44
|
-
if
|
45
|
-
|
46
|
-
|
47
|
-
next unless workspace.task_include?(proj, key)
|
48
|
-
end
|
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)
|
52
|
+
|
49
53
|
if (g = proj.group)
|
50
54
|
id << g
|
51
|
-
(group[:"#{key}:#{g}"] ||= []).push(
|
55
|
+
(group[:"#{key}:#{g}"] ||= []).push(task)
|
52
56
|
else
|
53
|
-
items <<
|
57
|
+
items << task
|
54
58
|
end
|
55
|
-
next unless (b = find_base(proj)) && (name = b.
|
59
|
+
next unless (b = ws.find_base(proj)) && (name = b.ref.to_s) != g
|
56
60
|
|
57
61
|
id << name
|
58
|
-
(parent[:"#{key}:#{name}"] ||= []).push(
|
62
|
+
(parent[:"#{key}:#{name}"] ||= []).push(task)
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
63
|
-
self[key]
|
64
|
-
end
|
65
|
-
|
66
|
-
def finalize!(thread = [])
|
67
|
-
thread.map!(&:to_s)
|
66
|
+
def __build__(parallel: [], **)
|
68
67
|
group, parent, id = @session.values
|
69
68
|
merge!(parent) if id.uniq.size > 1
|
70
69
|
merge!(group)
|
71
70
|
each do |key, items|
|
72
71
|
next if items.empty?
|
73
72
|
|
74
|
-
|
73
|
+
name = key.to_s
|
74
|
+
key = @prefix ? "#{@prefix}:#{name}" : name
|
75
|
+
val = key.split(':').join(' => ')
|
75
76
|
if items.size > 1
|
76
|
-
multiple << key
|
77
|
-
if
|
78
|
-
desc "#{
|
77
|
+
@multiple << key
|
78
|
+
if parallel.include?(name) || (name.include?(':') && parallel.include?(name.split(':').first.to_sym))
|
79
|
+
desc "#{val} (thread)"
|
79
80
|
multitask key => items
|
80
|
-
parallel << key
|
81
|
+
@parallel << key
|
81
82
|
|
82
|
-
desc "#{
|
83
|
-
task "#{key}:sync"
|
84
|
-
sync << "#{key}:sync"
|
85
|
-
multiple << "#{key}:sync"
|
83
|
+
desc "#{val} (sync)"
|
84
|
+
task "#{key}:sync" => items
|
85
|
+
@sync << "#{key}:sync"
|
86
86
|
next
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
desc
|
90
|
+
desc val
|
91
91
|
task key => items
|
92
92
|
end
|
93
|
+
@multiple += sync
|
93
94
|
@session = nil
|
94
95
|
end
|
95
96
|
|
@@ -97,6 +98,14 @@ module Squared
|
|
97
98
|
!key.nil? && key?(key = key.to_sym) && !self[key].empty?
|
98
99
|
end
|
99
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
|
+
|
100
109
|
def multiple?(val = nil)
|
101
110
|
already_invoked?(multiple, val)
|
102
111
|
end
|
@@ -109,14 +118,16 @@ module Squared
|
|
109
118
|
already_invoked?(parallel, val)
|
110
119
|
end
|
111
120
|
|
112
|
-
def respond_to_missing?(key, *)
|
113
|
-
key?(key)
|
114
|
-
end
|
115
|
-
|
116
121
|
private
|
117
122
|
|
123
|
+
def method_missing(key, *)
|
124
|
+
raise NoMethodError, key unless key?(key)
|
125
|
+
|
126
|
+
self[key]
|
127
|
+
end
|
128
|
+
|
118
129
|
def already_invoked?(list, val)
|
119
|
-
return list.include?(val) && invoked?(val) if val
|
130
|
+
return list.include?(val) && Common::Task.invoked?(val) if val
|
120
131
|
|
121
132
|
::Rake::Task.tasks.any? { |item| item.already_invoked && list.include?(item.name) }
|
122
133
|
end
|
data/lib/squared/workspace.rb
CHANGED
@@ -5,12 +5,14 @@ require_relative 'common'
|
|
5
5
|
module Squared
|
6
6
|
module Workspace
|
7
7
|
class << self
|
8
|
+
include Common
|
9
|
+
|
8
10
|
def resolve(*args)
|
9
11
|
ret = args.map do |id|
|
10
12
|
if id.is_a?(::Symbol)
|
11
13
|
project id
|
12
14
|
else
|
13
|
-
|
15
|
+
id = dirpath(id) if id.is_a?(::String)
|
14
16
|
__get__(:project).find { |_, val| val.path.to_s == id.to_s }
|
15
17
|
end
|
16
18
|
end
|
@@ -21,7 +23,13 @@ module Squared
|
|
21
23
|
ret = project(name)
|
22
24
|
return ret if ret&.path&.directory?
|
23
25
|
|
24
|
-
raise NoMethodError,
|
26
|
+
raise NoMethodError, message('project is not initialized', hint: name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def dirpath(val, absolute: true)
|
30
|
+
Pathname.new(val).realdirpath
|
31
|
+
rescue StandardError
|
32
|
+
absolute ? Pathname.pwd.join(val) : Pathname.new(val)
|
25
33
|
end
|
26
34
|
|
27
35
|
def project?(name)
|
@@ -37,6 +45,6 @@ module Squared
|
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
40
|
-
require_relative 'workspace/application'
|
41
48
|
require_relative 'workspace/series'
|
49
|
+
require_relative 'workspace/application'
|
42
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
|