squared 0.0.6 → 0.0.8
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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9b753ae5817f7ddd43ccf1152dde2bd4bc8d37ed2eae1d39d7c118e84c20947
|
4
|
+
data.tar.gz: 910b375d08c1fda296862a22e612832eb0ebbbea505a6d860f2db9e48ff9a2ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3595a660add974bb7bf69df55aaca30d7fb8bfb47ae21cdfd0b5d978ce36f35acb97e15f746d97204afa1a800c639a028e3835a9431addf63e6eb6402df6f87c
|
7
|
+
data.tar.gz: cda2b5a2aa217354d8f06d307c3136ae25d77358b0a478195c7ad945701f08f1e16450340819bd1a41e958a1a31f5e4b13ce167dee4a0d40630f4a3e9a61ada7
|
data/README.ruby.md
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
## Prerequisites
|
8
8
|
|
9
|
-
* Ruby 2.4
|
9
|
+
* Ruby 2.4
|
10
10
|
|
11
11
|
### Optional
|
12
12
|
|
13
13
|
* [Repo](https://source.android.com/docs/setup/reference/repo)
|
14
|
-
* Python 3.6
|
14
|
+
* Python 3.6
|
15
15
|
|
16
16
|
```sh
|
17
17
|
mkdir -p ~/.bin
|
@@ -36,44 +36,61 @@ require "squared/workspace/repo" # Repo (optional)
|
|
36
36
|
|
37
37
|
# REPO_ROOT = /workspaces
|
38
38
|
# REPO_HOME = /workspaces/squared
|
39
|
+
# NODE_ENV = production
|
39
40
|
# rake = /workspaces/squared/Rakefile
|
40
41
|
|
41
42
|
Workspace::Application
|
42
|
-
.new("squared") #
|
43
|
-
.repo("https://github.com/anpham6/squared-repo", "nightly", run: "build") # Repo (optional)
|
43
|
+
.new(main: "squared") # Dir.pwd? (main? is implicitly basename)
|
44
|
+
.repo("https://github.com/anpham6/squared-repo", "nightly", run: "build", ref: :node) # Repo (optional)
|
44
45
|
.run("rake install", ref: :ruby)
|
45
|
-
.
|
46
|
+
.depend(false, group: "default")
|
47
|
+
.clean("rake clean", group: "default")
|
46
48
|
.clean(["build/"], group: "app")
|
47
49
|
.add("pathname", run: "rake compile", copy: "rake install", test: "rake test", group: "default", ref: :ruby) # Ruby (with C extensions)
|
48
50
|
.add("optparse", doc: "rake rdoc", group: "default") # Uses bundler/gem_tasks (without C extensions)
|
49
51
|
.add("logger", copy: { from: "lib", glob: "**/*.rb", gemdir: "~/.rvm/gems/ruby-3.3.5/gems/logger-1.6.1" }, clean: ["tmp/"]) # autodetect: true
|
50
|
-
.add("android", "android-docs", run: false, doc: "make html", ref: :python) # Python
|
51
52
|
.add("emc", "e-mc", copy: { from: "publish", into: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
|
52
53
|
.add("pir", "pi-r", copy: { from: "publish", into: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
|
53
54
|
.add("squared", log: { file: "tmp/%Y-%m-%d.log", level: "debug" }, group: "app") # Copy target (main)
|
54
|
-
.
|
55
|
+
.add("sqd", "squared/sqd", script: ["build:sqd", "prod:sqd"], depend: false, clean: ["build/sqd/"], exclude: :git) # NPM workspaces
|
56
|
+
.style("banner", 255.255) # 256 colors (fg | fg.bg | -0.bg)
|
55
57
|
.build(default: "status", parallel: ["pull", "fetch", "rebase", "copy", "clean"]) do |workspace|
|
56
58
|
workspace
|
57
59
|
.enable_aixterm
|
58
|
-
.style(
|
59
|
-
|
60
|
+
.style({
|
61
|
+
banner: ["bright_cyan", "bold", "bright_black!"],
|
62
|
+
border: "bright_white"
|
63
|
+
})
|
60
64
|
end
|
61
65
|
# pathname = /workspaces/pathname
|
62
66
|
# optparse = /workspaces/optparse
|
63
67
|
# log = /workspaces/logger
|
64
|
-
# android = /workspaces/android-docs
|
65
68
|
# emc = /workspaces/e-mc
|
66
69
|
# pir = /workspaces/pi-r
|
67
70
|
# squared = /workspaces/squared
|
68
71
|
|
69
|
-
|
70
|
-
.new("
|
71
|
-
.group("default", "ruby", run: "rake build", copy: "rake install", clean: "rake clean",
|
72
|
+
Workspace::Application
|
73
|
+
.new(ENV["SQUARED_DIR"], prefix: "rb", common: false) # Has empty styles
|
74
|
+
.group("default", "ruby", run: "rake build", copy: "rake install", clean: "rake clean", ref: :ruby, override: {
|
75
|
+
pathname: {
|
76
|
+
run: "rake compile" # rake rb:pathname:build
|
77
|
+
}
|
78
|
+
})
|
79
|
+
.with(ref: :python) do # Python
|
80
|
+
doc("make html") # rake rb:doc | rb:doc:python
|
81
|
+
run(false) # rake rb:build (disabled)
|
82
|
+
exclude(%i[base git]) # superclass
|
83
|
+
add("android", "android-docs") # rake rb:android:doc
|
84
|
+
add("chrome", "chrome-docs") # rake rb:chrome:doc
|
85
|
+
end
|
86
|
+
.style("inline", "bold")
|
72
87
|
.build
|
73
88
|
# default = /workspaces/ruby/*
|
74
89
|
# pathname = /workspaces/ruby/pathname
|
75
90
|
# optparse = /workspaces/ruby/optparse
|
76
91
|
# logger = /workspaces/ruby/logger
|
92
|
+
# android = /workspaces/android-docs
|
93
|
+
# chrome = /workspaces/chrome-docs
|
77
94
|
```
|
78
95
|
|
79
96
|
**NOTE**: The use of "**ref**" (class name) is only necessary when running `repo:init` for the first time into an empty directory.
|
@@ -93,6 +110,7 @@ rake pull:node # emc + pir + squared
|
|
93
110
|
|
94
111
|
rake build # All except "android"
|
95
112
|
rake doc # optparse + android
|
113
|
+
rake depend # All except "default"
|
96
114
|
|
97
115
|
rake build:ruby # rake compile + rake install + rake install
|
98
116
|
|
@@ -103,6 +121,23 @@ rake clean:app # none + skip + ["build/"]
|
|
103
121
|
rake clean:node # none + ["publish/**/*.js", "tmp/"] + ["build/"]
|
104
122
|
```
|
105
123
|
|
124
|
+
## Commands
|
125
|
+
|
126
|
+
* run
|
127
|
+
* depend
|
128
|
+
* test
|
129
|
+
* doc
|
130
|
+
* clean
|
131
|
+
|
132
|
+
## Styles
|
133
|
+
|
134
|
+
* banner
|
135
|
+
* border
|
136
|
+
* header
|
137
|
+
* active
|
138
|
+
* inline
|
139
|
+
* major
|
140
|
+
|
106
141
|
## LICENSE
|
107
142
|
|
108
143
|
BSD 3-Clause
|
data/lib/squared/common/base.rb
CHANGED
@@ -23,7 +23,12 @@ module Squared
|
|
23
23
|
white!: '47'
|
24
24
|
},
|
25
25
|
theme: {
|
26
|
-
workspace: {
|
26
|
+
workspace: {
|
27
|
+
header: %i[bold],
|
28
|
+
active: %i[bold],
|
29
|
+
inline: %i[bold],
|
30
|
+
major: %i[bold]
|
31
|
+
},
|
27
32
|
project: {},
|
28
33
|
viewer: {
|
29
34
|
banner: %i[blue bold],
|
@@ -59,7 +64,15 @@ module Squared
|
|
59
64
|
VAR[key.is_a?(::String) ? key.to_sym : key] = val
|
60
65
|
end
|
61
66
|
|
62
|
-
def
|
67
|
+
def __freeze__
|
68
|
+
VAR.each_value(&:freeze)
|
69
|
+
VAR[:theme].each_value(&:freeze)
|
70
|
+
VAR.freeze
|
71
|
+
end
|
72
|
+
|
73
|
+
module_function
|
74
|
+
|
75
|
+
def env(key, default = nil, equals: nil, ignore: nil, **)
|
63
76
|
ret = ENV.fetch(key, '')
|
64
77
|
return ret == equals.to_s unless equals.nil?
|
65
78
|
|
@@ -70,22 +83,15 @@ module Squared
|
|
70
83
|
args.reject(&:empty?).join(' => ') + (hint ? " (#{hint})" : '')
|
71
84
|
end
|
72
85
|
|
73
|
-
def as_a(obj, flat: nil)
|
74
|
-
if obj.nil?
|
75
|
-
|
76
|
-
|
77
|
-
[obj]
|
86
|
+
def as_a(obj, meth = nil, flat: nil)
|
87
|
+
return [] if obj.nil?
|
88
|
+
|
89
|
+
if !obj.is_a?(::Array)
|
90
|
+
obj = [obj]
|
78
91
|
elsif flat
|
79
|
-
obj.flatten(flat == true ? nil : flat)
|
80
|
-
else
|
81
|
-
obj
|
92
|
+
obj = obj.flatten(flat == true ? nil : flat)
|
82
93
|
end
|
83
|
-
|
84
|
-
|
85
|
-
def finalize!
|
86
|
-
VAR.each_value(&:freeze)
|
87
|
-
VAR[:theme].each_value(&:freeze)
|
88
|
-
VAR.freeze
|
94
|
+
meth ? obj.map(&meth) : obj
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
data/lib/squared/common/class.rb
CHANGED
@@ -39,46 +39,8 @@ module Squared
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def emphasize(val, title: nil, cols: nil, sub: nil, pipe: nil)
|
43
|
-
n = 0
|
44
|
-
if title
|
45
|
-
title = title.to_s
|
46
|
-
n = title.size
|
47
|
-
end
|
48
|
-
if val.is_a?(::Array)
|
49
|
-
lines = val
|
50
|
-
else
|
51
|
-
lines = val.to_s.lines.map(&:chomp)
|
52
|
-
lines[0] = "#{val.class}: #{lines.first}" if (err = val.is_a?(::StandardError))
|
53
|
-
end
|
54
|
-
n = cols || [n, lines.max_by(&:size).size].max
|
55
|
-
if $stdout.tty?
|
56
|
-
require 'io/console'
|
57
|
-
(n = [n, $stdout.winsize[1] - 4].min) rescue nil
|
58
|
-
end
|
59
|
-
out = []
|
60
|
-
bord = '-' * (n + 4)
|
61
|
-
sub = as_a(sub)
|
62
|
-
pr = lambda do |line|
|
63
|
-
s = line.ljust(n)
|
64
|
-
sub.each { |h| s = sub_style(s, **h) }
|
65
|
-
"| #{s} |"
|
66
|
-
end
|
67
|
-
out << bord
|
68
|
-
out.push(pr.(title), bord) if title
|
69
|
-
lines.each { |line| out << pr.(line) }
|
70
|
-
out << bord
|
71
|
-
if block_given?
|
72
|
-
yield out
|
73
|
-
elsif pipe.respond_to?(:puts)
|
74
|
-
pipe.puts out
|
75
|
-
else
|
76
|
-
err ? warn(out) : puts(out)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
42
|
def sub_style(val, *args, styles: nil, pat: nil, index: 1)
|
81
|
-
return val unless ENV
|
43
|
+
return val unless ENV.fetch('NO_COLOR', '').empty? && !__get__(:no_color)
|
82
44
|
|
83
45
|
if pat && index != 0
|
84
46
|
return val unless (data = pat.match(val))
|
@@ -158,11 +120,12 @@ module Squared
|
|
158
120
|
ret << "-0.#{b}".to_f unless b.to_i > 255
|
159
121
|
end
|
160
122
|
end
|
161
|
-
|
123
|
+
ret if empty || !ret.empty?
|
162
124
|
end
|
163
125
|
|
164
126
|
def apply_style(data, key, *args, empty: true)
|
165
|
-
|
127
|
+
data = __get__(:theme)[data] if data.is_a?(Symbol)
|
128
|
+
return unless data
|
166
129
|
|
167
130
|
set = ->(k, v) { data[k.to_sym] = check_style(v, empty: empty) }
|
168
131
|
if key.is_a?(Hash)
|
@@ -172,10 +135,6 @@ module Squared
|
|
172
135
|
end
|
173
136
|
end
|
174
137
|
|
175
|
-
def raise_error(*args, hint: nil, kind: ArgumentError)
|
176
|
-
raise kind, message(*args, hint: hint)
|
177
|
-
end
|
178
|
-
|
179
138
|
def log_title(level, color: true)
|
180
139
|
level = if level.is_a?(::Numeric)
|
181
140
|
case level
|
@@ -209,6 +168,50 @@ module Squared
|
|
209
168
|
msg << (color ? sub_style(subject, :underline) : subject) if subject
|
210
169
|
message(msg.join(' '), *args, hint: hint)
|
211
170
|
end
|
171
|
+
|
172
|
+
def raise_error(*args, hint: nil, kind: ArgumentError)
|
173
|
+
raise kind, message(*args, hint: hint)
|
174
|
+
end
|
175
|
+
|
176
|
+
module_function
|
177
|
+
|
178
|
+
def emphasize(val, title: nil, cols: nil, sub: nil, pipe: nil)
|
179
|
+
n = 0
|
180
|
+
if title
|
181
|
+
title = title.to_s
|
182
|
+
n = title.size
|
183
|
+
end
|
184
|
+
if val.is_a?(::Array)
|
185
|
+
lines = val
|
186
|
+
else
|
187
|
+
lines = val.to_s.lines.map(&:chomp)
|
188
|
+
lines[0] = "#{val.class}: #{lines.first}" if (err = val.is_a?(::StandardError))
|
189
|
+
end
|
190
|
+
n = cols || [n, lines.max_by(&:size).size].max
|
191
|
+
if $stdout.tty?
|
192
|
+
require 'io/console'
|
193
|
+
(n = [n, $stdout.winsize[1] - 4].min) rescue nil
|
194
|
+
end
|
195
|
+
out = []
|
196
|
+
bord = '-' * (n + 4)
|
197
|
+
sub = [sub] if sub && !sub.is_a?(::Array)
|
198
|
+
pr = lambda do |line|
|
199
|
+
s = line.ljust(n)
|
200
|
+
sub&.each { |h| s = sub_style(s, **h) }
|
201
|
+
"| #{s} |"
|
202
|
+
end
|
203
|
+
out << bord
|
204
|
+
out << pr.(title) << bord if title
|
205
|
+
lines.each { |line| out << pr.(line) }
|
206
|
+
out << bord
|
207
|
+
if block_given?
|
208
|
+
yield out
|
209
|
+
elsif pipe.respond_to?(:puts)
|
210
|
+
pipe.puts out
|
211
|
+
else
|
212
|
+
err ? warn(out) : puts(out)
|
213
|
+
end
|
214
|
+
end
|
212
215
|
end
|
213
216
|
end
|
214
217
|
end
|
data/lib/squared/common/shell.rb
CHANGED
@@ -6,12 +6,12 @@ require 'rake'
|
|
6
6
|
module Squared
|
7
7
|
module Common
|
8
8
|
module Shell
|
9
|
-
|
9
|
+
module_function
|
10
10
|
|
11
11
|
def shell_escape(val, quote: false)
|
12
|
-
return (
|
12
|
+
return Shellwords.escape(val) unless ::Rake::Win32.windows?
|
13
13
|
|
14
|
-
|
14
|
+
quote ? shell_quote(val, force: false) : val
|
15
15
|
end
|
16
16
|
|
17
17
|
def shell_quote(val, force: true)
|
@@ -6,7 +6,7 @@ require 'fileutils'
|
|
6
6
|
module Squared
|
7
7
|
module Common
|
8
8
|
module System
|
9
|
-
|
9
|
+
module_function
|
10
10
|
|
11
11
|
def shell(*cmd, **kwargs)
|
12
12
|
if RUBY_VERSION =~ /^2\.[0-5]\./
|
@@ -20,13 +20,44 @@ module Squared
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def confirm(msg, agree: 'Y', cancel: 'N', default: nil, attempts: 5, timeout: 15)
|
24
|
+
require 'readline'
|
25
|
+
require 'timeout'
|
26
|
+
agree = /^#{agree}$/i if agree.is_a?(String)
|
27
|
+
cancel = /^#{cancel}$/i if cancel.is_a?(String)
|
28
|
+
Timeout.timeout(timeout) do
|
29
|
+
begin
|
30
|
+
while (ch = Readline.readline(msg, true))
|
31
|
+
ch = ch.chomp
|
32
|
+
ch = default if ch.empty?
|
33
|
+
case ch
|
34
|
+
when agree
|
35
|
+
return true
|
36
|
+
when cancel
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
attempts -= 1
|
40
|
+
exit 1 unless attempts >= 0
|
41
|
+
end
|
42
|
+
rescue Interrupt
|
43
|
+
puts
|
44
|
+
exit 0
|
45
|
+
else
|
46
|
+
false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
23
51
|
def copy_d(src, dest, glob: ['**/*'], create: false, verbose: true)
|
52
|
+
src = Pathname.new(src)
|
53
|
+
dest = Pathname.new(dest)
|
24
54
|
raise "#{dest} (not found)" if !create && !dest.exist?
|
25
55
|
|
26
56
|
subdir = []
|
27
57
|
files = 0
|
28
58
|
dest.mkpath if create
|
29
|
-
|
59
|
+
glob = [glob] unless glob.is_a?(::Array)
|
60
|
+
glob.each do |val|
|
30
61
|
Dir.glob(src.join(val)) do |path|
|
31
62
|
ent = Pathname.new(path)
|
32
63
|
next if ent.directory?
|
@@ -48,7 +79,8 @@ module Squared
|
|
48
79
|
if !overwrite
|
49
80
|
path = Pathname.new(dest)
|
50
81
|
if path.directory?
|
51
|
-
src =
|
82
|
+
src = [src] unless src.is_a?(::Array)
|
83
|
+
src = src.reject { |val| path.join(File.basename(val)).exist? }
|
52
84
|
elsif path.exist?
|
53
85
|
return
|
54
86
|
end
|
data/lib/squared/common/task.rb
CHANGED
@@ -5,22 +5,14 @@ require 'rake'
|
|
5
5
|
module Squared
|
6
6
|
module Common
|
7
7
|
module Task
|
8
|
-
|
8
|
+
module_function
|
9
9
|
|
10
|
-
def
|
11
|
-
ret = []
|
12
|
-
return ret unless args.is_a?(::Rake::TaskArguments)
|
13
|
-
|
14
|
-
keys.each { |key| ret << args.fetch(key) if args.key?(key) }
|
15
|
-
ret += args.extras
|
16
|
-
end
|
17
|
-
|
18
|
-
def invoke(name, *args, exception: true)
|
10
|
+
def invoke(name, *args, exception: true, warning: true)
|
19
11
|
::Rake::Task[name].invoke(*args)
|
20
12
|
rescue StandardError => e
|
21
13
|
raise if exception
|
22
14
|
|
23
|
-
warn e
|
15
|
+
warn e if warning
|
24
16
|
end
|
25
17
|
|
26
18
|
def invoked?(name)
|
data/lib/squared/config.rb
CHANGED
@@ -9,7 +9,6 @@ module Squared
|
|
9
9
|
class Viewer
|
10
10
|
include Common
|
11
11
|
include Format
|
12
|
-
include Task
|
13
12
|
include ::Rake::DSL
|
14
13
|
|
15
14
|
class << self
|
@@ -18,14 +17,15 @@ module Squared
|
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
attr_reader :
|
20
|
+
attr_reader :main, :name, :project, :theme
|
22
21
|
|
23
|
-
def initialize(main, name = nil, project: nil, dump: nil, opts: {}, auto: true, common: true)
|
22
|
+
def initialize(main, name = nil, project: nil, prefix: nil, dump: nil, opts: {}, auto: true, common: true)
|
24
23
|
if project
|
25
24
|
main = @project.base_path(main).to_s if (@project = __get__(:project)[project.to_sym])
|
26
25
|
@required = true
|
27
26
|
end
|
28
27
|
@name = name&.to_s || @project&.name
|
28
|
+
@prefix = prefix
|
29
29
|
@ext = File.extname(main)
|
30
30
|
@dump = dump
|
31
31
|
@mime = {}
|
@@ -52,7 +52,7 @@ module Squared
|
|
52
52
|
@required = true
|
53
53
|
project ? [project, 'not found'] : %w[name missing]
|
54
54
|
end
|
55
|
-
warn log_message(:warn, msg, subject: self.class, hint: hint
|
55
|
+
warn log_message(:warn, msg, subject: self.class, hint: hint)
|
56
56
|
end
|
57
57
|
|
58
58
|
def build
|
@@ -60,18 +60,19 @@ module Squared
|
|
60
60
|
|
61
61
|
params = ->(args) { exist? ? [realpath, [args.keys] + args.extras] : [args.keys, args.extras] }
|
62
62
|
|
63
|
-
|
63
|
+
ns = @prefix ? "#{@prefix}:#{name}" : name
|
64
|
+
namespace ns do
|
64
65
|
view = @command && @command != name ? @command : 'view'
|
65
66
|
namespace view do
|
66
|
-
if @mime['json'] && (exist? || !::Rake::Task.task_defined?("#{
|
67
|
-
desc format_desc(view,
|
67
|
+
if @mime['json'] && (exist? || !::Rake::Task.task_defined?("#{ns}:#{view}:json"))
|
68
|
+
desc format_desc(view, 'json')
|
68
69
|
task 'json', [:keys] do |_, args|
|
69
70
|
read_keys(JSON, 'json', *params.(args))
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
if @mime['yaml'] && (exist? || !::Rake::Task.task_defined?("#{
|
74
|
-
desc format_desc(view,
|
74
|
+
if @mime['yaml'] && (exist? || !::Rake::Task.task_defined?("#{ns}:#{view}:yaml"))
|
75
|
+
desc format_desc(view, 'yaml', 'yml')
|
75
76
|
task 'yaml', [:keys] do |_, args|
|
76
77
|
require 'yaml'
|
77
78
|
read_keys(YAML, 'yaml', *params.(args), ext: %w[yml yaml])
|
@@ -92,12 +93,13 @@ module Squared
|
|
92
93
|
obj = eval(parse)
|
93
94
|
ext << type if (ext = as_a(ext)).empty?
|
94
95
|
file = realpath if file.nil? && exist?
|
95
|
-
|
96
|
-
|
96
|
+
|
97
|
+
namespace(@prefix ? "#{@prefix}:#{name}" : name) do
|
98
|
+
desc format_desc(command, *ext, exist: exist)
|
97
99
|
namespace command do
|
98
100
|
task type, [:keys] do |_, args|
|
99
101
|
if file
|
100
|
-
read_keys(obj, type, file.to_s,
|
102
|
+
read_keys(obj, type, file.to_s, args.to_a, ext: ext)
|
101
103
|
else
|
102
104
|
read_keys(obj, type, args.keys, args.extras, ext: ext)
|
103
105
|
end
|
@@ -159,7 +161,7 @@ module Squared
|
|
159
161
|
!@required || (!project.nil? && project.enabled?)
|
160
162
|
end
|
161
163
|
|
162
|
-
|
164
|
+
private
|
163
165
|
|
164
166
|
def read_keys(reader, type, file, keys, ext: [type])
|
165
167
|
if (mime = mime_type(file)) && base_path(file).exist?
|
@@ -188,7 +190,7 @@ module Squared
|
|
188
190
|
title = Pathname.new(file)
|
189
191
|
.realpath
|
190
192
|
.to_s
|
191
|
-
.sub(
|
193
|
+
.sub(Regexp.new("^#{Regexp.escape(File.join(Dir.pwd, ''))}"), '')
|
192
194
|
sub = if pipe?
|
193
195
|
nil
|
194
196
|
else
|
@@ -225,7 +227,7 @@ module Squared
|
|
225
227
|
end
|
226
228
|
end
|
227
229
|
rescue StandardError
|
228
|
-
project&.log&.warn "#{Viewer}(#{type}) => #{file
|
230
|
+
project&.log&.warn "#{Viewer}(#{type}) => #{file && "#{file} "}{#{key}: undefined}"
|
229
231
|
val = Regexp.escape($!.message)
|
230
232
|
key = key.sub(/(#{val})\.|\.(#{val})|(#{val})/) do
|
231
233
|
s = "<#{$3 || $2 || $1}>"
|
@@ -263,8 +265,9 @@ module Squared
|
|
263
265
|
end
|
264
266
|
end
|
265
267
|
|
266
|
-
def format_desc(command, ext, exist: exist?)
|
267
|
-
message(
|
268
|
+
def format_desc(command, *ext, exist: exist?)
|
269
|
+
message(@prefix || '', *name.split(':'), command,
|
270
|
+
"#{ext.first}[#{exist ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys*]")
|
268
271
|
end
|
269
272
|
|
270
273
|
def realpath
|
@@ -284,7 +287,7 @@ module Squared
|
|
284
287
|
end
|
285
288
|
|
286
289
|
def warning?
|
287
|
-
project
|
290
|
+
project ? project.workspace.warning : true
|
288
291
|
end
|
289
292
|
end
|
290
293
|
end
|
data/lib/squared/version.rb
CHANGED