squared 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/squared/config.rb +14 -15
- data/lib/squared/repo/project/node.rb +4 -4
- data/lib/squared/repo/project/python.rb +3 -3
- data/lib/squared/repo/project/ruby.rb +16 -8
- data/lib/squared/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1795e8352e8278c8f4e26ced26ac936ce906ee8e626a9cf2ff2bf6a86412f09c
|
4
|
+
data.tar.gz: '08b8e2538b6316ffb141c15e560187222cbb18e0a37f5c74af6ed5fda87e6dc3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d6bd537e66b744edd760ead7441aad45961bdc746e9ca81f577e8183893cd6209203f2ba507b5ab608bbf3ebe7a15aeb23aa84005a76bf10d0f3b3704c403d
|
7
|
+
data.tar.gz: 9a29c720ce14050bc604c9b561c376f55437865610827075dd6a2a961ce82b22c1f4b3fd303884186f9c59b1a330ed73ce14ad16169724c3578d8d4e01388bfe
|
data/lib/squared/config.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
4
|
+
|
3
5
|
module Squared
|
4
6
|
module Config
|
5
7
|
class Viewer
|
@@ -16,13 +18,14 @@ module Squared
|
|
16
18
|
|
17
19
|
attr_reader :name, :main, :project, :theme
|
18
20
|
|
19
|
-
def initialize(main, name = nil, project: nil, opts: {}, auto: true, common: true)
|
21
|
+
def initialize(main, name = nil, project: nil, dump: nil, opts: {}, auto: true, common: true)
|
20
22
|
if project
|
21
23
|
main = @project.base_path(main).to_s if (@project = __get__(:project)[project.to_sym])
|
22
24
|
@required = true
|
23
25
|
end
|
24
26
|
@name = name&.to_s || @project&.name
|
25
27
|
@ext = File.extname(main)
|
28
|
+
@dump = dump
|
26
29
|
@mime = {}
|
27
30
|
@theme = common ? __get__(:theme)[:viewer] : {}
|
28
31
|
if exist?
|
@@ -61,7 +64,6 @@ module Squared
|
|
61
64
|
if @mime['json'] && (exist? || !::Rake::Task.task_defined?("#{name}:#{view}:json"))
|
62
65
|
desc format_desc(view, %w[json])
|
63
66
|
task :json, [:keys] do |_, args|
|
64
|
-
require 'json'
|
65
67
|
read_keys(JSON, 'json', *params.(args))
|
66
68
|
end
|
67
69
|
end
|
@@ -79,18 +81,17 @@ module Squared
|
|
79
81
|
yield self if block_given?
|
80
82
|
end
|
81
83
|
|
82
|
-
def add(type, gem: nil, parse: nil, ext:
|
84
|
+
def add(type, gem: nil, parse: nil, ext: nil, opts: {}, command: 'view', file: nil, exist: nil)
|
83
85
|
return self if @mime.frozen?
|
84
86
|
|
85
87
|
type = type.to_s
|
86
88
|
if parse && enabled?
|
87
89
|
require(gem || type)
|
88
90
|
obj = eval(parse)
|
89
|
-
ext = as_a(ext)
|
90
|
-
ext << type if ext.empty?
|
91
|
+
ext << type if (ext = as_a(ext)).empty?
|
91
92
|
file = realpath if file.nil? && exist?
|
92
93
|
namespace name do
|
93
|
-
desc format_desc(command, ext)
|
94
|
+
desc format_desc(command, ext, exist: exist)
|
94
95
|
namespace command do
|
95
96
|
task type, [:keys] do |_, args|
|
96
97
|
if file
|
@@ -128,7 +129,7 @@ module Squared
|
|
128
129
|
end
|
129
130
|
end
|
130
131
|
name ||= file.basename.to_s.chomp(File.extname(file))
|
131
|
-
add(type, gem: gem, parse: parse, ext: ext, opts: opts, command: name, file: file)
|
132
|
+
add(type, gem: gem, parse: parse, ext: ext, opts: opts, command: name, file: file, exist: true)
|
132
133
|
end
|
133
134
|
|
134
135
|
def style(name, *args)
|
@@ -234,16 +235,14 @@ module Squared
|
|
234
235
|
$2 ? ".#{s}" : "#{s}."
|
235
236
|
end
|
236
237
|
end
|
237
|
-
out << [key, pipe? ? nil : 'undefined']
|
238
|
+
out << [key, pipe? ? JSON.dump(nil) : 'undefined']
|
238
239
|
else
|
239
|
-
out << [key, pipe? ? val : val.inspect]
|
240
|
+
out << [key, @dump == 'json' || pipe? ? JSON.dump(val) : val.inspect]
|
240
241
|
end
|
241
|
-
pad = key.size
|
242
|
+
pad = [pad, key.size].max
|
242
243
|
end
|
243
244
|
if pipe?
|
244
|
-
|
245
|
-
out = out.map { |item| JSON.dump(item[1]) }
|
246
|
-
puts out.join("\n")
|
245
|
+
puts out.map(&:last).join("\n")
|
247
246
|
else
|
248
247
|
out.map { |item| "#{item[0].ljust(pad)} : #{item[1]}" }
|
249
248
|
end
|
@@ -264,8 +263,8 @@ module Squared
|
|
264
263
|
end
|
265
264
|
end
|
266
265
|
|
267
|
-
def format_desc(command, ext)
|
268
|
-
message(name, command, "#{ext.first}[#{exist
|
266
|
+
def format_desc(command, ext, exist: exist?)
|
267
|
+
message(name, command, "#{ext.first}[#{exist ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys*]")
|
269
268
|
end
|
270
269
|
|
271
270
|
def realpath
|
@@ -71,7 +71,7 @@ module Squared
|
|
71
71
|
when :install
|
72
72
|
desc format_desc(action, flag)
|
73
73
|
task flag do
|
74
|
-
|
74
|
+
depend(flag, override: true)
|
75
75
|
end
|
76
76
|
when :outdated
|
77
77
|
desc format_desc(action, flag, %w[prune dry-run], req: 'opts?')
|
@@ -134,10 +134,10 @@ module Squared
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
def depend(flag = nil)
|
138
|
-
if @depend
|
137
|
+
def depend(flag = nil, override: false)
|
138
|
+
if @depend && !override
|
139
139
|
super
|
140
|
-
|
140
|
+
elsif outdated?
|
141
141
|
frozen = flag == :frozen
|
142
142
|
force = flag == :force
|
143
143
|
dedupe = flag == :dedupe
|
@@ -59,7 +59,7 @@ module Squared
|
|
59
59
|
desc options.()
|
60
60
|
end
|
61
61
|
task flag do |_, args|
|
62
|
-
|
62
|
+
depend(flag, opts: collect_args(args, :opts), override: true)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -68,8 +68,8 @@ module Squared
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def depend(flag = nil, opts: [])
|
72
|
-
if @depend
|
71
|
+
def depend(flag = nil, opts: [], override: false)
|
72
|
+
if @depend && !override
|
73
73
|
super
|
74
74
|
elsif outdated?
|
75
75
|
case install_type
|
@@ -7,7 +7,7 @@ module Squared
|
|
7
7
|
REF = :ruby
|
8
8
|
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
|
9
9
|
OPT_INSTALL = %w[no-cache force quiet verbose].freeze
|
10
|
-
OPT_UPDATE = %w[redownload local strict conservative quiet verbose].freeze
|
10
|
+
OPT_UPDATE = %w[redownload local strict conservative group=s quiet verbose].freeze
|
11
11
|
private_constant :REF, :GEMFILE, :OPT_INSTALL, :OPT_UPDATE
|
12
12
|
|
13
13
|
class << self
|
@@ -80,12 +80,12 @@ module Squared
|
|
80
80
|
when :'with-g', :'without-g'
|
81
81
|
desc format_desc(action, flag, 'group+')
|
82
82
|
task flag, [:group] do |_, args|
|
83
|
-
|
83
|
+
depend(flag, group: collect_args(args, :group), override: true)
|
84
84
|
end
|
85
85
|
else
|
86
86
|
desc format_desc(action, flag, OPT_INSTALL)
|
87
87
|
task flag, [:opts] do |_, args|
|
88
|
-
|
88
|
+
depend(flag, opts: collect_args(args, :opts), override: true)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
when :update
|
@@ -106,10 +106,10 @@ module Squared
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
def depend(flag = nil, opts: [], group: [])
|
110
|
-
if @depend
|
109
|
+
def depend(flag = nil, opts: [], group: [], override: false)
|
110
|
+
if @depend && !override
|
111
111
|
super
|
112
|
-
|
112
|
+
elsif outdated?
|
113
113
|
case flag
|
114
114
|
when :redownload, :local, :'prefer-local'
|
115
115
|
cmd = bundle_session 'install'
|
@@ -248,7 +248,9 @@ module Squared
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def outdated?
|
251
|
-
|
251
|
+
return @outdated unless @outdated.nil?
|
252
|
+
|
253
|
+
@outdated = GEMFILE.any? { |file| base_path(file).exist? }
|
252
254
|
end
|
253
255
|
|
254
256
|
def dev?
|
@@ -261,7 +263,13 @@ module Squared
|
|
261
263
|
if (val = env('BUNDLE_JOBS')).to_i > 0
|
262
264
|
@session << "-j#{val}"
|
263
265
|
end
|
264
|
-
list.each
|
266
|
+
list.each do |flag|
|
267
|
+
if opts.include?(flag)
|
268
|
+
@session << "--#{flag}"
|
269
|
+
elsif /^g(?:roup)?=(.+)$/.match(flag)
|
270
|
+
@session << "--group=#{$1}"
|
271
|
+
end
|
272
|
+
end
|
265
273
|
end
|
266
274
|
|
267
275
|
def gem_session(*cmd)
|
data/lib/squared/version.rb
CHANGED