archon 0.0.3 → 0.0.4
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/lib/archon.rb +1 -0
 - data/lib/archon/insert_into_select.rb +7 -3
 - data/lib/archon/nodes.rb +1 -0
 - data/lib/archon/nodes/values_list.rb +32 -0
 - data/lib/archon/power_overwhelming.rb +8 -0
 - data/lib/archon/version.rb +1 -1
 - data/lib/archon/visitors.rb +8 -0
 - data/lib/archon/visitors/values_list.rb +30 -0
 - metadata +21 -18
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: de9e479ea8d74dee6b772bcb7a3a13a279cab668
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d6cf560e818c6d4bcb14ea0530043244db791db3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 80dedf0d2c4ae62537a3ecc94bcc621e6bcd2a07a67ed7d86a112edbcaaf1c8a4d5b711d79adc75d2bb0252bde874be4836cde408fa2f13ca8782a8e169a39d6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3b8823e62118f6e2338ab19deec2d7690bdd9cf7447241cf25e165c3893404306077b4f923cb10387a499f38bd32867210df1f618d925ce0a14670eb0890bbb5
         
     | 
    
        data/lib/archon.rb
    CHANGED
    
    
| 
         @@ -24,12 +24,16 @@ module Archon 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  self.columns.concat options.fetch(
         
     | 
| 
       25 
25 
     | 
    
         
             
                    :columns,
         
     | 
| 
       26 
26 
     | 
    
         
             
                    ast.select.projections.map do |projection|
         
     | 
| 
       27 
     | 
    
         
            -
                      column_name =  
     | 
| 
      
 27 
     | 
    
         
            +
                      column_name = case projection
         
     | 
| 
      
 28 
     | 
    
         
            +
                                    when Arel::Attributes::Attribute
         
     | 
| 
       28 
29 
     | 
    
         
             
                                      projection.name
         
     | 
| 
       29 
     | 
    
         
            -
                                     
     | 
| 
      
 30 
     | 
    
         
            +
                                    when Arel::Nodes::As
         
     | 
| 
       30 
31 
     | 
    
         
             
                                      projection.right.delete('"').to_sym
         
     | 
| 
       31 
     | 
    
         
            -
                                     
     | 
| 
      
 32 
     | 
    
         
            +
                                    when Arel::Nodes::NamedFunction
         
     | 
| 
       32 
33 
     | 
    
         
             
                                      projection.alias.delete('"').to_sym
         
     | 
| 
      
 34 
     | 
    
         
            +
                                    when String
         
     | 
| 
      
 35 
     | 
    
         
            +
                                      _table, name = projection.split('.') if projection['.']
         
     | 
| 
      
 36 
     | 
    
         
            +
                                      (name || projection).delete('"').to_sym
         
     | 
| 
       33 
37 
     | 
    
         
             
                                    else
         
     | 
| 
       34 
38 
     | 
    
         
             
                                      raise "Don't know how to..."
         
     | 
| 
       35 
39 
     | 
    
         
             
                                    end
         
     | 
    
        data/lib/archon/nodes.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Archon
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Factory method
         
     | 
| 
      
 3 
     | 
    
         
            +
              def self.values_list expressions
         
     | 
| 
      
 4 
     | 
    
         
            +
                return Nodes::ValuesList.new expressions
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              module Nodes
         
     | 
| 
      
 8 
     | 
    
         
            +
                class ValuesList < Arel::Nodes::Binary
         
     | 
| 
      
 9 
     | 
    
         
            +
                  alias :expressions :left
         
     | 
| 
      
 10 
     | 
    
         
            +
                  alias :expressions= :left=
         
     | 
| 
      
 11 
     | 
    
         
            +
                  alias :columns :right
         
     | 
| 
      
 12 
     | 
    
         
            +
                  alias :columns= :right=
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize expressions
         
     | 
| 
      
 15 
     | 
    
         
            +
                    super expressions, []
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              # Only include the visitor module on the SQL vendors that support it:
         
     | 
| 
      
 21 
     | 
    
         
            +
              Arel::Visitors::PostgreSQL.class_eval do
         
     | 
| 
      
 22 
     | 
    
         
            +
                include Archon::Visitors::ValuesList
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              Arel::Visitors::Oracle.class_eval do
         
     | 
| 
      
 26 
     | 
    
         
            +
                include Archon::Visitors::ValuesList
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              Arel::Visitors::Oracle12.class_eval do
         
     | 
| 
      
 30 
     | 
    
         
            +
                include Archon::Visitors::ValuesList
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -27,6 +27,14 @@ module Archon 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    transaction do
         
     | 
| 
       28 
28 
     | 
    
         
             
                      timestamp = ActiveRecord::Base.connection.quoted_date(Time.now)
         
     | 
| 
       29 
29 
     | 
    
         
             
                      timestamp = Arel::Nodes::SqlLiteral.new("'#{timestamp}'")
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                      insert_result = connection.execute Archon.insert_into_select(
         
     | 
| 
      
 32 
     | 
    
         
            +
                        arel_table, selectish.arel
         
     | 
| 
      
 33 
     | 
    
         
            +
                      ).to_sql
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                      Rails.logger.debug "Inserted #{insert_result.cmd_tuples} records " \
         
     | 
| 
      
 36 
     | 
    
         
            +
                                         "to table '#{arel_table.name}'."
         
     | 
| 
      
 37 
     | 
    
         
            +
                      insert_result
         
     | 
| 
       30 
38 
     | 
    
         
             
                    end
         
     | 
| 
       31 
39 
     | 
    
         
             
                  end
         
     | 
| 
       32 
40 
     | 
    
         
             
                end
         
     | 
    
        data/lib/archon/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Archon
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Visitors
         
     | 
| 
      
 3 
     | 
    
         
            +
                module ValuesList
         
     | 
| 
      
 4 
     | 
    
         
            +
                  private
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def visit_Archon_Nodes_ValuesList o, collector
         
     | 
| 
      
 7 
     | 
    
         
            +
                    collector << 'VALUES '
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    len_a = o.expressions.length - 1
         
     | 
| 
      
 10 
     | 
    
         
            +
                    o.expressions.each_with_index do |values, i|
         
     | 
| 
      
 11 
     | 
    
         
            +
                      collector << '('
         
     | 
| 
      
 12 
     | 
    
         
            +
                      len_b = values.length - 1
         
     | 
| 
      
 13 
     | 
    
         
            +
                      values.each_with_index do |value, ii|
         
     | 
| 
      
 14 
     | 
    
         
            +
                        case value
         
     | 
| 
      
 15 
     | 
    
         
            +
                        when Arel::Nodes::SqlLiteral, Arel::Nodes::BindParam
         
     | 
| 
      
 16 
     | 
    
         
            +
                          collector = visit value, collector
         
     | 
| 
      
 17 
     | 
    
         
            +
                        else
         
     | 
| 
      
 18 
     | 
    
         
            +
                          collector << quote(value).to_s
         
     | 
| 
      
 19 
     | 
    
         
            +
                        end
         
     | 
| 
      
 20 
     | 
    
         
            +
                        collector << Arel::Visitors::ToSql::COMMA unless ii == len_b
         
     | 
| 
      
 21 
     | 
    
         
            +
                      end
         
     | 
| 
      
 22 
     | 
    
         
            +
                      collector << ')'
         
     | 
| 
      
 23 
     | 
    
         
            +
                      collector << Arel::Visitors::ToSql::COMMA unless i == len_a
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    collector
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,69 +1,69 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: archon
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Roberto Quintanilla
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-04-15 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
19 
     | 
    
         
             
                    version: '4.2'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - -  
     | 
| 
      
 24 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '4.2'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: bundler
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - -  
     | 
| 
      
 31 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
33 
     | 
    
         
             
                    version: '1.13'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - -  
     | 
| 
      
 38 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '1.13'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
     | 
    
         
            -
                - -  
     | 
| 
      
 45 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
47 
     | 
    
         
             
                    version: '10.0'
         
     | 
| 
       48 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       49 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - -  
     | 
| 
      
 52 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '10.0'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
56 
     | 
    
         
             
              name: rspec
         
     | 
| 
       57 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - -  
     | 
| 
      
 59 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
61 
     | 
    
         
             
                    version: '3.5'
         
     | 
| 
       62 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       63 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
     | 
    
         
            -
                - -  
     | 
| 
      
 66 
     | 
    
         
            +
                - - ~>
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '3.5'
         
     | 
| 
       69 
69 
     | 
    
         
             
            description: A collection of methods and classes that unleash the power of the database
         
     | 
| 
         @@ -74,11 +74,11 @@ executables: [] 
     | 
|
| 
       74 
74 
     | 
    
         
             
            extensions: []
         
     | 
| 
       75 
75 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       76 
76 
     | 
    
         
             
            files:
         
     | 
| 
       77 
     | 
    
         
            -
            -  
     | 
| 
       78 
     | 
    
         
            -
            -  
     | 
| 
       79 
     | 
    
         
            -
            -  
     | 
| 
       80 
     | 
    
         
            -
            -  
     | 
| 
       81 
     | 
    
         
            -
            -  
     | 
| 
      
 77 
     | 
    
         
            +
            - .codeclimate.yml
         
     | 
| 
      
 78 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 79 
     | 
    
         
            +
            - .rspec
         
     | 
| 
      
 80 
     | 
    
         
            +
            - .rubocop.yml
         
     | 
| 
      
 81 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
       82 
82 
     | 
    
         
             
            - CODE_OF_CONDUCT.md
         
     | 
| 
       83 
83 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       84 
84 
     | 
    
         
             
            - LICENSE
         
     | 
| 
         @@ -94,8 +94,11 @@ files: 
     | 
|
| 
       94 
94 
     | 
    
         
             
            - lib/archon/nodes.rb
         
     | 
| 
       95 
95 
     | 
    
         
             
            - lib/archon/nodes/coalesce.rb
         
     | 
| 
       96 
96 
     | 
    
         
             
            - lib/archon/nodes/populated_recordset.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/archon/nodes/values_list.rb
         
     | 
| 
       97 
98 
     | 
    
         
             
            - lib/archon/power_overwhelming.rb
         
     | 
| 
       98 
99 
     | 
    
         
             
            - lib/archon/version.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib/archon/visitors.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            - lib/archon/visitors/values_list.rb
         
     | 
| 
       99 
102 
     | 
    
         
             
            homepage: https://github.com/IcaliaLabs/archon-gem
         
     | 
| 
       100 
103 
     | 
    
         
             
            licenses:
         
     | 
| 
       101 
104 
     | 
    
         
             
            - MIT
         
     | 
| 
         @@ -106,17 +109,17 @@ require_paths: 
     | 
|
| 
       106 
109 
     | 
    
         
             
            - lib
         
     | 
| 
       107 
110 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       108 
111 
     | 
    
         
             
              requirements:
         
     | 
| 
       109 
     | 
    
         
            -
              - -  
     | 
| 
      
 112 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       110 
113 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       111 
114 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       112 
115 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       113 
116 
     | 
    
         
             
              requirements:
         
     | 
| 
       114 
     | 
    
         
            -
              - -  
     | 
| 
      
 117 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       115 
118 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       116 
119 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       117 
120 
     | 
    
         
             
            requirements: []
         
     | 
| 
       118 
121 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       119 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 122 
     | 
    
         
            +
            rubygems_version: 2.0.14.1
         
     | 
| 
       120 
123 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       121 
124 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       122 
125 
     | 
    
         
             
            summary: 'ARchon: Summoning the powers of ActiveRecord and ARel to wreak havoc'
         
     |