wash 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 564995e2e64780be1da143efd49c1814123eae654acd381e245b6e59738104d4
4
- data.tar.gz: 870a5691d24dfcf51dadd3b5b67e2fa963c58a45c8e362bd3a9d01ba57358467
3
+ metadata.gz: 29c5e73c61e19273eeeb661fe0632dd71d98c6b5155b3928a71165b4dbcb255d
4
+ data.tar.gz: 96435335cf622b25ef9fd412ba4a66db4f4ad2d20c12eea766ffad0afdab1d9b
5
5
  SHA512:
6
- metadata.gz: 02245abc3f32840842da57d9238768a477b981af2ba1a485a9ca23d6baa1b5d22de1d856bb9b3d5daeba79e2ff6aad979f9d9242c05781858c84e8894d1691c5
7
- data.tar.gz: 4dd768b920b3121d5652770111448bf1bf701366aa6745a3b9bcc42ea2248099107be84f2c4b0007840edaccc0049809dc5db12dea8e40a025fe2e13d7ef260d
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/external_plugins/ for details on what this should look like"
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 @meta fields
16
- # attributes :mtime, :meta
15
+ # # Instances of Foo will be able to set the @mtime and @size fields
16
+ # attributes :mtime, :size
17
17
  #
18
- # def initialize(mtime, meta)
18
+ # def initialize(mtime, size)
19
19
  # @mtime = mtime
20
- # @meta = meta
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
- # meta_attribute_schema sets the meta attribute's schema to schema. It is a helper
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 meta attribute's JSON schema
127
- def meta_attribute_schema(schema)
128
- @meta_attribute_schema = schema
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
- meta_attribute_schema: @meta_attribute_schema,
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
- STDOUT.print(entry.read)
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.2.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: 2019-11-15 00:00:00.000000000 Z
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.10
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