scout-essentials 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a848d630e2eeffecaf053c2cd4a531e526edd32117fafd71c35833abdb41cc3b
4
- data.tar.gz: 8b18cd5f7c4819814aee3edbabcb88975b7cb635ae2e0b7c0fc87cf37fc3bd6d
3
+ metadata.gz: b180a31f0775b92588e69028899896e5d7a865a818eaa3ac07235e9e3cbe0a4b
4
+ data.tar.gz: dee502eb8812dd3dbeb039858225110114b7b6279eb6fb7c062dff3f86e697d7
5
5
  SHA512:
6
- metadata.gz: 52ef4a13bd1950d21dcad55fa0b5811521388b276ba11908f88e1e2bd13cd9658320591eb83aa689c7d62f724104c28706449c38e1dd79877882268893fe3cea
7
- data.tar.gz: b412f4e6b21198aaaaaabdb87908e9e5222fab838d32f4666d33e336b497b23990ac5db1e7236cc89c0a6b79fab4d9435c21f0d5202537620d1bcb66089c136a
6
+ metadata.gz: 224014296d5798f7dbe980d67eb241456c62de05b21ddaf255c429f1f8c76a3d28de89fdff69f8c37ed06e8de65cc244a77f9d34004545318d986c8386de2ff2
7
+ data.tar.gz: de7644e77bac10982314a1f73ea200294755901e66aff6010c027c6808f3209c35da1d6675a179689662c6c57370ddf8c2f61bf5df358b59fe747936d682f889
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -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 > 100
19
+ if obj.length > FP_MAX_STRING
17
20
  digest = Digest::MD5.hexdigest(obj)
18
- "'" << obj.slice(0,30) << "<...#{obj.length} - #{digest[0..4]}...>" << obj.slice(-10,30)<< "'"
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) > 10
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 > 10
42
+ if obj.length > FP_MAX_HASH
38
43
  "H:{"<< fingerprint(obj.keys) << ";" << fingerprint(obj.values) << "}"
39
44
  else
40
45
  new = "{"
@@ -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
- new.remove_instance_variable("@#{a}")
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
@@ -9,6 +9,8 @@ module Misc
9
9
  #'\'' << obj << '\''
10
10
  if Path === obj || ! Open.exists?(obj)
11
11
  '\'' << obj << '\''
12
+ elsif File.directory?(obj)
13
+ "Directory MD5: #{digest_str(Dir.glob(File.join(obj, "*")))}"
12
14
  else
13
15
  "File MD5: #{Misc.file_md5(obj)}"
14
16
  end
@@ -8,8 +8,8 @@ module Misc
8
8
  res = nil
9
9
  begin
10
10
  measure = Benchmark.measure do
11
- repeats.times do
12
- res = yield
11
+ repeats.times do |i|
12
+ res = yield i
13
13
  end
14
14
  end
15
15
  if message
@@ -31,6 +31,7 @@ module Open
31
31
  end
32
32
 
33
33
  def self.wget(url, options = {})
34
+ options = options[:wget_options] if options.include?(:wget_options)
34
35
  if ! (options[:force] || options[:nocache]) && cache_file = in_cache(url, options)
35
36
  return file_open(cache_file)
36
37
  end
@@ -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
@@ -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}', path.libdir || (path.pkgdir.respond_to?(:libdir) && path.pkgdir.libdir) || Path.caller_lib_dir || "NOLIBDIR").
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(/\/+/,'/')
@@ -34,6 +34,10 @@ module Path
34
34
  File.directory?(self.find)
35
35
  end
36
36
 
37
+ def sub(*args)
38
+ self.annotate super(*args)
39
+ end
40
+
37
41
  def dirname
38
42
  self.annotate(File.dirname(self))
39
43
  end
@@ -52,7 +52,7 @@ module Persist
52
52
  when nil, :string, :text, :file, :stream, :select, :folder
53
53
  serialized
54
54
  when :path
55
- Path.setup(serialized)
55
+ Path.setup(serialized.strip)
56
56
  when :integer
57
57
  serialized.to_i
58
58
  when :float
@@ -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.1.0 ruby lib
5
+ # stub: scout-essentials 1.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-essentials".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.1.1"
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-07-06"
14
+ s.date = "2023-08-01"
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",
@@ -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.1.0
4
+ version: 1.1.1
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-07-06 00:00:00.000000000 Z
11
+ date: 2023-08-01 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