arel-extensions 1.4.0 → 1.5.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 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 608dab3c15e77d6dd8ee5c39d54b442886f67cf4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d2fb99dc3fc50b3668cb192561883284891fc2e1
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: db29b2210f174795a094f396f76d031e373c6391e13030e17ef2a24ec6eb840ae58c870acf863251c01053c9784332a72e8b477fbf744042720e7f36b5141575
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6b059b8c0c0fa4a6961c969cb6798ea2de47ed904381d0b73d48a8362dc516b4f2cc2c2be55c7b2c4f1907df227cc37b11ccf1dd9e1e33651ea57a41f30af4cd
         
     | 
    
        data/arel-extensions.gemspec
    CHANGED
    
    
    
        data/lib/arel/extensions.rb
    CHANGED
    
    | 
         @@ -19,6 +19,10 @@ require File.expand_path('../nodes/ts_match', __FILE__) 
     | 
|
| 
       19 
19 
     | 
    
         
             
            require File.expand_path('../ts_predications', __FILE__)
         
     | 
| 
       20 
20 
     | 
    
         
             
            Arel::Attributes::Attribute.include(Arel::TSPredications)
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            require File.expand_path('../gis_predications', __FILE__)
         
     | 
| 
      
 24 
     | 
    
         
            +
            Arel::Attributes::Attribute.include(Arel::GISPredications)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       22 
26 
     | 
    
         
             
            require File.expand_path('../../active_record/query_methods', __FILE__)
         
     | 
| 
       23 
27 
     | 
    
         | 
| 
       24 
28 
     | 
    
         
             
            if defined?(Arel::Visitors::PostgreSQL)
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Arel
         
     | 
| 
      
 2 
     | 
    
         
            +
              module GISPredications
         
     | 
| 
      
 3 
     | 
    
         
            +
                
         
     | 
| 
      
 4 
     | 
    
         
            +
                def within(n=nil, e=nil, s=nil, w=nil)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  if n.class.to_s == 'String' && e.nil?
         
     | 
| 
      
 6 
     | 
    
         
            +
                    within(*n.split(','))
         
     | 
| 
      
 7 
     | 
    
         
            +
                  elsif n.is_a?(Array)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    within(*n)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  elsif n.is_a?(Hash)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    if (n.keys - [:n, :e, :s, :w]).empty?
         
     | 
| 
      
 11 
     | 
    
         
            +
                      within(n[:n], n[:e], n[:s], n[:w])
         
     | 
| 
      
 12 
     | 
    
         
            +
                    elsif (n.keys - [:north, :east, :south, :west]).empty?
         
     | 
| 
      
 13 
     | 
    
         
            +
                      within(n[:north], n[:east], n[:south], n[:west])
         
     | 
| 
      
 14 
     | 
    
         
            +
                    else
         
     | 
| 
      
 15 
     | 
    
         
            +
                      radius = n[:radius] * 1609.34
         
     | 
| 
      
 16 
     | 
    
         
            +
                      point_args = [point[:longitude], point[:latitude], radius].map { |x| Arel::Nodes.build_quoted(x) }
         
     | 
| 
      
 17 
     | 
    
         
            +
                      point = Arel::Nodes::NamedFunction.new('ST_MakePoint', point_args).cast_as('geography')
         
     | 
| 
      
 18 
     | 
    
         
            +
                      Arel::Nodes::NamedFunction.new('ST_DWithin', [self, point, radius])
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  else
         
     | 
| 
      
 21 
     | 
    
         
            +
                    make_envelope_args = [w, s, e, n, 4326].map { |x| Arel::Nodes.build_quoted(x) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                    envelope = Arel::Nodes::NamedFunction.new('ST_MakeEnvelope', make_envelope_args)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    # Arel::Nodes::NamedFunction.new('ST_Contains', [envelope, self])
         
     | 
| 
      
 24 
     | 
    
         
            +
                    Arel::Nodes::NamedFunction.new('ST_Within', [self, envelope])
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -22,6 +22,15 @@ module Arel 
     | 
|
| 
       22 
22 
     | 
    
         
             
                    collector
         
     | 
| 
       23 
23 
     | 
    
         
             
                  end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
                  def visit_Arel_Nodes_Excludes o, collector
         
     | 
| 
      
 26 
     | 
    
         
            +
                    collector << 'NOT ('
         
     | 
| 
      
 27 
     | 
    
         
            +
                    visit o.left, collector
         
     | 
| 
      
 28 
     | 
    
         
            +
                    collector << ' @> '
         
     | 
| 
      
 29 
     | 
    
         
            +
                    collector << quote(o.left.type_cast_for_database(o.right))
         
     | 
| 
      
 30 
     | 
    
         
            +
                    collector << ')'
         
     | 
| 
      
 31 
     | 
    
         
            +
                    collector
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       25 
34 
     | 
    
         
             
                  def visit_Arel_Nodes_Overlaps o, collector
         
     | 
| 
       26 
35 
     | 
    
         
             
                    visit o.left, collector
         
     | 
| 
       27 
36 
     | 
    
         
             
                    collector << ' && '
         
     | 
| 
         @@ -5,17 +5,23 @@ module Arel 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
                  def visit_Arel_Nodes_Contains o, collector
         
     | 
| 
       7 
7 
     | 
    
         
             
                    key = visit(o.left, collector)
         
     | 
| 
       8 
     | 
    
         
            -
                    value = { : 
     | 
| 
      
 8 
     | 
    
         
            +
                    value = { contains:  visit(o.right, collector) }
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                    if key.is_a?(Hash)
         
     | 
| 
       11 
11 
     | 
    
         
             
                      add_to_bottom_of_hash(key, value)
         
     | 
| 
       12 
12 
     | 
    
         
             
                    else
         
     | 
| 
       13 
     | 
    
         
            -
                      key  
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                      { key => value }
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  def visit_Arel_Nodes_Excludes o, collector
         
     | 
| 
      
 18 
     | 
    
         
            +
                    key = visit(o.left, collector)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    value = { excludes: visit(o.right, collector) }
         
     | 
| 
      
 20 
     | 
    
         
            +
                    
         
     | 
| 
      
 21 
     | 
    
         
            +
                    if key.is_a?(Hash)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      add_to_bottom_of_hash(key, value)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    else
         
     | 
| 
      
 24 
     | 
    
         
            +
                      { key => value }
         
     | 
| 
       19 
25 
     | 
    
         
             
                    end
         
     | 
| 
       20 
26 
     | 
    
         
             
                  end
         
     | 
| 
       21 
27 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: arel-extensions
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.5.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jon Bracy
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-04-14 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: arel
         
     | 
| 
         @@ -67,9 +67,11 @@ files: 
     | 
|
| 
       67 
67 
     | 
    
         
             
            - lib/arel/attributes/cast.rb
         
     | 
| 
       68 
68 
     | 
    
         
             
            - lib/arel/attributes/key.rb
         
     | 
| 
       69 
69 
     | 
    
         
             
            - lib/arel/extensions.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - lib/arel/gis_predications.rb
         
     | 
| 
       70 
71 
     | 
    
         
             
            - lib/arel/json_predications.rb
         
     | 
| 
       71 
72 
     | 
    
         
             
            - lib/arel/nodes/contained_by.rb
         
     | 
| 
       72 
73 
     | 
    
         
             
            - lib/arel/nodes/contains.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/arel/nodes/excludes.rb
         
     | 
| 
       73 
75 
     | 
    
         
             
            - lib/arel/nodes/has_any_key.rb
         
     | 
| 
       74 
76 
     | 
    
         
             
            - lib/arel/nodes/has_key.rb
         
     | 
| 
       75 
77 
     | 
    
         
             
            - lib/arel/nodes/has_keys.rb
         
     |