scout-essentials 1.8.5 → 1.8.6
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/.vimproject +2 -0
- data/VERSION +1 -1
- data/lib/scout/annotation/annotated_object.rb +5 -0
- data/lib/scout/annotation.rb +1 -1
- data/lib/scout/log/fingerprint.rb +2 -0
- data/lib/scout/misc/digest.rb +3 -0
- data/lib/scout/misc/format.rb +7 -6
- data/lib/scout/misc/system.rb +19 -11
- data/lib/scout/open/final.rb +5 -2
- data/lib/scout/path/find.rb +1 -1
- data/lib/scout/path/util.rb +9 -0
- data/lib/scout/path.rb +1 -1
- data/lib/scout/persist/serialize.rb +1 -1
- data/lib/scout/persist.rb +6 -4
- data/scout-essentials.gemspec +3 -3
- data/test/scout/path/test_util.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 860143272938aa7cf5cea99f3c6b58206ed6670cf0c8638adcfe62774fcab925
|
|
4
|
+
data.tar.gz: 6c92e398a80f3d39c3cae9db84d947c9386d8a08cb0bfffab2239c0810d1ba6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aef77cc47e9de21fa0da8ddc9e0246afd91849aad07b3e7d8b33813098cde01a9971c6dcd58d8b07d2b9c372a580ce74aaa484258b5cf914c48e0eae28dc165e
|
|
7
|
+
data.tar.gz: 4638f2423e319274ff0ad0b5885b9669b156c519278e775e6ab33733faf0b1c2abeb561f7256c8ebada13c4faaaf2325897a39e0d85b0c49d19413dd0fc6c125
|
data/.vimproject
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.6
|
data/lib/scout/annotation.rb
CHANGED
data/lib/scout/misc/digest.rb
CHANGED
data/lib/scout/misc/format.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Misc
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
MAX_TTY_LINE_WIDTH =
|
|
39
|
+
MAX_TTY_LINE_WIDTH = 120
|
|
40
40
|
def self.format_paragraph(text, size = nil, indent = nil, offset = nil)
|
|
41
41
|
size ||= Log.tty_size || MAX_TTY_LINE_WIDTH
|
|
42
42
|
size = MAX_TTY_LINE_WIDTH if size > MAX_TTY_LINE_WIDTH
|
|
@@ -45,8 +45,8 @@ module Misc
|
|
|
45
45
|
|
|
46
46
|
i = 0
|
|
47
47
|
#size = size + offset + indent
|
|
48
|
-
re = /((?:\n\s*\n\s*)|(?:\n\s*(?=\*)))/
|
|
49
|
-
|
|
48
|
+
re = /((?:\n\s*\n\s*)|(?:\n\s*(?=\*))|(?:\n\s\s+)|(?:\n\s*[-\*]))/
|
|
49
|
+
text.split(re).collect do |paragraph|
|
|
50
50
|
i += 1
|
|
51
51
|
str = if i % 2 == 1
|
|
52
52
|
words = paragraph.gsub(/\s+/, "\s").split(" ")
|
|
@@ -75,11 +75,12 @@ module Misc
|
|
|
75
75
|
def self.format_definition_list_item(dt, dd, indent = nil, size = nil, color: :yellow)
|
|
76
76
|
if size.nil?
|
|
77
77
|
base_size = Log.tty_size || MAX_TTY_LINE_WIDTH
|
|
78
|
+
base_size = MAX_TTY_LINE_WIDTH if base_size > MAX_TTY_LINE_WIDTH
|
|
78
79
|
base_indent = indent || (base_size / 3)
|
|
79
80
|
size = base_size - base_indent
|
|
80
81
|
end
|
|
81
82
|
|
|
82
|
-
indent ||= base_indent || size / 3
|
|
83
|
+
indent ||= base_indent || (size / 3)
|
|
83
84
|
|
|
84
85
|
dd = "" if dd.nil?
|
|
85
86
|
dt = Log.color color, dt if color
|
|
@@ -87,12 +88,12 @@ module Misc
|
|
|
87
88
|
len = Log.uncolor(dt).length
|
|
88
89
|
|
|
89
90
|
if indent < 0
|
|
90
|
-
text = format_paragraph(dd,
|
|
91
|
+
text = format_paragraph(dd, base_size, indent.abs-1, 0)
|
|
91
92
|
text = dt << "\n" << text
|
|
92
93
|
else
|
|
93
94
|
offset = len - indent
|
|
94
95
|
offset = 0 if offset < 0
|
|
95
|
-
text = format_paragraph(dd,
|
|
96
|
+
text = format_paragraph(dd, base_size, indent.abs+1, offset)
|
|
96
97
|
text[0..len-1] = dt
|
|
97
98
|
end
|
|
98
99
|
text
|
data/lib/scout/misc/system.rb
CHANGED
|
@@ -48,17 +48,7 @@ module Misc
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def self.
|
|
52
|
-
old_value = ENV[var]
|
|
53
|
-
begin
|
|
54
|
-
ENV[var] = value
|
|
55
|
-
yield
|
|
56
|
-
ensure
|
|
57
|
-
ENV[var] = old_value
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def self.with_envs(hash, &block)
|
|
51
|
+
def self.with_env_hash(hash, &block)
|
|
62
52
|
old_value = {}
|
|
63
53
|
begin
|
|
64
54
|
hash.each do |var,value|
|
|
@@ -73,6 +63,24 @@ module Misc
|
|
|
73
63
|
end
|
|
74
64
|
end
|
|
75
65
|
|
|
66
|
+
def self.with_env(var, value = nil, &block)
|
|
67
|
+
if Hash === value
|
|
68
|
+
with_env_hash(var, &block)
|
|
69
|
+
else
|
|
70
|
+
old_value = ENV[var]
|
|
71
|
+
begin
|
|
72
|
+
ENV[var] = value
|
|
73
|
+
yield
|
|
74
|
+
ensure
|
|
75
|
+
ENV[var] = old_value
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class << self
|
|
81
|
+
alias with_envs with_env_hash
|
|
82
|
+
end
|
|
83
|
+
|
|
76
84
|
|
|
77
85
|
def self.update_git(gem_name = 'scout-essentials')
|
|
78
86
|
gem_name = 'scout-essentials' if gem_name.nil?
|
data/lib/scout/open/final.rb
CHANGED
|
@@ -144,8 +144,11 @@ module Open
|
|
|
144
144
|
file = file.find if Path === file
|
|
145
145
|
begin
|
|
146
146
|
if File.symlink?(file) || File.stat(file).nlink > 1
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
info_file = file + '.info'
|
|
148
|
+
if File.exist?(info_file) && defined?(Step)
|
|
149
|
+
done = Persist.memory([info_file, File.mtime(info_file)], persist: true ) do
|
|
150
|
+
Persist.load(info_file, Step::SERIALIZER)[:done]
|
|
151
|
+
end
|
|
149
152
|
return done if done
|
|
150
153
|
end
|
|
151
154
|
|
data/lib/scout/path/find.rb
CHANGED
|
@@ -203,7 +203,7 @@ module Path
|
|
|
203
203
|
def annotate_found_where(found, where)
|
|
204
204
|
self.annotate(found).tap{|p|
|
|
205
205
|
p.instance_variable_set("@where", where)
|
|
206
|
-
p.instance_variable_set("@original", self.dup)
|
|
206
|
+
p.instance_variable_set("@original", self.annotate(self.dup))
|
|
207
207
|
}
|
|
208
208
|
end
|
|
209
209
|
|
data/lib/scout/path/util.rb
CHANGED
|
@@ -23,6 +23,15 @@ module Path
|
|
|
23
23
|
return true
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def self.can_write?(string)
|
|
27
|
+
return false if Open.remote?(string)
|
|
28
|
+
return false unless Path.is_filename?(string)
|
|
29
|
+
string = string.find if Path === string
|
|
30
|
+
return false if File.directory?(string)
|
|
31
|
+
return File.writable?(string) if File.exist?(string)
|
|
32
|
+
return File.writable?(File.dirname(string))
|
|
33
|
+
end
|
|
34
|
+
|
|
26
35
|
def self.sanitize_filename(filename, length = 254)
|
|
27
36
|
if filename.length > length
|
|
28
37
|
if filename =~ /(\..{2,9})$/
|
data/lib/scout/path.rb
CHANGED
|
@@ -129,7 +129,7 @@ module Persist
|
|
|
129
129
|
type = MEMORY if type == :memory
|
|
130
130
|
return unless Hash === type || Open.exist?(file)
|
|
131
131
|
|
|
132
|
-
Log.debug "Load #{Log.fingerprint type}
|
|
132
|
+
Log.debug "Load #{Log.fingerprint type} from #{file}"
|
|
133
133
|
if load_drivers[type]
|
|
134
134
|
return load_drivers[type].call(file)
|
|
135
135
|
end
|
data/lib/scout/persist.rb
CHANGED
|
@@ -42,16 +42,18 @@ module Persist
|
|
|
42
42
|
update = Open.mtime(update) if Path === update
|
|
43
43
|
|
|
44
44
|
update = true if file.outdated?(check) if Path === file && check
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
if update
|
|
46
|
+
file_mtime = Open.mtime(file)
|
|
47
|
+
update = file_mtime >= update ? false : true if file_mtime && Time === update
|
|
48
|
+
update = file_mtime >= (Time.now - update) ? false : true if file_mtime && Numeric === update
|
|
49
|
+
end
|
|
48
50
|
|
|
49
51
|
if type == :memory
|
|
50
52
|
repo = options[:memory] || options[:repo] || MEMORY_CACHE
|
|
51
53
|
if update
|
|
52
54
|
repo[file] = yield
|
|
53
55
|
else
|
|
54
|
-
repo[file]
|
|
56
|
+
repo[file] = yield unless repo.include? file
|
|
55
57
|
end
|
|
56
58
|
return repo[file]
|
|
57
59
|
end
|
data/scout-essentials.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: scout-essentials 1.8.
|
|
5
|
+
# stub: scout-essentials 1.8.6 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "scout-essentials".freeze
|
|
9
|
-
s.version = "1.8.
|
|
9
|
+
s.version = "1.8.6".freeze
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib".freeze]
|
|
@@ -159,7 +159,7 @@ Gem::Specification.new do |s|
|
|
|
159
159
|
]
|
|
160
160
|
s.homepage = "http://github.com/mikisvaz/scout-essentials".freeze
|
|
161
161
|
s.licenses = ["MIT".freeze]
|
|
162
|
-
s.rubygems_version = "3.7.
|
|
162
|
+
s.rubygems_version = "3.7.2".freeze
|
|
163
163
|
s.summary = "Scout essential tools".freeze
|
|
164
164
|
|
|
165
165
|
s.specification_version = 4
|
|
@@ -37,5 +37,26 @@ class TestPathUtil < Test::Unit::TestCase
|
|
|
37
37
|
refute Path.newer? dir.f2.find, dir.f1.find
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
def test_can_read
|
|
42
|
+
TmpFile.with_path do |dir|
|
|
43
|
+
Open.write dir.f1, 'test1'
|
|
44
|
+
sleep 0.1
|
|
45
|
+
Open.write dir.f2, 'test2'
|
|
46
|
+
Open.write dir.f4, 'test4'
|
|
47
|
+
|
|
48
|
+
CMD.cmd("chmod -w #{dir.f4.find}")
|
|
49
|
+
|
|
50
|
+
assert Path.can_read? dir.f1
|
|
51
|
+
assert Path.can_read? dir.f3
|
|
52
|
+
assert Path.can_write? dir.f3
|
|
53
|
+
|
|
54
|
+
refute Path.can_write? dir.f4
|
|
55
|
+
|
|
56
|
+
CMD.cmd("chmod -w #{dir.find}")
|
|
57
|
+
refute Path.can_write? dir.f3
|
|
58
|
+
CMD.cmd("chmod +w #{dir.find}")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
40
61
|
end
|
|
41
62
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scout-essentials
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miguel Vazquez
|
|
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
298
298
|
- !ruby/object:Gem::Version
|
|
299
299
|
version: '0'
|
|
300
300
|
requirements: []
|
|
301
|
-
rubygems_version: 3.7.
|
|
301
|
+
rubygems_version: 3.7.2
|
|
302
302
|
specification_version: 4
|
|
303
303
|
summary: Scout essential tools
|
|
304
304
|
test_files: []
|