wavefront-sdk 1.5.0 → 1.6.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 +4 -4
- data/README.md +14 -6
- data/lib/wavefront-sdk/mixins.rb +1 -26
- data/lib/wavefront-sdk/stdlib.rb +5 -0
- data/lib/wavefront-sdk/stdlib/array.rb +14 -0
- data/lib/wavefront-sdk/stdlib/hash.rb +13 -0
- data/lib/wavefront-sdk/stdlib/string.rb +14 -0
- data/lib/wavefront-sdk/validators.rb +2 -1
- data/lib/wavefront-sdk/version.rb +1 -1
- data/spec/wavefront-sdk/stdlib/array_spec.rb +16 -0
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +20 -0
- data/spec/wavefront-sdk/stdlib/string_spec.rb +13 -0
- data/spec/wavefront-sdk/validators_spec.rb +1 -0
- data/spec/wavefront-sdk/write_spec.rb +0 -5
- metadata +12 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e68e0e9c6233a7fb449408c84111beaf522c023370188d155c234aa3387c411c
         | 
| 4 | 
            +
              data.tar.gz: 0a3575ed176110827a011b6793b1d6f3cf8eb64e96dba1ce4b2f129ef1234219
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 47af2cca2a5ca29d545aefb936e3850234e117d53d6ee46580b931e505fda6fdb446004680102631b1b19d463889cf601d6578de27b0e7358094b498a24174ee
         | 
| 7 | 
            +
              data.tar.gz: 736e992312831e5c1b2f37558c70cfec883950eab7f82777baa1c9a2ba3848b0adc0abc20972d27f70e34fbe77ce027b850b65bc6781c55e78cc50a6edbfa294
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,9 +2,14 @@ | |
| 2 2 | 
             
            [](https://travis-ci.org/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://badge.fury.io/rb/wavefront-sdk) 
         | 
| 3 3 |  | 
| 4 4 | 
             
            This is a Ruby SDK for v2 of
         | 
| 5 | 
            -
            [Wavefront](https://www.wavefront.com/)'s public API. It  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 5 | 
            +
            [Wavefront](https://www.wavefront.com/)'s public API. It aims to be
         | 
| 6 | 
            +
            more lightweight, consistent, simple, and convenient than an
         | 
| 7 | 
            +
            auto-generated SDK.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            As well as complete API coverage, `wavefront-sdk` includes methods
         | 
| 10 | 
            +
            which facilitate various common tasks, and provides non-API
         | 
| 11 | 
            +
            features such as credential management, and writing points through a
         | 
| 12 | 
            +
            proxy.
         | 
| 8 13 |  | 
| 9 14 | 
             
            ## Installation
         | 
| 10 15 |  | 
| @@ -18,6 +23,10 @@ or to build locally, | |
| 18 23 | 
             
            $ gem build wavefront-sdk.gemspec
         | 
| 19 24 | 
             
            ```
         | 
| 20 25 |  | 
| 26 | 
            +
            `wavefront-sdk` requires Ruby >= 2.2. All its dependencies are pure
         | 
| 27 | 
            +
            Ruby, right the way down, so a compiler should never be required to
         | 
| 28 | 
            +
            install it.
         | 
| 29 | 
            +
             | 
| 21 30 | 
             
            ## Documentation
         | 
| 22 31 |  | 
| 23 32 | 
             
            The code is documented with [YARD](http://yardoc.org/) and
         | 
| @@ -121,7 +130,7 @@ path with a delta symbol, or by using the `write_delta()` method | |
| 121 130 |  | 
| 122 131 | 
             
            The SDK also provides a helper class for extracting credentials from a
         | 
| 123 132 | 
             
            configuration file. If you don't supply a file, defaults will be
         | 
| 124 | 
            -
            used.
         | 
| 133 | 
            +
            used. You can even override things with environment variables.
         | 
| 125 134 |  | 
| 126 135 | 
             
            ```ruby
         | 
| 127 136 | 
             
            require 'wavefront-sdk/credentials'
         | 
| @@ -142,5 +151,4 @@ wf = Wavefront::Write.new(c.proxy) | |
| 142 151 | 
             
            ## Contributing
         | 
| 143 152 |  | 
| 144 153 | 
             
            Fork it, fix it, send me a PR. Please supply tests, and try to keep
         | 
| 145 | 
            -
            [Rubocop](https://github.com/bbatsov/rubocop)
         | 
| 146 | 
            -
            happy.
         | 
| 154 | 
            +
            [Rubocop](https://github.com/bbatsov/rubocop) happy.
         | 
    
        data/lib/wavefront-sdk/mixins.rb
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require 'date'
         | 
| 2 2 | 
             
            require_relative 'exception'
         | 
| 3 3 | 
             
            require_relative 'parse_time'
         | 
| 4 | 
            +
            require_relative 'stdlib'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module Wavefront
         | 
| 6 7 | 
             
              #
         | 
| @@ -75,29 +76,3 @@ module Wavefront | |
| 75 76 | 
             
                end
         | 
| 76 77 | 
             
              end
         | 
| 77 78 | 
             
            end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
            # Extensions to stdlib Hash
         | 
| 80 | 
            -
            #
         | 
| 81 | 
            -
            class Hash
         | 
| 82 | 
            -
              # Convert a tag hash into a string. The quoting is recommended in
         | 
| 83 | 
            -
              # the WF wire-format guide. No validation is performed here.
         | 
| 84 | 
            -
              #
         | 
| 85 | 
            -
              def to_wf_tag
         | 
| 86 | 
            -
                map { |k, v| "#{k}=\"#{v}\"" }.join(' ')
         | 
| 87 | 
            -
              end
         | 
| 88 | 
            -
            end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
            # Extensions to stdlib Array
         | 
| 91 | 
            -
            #
         | 
| 92 | 
            -
            class Array
         | 
| 93 | 
            -
              # Join strings together to make a URI path in a way that is more
         | 
| 94 | 
            -
              # flexible than URI::Join.  Removes multiple and trailing
         | 
| 95 | 
            -
              # separators. Does not have to produce fully qualified paths. Has
         | 
| 96 | 
            -
              # no concept of protocols, hostnames, or query strings.
         | 
| 97 | 
            -
              #
         | 
| 98 | 
            -
              # @return [String] a URI path
         | 
| 99 | 
            -
              #
         | 
| 100 | 
            -
              def uri_concat
         | 
| 101 | 
            -
                join('/').squeeze('/').sub(%r{\/$}, '').sub(%r{\/\?}, '?')
         | 
| 102 | 
            -
              end
         | 
| 103 | 
            -
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # Extensions to stdlib Array
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            class Array
         | 
| 4 | 
            +
              # Join strings together to make a URI path in a way that is more
         | 
| 5 | 
            +
              # flexible than URI::Join.  Removes multiple and trailing
         | 
| 6 | 
            +
              # separators. Does not have to produce fully qualified paths. Has
         | 
| 7 | 
            +
              # no concept of protocols, hostnames, or query strings.
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              # @return [String] a URI path
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              def uri_concat
         | 
| 12 | 
            +
                join('/').squeeze('/').sub(%r{\/$}, '').sub(%r{\/\?}, '?')
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require_relative 'string'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Extensions to stdlib Hash
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            class Hash
         | 
| 6 | 
            +
              # Convert a tag hash into a string. The quoting is recommended in
         | 
| 7 | 
            +
              # the WF wire-format guide. No validation is performed here.
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              # rubocop:disable Style/FormatStringToken
         | 
| 10 | 
            +
              def to_wf_tag
         | 
| 11 | 
            +
                map { |k, v| format('%s="%s"', k, v.tagescape) }.join(' ')
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # Extensions to stdlib String
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            class String
         | 
| 4 | 
            +
              # Join strings together to make a URI path in a way that is more
         | 
| 5 | 
            +
              # flexible than URI::Join.  Removes multiple and trailing
         | 
| 6 | 
            +
              # separators. Does not have to produce fully qualified paths. Has
         | 
| 7 | 
            +
              # no concept of protocols, hostnames, or query strings.
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              # @return [String] a URI path
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              def tagescape
         | 
| 12 | 
            +
                gsub(/"/, '\"')
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| @@ -175,7 +175,8 @@ module Wavefront | |
| 175 175 | 
             
                # @return nil
         | 
| 176 176 | 
             
                #
         | 
| 177 177 | 
             
                def wf_point_tag?(k, v)
         | 
| 178 | 
            -
                  return if k && v && (k.size + v.size < 254) && k =~ /^[\w\-\.:]+$/
         | 
| 178 | 
            +
                  return if k && v && (k.size + v.size < 254) && k =~ /^[\w\-\.:]+$/ &&
         | 
| 179 | 
            +
                            v !~ /\\$/
         | 
| 179 180 | 
             
                  raise Wavefront::Exception::InvalidTag
         | 
| 180 181 | 
             
                end
         | 
| 181 182 |  | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            WF_SDK_VERSION = '1. | 
| 1 | 
            +
            WF_SDK_VERSION = '1.6.0'.freeze
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative '../../spec_helper'
         | 
| 4 | 
            +
            require_relative '../../../lib/wavefront-sdk/stdlib/array'
         | 
| 5 | 
            +
            require 'spy/integration'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            class ArrayTest < MiniTest::Test
         | 
| 8 | 
            +
              def test_uri_concat
         | 
| 9 | 
            +
                assert_equal %w[a b].uri_concat, 'a/b'
         | 
| 10 | 
            +
                assert_equal ['', 'a', 'b'].uri_concat, '/a/b'
         | 
| 11 | 
            +
                assert_equal %w[a /b].uri_concat, 'a/b'
         | 
| 12 | 
            +
                assert_equal ['', 'a', 'b/'].uri_concat, '/a/b'
         | 
| 13 | 
            +
                assert_equal %w[/a /b/ /c].uri_concat, '/a/b/c'
         | 
| 14 | 
            +
                assert_equal ['/a', '/b c'].uri_concat, '/a/b c'
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative '../../spec_helper'
         | 
| 4 | 
            +
            require_relative '../../../lib/wavefront-sdk/stdlib/hash'
         | 
| 5 | 
            +
            require 'spy/integration'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Test extensions to stdlib hash class
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            class HashTest < MiniTest::Test
         | 
| 10 | 
            +
              def test_to_wf_tag
         | 
| 11 | 
            +
                assert_equal({}.to_wf_tag, '')
         | 
| 12 | 
            +
                assert_equal({ gt1: 'gv1', gt2: 'gv2' }.to_wf_tag,
         | 
| 13 | 
            +
                             'gt1="gv1" gt2="gv2"')
         | 
| 14 | 
            +
                assert_equal({ tag: 'value' }.to_wf_tag, 'tag="value"')
         | 
| 15 | 
            +
                assert_equal({ tag: 'two words' }.to_wf_tag, 'tag="two words"')
         | 
| 16 | 
            +
                assert_equal('tag="say \"hi\""', { tag: 'say "hi"' }.to_wf_tag)
         | 
| 17 | 
            +
                assert_equal('tag1="say \"hi\"" tag2="some stuff!"',
         | 
| 18 | 
            +
                             { tag1: 'say "hi"', tag2: 'some stuff!' }.to_wf_tag)
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative '../../spec_helper'
         | 
| 4 | 
            +
            require_relative '../../../lib/wavefront-sdk/stdlib/string'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class StringTest < MiniTest::Test
         | 
| 7 | 
            +
              def test_tagescape
         | 
| 8 | 
            +
                assert_equal('value', 'value'.tagescape)
         | 
| 9 | 
            +
                assert_equal('two words', 'two words'.tagescape)
         | 
| 10 | 
            +
                assert_equal('say \"hello\"', 'say "hello"'.tagescape)
         | 
| 11 | 
            +
                assert_equal('\"\"\"\"', '""""'.tagescape)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -91,6 +91,7 @@ class WavefrontValidatorsTest < MiniTest::Test | |
| 91 91 | 
             
                        { 'TAG-1': 'val 1', tag2: 'val 2' },
         | 
| 92 92 | 
             
                        { tag1: '(>_<)', tag2: '^_^' }]
         | 
| 93 93 | 
             
                bad  = ['key=value',
         | 
| 94 | 
            +
                        { tag: 'badval\\' },
         | 
| 94 95 | 
             
                        { 'tag 1': 'val1', 'tag 2': 'val2' },
         | 
| 95 96 | 
             
                        { 'TAG*1': 'val 1', tag_2: 'val 2' },
         | 
| 96 97 | 
             
                        { '(>_<)': 'val1', '^_^': 'val2' },
         | 
| @@ -151,11 +151,6 @@ class WavefrontWriteTest < MiniTest::Test | |
| 151 151 | 
             
                end
         | 
| 152 152 | 
             
              end
         | 
| 153 153 |  | 
| 154 | 
            -
              def test_to_wf_tag
         | 
| 155 | 
            -
                assert_equal({}.to_wf_tag, '')
         | 
| 156 | 
            -
                assert_equal(TAGS.to_wf_tag, 'gt1="gv1" gt2="gv2"')
         | 
| 157 | 
            -
              end
         | 
| 158 | 
            -
             | 
| 159 154 | 
             
              def test_send_point
         | 
| 160 155 | 
             
                mocket = Mocket.new
         | 
| 161 156 | 
             
                Spy.on(TCPSocket, :new).and_return(mocket)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: wavefront-sdk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.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- | 
| 11 | 
            +
            date: 2018-08-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: addressable
         | 
| @@ -218,6 +218,10 @@ files: | |
| 218 218 | 
             
            - lib/wavefront-sdk/savedsearch.rb
         | 
| 219 219 | 
             
            - lib/wavefront-sdk/search.rb
         | 
| 220 220 | 
             
            - lib/wavefront-sdk/source.rb
         | 
| 221 | 
            +
            - lib/wavefront-sdk/stdlib.rb
         | 
| 222 | 
            +
            - lib/wavefront-sdk/stdlib/array.rb
         | 
| 223 | 
            +
            - lib/wavefront-sdk/stdlib/hash.rb
         | 
| 224 | 
            +
            - lib/wavefront-sdk/stdlib/string.rb
         | 
| 221 225 | 
             
            - lib/wavefront-sdk/user.rb
         | 
| 222 226 | 
             
            - lib/wavefront-sdk/validators.rb
         | 
| 223 227 | 
             
            - lib/wavefront-sdk/version.rb
         | 
| @@ -250,6 +254,9 @@ files: | |
| 250 254 | 
             
            - spec/wavefront-sdk/savedsearch_spec.rb
         | 
| 251 255 | 
             
            - spec/wavefront-sdk/search_spec.rb
         | 
| 252 256 | 
             
            - spec/wavefront-sdk/source_spec.rb
         | 
| 257 | 
            +
            - spec/wavefront-sdk/stdlib/array_spec.rb
         | 
| 258 | 
            +
            - spec/wavefront-sdk/stdlib/hash_spec.rb
         | 
| 259 | 
            +
            - spec/wavefront-sdk/stdlib/string_spec.rb
         | 
| 253 260 | 
             
            - spec/wavefront-sdk/user_spec.rb
         | 
| 254 261 | 
             
            - spec/wavefront-sdk/validators_spec.rb
         | 
| 255 262 | 
             
            - spec/wavefront-sdk/webhook_spec.rb
         | 
| @@ -306,6 +313,9 @@ test_files: | |
| 306 313 | 
             
            - spec/wavefront-sdk/savedsearch_spec.rb
         | 
| 307 314 | 
             
            - spec/wavefront-sdk/search_spec.rb
         | 
| 308 315 | 
             
            - spec/wavefront-sdk/source_spec.rb
         | 
| 316 | 
            +
            - spec/wavefront-sdk/stdlib/array_spec.rb
         | 
| 317 | 
            +
            - spec/wavefront-sdk/stdlib/hash_spec.rb
         | 
| 318 | 
            +
            - spec/wavefront-sdk/stdlib/string_spec.rb
         | 
| 309 319 | 
             
            - spec/wavefront-sdk/user_spec.rb
         | 
| 310 320 | 
             
            - spec/wavefront-sdk/validators_spec.rb
         | 
| 311 321 | 
             
            - spec/wavefront-sdk/webhook_spec.rb
         |