squared 0.4.12 → 0.5.0

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: 29f44c24914fda199da7719eed8e90da0b508d0c93cf234ff16581e7bf34d112
4
- data.tar.gz: aec5400d8d7abfc44c4abd31bf091de65873f177c57b0782118c081e5875009b
3
+ metadata.gz: 46ea608e0b2d67acb3d15eaf67d7c70fc4c301c1c7ebf0dbfa9fba2e9ccabe0b
4
+ data.tar.gz: 806aeee453718e1ff75f1f83c3f2ac763fd989cdddeca18b570a1d383c90484c
5
5
  SHA512:
6
- metadata.gz: 48e5e2e436689d44a146562e4d791cebf5e19da9ca012c7cdd1860b2fd370c163933fdf58638bf48d4a1b1111170f5f8ed890269388a965dcf2e9e47619a4ea6
7
- data.tar.gz: 816de955802b80b8687c6f8903187dfda9f60720696f4ea80ce1295df7e07a3c3bd38bf4b1da5f6ceb6f7ab0031953ccbab54a13adddc7a41c195adcb9f83912
6
+ metadata.gz: bcde780730f2426af5561183d7d33d172f7dc7a096f9b21b3098593e18758a6a5bdb26e40ccabfaf7e0cf2e6963f067289c304e2e7626b85c15dd2c589e907e0
7
+ data.tar.gz: efcae50c9cfd39b72c013035df135533fee434e7985c3896d409a3d2d1850f16c2c7d2dd811e89431ddc46e2fbc64f752ece5bc8f1205d79d052bcec59fb7749
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.0] - 2025-06-16
4
+
5
+ ### Added
6
+
7
+ - Node command exec through NVM was implemented.
8
+ - Git command options were updated to version 2.49.
9
+
10
+ ### Changed
11
+
12
+ - Gem specification required Ruby version set to 2.5.
13
+ - Docker build options from ENV do not require dashes.
14
+ - Unused task descriptions are not generated.
15
+ - Class object shapes were declared in initialize.
16
+ - Project outdated interactive uses a more compact prompt.
17
+ - Workspace banner configuration uses a struct.
18
+
19
+ ### Removed
20
+
21
+ - Git commit hash identifier uses only a colon for a prefix.
22
+ - Common module for classes was delegated to support namespaces.
23
+
24
+ ### Fixed
25
+
26
+ - Project private variables external modification was revised.
27
+
28
+ ## [0.4.13] - 2025-06-16
29
+
30
+ ### Added
31
+
32
+ - Docker command image action tag was implemented.
33
+ - Docker command image action save was implemented.
34
+ - Docker command container action create was implemented.
35
+ - Node command exec with NPM and PNPM were implemented.
36
+ - Ruby command exec and config are interactive.
37
+ - Python command exec using Kernel.exec was implemented.
38
+ - Theme color "latest" for semver was created.
39
+ - Project can be sorted by graph using comparison operator.
40
+ - Project base command prereqs was created.
41
+ - Project setter methods for private variables with validation.
42
+
43
+ ### Changed
44
+
45
+ - Mismatched shell quoted options are fixed rather than wrapped.
46
+ - Python command venv action run was renamed exec.
47
+ - Ruby command file can accept a glob file pattern.
48
+
49
+ ### Fixed
50
+
51
+ - Shell option quote detection uses Regexp conditionals.
52
+ - Docker property registry did not detect nil values.
53
+ - Gem command exec did not include gem option flag.
54
+ - Project method variable_set did not call block.
55
+ - Project output divider was not printed when not verbose.
56
+
3
57
  ## [0.4.12] - 2025-05-18
4
58
 
5
59
  ### Added
@@ -707,6 +761,8 @@
707
761
 
708
762
  - Changelog was created.
709
763
 
764
+ [0.5.0]: https://github.com/anpham6/squared/releases/tag/v0.5.0-ruby
765
+ [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
710
766
  [0.4.12]: https://github.com/anpham6/squared/releases/tag/v0.4.12-ruby
711
767
  [0.4.11]: https://github.com/anpham6/squared/releases/tag/v0.4.11-ruby
712
768
  [0.4.10]: https://github.com/anpham6/squared/releases/tag/v0.4.10-ruby
data/README.md CHANGED
@@ -140,13 +140,13 @@ rake clone # node + docs
140
140
  # PIPE_FAIL={0,1}
141
141
  # PORT=3000
142
142
  docker build -t squared --build-arg MANIFEST=prod --build-arg NODE_ENV=production .
143
- docker build -t node --build-arg NODE_TAG=22 --build-arg NODE_INSTALL=pnpm -f slim.Dockerfile .
143
+ docker build -t node --build-arg NODE_TAG=22 --build-arg NODE_INSTALL=pnpm -f Dockerfile.slim .
144
144
  NODE=22 docker buildx bake node
145
145
  # OR
146
- docker build -t ruby --build-arg RUBY_TAG=3.4.0 --build-arg NODE_VERSION=22 --build-arg PIPE_FAIL=0 -f ruby.Dockerfile .
146
+ docker build -t ruby --build-arg RUBY_TAG=3.4.0 --build-arg NODE_VERSION=22 --build-arg PIPE_FAIL=0 -f Dockerfile.ruby .
147
147
  RUBY=3.4.0 docker buildx bake ruby
148
148
  # OR
149
- docker build -t nginx --build-arg NGINX_VERSION=1.27 --build-arg PORT=3000 --build-arg NODE_VERSION=20 -f nginx.Dockerfile .
149
+ docker build -t nginx --build-arg NGINX_VERSION=1.27 --build-arg PORT=3000 --build-arg NODE_VERSION=20 -f Dockerfile.nginx .
150
150
  NGINX=1.27 docker buildx bake nginx
151
151
 
152
152
  # Express
@@ -1359,4 +1359,4 @@ NOTE: Defining an element "**id**" will prevent it from being removed during the
1359
1359
 
1360
1360
  ## LICENSE
1361
1361
 
1362
- BSD 3-Clause
1362
+ BSD 3-Clause
data/README.ruby.md CHANGED
@@ -1,16 +1,17 @@
1
- # squared 0.4
1
+ # squared 0.5
2
2
 
3
3
  * [source](https://github.com/anpham6/squared)
4
4
  * [docs](https://squared.readthedocs.io)
5
5
 
6
6
  ## Version Compatibility
7
7
 
8
- | Date | squared | Min | Max | Git |
9
- | :--------: | ------: | -----: | -----: | -----: |
10
- | 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 | 2.39 |
11
- | 2025-01-07 | 0.2.0 | 2.4.0 | 3.4.0 | 2.39 |
12
- | 2025-02-07 | 0.3.0 | 2.4.0 | 3.4.1 | 2.39 |
13
- | 2025-03-06 | 0.4.0 | 2.4.0 | 3.4.2 | 2.39 |
8
+ | Date | squared | Min | Max |
9
+ | :--------: | ------: | -----: | -----: |
10
+ | 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 |
11
+ | 2025-01-07 | 0.2.0 | | 3.4.0 |
12
+ | 2025-02-07 | 0.3.0 | | 3.4.1 |
13
+ | 2025-03-06 | 0.4.0 | | 3.4.2 |
14
+ | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.3 |
14
15
 
15
16
  The range chart indicates the latest Ruby tested against at the time of release.
16
17
 
@@ -263,7 +264,7 @@ Workspace::Application
263
264
  add("squared") do
264
265
  revbuild(include: %w[src/ framework/ types/]) # Git revision build command (optional)
265
266
  chain "all", "revbuild", after: "express:build" # step: 4
266
- chain "publish", "bump:patch", "publish:latest", step: 0, sync: true # rake publish -> squared:bump:patch -> squared:publish:latest
267
+ chain "publish", "bump:patch", "publish:latest", step: 0, sync: true # rake publish
267
268
  end
268
269
  end
269
270
  .with(:python) do
@@ -275,12 +276,12 @@ Workspace::Application
275
276
  chain "all", "doc", with: "squared", before: "squared:revbuild" # Same
276
277
  end
277
278
  end
278
- .chain "all", "status", with: "squared", after: "android-docs" # Global tasks (e.g. without ":")
279
+ .chain("all", "status", with: "squared", after: "android-docs") # Global tasks (e.g. without ":")
279
280
  .build
280
281
  ```
281
282
 
282
283
  ```sh
283
- rake all # all[1-3-4]
284
+ rake all # all[1-3-4]
284
285
  rake all:print
285
286
  ```
286
287
 
@@ -480,6 +481,7 @@ Non-task:
480
481
  * warn
481
482
  * caution
482
483
  * current
484
+ * latest
483
485
  * extra
484
486
  * major
485
487
  * red
@@ -536,7 +538,6 @@ Commands which use commit hashes are parsed using a ":" prefix as to not be conf
536
538
 
537
539
  ```sh
538
540
  rake squared:log:view[:af012345] # git log af012345
539
- rake squared:log:view[#{af012345}] # deprecated
540
541
  rake squared:log:view[H1,HEAD^5,all,lib,./H12345] # git log --all @~1 @^5 -- 'lib' 'H12345'
541
542
  ```
542
543
 
@@ -595,6 +596,9 @@ BANNER_${NAME}=0 #
595
596
 
596
597
  REVBUILD_FORCE=1 # Rebuild all targets
597
598
  REVBUILD_FORCE_${NAME}=1 # Rebuild project
599
+
600
+ PREREQS_${NAME}=build,copy # Class method name to invoke
601
+ PREREQS_${REF}=depend # e.g. Node
598
602
  ```
599
603
 
600
604
  ### Graph
@@ -637,7 +641,7 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
637
641
  | checkout | track | COUNT=n |
638
642
  | checkout | global path | HEAD=s PATHSPEC=s |
639
643
  | checkout | * | FORCE MERGE |
640
- | clone | * | DEPTH=n ORIGIN=s BRANCH=s LOCAL=0,1 |
644
+ | clone | * | DEPTH=n ORIGIN=s BRANCH=s REVISION=s LOCAL=0,1 |
641
645
  | commit | * | UPSTREAM=s DRY_RUN EDIT=0 M|MESSAGE=s |
642
646
  | diff | -between -contain | MERGE_BASE |
643
647
  | diff | head branch | INDEX=n |
@@ -679,6 +683,9 @@ DOCKER_TAG=latest # all
679
683
  DOCKER_TAG_${NAME}=v0.1.0 # project only (override)
680
684
  DOCKER_ALL=1 # list every image/container
681
685
  DOCKER_Y=1 # confirm all
686
+
687
+ BUILD_SQUARED_OPTS="NODE_TAG=24 RUBY_VERSION=3.4.0" DOCKER_SQUARED_OPTS="--no-cache --label=v1" rake squared:build
688
+ docker build --no-cache --label=v1 --build-arg='NODE_TAG=24' --build-arg='RUBY_VERSION=3.4.0' .
682
689
  ```
683
690
 
684
691
  | Command | Flag | ENV |
@@ -99,7 +99,7 @@ module Squared
99
99
 
100
100
  module_function
101
101
 
102
- def as_a(obj, meth = nil, flat: nil, compact: false, &blk)
102
+ def as_a(obj, *meth, flat: nil, compact: false, &blk)
103
103
  return [] if obj.nil?
104
104
 
105
105
  unless obj.is_a?(::Array)
@@ -111,8 +111,10 @@ module Squared
111
111
  end
112
112
  obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
113
113
  obj = obj.compact if compact
114
- obj = obj.map(&meth) if meth
115
- block_given? ? obj.select(&blk) : obj
114
+ obj = obj.map(&meth.shift) until meth.empty?
115
+ return obj unless block_given?
116
+
117
+ obj.select(&blk)
116
118
  end
117
119
  end
118
120
  end
@@ -35,7 +35,7 @@ module Squared
35
35
 
36
36
  def enable_aixterm
37
37
  unless (colors = __get__(:colors)).frozen?
38
- colors.merge!(AIX_TERM)
38
+ colors.update(AIX_TERM)
39
39
  end
40
40
  self
41
41
  end
@@ -11,24 +11,22 @@ module Squared
11
11
  agree = /^#{Regexp.escape(agree)}$/i if agree.is_a?(::String)
12
12
  cancel = /^#{Regexp.escape(cancel)}$/i if cancel.is_a?(::String)
13
13
  Timeout.timeout(timeout) do
14
- begin
15
- while (ch = Readline.readline(msg))
16
- ch = ch.chomp
17
- case (ch.empty? ? default : ch)
18
- when agree
19
- return true
20
- when cancel
21
- return false
22
- end
23
- attempts -= 1
24
- exit 1 unless attempts > 0
14
+ while (ch = Readline.readline(msg))
15
+ ch = ch.chomp
16
+ case (ch.empty? ? default : ch)
17
+ when agree
18
+ return true
19
+ when cancel
20
+ return false
25
21
  end
26
- rescue Interrupt
27
- puts
28
- exit 0
29
- else
30
- false
22
+ attempts -= 1
23
+ exit 1 unless attempts > 0
31
24
  end
25
+ rescue Interrupt
26
+ puts
27
+ exit 0
28
+ else
29
+ false
32
30
  end
33
31
  end
34
32
 
@@ -56,33 +54,31 @@ module Squared
56
54
  end
57
55
  valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max) }
58
56
  Timeout.timeout(timeout) do
59
- begin
60
- while (ch = Readline.readline(msg))
61
- unless (ch = ch.strip).empty?
62
- if multiple
63
- a = ch.split(/\s*,\s*/)
64
- b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
65
- next unless a.size == b.size
66
- return b unless items
67
- next if multiple.is_a?(::Numeric) && multiple != b.size
57
+ while (ch = Readline.readline(msg))
58
+ unless (ch = ch.strip).empty?
59
+ if multiple
60
+ a = ch.split(/\s*,\s*/)
61
+ b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
62
+ next unless a.size == b.size
63
+ return b unless items
64
+ next if multiple.is_a?(::Numeric) && multiple != b.size
68
65
 
69
- return b.map! { |i| items[i - 1] }
70
- elsif valid.call(ch)
71
- return items ? items[ch.to_i - 1] : ch.to_i
72
- end
66
+ return b.map! { |i| items[i - 1] }
67
+ elsif valid.call(ch)
68
+ return items ? items[ch.to_i - 1] : ch.to_i
73
69
  end
74
- attempts -= 1
75
- next if attempts > 0
76
- break unless force
77
-
78
- exit 1
79
70
  end
80
- rescue Interrupt
81
- puts
82
- exit 0
83
- else
84
- multiple ? [] : nil
71
+ attempts -= 1
72
+ next if attempts > 0
73
+ break unless force
74
+
75
+ exit 1
85
76
  end
77
+ rescue Interrupt
78
+ puts
79
+ exit 0
80
+ else
81
+ multiple ? [] : nil
86
82
  end
87
83
  end
88
84
 
@@ -9,23 +9,23 @@ module Squared
9
9
  module_function
10
10
 
11
11
  def shell_escape(val, quote: false, force: false, double: false, option: false, override: false)
12
- if (r = /\A(--?)([^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val if !r[3] || (!r[5] && !r[6].match?(/\s/))
14
-
15
- combine = lambda do |opt|
16
- if r[2] =~ /\A(["'])(.+)\1\z/m
17
- double = $1 == '"'
18
- r[2] = $2
19
- override = true
20
- end
21
- r[1] + r[2] + r[4] + shell_quote(opt, double: double, force: force, override: override)
12
+ if (r = /\A(--?)([^= ]+)((=|\s+)(["'])?(?(5)(.*)\5|(.*)))?\z/m.match(val = val.to_s))
13
+ if (data = r[2].match(/\A(["'])(.+)\1\z/))
14
+ double = data[1] == '"'
15
+ override = true
16
+ elsif !r[3] || r[6]
17
+ return val
22
18
  end
23
- if r[5] == r[7]
24
- r[5] ? val : combine.call(r[6])
19
+ if r[7].match?(/\A["']/)
20
+ opt = "#{r[7]}#{r[7][0]}"
21
+ elsif r[7].match?(/["']\z/)
22
+ opt = "#{r[7][-1]}#{r[7]}"
25
23
  else
26
- force = true
27
- combine.call(r[5] + r[6] + r[7])
24
+ return val unless r[7].match?(/\s/)
25
+
26
+ opt = r[7]
28
27
  end
28
+ r[1] + (data ? data[2] : r[2]) + r[4] + shell_quote(opt, double: double, force: force, override: override)
29
29
  elsif option && val =~ /\A([^=]+)=(.+)\z/m
30
30
  return val if $2.match?(/\A(["']).+\1\z/m)
31
31
 
@@ -85,26 +85,31 @@ module Squared
85
85
  end}"
86
86
  end
87
87
 
88
- def shell_split(val, quote: false, force: false, join: nil)
88
+ def shell_split(val, join: nil, **kwargs)
89
89
  ret = val.shellsplit
90
- ret.map! { |opt| shell_escape(opt, quote: quote, force: force, double: true, option: true) }
90
+ ret.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
91
91
  return ret unless join
92
92
 
93
93
  ret.join(join.is_a?(::String) ? join : ' ')
94
94
  end
95
95
 
96
- def fill_option(val, double: false)
96
+ def line_width(lines)
97
+ ret = [lines.max_by(&:size).size, 80].max
98
+ [ret, Rake.application.terminal_width].min
99
+ end
100
+
101
+ def fill_option(val, **kwargs)
97
102
  return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
98
103
 
99
- shell_escape(val.start_with?('-') ? val : "--#{val}", double: double)
104
+ shell_escape(val.start_with?('-') ? val : "--#{val}", **kwargs)
100
105
  end
101
106
 
102
- def quote_option(flag, val, option: true, double: false, merge: false)
103
- shell_option(flag, val, escape: false, option: option, double: double, merge: merge)
107
+ def quote_option(flag, val, **kwargs)
108
+ shell_option(flag, val, escape: false, **kwargs)
104
109
  end
105
110
 
106
- def basic_option(flag, val, merge: false)
107
- shell_option(flag, val, escape: false, force: false, merge: merge)
111
+ def basic_option(flag, val, **kwargs)
112
+ shell_option(flag, val, escape: false, force: false, **kwargs)
108
113
  end
109
114
  end
110
115
  end
@@ -11,37 +11,39 @@ module Squared
11
11
  def shell(*args, **kwargs)
12
12
  if RUBY_VERSION < '2.6'
13
13
  exception = kwargs.delete(:exception)
14
- ret = system(*args, **kwargs)
14
+ ret = Kernel.system(*args, **kwargs)
15
15
  return ret if ret || !exception
16
16
 
17
17
  raise $?.to_s
18
18
  else
19
- system(*args, **kwargs)
19
+ Kernel.system(*args, **kwargs)
20
20
  end
21
21
  end
22
22
 
23
- def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, verbose: true)
24
- src = Pathname.new(src)
25
- dest = Pathname.new(dest)
26
- raise "#{dest.cleanpath} (not found)" if !create && !dest.parent.exist?
23
+ def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, hidden: false,
24
+ verbose: true)
25
+ base = Pathname.new(src)
26
+ target = Pathname.new(dest)
27
+ raise "#{target.cleanpath} (not found)" if !create && !target.parent.exist?
27
28
 
28
29
  subdir = {}
29
- dest.mkpath if create
30
+ target.mkpath if create
31
+ flags = hidden ? [File::FNM_DOTMATCH] : []
30
32
  if pass
31
33
  exclude = []
32
- pass = [pass] unless pass.is_a?(::Enumerable)
33
- pass.each { |val| exclude.concat(Dir.glob(src + val)) }
34
+ pass = [pass] unless pass.is_a?(::Array)
35
+ pass.each { |val| exclude.concat(Dir.glob(val, *flags, base: base)) }
34
36
  end
35
37
  (glob.is_a?(::Enumerable) ? glob : [glob]).each do |val|
36
- Dir.glob(src + val) do |path|
37
- next if exclude&.include?(path) || (path = Pathname.new(path)).directory?
38
+ Dir.glob(val, *flags, base: base) do |file|
39
+ next if exclude&.include?(file) || (entry = base + file).directory?
38
40
 
39
- dir = dest.join(path.relative_path_from(src)).dirname
41
+ dir = target.join(file).dirname
40
42
  if (data = subdir[dir.to_s])
41
- data << path
43
+ data << entry
42
44
  else
43
45
  dir.mkpath
44
- subdir[dir.to_s] = [path]
46
+ subdir[dir.to_s] = [entry]
45
47
  end
46
48
  end
47
49
  end
@@ -49,23 +51,24 @@ module Squared
49
51
  soft = 0
50
52
  subdir.each do |dir, files|
51
53
  if link
52
- items = files.dup
53
- files.clear
54
- items.each do |file|
55
- if file.exist?
56
- if file.symlink?
57
- next unless force
54
+ files.dup.yield_self do |items|
55
+ files.clear
56
+ items.each do |file|
57
+ if file.exist?
58
+ if file.symlink?
59
+ next unless force
60
+ else
61
+ files << file
62
+ next
63
+ end
64
+ end
65
+ if link == 'hard'
66
+ FileUtils.ln(file, dir, force: force, verbose: false)
58
67
  else
59
- files << file
60
- next
68
+ FileUtils.ln_s(file, dir, force: force, verbose: false)
61
69
  end
70
+ soft += 1
62
71
  end
63
- if link == 'hard'
64
- FileUtils.ln(file, dir, force: force, verbose: false)
65
- else
66
- FileUtils.ln_s(file, dir, force: force, verbose: false)
67
- end
68
- soft += 1
69
72
  end
70
73
  end
71
74
  next if files.empty?
@@ -73,16 +76,17 @@ module Squared
73
76
  out = FileUtils.cp(files, dir, verbose: false)
74
77
  count += out.size
75
78
  end
76
- puts [dest.realpath, subdir.size, soft > 0 ? "#{count}+#{soft}" : count].join(' => ') if verbose
79
+ puts [target.realpath, subdir.size, soft > 0 ? "#{count}+#{soft}" : count].join(' => ') if verbose
77
80
  end
78
81
 
79
82
  def copy_guard(src, dest, link: nil, force: false, verbose: true)
80
83
  unless force
81
- if (path = Pathname.new(dest)).directory?
84
+ target = Pathname.new(dest)
85
+ if target.directory?
82
86
  src = [src] unless src.is_a?(::Enumerable)
83
- src = src.reject { |val| path.join(File.basename(val)).exist? }
87
+ src = src.reject { |val| target.join(File.basename(val)).exist? }
84
88
  return if src.empty?
85
- elsif path.exist?
89
+ elsif target.exist?
86
90
  return
87
91
  end
88
92
  end
@@ -88,18 +88,6 @@ module Squared
88
88
  end
89
89
  end
90
90
 
91
- def time_offset(val = nil)
92
- val = DateTime.parse(val) if val.is_a?(::String)
93
- cur = DateTime.now
94
- ret = 0
95
- if (r = /^([+-])(\d+):(\d+):(\d+)$/.match((val || cur).strftime('%::z')))
96
- ret += (r[1] == '+' ? -1 : 1) * ((r[2].to_i * 60 * 60) + (r[3].to_i * 60) + r[4].to_i) * 1000
97
- end
98
- return ret unless val
99
-
100
- (cur.strftime('%Q').to_i + time_offset) - (val.strftime('%Q').to_i + ret)
101
- end
102
-
103
91
  def time_since(val, ms: true)
104
92
  s = ms ? '%s%L' : '%s'
105
93
  Time.now.utc.strftime(s).to_i - Time.parse(val).utc.strftime(s).to_i
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  require_relative 'common/base'
4
- require_relative 'common/class'
5
6
  require_relative 'common/format'
6
7
  require_relative 'common/prompt'
7
8
  require_relative 'common/shell'
@@ -27,7 +27,7 @@ module Squared
27
27
  def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
28
28
  return unless project.enabled?
29
29
 
30
- ret = Viewer.new(main, name, project: project, **kwargs)
30
+ ret = new(main, name, project: project, **kwargs)
31
31
  ret.instance_eval(&blk) if block_given?
32
32
  ret
33
33
  end
@@ -170,7 +170,7 @@ module Squared
170
170
  end
171
171
 
172
172
  def style(name, *args)
173
- apply_style(theme, name, args)
173
+ apply_style theme, name, args
174
174
  self
175
175
  end
176
176
 
@@ -213,7 +213,7 @@ module Squared
213
213
  file = nil
214
214
  ext[0] = mime
215
215
  elsif file
216
- keys.unshift(file)
216
+ keys.prepend(file)
217
217
  alt = basepath("#{main}.{#{ext.join(',')}}")
218
218
  file = Dir[alt].first
219
219
  else
@@ -243,13 +243,14 @@ module Squared
243
243
  [
244
244
  { pat: /\A((?:[^:]|(?<! ):(?! ))+)\z/, styles: theme[:banner] },
245
245
  { pat: /\A(.*?)(<[^>]+>)(.+)\z/m, styles: theme[:undefined], index: 2 },
246
- { pat: /\A(.+)( : (?!undefined).+)\z/m, styles: theme[:key] },
247
- { pat: /\A(.+ : )(-?[\d.]+)(\s*)\z/m, styles: theme[:number],
246
+ { pat: /\A((?~ : ))( : (?!undefined).+)\z/m, styles: theme[:key] },
247
+ { pat: /\A((?~: ): )(-?[\d.]+)(\s*)\z/m, styles: theme[:number],
248
248
  index: 2 },
249
- { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
250
- { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
251
- { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
252
- { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
249
+ { pat: /\A((?~: ): ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
250
+ { pat: /\A((?~: ): \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
251
+ { pat: /\A((?~: ): \[)(.+)(\]\s*)\z/m, styles: theme[:array],
252
+ index: 2 },
253
+ { pat: /\A((?~: ): (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
253
254
  index: 2 }
254
255
  ]
255
256
  end, border: theme[:border])
@@ -308,7 +309,7 @@ module Squared
308
309
  return unless Rake::TaskManager.record_task_metadata
309
310
 
310
311
  val = "#{ext.first}[#{target ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
311
- args = *name.split(':').push(command, val)
312
+ args = *name.split(':').append(command, val)
312
313
  if project
313
314
  project.workspace.task_desc(*args)
314
315
  else
@@ -346,7 +347,7 @@ module Squared
346
347
  end
347
348
 
348
349
  def basepath(file)
349
- project ? project.basepath(file) : Pathname.new(file).realdirpath
350
+ project ? project.basepath(file) : Pathname.pwd + file
350
351
  end
351
352
  end
352
353
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.12'
4
+ VERSION = '0.5.0'
5
5
  end