scout-essentials 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/scout/log/fingerprint.rb +9 -4
- data/lib/scout/meta_extension.rb +2 -1
- data/lib/scout/misc/digest.rb +2 -0
- data/lib/scout/misc/monitor.rb +2 -2
- data/lib/scout/named_array.rb +7 -0
- data/lib/scout/open/remote.rb +1 -0
- data/lib/scout/open/util.rb +4 -0
- data/lib/scout/path/find.rb +16 -3
- data/lib/scout/path/util.rb +4 -0
- data/lib/scout/persist/serialize.rb +1 -1
- data/lib/scout/resource/scout.rb +2 -0
- data/scout-essentials.gemspec +5 -4
- data/test/scout/log/test_fingerprint.rb +10 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0a00cab2e80f5ac221c5b89ba51ac9d2e179108523533ccff04bcffa28b621
|
4
|
+
data.tar.gz: 59658780d237328a638a962d9645de6994534015c932deddd7c7b55ddad394c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d48ab2416e00f99db24211774c93841e3aab8bbe14d9a495358f77771aaf3fa03e08d9864a81e5e9818de13bc0bcafe94e975a2d8186312909dc1934750906
|
7
|
+
data.tar.gz: 2cdc543433977a1901f6cc15ad92d30acbb3718bc70919829912083f4cd71e8e18fe9bc63bc396625a78946d15450802b38fd564f6ba63dcd8b2723393db4d84
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
module Log
|
3
|
+
FP_MAX_STRING = 150
|
4
|
+
FP_MAX_ARRAY = 20
|
5
|
+
FP_MAX_HASH = 10
|
3
6
|
def self.fingerprint(obj)
|
4
7
|
return obj.fingerprint if obj.respond_to?(:fingerprint)
|
5
8
|
|
@@ -13,9 +16,11 @@ module Log
|
|
13
16
|
when Symbol
|
14
17
|
":" << obj.to_s
|
15
18
|
when String
|
16
|
-
if obj.length >
|
19
|
+
if obj.length > FP_MAX_STRING
|
17
20
|
digest = Digest::MD5.hexdigest(obj)
|
18
|
-
|
21
|
+
middle = "<...#{obj.length} - #{digest[0..4]}...>"
|
22
|
+
s = (FP_MAX_STRING - middle.length) / 2
|
23
|
+
"'" << obj.slice(0,s-1) << middle << obj.slice(-s, obj.length )<< "'"
|
19
24
|
else
|
20
25
|
"'" << obj << "'"
|
21
26
|
end
|
@@ -28,13 +33,13 @@ module Log
|
|
28
33
|
when File
|
29
34
|
"<File:" + obj.path + ">"
|
30
35
|
when Array
|
31
|
-
if (length = obj.length) >
|
36
|
+
if (length = obj.length) > FP_MAX_ARRAY
|
32
37
|
"[#{length}--" << (obj.values_at(0,1, length / 2, -2, -1).collect{|e| fingerprint(e)} * ",") << "]"
|
33
38
|
else
|
34
39
|
"[" << (obj.collect{|e| fingerprint(e) } * ", ") << "]"
|
35
40
|
end
|
36
41
|
when Hash
|
37
|
-
if obj.length >
|
42
|
+
if obj.length > FP_MAX_HASH
|
38
43
|
"H:{"<< fingerprint(obj.keys) << ";" << fingerprint(obj.values) << "}"
|
39
44
|
else
|
40
45
|
new = "{"
|
data/lib/scout/meta_extension.rb
CHANGED
@@ -68,7 +68,8 @@ module MetaExtension
|
|
68
68
|
|
69
69
|
if new.instance_variables.include?(:@extension_attrs)
|
70
70
|
new.instance_variable_get(:@extension_attrs).each do |a|
|
71
|
-
|
71
|
+
var_name = "@#{a}".to_sym
|
72
|
+
new.remove_instance_variable(var_name) if new.instance_variables.include? var_name
|
72
73
|
end
|
73
74
|
new.remove_instance_variable("@extension_attrs")
|
74
75
|
end
|
data/lib/scout/misc/digest.rb
CHANGED
data/lib/scout/misc/monitor.rb
CHANGED
data/lib/scout/named_array.rb
CHANGED
@@ -70,6 +70,13 @@ module NamedArray
|
|
70
70
|
super(pos)
|
71
71
|
end
|
72
72
|
|
73
|
+
def []=(key, value)
|
74
|
+
pos = NamedArray.identify_name(@fields, key)
|
75
|
+
return nil if pos.nil?
|
76
|
+
super(pos, value)
|
77
|
+
end
|
78
|
+
|
79
|
+
|
73
80
|
def concat(other)
|
74
81
|
super(other)
|
75
82
|
self.fields.concat(other.fields) if NamedArray === other
|
data/lib/scout/open/remote.rb
CHANGED
data/lib/scout/open/util.rb
CHANGED
@@ -114,6 +114,10 @@ module Open
|
|
114
114
|
end
|
115
115
|
class << self; alias exist? exists? end
|
116
116
|
|
117
|
+
def self.exist_or_link?(file)
|
118
|
+
self.exists?(file) || File.symlink?(file)
|
119
|
+
end
|
120
|
+
|
117
121
|
def self.mv(source, target, options = {})
|
118
122
|
target = target.find if Path === target
|
119
123
|
source = source.find if Path === source
|
data/lib/scout/path/find.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative '../indiferent_hash'
|
|
2
2
|
module Path
|
3
3
|
|
4
4
|
def self.caller_lib_dir(file = nil, relative_to = ['lib', 'bin'])
|
5
|
-
|
5
|
+
|
6
6
|
if file.nil?
|
7
7
|
caller_dup = caller.dup
|
8
8
|
while file = caller_dup.shift
|
@@ -41,7 +41,7 @@ module Path
|
|
41
41
|
sub('{SUBPATH}', path._subpath).
|
42
42
|
sub('{BASENAME}', File.basename(path)).
|
43
43
|
sub('{PATH}', path).
|
44
|
-
sub('{LIBDIR}'
|
44
|
+
sub('{LIBDIR}'){ path.libdir || (path.pkgdir.respond_to?(:libdir) && path.pkgdir.libdir) || Path.caller_lib_dir || "NOLIBDIR" }.
|
45
45
|
sub('{MAPNAME}', map_name.to_s).
|
46
46
|
sub('{REMOVE}/', '').
|
47
47
|
sub('{REMOVE}', '').gsub(/\/+/,'/')
|
@@ -88,6 +88,19 @@ module Path
|
|
88
88
|
@@map_order = nil
|
89
89
|
end
|
90
90
|
|
91
|
+
def self.load_path_maps(filename)
|
92
|
+
Path.setup(filename) unless Path === filename
|
93
|
+
if filename.exist?
|
94
|
+
begin
|
95
|
+
YAML.load(filename.read).each do |where, location|
|
96
|
+
@@path_maps[where.to_sym] = location
|
97
|
+
end
|
98
|
+
rescue
|
99
|
+
Log.error "Error loading search_paths from #{filename}: " << $!.message
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
91
104
|
def _parts
|
92
105
|
@_parts ||= self.split("/")
|
93
106
|
end
|
@@ -95,7 +108,7 @@ module Path
|
|
95
108
|
def _subpath
|
96
109
|
@subpath ||= _parts.length > 1 ? _parts[1..-1] * "/" : _parts[0] || ""
|
97
110
|
end
|
98
|
-
|
111
|
+
|
99
112
|
def _toplevel
|
100
113
|
@toplevel ||= _parts.length > 1 ? _parts[0] : ""
|
101
114
|
end
|
data/lib/scout/path/util.rb
CHANGED
data/lib/scout/resource/scout.rb
CHANGED
data/scout-essentials.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.
|
5
|
+
# stub: scout-essentials 1.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "scout-essentials".freeze
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.2.0"
|
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]
|
13
13
|
s.authors = ["Miguel Vazquez".freeze]
|
14
|
-
s.date = "2023-
|
14
|
+
s.date = "2023-08-08"
|
15
15
|
s.description = "Things a scout can use anywhere".freeze
|
16
16
|
s.email = "mikisvaz@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -88,6 +88,7 @@ Gem::Specification.new do |s|
|
|
88
88
|
"test/scout/indiferent_hash/test_case_insensitive.rb",
|
89
89
|
"test/scout/indiferent_hash/test_options.rb",
|
90
90
|
"test/scout/log/test_color.rb",
|
91
|
+
"test/scout/log/test_fingerprint.rb",
|
91
92
|
"test/scout/log/test_progress.rb",
|
92
93
|
"test/scout/misc/test_digest.rb",
|
93
94
|
"test/scout/misc/test_filesystem.rb",
|
@@ -127,7 +128,7 @@ Gem::Specification.new do |s|
|
|
127
128
|
]
|
128
129
|
s.homepage = "http://github.com/mikisvaz/scout-essentials".freeze
|
129
130
|
s.licenses = ["MIT".freeze]
|
130
|
-
s.rubygems_version = "3.
|
131
|
+
s.rubygems_version = "3.5.0.dev".freeze
|
131
132
|
s.summary = "Scout essential tools".freeze
|
132
133
|
|
133
134
|
s.specification_version = 4
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
class TestFingerprint < Test::Unit::TestCase
|
5
|
+
def test_str
|
6
|
+
str = "Start-" + ("0123456789" * 20) + "-End"
|
7
|
+
assert_equal 150, Log.fingerprint(str).length
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-essentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- test/scout/indiferent_hash/test_case_insensitive.rb
|
186
186
|
- test/scout/indiferent_hash/test_options.rb
|
187
187
|
- test/scout/log/test_color.rb
|
188
|
+
- test/scout/log/test_fingerprint.rb
|
188
189
|
- test/scout/log/test_progress.rb
|
189
190
|
- test/scout/misc/test_digest.rb
|
190
191
|
- test/scout/misc/test_filesystem.rb
|
@@ -240,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
241
|
- !ruby/object:Gem::Version
|
241
242
|
version: '0'
|
242
243
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
244
|
+
rubygems_version: 3.5.0.dev
|
244
245
|
signing_key:
|
245
246
|
specification_version: 4
|
246
247
|
summary: Scout essential tools
|