wavefront-cli 2.5.0 → 2.6.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: 367f4cd2831b3bb22eeae430ab3b3bd9f065d847a68b59f7f6ecafa39c46c156
4
- data.tar.gz: 11e4a86ec0ed8134ce921b237a068cc2910e01b600becef4d35f7a49d35e3564
3
+ metadata.gz: b7e6e0c9d8fddd6df88fbd3f2f3f8410a74f508627b818b95e5eccaeafdcaf06
4
+ data.tar.gz: ac3fabdf56be3ce5585802ea5459d66a0a37471171460dd7a30bc22cb07d0992
5
5
  SHA512:
6
- metadata.gz: faa0fecdf792a026db31353defb49e24cd5e72e8ff2d8702aa38846dd31af53abad50f9c79bed30ccb00b323196e9d9ba5da2f53c9318066dfd731898f93cafb
7
- data.tar.gz: c6febba432e3dff6aa0a5125fd1b366dbcb59d9f056ca6f2924366b9dd9f01eb64423d4385488fbdc695649010c75f448f59e173d5333f737c6d26809a14ef3c
6
+ metadata.gz: 5a29eb0de9db686d9a4cd4c32beb3c17379a9385fc5532d398af6553aa33406ad06b4637752f5555cc3482f917022ae3ea08f48bc27ff1f4c361048444be1948
7
+ data.tar.gz: 49d870efddc368949dc08e14da1c740e6200255cb667379918b50ec6ab90dca6b35c2b4bc69226fe2ed55df9a8322c88bedda58081acd31f4d6408306a970d14
data/HISTORY.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ## 2.5.0
3
+ ## 2.6.0 (27/06/2018)
4
+
5
+ * Anything which can be imported can be imported from STDIN. The CLI
6
+ will do its best to work out if the format is YAML or JSON.
7
+
8
+ ## 2.5.0 (25/06/2018)
4
9
 
5
10
  * Support [derived
6
11
  metrics](https://docs.wavefront.com/derived_metrics.html).
@@ -266,7 +266,7 @@ module WavefrontCli
266
266
  # Give it a path to a file (as a string) and it will return the
267
267
  # contents of that file as a Ruby object. Automatically detects
268
268
  # JSON and YAML. Raises an exception if it doesn't look like
269
- # either.
269
+ # either. If path is '-' then it will read STDIN.
270
270
  #
271
271
  # @param path [String] the file to load
272
272
  # @return [Hash] a Ruby object of the loaded file
@@ -274,6 +274,8 @@ module WavefrontCli
274
274
  # @raise pass through any error loading or parsing the file
275
275
  #
276
276
  def load_file(path)
277
+ return load_from_stdin if path == '-'
278
+
277
279
  file = Pathname.new(path)
278
280
  raise 'Import file does not exist.' unless file.exist?
279
281
 
@@ -286,6 +288,26 @@ module WavefrontCli
286
288
  end
287
289
  end
288
290
 
291
+ # Read STDIN and return a Ruby object, assuming that STDIN is
292
+ # valid JSON or YAML. This is a dumb method, it does no
293
+ # buffering, so STDIN must be a single block of data. This
294
+ # appears to be a valid assumption for use-cases of this CLI.
295
+ #
296
+ # @return [Object]
297
+ # @raise 'cannot parse stdin' if it, well you know.
298
+ #
299
+ def load_from_stdin
300
+ raw = STDIN.read
301
+
302
+ if raw.start_with?('---')
303
+ YAML.safe_load(raw)
304
+ else
305
+ JSON.parse(raw)
306
+ end
307
+ rescue
308
+ raise 'Cannot parse stdin.'
309
+ end
310
+
289
311
  # Below here are common methods. Most are used by most classes,
290
312
  # but if they don't match a command described in the docopt
291
313
  # text, the dispatcher will never call them. So, there's no
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.5.0'.freeze
1
+ WF_CLI_VERSION = '2.6.0'.freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt