plunk 0.2.5 → 0.2.6
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/.ruby-version +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/plunk.rb +2 -1
- data/lib/plunk/result_set.rb +2 -2
- data/plunk.gemspec +1 -1
- data/spec/basic_spec.rb +1 -1
- data/spec/chained_search_spec.rb +1 -1
- data/spec/last_spec.rb +6 -6
- data/spec/nested_search_spec.rb +2 -2
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1bc1207f69f06280c177f65cdce11a259502ac58
         | 
| 4 | 
            +
              data.tar.gz: 909ee371c459abed454a019ac37f46fd48c3bfd5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b45c80c41996d29e5391ab23368e27e50de2c00780d1d652d95adbf60c20ef471830821f3bfd4e8e0a1f8d12ff5041edb7b8d90782f80380e4a7633aa0fede4a
         | 
| 7 | 
            +
              data.tar.gz: 8a6d79f487a627265335408439504726f5293e7e1ec8f81e275da83110e8cf55ad0b80f35e0af25baba46c3cf6c63b2c09fcf8864a538e7e91f9a2b83eac5757
         | 
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            2.0.0
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -3,6 +3,12 @@ Plunk | |
| 3 3 |  | 
| 4 4 | 
             
            Human-friendly query language for Elasticsearch
         | 
| 5 5 |  | 
| 6 | 
            +
            ## About
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Plunk is a ruby gem to take a human-friendly search command and translate it
         | 
| 9 | 
            +
            to something Elasticsearch understands. Currently it only supports a few
         | 
| 10 | 
            +
            commands, but the framework is in place
         | 
| 11 | 
            +
             | 
| 6 12 | 
             
            ## Installation
         | 
| 7 13 | 
             
            ```
         | 
| 8 14 | 
             
            gem install plunk
         | 
| @@ -31,7 +37,9 @@ Plunk.search 'foo.field = (bar OR baz)' | |
| 31 37 | 
             
            ```
         | 
| 32 38 |  | 
| 33 39 |  | 
| 34 | 
            -
            ## Translation | 
| 40 | 
            +
            ## Translation
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            Plunk takes your command and translates
         | 
| 35 43 |  | 
| 36 44 | 
             
            ```last 24h _type=syslog```
         | 
| 37 45 |  | 
    
        data/lib/plunk.rb
    CHANGED
    
    | @@ -8,11 +8,12 @@ require 'plunk/result_set' | |
| 8 8 | 
             
            module Plunk
         | 
| 9 9 | 
             
              class << self
         | 
| 10 10 | 
             
                attr_accessor :elasticsearch_options, :elasticsearch_client,
         | 
| 11 | 
            -
                  :parser, :transformer, :max_number_of_hits
         | 
| 11 | 
            +
                  :parser, :transformer, :max_number_of_hits, :timestamp_field
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              def self.configure(&block)
         | 
| 15 15 | 
             
                class_eval(&block)
         | 
| 16 | 
            +
                self.timestamp_field ||= :timestamp
         | 
| 16 17 | 
             
                initialize_parser
         | 
| 17 18 | 
             
                initialize_transformer
         | 
| 18 19 | 
             
                initialize_elasticsearch
         | 
    
        data/lib/plunk/result_set.rb
    CHANGED
    
    | @@ -13,7 +13,7 @@ module Plunk | |
| 13 13 | 
             
                    @query[:query][:filtered][:filter] = {
         | 
| 14 14 | 
             
                      and: [
         | 
| 15 15 | 
             
                        range: {
         | 
| 16 | 
            -
                           | 
| 16 | 
            +
                          Plunk.timestamp_field => {
         | 
| 17 17 | 
             
                            gte: opts[:start_time],
         | 
| 18 18 | 
             
                            lte: opts[:end_time] }}]}
         | 
| 19 19 | 
             
                  else
         | 
| @@ -24,7 +24,7 @@ module Plunk | |
| 24 24 | 
             
                    elsif opts[:start_time] and opts[:end_time]
         | 
| 25 25 | 
             
                      @query[:query][:filtered][:query] = {
         | 
| 26 26 | 
             
                        range: {
         | 
| 27 | 
            -
                           | 
| 27 | 
            +
                          Plunk.timestamp_field => {
         | 
| 28 28 | 
             
                            gte: opts[:start_time],
         | 
| 29 29 | 
             
                            lte: opts[:end_time] }}}
         | 
| 30 30 | 
             
                    end
         | 
    
        data/plunk.gemspec
    CHANGED
    
    
    
        data/spec/basic_spec.rb
    CHANGED
    
    
    
        data/spec/chained_search_spec.rb
    CHANGED
    
    
    
        data/spec/last_spec.rb
    CHANGED
    
    | @@ -5,7 +5,7 @@ describe 'the last command' do | |
| 5 5 | 
             
                result = @transformer.apply @parser.parse('last 24h')
         | 
| 6 6 | 
             
                expect(result.query.to_s).to eq({query:{filtered:{query:{
         | 
| 7 7 | 
             
                  range: {
         | 
| 8 | 
            -
                     | 
| 8 | 
            +
                    Plunk.timestamp_field => {
         | 
| 9 9 | 
             
                      gte: 24.hours.ago.utc.to_datetime.iso8601(3),
         | 
| 10 10 | 
             
                      lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 11 11 | 
             
                }}}}}}.to_s)
         | 
| @@ -15,7 +15,7 @@ describe 'the last command' do | |
| 15 15 | 
             
                result = @transformer.apply @parser.parse('last 24d')
         | 
| 16 16 | 
             
                expect(result.query.to_s).to eq({query:{filtered:{query:{
         | 
| 17 17 | 
             
                  range: {
         | 
| 18 | 
            -
                     | 
| 18 | 
            +
                    Plunk.timestamp_field => {
         | 
| 19 19 | 
             
                      gte: 24.days.ago.utc.to_datetime.iso8601(3),
         | 
| 20 20 | 
             
                      lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 21 21 | 
             
                }}}}}}.to_s)
         | 
| @@ -25,7 +25,7 @@ describe 'the last command' do | |
| 25 25 | 
             
                result = @transformer.apply @parser.parse('last 24w')
         | 
| 26 26 | 
             
                expect(result.query.to_s).to eq({query:{filtered:{query:{
         | 
| 27 27 | 
             
                  range: {
         | 
| 28 | 
            -
                     | 
| 28 | 
            +
                    Plunk.timestamp_field => {
         | 
| 29 29 | 
             
                      gte: 24.weeks.ago.utc.to_datetime.iso8601(3),
         | 
| 30 30 | 
             
                      lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 31 31 | 
             
                }}}}}}.to_s)
         | 
| @@ -35,7 +35,7 @@ describe 'the last command' do | |
| 35 35 | 
             
                result = @transformer.apply @parser.parse('last 24s')
         | 
| 36 36 | 
             
                expect(result.query.to_s).to eq({query:{filtered:{query:{
         | 
| 37 37 | 
             
                  range: {
         | 
| 38 | 
            -
                     | 
| 38 | 
            +
                    Plunk.timestamp_field => {
         | 
| 39 39 | 
             
                      gte: 24.seconds.ago.utc.to_datetime.iso8601(3),
         | 
| 40 40 | 
             
                      lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 41 41 | 
             
                }}}}}}.to_s)
         | 
| @@ -45,7 +45,7 @@ describe 'the last command' do | |
| 45 45 | 
             
                result = @transformer.apply @parser.parse('last 24m')
         | 
| 46 46 | 
             
                expect(result.query.to_s).to eq({query:{filtered:{query:{
         | 
| 47 47 | 
             
                  range: {
         | 
| 48 | 
            -
                     | 
| 48 | 
            +
                    Plunk.timestamp_field => {
         | 
| 49 49 | 
             
                      gte: 24.minutes.ago.utc.to_datetime.iso8601(3),
         | 
| 50 50 | 
             
                      lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 51 51 | 
             
                }}}}}}.to_s)
         | 
| @@ -61,7 +61,7 @@ describe 'the last command' do | |
| 61 61 | 
             
                  filter: {
         | 
| 62 62 | 
             
                    and: [
         | 
| 63 63 | 
             
                      range: {
         | 
| 64 | 
            -
                         | 
| 64 | 
            +
                        Plunk.timestamp_field => {
         | 
| 65 65 | 
             
                          gte: 1.hour.ago.utc.to_datetime.iso8601(3),
         | 
| 66 66 | 
             
                          lte: Time.now.utc.to_datetime.iso8601(3)
         | 
| 67 67 | 
             
                }}]}}}}.to_s)
         | 
    
        data/spec/nested_search_spec.rb
    CHANGED
    
    | @@ -6,13 +6,13 @@ describe 'nested searches' do | |
| 6 6 | 
             
                  foo: 'bar',
         | 
| 7 7 | 
             
                  baz: 5,
         | 
| 8 8 | 
             
                  arr: [ 0, 1, 2, 3 ],
         | 
| 9 | 
            -
                   | 
| 9 | 
            +
                  :timestamp => Time.now.utc.iso8601(3)
         | 
| 10 10 | 
             
                }.to_json
         | 
| 11 11 | 
             
                Plunk::ResultSet.any_instance.stub(:eval).and_return(fake_results)
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              it 'should transform' do
         | 
| 15 | 
            -
                results = @transformer.apply @parser.parse('foo=`bar=baz|baz`')
         | 
| 15 | 
            +
                results = @transformer.apply @parser.parse('foo=`bar=baz|baz,fass,fdsd`')
         | 
| 16 16 | 
             
                expect(results.query).to eq({query:{filtered:{query:{query_string:{
         | 
| 17 17 | 
             
                  query: 'foo:(5)'
         | 
| 18 18 | 
             
                }}}}})
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: plunk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ram Mehta
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2014-01- | 
| 12 | 
            +
            date: 2014-01-28 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: json
         | 
| @@ -90,6 +90,7 @@ extensions: [] | |
| 90 90 | 
             
            extra_rdoc_files: []
         | 
| 91 91 | 
             
            files:
         | 
| 92 92 | 
             
            - .gitignore
         | 
| 93 | 
            +
            - .ruby-version
         | 
| 93 94 | 
             
            - AUTHORS
         | 
| 94 95 | 
             
            - Gemfile
         | 
| 95 96 | 
             
            - Gemfile.lock
         |