scout-essentials 1.1.1 → 1.3.0

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: b180a31f0775b92588e69028899896e5d7a865a818eaa3ac07235e9e3cbe0a4b
4
- data.tar.gz: dee502eb8812dd3dbeb039858225110114b7b6279eb6fb7c062dff3f86e697d7
3
+ metadata.gz: 635a27a40f5897e83e1632e43a1cfa9343edd5c53e7eee522fc99f4a74e03171
4
+ data.tar.gz: 19bb00a9be1cc0ab21661cedc46bfd1d21118cd0fed9f0d240b205580e8a733a
5
5
  SHA512:
6
- metadata.gz: 224014296d5798f7dbe980d67eb241456c62de05b21ddaf255c429f1f8c76a3d28de89fdff69f8c37ed06e8de65cc244a77f9d34004545318d986c8386de2ff2
7
- data.tar.gz: de7644e77bac10982314a1f73ea200294755901e66aff6010c027c6808f3209c35da1d6675a179689662c6c57370ddf8c2f61bf5df358b59fe747936d682f889
6
+ metadata.gz: 11813ec485609e4275258e12aee416663bb70e99c453dc9e7ec2363a864370c07506c74c38b20ac43426a12e7872456eb37e9e368fc10e3f2d3a5b1083d12281
7
+ data.tar.gz: da326b8fa64b0850fd2d4e50ab1e0e13d4a881039b4945503a56debcd800a8c5850b5b09f6f63d2631746ae177dcce16ce235ae9deb803b095e8b7d7e588c0a0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.3.0
@@ -57,7 +57,6 @@ module Misc
57
57
  def self.file_md5(file)
58
58
  file = file.find if Path === file
59
59
  file = File.expand_path(file)
60
- #md5file = file + '.md5'
61
60
  Persist.persist("MD5:#{file}", :string) do
62
61
  Digest::MD5.file(file).hexdigest
63
62
  end
@@ -3,6 +3,10 @@ module NamedArray
3
3
  extend MetaExtension
4
4
  extension_attr :fields, :key
5
5
 
6
+ def all_fields
7
+ [key, fields].compact.flatten
8
+ end
9
+
6
10
  def self.field_match(field, name)
7
11
  if (String === field) && (String === name)
8
12
  field == name ||
@@ -70,6 +74,13 @@ module NamedArray
70
74
  super(pos)
71
75
  end
72
76
 
77
+ def []=(key, value)
78
+ pos = NamedArray.identify_name(@fields, key)
79
+ return nil if pos.nil?
80
+ super(pos, value)
81
+ end
82
+
83
+
73
84
  def concat(other)
74
85
  super(other)
75
86
  self.fields.concat(other.fields) if NamedArray === other
@@ -123,6 +134,7 @@ module NamedArray
123
134
 
124
135
  def self.add_zipped(source, new)
125
136
  source.zip(new).each do |s,n|
137
+ next if n.nil?
126
138
  s.concat(n)
127
139
  end
128
140
  source
@@ -7,7 +7,7 @@ module Path
7
7
  caller_dup = caller.dup
8
8
  while file = caller_dup.shift
9
9
  break unless file =~ /(?:scout|rbbt)\/(?:resource\.rb|workflow\.rb)/ or
10
- file =~ /(?:scout|rbbt)\/(?:.*\/)?path\.rb/ or
10
+ file =~ /(?:scout|rbbt)\/(?:.*\/)?(path|open)\.rb/ or
11
11
  file =~ /(?:scout|rbbt)\/(?:.*\/)?path\/(?:find|refactor|util)\.rb/ or
12
12
  file =~ /(?:scout|rbbt)\/persist.rb/ or
13
13
  file =~ /scout\/resource\/produce.rb/ or
@@ -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
@@ -49,8 +49,10 @@ module Persist
49
49
  type = SERIALIZER if type == :serializer
50
50
 
51
51
  case type
52
- when nil, :string, :text, :file, :stream, :select, :folder
52
+ when nil, :text, :stream
53
53
  serialized
54
+ when :string, :file, :select, :folder
55
+ serialized.strip
54
56
  when :path
55
57
  Path.setup(serialized.strip)
56
58
  when :integer
@@ -142,7 +144,11 @@ module Persist
142
144
  when :file
143
145
  value = Open.read(file)
144
146
  value.sub!(/^\./, File.dirname(file)) if value.start_with?("./")
145
- value
147
+ if Misc.is_filename?(value)
148
+ value
149
+ else
150
+ file
151
+ end
146
152
  when :file_array
147
153
  Open.read(file).split("\n").collect do |f|
148
154
  f.sub!(/^\./, File.dirname(file)) if f.start_with?("./")
@@ -151,7 +157,8 @@ module Persist
151
157
  when Hash
152
158
  type[file]
153
159
  else
154
- deserialize(Open.read(file), type)
160
+ serialized = Open.read(file)
161
+ deserialize(serialized, type)
155
162
  end
156
163
  end
157
164
  end
data/lib/scout/persist.rb CHANGED
@@ -55,7 +55,13 @@ module Persist
55
55
  res = yield
56
56
 
57
57
  if res.nil?
58
- return Persist.load(file, type)
58
+ if type.nil?
59
+ Log.debug "Empty result and no persist type; not loading result file"
60
+ return nil
61
+ else
62
+ Log.debug "Empty result; loading #{type} result from file"
63
+ return Persist.load(file, type)
64
+ end
59
65
  end
60
66
 
61
67
  Open.rm(file)
@@ -1,5 +1,6 @@
1
1
  module Path
2
2
  def produce(force = false)
3
+ raise @produced if Exception === @produced
3
4
  return self if ! force && (Open.exist?(self) || @produced)
4
5
  begin
5
6
  if Resource === self.pkgdir
@@ -8,14 +9,14 @@ module Path
8
9
  false
9
10
  end
10
11
  rescue ResourceNotFound
11
- false
12
+ @produced = false
12
13
  rescue
13
14
  message = $!.message
14
15
  message = "No exception message" if message.nil? || message.empty?
15
16
  Log.warn "Error producing #{self}: #{message}"
16
17
  raise $!
17
18
  ensure
18
- @produced = true
19
+ @produced = true if @produced.nil?
19
20
  end
20
21
  end
21
22
 
@@ -1,3 +1,5 @@
1
1
  module Scout
2
2
  extend Resource
3
3
  end
4
+
5
+ Path.load_path_maps(Scout.etc["path_maps"])
@@ -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.1 ruby lib
5
+ # stub: scout-essentials 1.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-essentials".freeze
9
- s.version = "1.1.1"
9
+ s.version = "1.3.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-08-01"
14
+ s.date = "2023-11-07"
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 = [
@@ -128,7 +128,7 @@ Gem::Specification.new do |s|
128
128
  ]
129
129
  s.homepage = "http://github.com/mikisvaz/scout-essentials".freeze
130
130
  s.licenses = ["MIT".freeze]
131
- s.rubygems_version = "3.4.13".freeze
131
+ s.rubygems_version = "3.5.0.dev".freeze
132
132
  s.summary = "Scout essential tools".freeze
133
133
 
134
134
  s.specification_version = 4
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.1
4
+ version: 1.3.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-08-01 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
243
  requirements: []
244
- rubygems_version: 3.4.13
244
+ rubygems_version: 3.5.0.dev
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: Scout essential tools