wash 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wash.rb +1 -1
- data/lib/wash/entry.rb +22 -9
- data/lib/wash/method.rb +11 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c5e73c61e19273eeeb661fe0632dd71d98c6b5155b3928a71165b4dbcb255d
|
4
|
+
data.tar.gz: 96435335cf622b25ef9fd412ba4a66db4f4ad2d20c12eea766ffad0afdab1d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69b74fb0465cd0b9706e597e4226eaf5304aa1888b824e516d8606dc62a998f807b72ae3445068d28afb801fc1252af63ee5876978f23d00ea3ababba7320c65
|
7
|
+
data.tar.gz: 1fc0e79f46a566a26ead6b30d82c84d62918b37abe7efd2fb45eb02abe0160df014281b2c2f174932c4b98fcfc9c8102f037d38c2930ce0c25e2b3bbc1b736cb
|
data/lib/wash.rb
CHANGED
@@ -92,7 +92,7 @@ module Wash
|
|
92
92
|
|
93
93
|
def self.next_arg(argv)
|
94
94
|
if argv.size < 1
|
95
|
-
raise "Invalid plugin-script invocation. See https://puppetlabs.github.io/wash/docs/
|
95
|
+
raise "Invalid plugin-script invocation. See https://puppetlabs.github.io/wash/docs/external-plugins for details on what this should look like"
|
96
96
|
end
|
97
97
|
return argv[0], argv[1..-1]
|
98
98
|
end
|
data/lib/wash/entry.rb
CHANGED
@@ -12,12 +12,12 @@ module Wash
|
|
12
12
|
#
|
13
13
|
# @example
|
14
14
|
# class Foo
|
15
|
-
# # Instances of Foo will be able to set the @mtime and @
|
16
|
-
# attributes :mtime, :
|
15
|
+
# # Instances of Foo will be able to set the @mtime and @size fields
|
16
|
+
# attributes :mtime, :size
|
17
17
|
#
|
18
|
-
# def initialize(mtime,
|
18
|
+
# def initialize(mtime, size)
|
19
19
|
# @mtime = mtime
|
20
|
-
# @
|
20
|
+
# @size = size
|
21
21
|
# end
|
22
22
|
# end
|
23
23
|
#
|
@@ -120,12 +120,12 @@ module Wash
|
|
120
120
|
add_signal_schema(name, regex, description)
|
121
121
|
end
|
122
122
|
|
123
|
-
#
|
123
|
+
# partial_metadata_schema sets the partial metadata's schema to schema. It is a helper
|
124
124
|
# for Entry schemas.
|
125
125
|
#
|
126
|
-
# @param schema A hash containing the
|
127
|
-
def
|
128
|
-
@
|
126
|
+
# @param schema A hash containing the partial metadata's JSON schema
|
127
|
+
def partial_metadata_schema(schema)
|
128
|
+
@partial_metadata_schema = schema
|
129
129
|
end
|
130
130
|
|
131
131
|
# metadata_schema sets the metadata schema to schema. It is a helper for Entry schemas.
|
@@ -179,7 +179,7 @@ module Wash
|
|
179
179
|
singleton: @singleton,
|
180
180
|
description: @description,
|
181
181
|
signals: @signals,
|
182
|
-
|
182
|
+
partial_metadata_schema: @partial_metadata_schema,
|
183
183
|
metadata_schema: @metadata_schema,
|
184
184
|
}
|
185
185
|
unless @child_klasses
|
@@ -241,6 +241,9 @@ module Wash
|
|
241
241
|
# included in the entry's state hash.
|
242
242
|
attr_accessor :name
|
243
243
|
|
244
|
+
# Contains the entry's partial metadata.
|
245
|
+
attr_accessor :partial_metadata
|
246
|
+
|
244
247
|
def to_json(*)
|
245
248
|
unless @name && @name.size > 0
|
246
249
|
unless singleton
|
@@ -258,6 +261,13 @@ module Wash
|
|
258
261
|
hash[:methods] = self.class.send(:methods).map do |method|
|
259
262
|
if prefetched_methods.include?(method)
|
260
263
|
[method, self.send(method)]
|
264
|
+
elsif method == :read
|
265
|
+
# Check if this entry is block-readable
|
266
|
+
#
|
267
|
+
# TODO: Generalize this to lib/wash/method.rb if Wash starts
|
268
|
+
# supporting more overloaded methods
|
269
|
+
block_readable = self.method(:read).arity > 0
|
270
|
+
[:read, block_readable]
|
261
271
|
else
|
262
272
|
method
|
263
273
|
end
|
@@ -269,6 +279,9 @@ module Wash
|
|
269
279
|
if attributes.size > 0 && (attributes_hash = to_hash(attributes))
|
270
280
|
hash[:attributes] = attributes_hash
|
271
281
|
end
|
282
|
+
if @partial_metadata
|
283
|
+
hash[:partial_metadata] = @partial_metadata
|
284
|
+
end
|
272
285
|
if cache_ttls.size > 0
|
273
286
|
hash[:cache_ttls] = cache_ttls
|
274
287
|
end
|
data/lib/wash/method.rb
CHANGED
@@ -36,8 +36,17 @@ module Wash
|
|
36
36
|
method(:delete)
|
37
37
|
method(:signal)
|
38
38
|
|
39
|
-
method(:read) do |entry,
|
40
|
-
|
39
|
+
method(:read) do |entry, *args|
|
40
|
+
if args.length > 0
|
41
|
+
# We're invoking read on a block-readable entry so munge
|
42
|
+
# the size and offset
|
43
|
+
args = args.map(&:to_i)
|
44
|
+
end
|
45
|
+
STDOUT.print(entry.read(*args))
|
46
|
+
end
|
47
|
+
|
48
|
+
method(:write) do |entry, _|
|
49
|
+
entry.write(STDIN)
|
41
50
|
end
|
42
51
|
|
43
52
|
method(:exec) do |entry, *args|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for building Wash external plugins
|
14
14
|
email:
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.7.
|
44
|
+
rubygems_version: 2.7.3
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: A library for building Wash external plugins
|