diff --git a/README.md b/README.md index 197dcb4..92f5aa9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,8 @@ -# Influxdb::Arel +# InfluxDB::Arel -Influxdb::Arel is a SQL AST manager for Influxdb dialect. It simplifies the generation of complex SQL queries. +InfluxDB::Arel is a SQL AST manager for InfluxDB dialect. It simplifies the generation of complex SQL queries. -[![Build Status](https://travis-ci.org/undr/influxdb-arel.svg?branch=master)](https://travis-ci.org/undr/influxdb-arel) -[![Code Climate](https://codeclimate.com/github/undr/influxdb-arel/badges/gpa.svg)](https://codeclimate.com/github/undr/influxdb-arel) -[![Gem Version](https://badge.fury.io/rb/influxdb-arel.svg)](http://badge.fury.io/rb/influxdb-arel) -[![Test Coverage](https://codeclimate.com/github/undr/influxdb-arel/badges/coverage.svg)](https://codeclimate.com/github/undr/influxdb-arel) +[![Build Status](https://travis-ci.org/undr/influxdb-arel.svg?branch=master)](https://travis-ci.org/undr/influxdb-arel) [![Code Climate](https://codeclimate.com/github/undr/influxdb-arel/badges/gpa.svg)](https://codeclimate.com/github/undr/influxdb-arel) [![Gem Version](https://badge.fury.io/rb/influxdb-arel.svg)](http://badge.fury.io/rb/influxdb-arel) [![Test Coverage](https://codeclimate.com/github/undr/influxdb-arel/badges/coverage.svg)](https://codeclimate.com/github/undr/influxdb-arel) ## Installation @@ -34,25 +31,25 @@ $ gem install influxdb-arel At start you should create a builder: ```ruby -builder = Influxdb::Arel::Builder.new(:events) -builder.to_sql +builder = InfluxDB::Arel::Builder.new(:events) +builder.select.to_sql # => SELECT * FROM events ``` You can set default table name for the builder. Possible to use both strings and symbols: ```ruby -Influxdb::Arel::Builder.new('events') == Influxdb::Arel::Builder.new(:events) +InfluxDB::Arel::Builder.new('events') == InfluxDB::Arel::Builder.new(:events) # => true ``` If you want to use convenient shortcuts, such as `10.h.ago` or `1.w` you should require a file with core extensions ```ruby -require 'influxdb/arel/core_extensions' +require 'influx_db/arel/core_extensions' 1.h -# => # +# => # 1.h.to_sql # => "1h" @@ -66,29 +63,28 @@ require 'influxdb/arel/core_extensions' A builder has methods for SQL construction. -* Specifying which attributes should be used in the query: `select`. +- Specifying which attributes should be used in the query: `select`. -* Specifying which tables and how they should be used in the query: `from`, `merge` and `join`. +- Specifying which tables and how they should be used in the query: `from`, `merge` and `join`. -* Conditions of query: `where`. +- Conditions of query: `where`. -* Grouping methods: `group` and `fill`. +- Grouping methods: `group` and `fill`. -* Ordering methods: `order`, `asc`, `desc` and `invert_order`. +- Ordering methods: `order`, `asc`, `desc` and `invert_order`. -* Specifying limitations of result set: `limit`. +- Specifying limitations of result set: `limit`. -* The part of continuous queries: `into`. +- The part of continuous queries: `into`. -Most of them accept a block for building part of SQL. Inside a block calling of method will be interpreted depending on current context. -For example: +Most of them accept a block for building part of SQL. Inside a block calling of method will be interpreted depending on current context. For example: #### In `SELECT`, `WHERE`and `GROUP` contexts: - All undefined methods will be interpreted as attributes: ```ruby -builder.where{ pp name.is_a?(Influxdb::Arel::Nodes::Attribute) } +builder.where{ pp name.is_a?(InfluxDB::Arel::Nodes::Attribute) } # true # => ... builder.where{ name =~ /undr/ }.to_sql @@ -103,17 +99,16 @@ builder.where{ pp a(:name) == name } # => ... ``` -- Method `time` returns `Influxdb::Arel::Nodes::Time` object. (It will be available only in `GROUP` context) - -- Method `now` returns `Influxdb::Arel::Nodes::Now` object. (It will be available only in `WHERE` context) +- Method `time` returns `InfluxDB::Arel::Nodes::Time` object. (It will be available only in `GROUP` context) +- Method `now` returns `InfluxDB::Arel::Nodes::Now` object. (It will be available only in `WHERE` context) #### In `FROM`, `JOIN` and `MERGE` contexts - All undefined methods will be interpreted as tables: ```ruby -builder.select{ pp events.is_a?(Influxdb::Arel::Nodes::Table) } +builder.select{ pp events.is_a?(InfluxDB::Arel::Nodes::Table) } # true # => ... builder.from{ events }.to_sql @@ -155,7 +150,7 @@ builder.from{ o{ regexp } }.to_sql You can specify attributes or expressions for `SELECT` clause using `select` method. ```ruby -builder = Influxdb::Arel::Builder.new(:cpu_load) +builder = InfluxDB::Arel::Builder.new(:cpu_load) builder.to_sql # => SELECT * FROM cpu_load @@ -216,7 +211,7 @@ builder.from(/.*/).to_sql # => SELECT * FROM /.*/ ``` -**Warning:** *You can call method with more then one regexp but only first will be used as table name* +**Warning:** _You can call method with more then one regexp but only first will be used as table name_ ```ruby builder.from(/.*/, /logs\..*/).to_sql @@ -237,7 +232,7 @@ You can join two tables using `join` method. It will join two first tables from tables list if method is called without argument ```ruby -builder = Influxdb::Arel::Builder.new(:table) +builder = InfluxDB::Arel::Builder.new(:table) builder.from(:table1, :table2).join.to_sql # => SELECT * FROM table1 INNER JOIN table2 builder.from{ [table1.as(:alias1), table2.as(:alias2)] }.join.to_sql @@ -286,7 +281,7 @@ You can merge two tables using `merge` method. It will merge two first tables from tables list if method is called without argument ```ruby -builder = Influxdb::Arel::Builder.new(:table) +builder = InfluxDB::Arel::Builder.new(:table) builder.from(:table1, :table2).merge.to_sql # => SELECT * FROM table1 MERGE table2 builder.from{ [table1.as(:alias1), table2.as(:alias2)] }.merge.to_sql @@ -333,7 +328,7 @@ builder.merge(:table1).merge(:table2).to_sql Grouping of results by specified attributes or expressions, such as `time(10m)`: ```ruby -builder = Influxdb::Arel::Builder.new(:table) +builder = InfluxDB::Arel::Builder.new(:table) builder.group{ [time(10.m), host] }.to_sql # => SELECT * FROM table GROUP BY time(10m), host ``` @@ -360,13 +355,13 @@ Yo can set the ordering of results using `order` method Possible values: -* `:asc`- Default value. Results will be sorted by ascending order. -* `'asc'`- Results will be sorted by ascending order. -* `:desc`- Results will be sorted by descending order. -* `'desc'`- Results will be sorted by descending order. +- `:asc`- Default value. Results will be sorted by ascending order. +- `'asc'`- Results will be sorted by ascending order. +- `:desc`- Results will be sorted by descending order. +- `'desc'`- Results will be sorted by descending order. ```ruby -builder = Influxdb::Arel::Builder.new(:table) +builder = InfluxDB::Arel::Builder.new(:table) builder.order(:desc).to_sql builder.order('desc').to_sql # => SELECT * FROM table ORDER DESC @@ -406,7 +401,7 @@ builder.asc.desc.to_sql You can specify conditions for query using `where` method ```ruby -builder = Influxdb::Arel::Builder.new(:table) +builder = InfluxDB::Arel::Builder.new(:table) builder.where(name: 'Undr').to_sql # => SELECT * FROM table WHERE name = 'Undr' ``` @@ -430,14 +425,14 @@ builder.where(name: 'Undr').where!{ time.lt(10.h.ago) }.to_sql You can set a limit for a result set ```ruby -builder = Influxdb::Arel::Builder.new(:cpu_load) +builder = InfluxDB::Arel::Builder.new(:cpu_load) builder.limit(100).to_sql # => SELECT * FROM cpu_load LIMIT 100 ``` ## Contributing -1. Fork it ( https://github.com/undr/influxdb-arel/fork ) +1. Fork it ( ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) diff --git a/influxdb-arel.gemspec b/influxdb-arel.gemspec index f4ec258..da6a443 100644 --- a/influxdb-arel.gemspec +++ b/influxdb-arel.gemspec @@ -1,15 +1,15 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'influxdb/arel/version' +require 'influx_db/arel/version' Gem::Specification.new do |spec| spec.name = "influxdb-arel" - spec.version = Influxdb::Arel::VERSION + spec.version = InfluxDB::Arel::VERSION spec.authors = ["undr"] spec.email = ["undr@yandex.ru"] - spec.summary = %q{Influxdb SQL AST manager.} - spec.description = %q{Influxdb::Arel is a SQL AST manager for Influxdb dialect.} + spec.summary = %q{InfluxDB SQL AST manager.} + spec.description = %q{InfluxDB::Arel is a SQL AST manager for InfluxDB dialect.} spec.homepage = "https://github.com/undr/influxdb-arel" spec.license = "MIT" diff --git a/lib/influx_db.rb b/lib/influx_db.rb new file mode 100644 index 0000000..e8325fa --- /dev/null +++ b/lib/influx_db.rb @@ -0,0 +1,4 @@ +require 'influx_db/arel' + +module InfluxDB +end diff --git a/lib/influxdb/arel.rb b/lib/influx_db/arel.rb similarity index 50% rename from lib/influxdb/arel.rb rename to lib/influx_db/arel.rb index 6dec3d8..902a050 100644 --- a/lib/influxdb/arel.rb +++ b/lib/influx_db/arel.rb @@ -1,23 +1,23 @@ require 'date' require 'time' -require "influxdb/arel/version" -require 'influxdb/arel/core_extensions' -require 'influxdb/arel/extensions' -require 'influxdb/arel/clauses' -require 'influxdb/arel/builder' - -require 'influxdb/arel/visitor' -require 'influxdb/arel/visitor/where_statement' -require 'influxdb/arel/visitor/select_statement' -require 'influxdb/arel/visitor/delete_statement' - -require 'influxdb/arel/tree_manager' -require 'influxdb/arel/select_manager' -require 'influxdb/arel/delete_manager' -require 'influxdb/arel/nodes' -require 'influxdb/arel/quoter' - -module Influxdb +require "influx_db/arel/version" +require 'influx_db/arel/core_extensions' +require 'influx_db/arel/extensions' +require 'influx_db/arel/clauses' +require 'influx_db/arel/builder' + +require 'influx_db/arel/visitor' +require 'influx_db/arel/visitor/where_statement' +require 'influx_db/arel/visitor/select_statement' +require 'influx_db/arel/visitor/delete_statement' + +require 'influx_db/arel/tree_manager' +require 'influx_db/arel/select_manager' +require 'influx_db/arel/delete_manager' +require 'influx_db/arel/nodes' +require 'influx_db/arel/quoter' + +module InfluxDB module Arel extend self diff --git a/lib/influxdb/arel/builder.rb b/lib/influx_db/arel/builder.rb similarity index 81% rename from lib/influxdb/arel/builder.rb rename to lib/influx_db/arel/builder.rb index fa8a25f..b7ea992 100644 --- a/lib/influxdb/arel/builder.rb +++ b/lib/influx_db/arel/builder.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class Builder attr_accessor :default_table @@ -9,19 +9,19 @@ def initialize(default_table = nil) # Specify tables for query # - # builder = Influxdb::Arel::Builder.new + # builder = InfluxDB::Arel::Builder.new # builder.from(:table1).to_sql # => SELECT * FROM table1 # - # builder = Influxdb::Arel::Builder.new + # builder = InfluxDB::Arel::Builder.new # builder.from{ table1.as(:alias1).join(table2.as(:alias2)) }.to_sql # => SELECT * FROM table1 AS alias1 INNER JOIN table2 AS alias2 # - # builder = Influxdb::Arel::Builder.new + # builder = InfluxDB::Arel::Builder.new # builder.from(/.*/).to_sql # => SELECT * FROM /.*/ # - # See: Influxdb::Arel::SelectManager#from + # See: InfluxDB::Arel::SelectManager#from # def from(*tables, &block) SelectManager.new(*tables, &block) @@ -31,13 +31,13 @@ def from(*tables, &block) # # Tt will merge default table from builder with given table if tables contains one table. # - # builder = Influxdb::Arel::Builder.new(:table1) + # builder = InfluxDB::Arel::Builder.new(:table1) # builder.merge(:table2).to_sql # => SELECT * FROM table1 MERGE table2 # # It will merge tables if tables contains two tables. # - # builder = Influxdb::Arel::Builder.new + # builder = InfluxDB::Arel::Builder.new # builder.merge(:table1, :table2).to_sql # => SELECT * FROM table1 MERGE table2 # @@ -46,7 +46,7 @@ def from(*tables, &block) # builder.merge.to_sql # => IllegalSQLConstruct: Ambiguous merging clause # - # See: Influxdb::Arel::SelectManager#merge + # See: InfluxDB::Arel::SelectManager#merge # def merge(*tables) from(default_table).merge(*tables) @@ -56,13 +56,13 @@ def merge(*tables) # # It will join default table from builder with given table if tables contains one table. # - # builder = Influxdb::Arel::Builder.new(:table1) + # builder = InfluxDB::Arel::Builder.new(:table1) # builder.join(:table2).to_sql # => SELECT * FROM table1 INNER JOIN table2 # # It will join tables if tables contains two tables. # - # builder = Influxdb::Arel::Builder.new + # builder = InfluxDB::Arel::Builder.new # builder.join(:table1, :table2).to_sql # => SELECT * FROM table1 INNER JOIN table2 # @@ -71,7 +71,7 @@ def merge(*tables) # builder.join.to_sql # => IllegalSQLConstruct: Ambiguous merging clause # - # See: Influxdb::Arel::SelectManager#join + # See: InfluxDB::Arel::SelectManager#join # def join(*tables) from(default_table).join(*tables) @@ -79,7 +79,7 @@ def join(*tables) # Grouping results by specified attributes or expressions, such as time(10m) # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.group{ time(10.s), host }.to_sql # => SELECT * FROM table GROUP BY time(10m), host # @@ -88,7 +88,7 @@ def join(*tables) # builder.group{ time(10.s), host }.fill(0).to_sql # => SELECT * FROM table GROUP BY time(10m), host fill(0) # - # See: Influxdb::Arel::SelectManager#group + # See: InfluxDB::Arel::SelectManager#group # def group(*attributes, &block) from(default_table).group(*attributes, &block) @@ -105,7 +105,7 @@ def group(*attributes, &block) # # Example: # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.order(:desc).to_sql # builder.order('desc').to_sql # => SELECT * FROM table ORDER DESC @@ -114,7 +114,7 @@ def group(*attributes, &block) # builder.order('asc').to_sql # => SELECT * FROM table ORDER ASC # - # See: Influxdb::Arel::SelectManager#order + # See: InfluxDB::Arel::SelectManager#order # def order(expr) from(default_table).order(expr) @@ -122,7 +122,7 @@ def order(expr) # Results will be sorted by ascending order. # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.asc.to_sql # => SELECT * FROM table ORDER ASC # @@ -132,7 +132,7 @@ def asc # Results will be sorted by descending order. # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.desc.to_sql # => SELECT * FROM table ORDER DESC # @@ -143,7 +143,7 @@ def desc # Specify conditions for selection or deletion query # Example: # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.where(name: 'Undr').to_sql # => SELECT * FROM table WHERE name = 'Undr' # @@ -153,7 +153,7 @@ def desc # builder.where{ name.eq('Undr').or(name.eq('Andrei')) }.to_sql # => SELECT * FROM table WHERE name = 'Undr' OR name = 'Andrei' # - # See: Influxdb::Arel::SelectManager#where + # See: InfluxDB::Arel::SelectManager#where # def where(conditions = nil, &block) from(default_table).where(conditions, &block) @@ -162,7 +162,7 @@ def where(conditions = nil, &block) # Specify attributes or expressions for select. # Example: # - # builder = Influxdb::Arel::Builder.new(:cpu_load) + # builder = InfluxDB::Arel::Builder.new(:cpu_load) # builder.to_sql # => SELECT * FROM cpu_load # @@ -172,7 +172,7 @@ def where(conditions = nil, &block) # builder.select{ [mean(idle).as(:idle_mean), mean(user).as(:user_mean)] }.to_sql # => SELECT MEAN(idle) AS idle_mean, MEAN(user) AS user_mean FROM cpu_load # - # See: Influxdb::Arel::SelectManager#select + # See: InfluxDB::Arel::SelectManager#select # def select(*attributes, &block) from(default_table).select(*attributes, &block) @@ -181,7 +181,7 @@ def select(*attributes, &block) # Set limit for result's points # Example: # - # builder = Influxdb::Arel::Builder.new(:table) + # builder = InfluxDB::Arel::Builder.new(:table) # builder.limit(100).to_sql # => SELECT * FROM table LIMIT 100 # @@ -189,7 +189,7 @@ def limit(amount) from(default_table).limit(amount) end - # Create Influxdb::Arel::SelectManager + # Create InfluxDB::Arel::SelectManager # def select_manager SelectManager.new(default_table) diff --git a/lib/influx_db/arel/clauses.rb b/lib/influx_db/arel/clauses.rb new file mode 100644 index 0000000..0d2a60c --- /dev/null +++ b/lib/influx_db/arel/clauses.rb @@ -0,0 +1,6 @@ +require 'influx_db/arel/clauses/base' +require 'influx_db/arel/clauses/expressions' +require 'influx_db/arel/clauses/select_clause' +require 'influx_db/arel/clauses/from_clause' +require 'influx_db/arel/clauses/where_clause' +require 'influx_db/arel/clauses/group_clause' diff --git a/lib/influxdb/arel/clauses/base.rb b/lib/influx_db/arel/clauses/base.rb similarity index 97% rename from lib/influxdb/arel/clauses/base.rb rename to lib/influx_db/arel/clauses/base.rb index 586913a..62c00ae 100644 --- a/lib/influxdb/arel/clauses/base.rb +++ b/lib/influx_db/arel/clauses/base.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses class Base diff --git a/lib/influxdb/arel/clauses/expressions.rb b/lib/influx_db/arel/clauses/expressions.rb similarity index 98% rename from lib/influxdb/arel/clauses/expressions.rb rename to lib/influx_db/arel/clauses/expressions.rb index fbd1f9d..3534d71 100644 --- a/lib/influxdb/arel/clauses/expressions.rb +++ b/lib/influx_db/arel/clauses/expressions.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses module Expressions diff --git a/lib/influxdb/arel/clauses/from_clause.rb b/lib/influx_db/arel/clauses/from_clause.rb similarity index 98% rename from lib/influxdb/arel/clauses/from_clause.rb rename to lib/influx_db/arel/clauses/from_clause.rb index 65b9ede..407923f 100644 --- a/lib/influxdb/arel/clauses/from_clause.rb +++ b/lib/influx_db/arel/clauses/from_clause.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses class FromClause < Base diff --git a/lib/influxdb/arel/clauses/group_clause.rb b/lib/influx_db/arel/clauses/group_clause.rb similarity index 97% rename from lib/influxdb/arel/clauses/group_clause.rb rename to lib/influx_db/arel/clauses/group_clause.rb index ea5ed2a..cc89e8d 100644 --- a/lib/influxdb/arel/clauses/group_clause.rb +++ b/lib/influx_db/arel/clauses/group_clause.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses class GroupClause < Base diff --git a/lib/influxdb/arel/clauses/select_clause.rb b/lib/influx_db/arel/clauses/select_clause.rb similarity index 97% rename from lib/influxdb/arel/clauses/select_clause.rb rename to lib/influx_db/arel/clauses/select_clause.rb index ce1fa19..5928009 100644 --- a/lib/influxdb/arel/clauses/select_clause.rb +++ b/lib/influx_db/arel/clauses/select_clause.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses class SelectClause < Base diff --git a/lib/influxdb/arel/clauses/where_clause.rb b/lib/influx_db/arel/clauses/where_clause.rb similarity index 99% rename from lib/influxdb/arel/clauses/where_clause.rb rename to lib/influx_db/arel/clauses/where_clause.rb index 1556e1c..1ab3afe 100644 --- a/lib/influxdb/arel/clauses/where_clause.rb +++ b/lib/influx_db/arel/clauses/where_clause.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Clauses class WhereClause < Base diff --git a/lib/influx_db/arel/core_extensions.rb b/lib/influx_db/arel/core_extensions.rb new file mode 100644 index 0000000..457cde8 --- /dev/null +++ b/lib/influx_db/arel/core_extensions.rb @@ -0,0 +1,33 @@ +class Integer + def u + InfluxDB::Arel::Nodes::Duration.new(self, 'u') + end + + def s + InfluxDB::Arel::Nodes::Duration.new(self, 's') + end + + def m + InfluxDB::Arel::Nodes::Duration.new(self, 'm') + end + + def h + InfluxDB::Arel::Nodes::Duration.new(self, 'h') + end + + def d + InfluxDB::Arel::Nodes::Duration.new(self, 'd') + end + + def w + InfluxDB::Arel::Nodes::Duration.new(self, 'w') + end +end + +class Object + def safe_clone + self.clone + rescue SecurityError, TypeError => e + self + end +end diff --git a/lib/influxdb/arel/delete_manager.rb b/lib/influx_db/arel/delete_manager.rb similarity index 98% rename from lib/influxdb/arel/delete_manager.rb rename to lib/influx_db/arel/delete_manager.rb index b6d56dd..94d1685 100644 --- a/lib/influxdb/arel/delete_manager.rb +++ b/lib/influx_db/arel/delete_manager.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class DeleteManager < TreeManager def initialize diff --git a/lib/influx_db/arel/extensions.rb b/lib/influx_db/arel/extensions.rb new file mode 100644 index 0000000..0807cc2 --- /dev/null +++ b/lib/influx_db/arel/extensions.rb @@ -0,0 +1,6 @@ +require 'influx_db/arel/extensions/expressions' +require 'influx_db/arel/extensions/boolean_predications' +require 'influx_db/arel/extensions/alias_predication' +require 'influx_db/arel/extensions/joining_merging' +require 'influx_db/arel/extensions/predications' +require 'influx_db/arel/extensions/math' diff --git a/lib/influxdb/arel/extensions/alias_predication.rb b/lib/influx_db/arel/extensions/alias_predication.rb similarity index 91% rename from lib/influxdb/arel/extensions/alias_predication.rb rename to lib/influx_db/arel/extensions/alias_predication.rb index 3b669a3..9d54f78 100644 --- a/lib/influxdb/arel/extensions/alias_predication.rb +++ b/lib/influx_db/arel/extensions/alias_predication.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module AliasPredication diff --git a/lib/influxdb/arel/extensions/boolean_predications.rb b/lib/influx_db/arel/extensions/boolean_predications.rb similarity index 94% rename from lib/influxdb/arel/extensions/boolean_predications.rb rename to lib/influx_db/arel/extensions/boolean_predications.rb index 7f3bf66..88f90c4 100644 --- a/lib/influxdb/arel/extensions/boolean_predications.rb +++ b/lib/influx_db/arel/extensions/boolean_predications.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module BooleanPredications diff --git a/lib/influxdb/arel/extensions/expressions.rb b/lib/influx_db/arel/extensions/expressions.rb similarity index 98% rename from lib/influxdb/arel/extensions/expressions.rb rename to lib/influx_db/arel/extensions/expressions.rb index 76695e9..88a8ec1 100644 --- a/lib/influxdb/arel/extensions/expressions.rb +++ b/lib/influx_db/arel/extensions/expressions.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module Expressions diff --git a/lib/influxdb/arel/extensions/joining_merging.rb b/lib/influx_db/arel/extensions/joining_merging.rb similarity index 96% rename from lib/influxdb/arel/extensions/joining_merging.rb rename to lib/influx_db/arel/extensions/joining_merging.rb index ddc8bfe..536f699 100644 --- a/lib/influxdb/arel/extensions/joining_merging.rb +++ b/lib/influx_db/arel/extensions/joining_merging.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module JoiningMerging diff --git a/lib/influxdb/arel/extensions/math.rb b/lib/influx_db/arel/extensions/math.rb similarity index 96% rename from lib/influxdb/arel/extensions/math.rb rename to lib/influx_db/arel/extensions/math.rb index c5ced21..e381139 100644 --- a/lib/influxdb/arel/extensions/math.rb +++ b/lib/influx_db/arel/extensions/math.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module Math diff --git a/lib/influxdb/arel/extensions/predications.rb b/lib/influx_db/arel/extensions/predications.rb similarity index 99% rename from lib/influxdb/arel/extensions/predications.rb rename to lib/influx_db/arel/extensions/predications.rb index e987632..2662af2 100644 --- a/lib/influxdb/arel/extensions/predications.rb +++ b/lib/influx_db/arel/extensions/predications.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Extensions module Predications diff --git a/lib/influx_db/arel/nodes.rb b/lib/influx_db/arel/nodes.rb new file mode 100644 index 0000000..d73ceac --- /dev/null +++ b/lib/influx_db/arel/nodes.rb @@ -0,0 +1,20 @@ +require 'influx_db/arel/nodes/node' +require 'influx_db/arel/nodes/unary' +require 'influx_db/arel/nodes/binary' +require 'influx_db/arel/nodes/now' +require 'influx_db/arel/nodes/select_statement' +require 'influx_db/arel/nodes/delete_statement' +require 'influx_db/arel/nodes/attribute' +require 'influx_db/arel/nodes/table' +require 'influx_db/arel/nodes/grouping' +require 'influx_db/arel/nodes/time' +require 'influx_db/arel/nodes/duration' +require 'influx_db/arel/nodes/equality' +require 'influx_db/arel/nodes/in' +require 'influx_db/arel/nodes/table_alias' +require 'influx_db/arel/nodes/infix_operation' +require 'influx_db/arel/nodes/and' +require 'influx_db/arel/nodes/function' +require 'influx_db/arel/nodes/sql_literal' +require 'influx_db/arel/nodes/ordering' +require 'influx_db/arel/nodes/merge' diff --git a/lib/influxdb/arel/nodes/and.rb b/lib/influx_db/arel/nodes/and.rb similarity index 96% rename from lib/influxdb/arel/nodes/and.rb rename to lib/influx_db/arel/nodes/and.rb index f5e6249..412e471 100644 --- a/lib/influxdb/arel/nodes/and.rb +++ b/lib/influx_db/arel/nodes/and.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class And < Node diff --git a/lib/influxdb/arel/nodes/attribute.rb b/lib/influx_db/arel/nodes/attribute.rb similarity index 96% rename from lib/influxdb/arel/nodes/attribute.rb rename to lib/influx_db/arel/nodes/attribute.rb index f45e99e..c76f9d0 100644 --- a/lib/influxdb/arel/nodes/attribute.rb +++ b/lib/influx_db/arel/nodes/attribute.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Attribute < Unary diff --git a/lib/influxdb/arel/nodes/binary.rb b/lib/influx_db/arel/nodes/binary.rb similarity index 98% rename from lib/influxdb/arel/nodes/binary.rb rename to lib/influx_db/arel/nodes/binary.rb index 7ad530e..c7c9ed0 100644 --- a/lib/influxdb/arel/nodes/binary.rb +++ b/lib/influx_db/arel/nodes/binary.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Binary < Node diff --git a/lib/influxdb/arel/nodes/delete_statement.rb b/lib/influx_db/arel/nodes/delete_statement.rb similarity index 97% rename from lib/influxdb/arel/nodes/delete_statement.rb rename to lib/influx_db/arel/nodes/delete_statement.rb index 0ef250b..a870276 100644 --- a/lib/influxdb/arel/nodes/delete_statement.rb +++ b/lib/influx_db/arel/nodes/delete_statement.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class DeleteStatement < Node diff --git a/lib/influxdb/arel/nodes/duration.rb b/lib/influx_db/arel/nodes/duration.rb similarity index 97% rename from lib/influxdb/arel/nodes/duration.rb rename to lib/influx_db/arel/nodes/duration.rb index e1ff2dd..e8a1e34 100644 --- a/lib/influxdb/arel/nodes/duration.rb +++ b/lib/influx_db/arel/nodes/duration.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Duration < Binary diff --git a/lib/influxdb/arel/nodes/equality.rb b/lib/influx_db/arel/nodes/equality.rb similarity index 91% rename from lib/influxdb/arel/nodes/equality.rb rename to lib/influx_db/arel/nodes/equality.rb index e451d41..79918aa 100644 --- a/lib/influxdb/arel/nodes/equality.rb +++ b/lib/influx_db/arel/nodes/equality.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Equality < Binary diff --git a/lib/influxdb/arel/nodes/function.rb b/lib/influx_db/arel/nodes/function.rb similarity index 98% rename from lib/influxdb/arel/nodes/function.rb rename to lib/influx_db/arel/nodes/function.rb index 2d257fa..422ef69 100644 --- a/lib/influxdb/arel/nodes/function.rb +++ b/lib/influx_db/arel/nodes/function.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Function < Node diff --git a/lib/influxdb/arel/nodes/grouping.rb b/lib/influx_db/arel/nodes/grouping.rb similarity index 93% rename from lib/influxdb/arel/nodes/grouping.rb rename to lib/influx_db/arel/nodes/grouping.rb index 9fc16ff..746107b 100644 --- a/lib/influxdb/arel/nodes/grouping.rb +++ b/lib/influx_db/arel/nodes/grouping.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Grouping < Unary diff --git a/lib/influxdb/arel/nodes/in.rb b/lib/influx_db/arel/nodes/in.rb similarity index 84% rename from lib/influxdb/arel/nodes/in.rb rename to lib/influx_db/arel/nodes/in.rb index 5a70921..62a6b0e 100644 --- a/lib/influxdb/arel/nodes/in.rb +++ b/lib/influx_db/arel/nodes/in.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class In < Equality diff --git a/lib/influxdb/arel/nodes/infix_operation.rb b/lib/influx_db/arel/nodes/infix_operation.rb similarity index 98% rename from lib/influxdb/arel/nodes/infix_operation.rb rename to lib/influx_db/arel/nodes/infix_operation.rb index d4d1063..625f38b 100644 --- a/lib/influxdb/arel/nodes/infix_operation.rb +++ b/lib/influx_db/arel/nodes/infix_operation.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class InfixOperation < Binary diff --git a/lib/influxdb/arel/nodes/merge.rb b/lib/influx_db/arel/nodes/merge.rb similarity index 94% rename from lib/influxdb/arel/nodes/merge.rb rename to lib/influx_db/arel/nodes/merge.rb index 5e6bb9d..ef0f8dc 100644 --- a/lib/influxdb/arel/nodes/merge.rb +++ b/lib/influx_db/arel/nodes/merge.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Merge < Binary diff --git a/lib/influxdb/arel/nodes/node.rb b/lib/influx_db/arel/nodes/node.rb similarity index 88% rename from lib/influxdb/arel/nodes/node.rb rename to lib/influx_db/arel/nodes/node.rb index ad70a3c..d1138f3 100644 --- a/lib/influxdb/arel/nodes/node.rb +++ b/lib/influx_db/arel/nodes/node.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Node @@ -19,7 +19,7 @@ def to_sql def extend(*extensions) extensions.each do |extension| if module_name = EXTENSIONS[extension] - singleton_class.send(:include, Influxdb::Arel::Extensions.const_get(module_name)) + singleton_class.send(:include, InfluxDB::Arel::Extensions.const_get(module_name)) end end diff --git a/lib/influxdb/arel/nodes/now.rb b/lib/influx_db/arel/nodes/now.rb similarity index 93% rename from lib/influxdb/arel/nodes/now.rb rename to lib/influx_db/arel/nodes/now.rb index b355409..5da8282 100644 --- a/lib/influxdb/arel/nodes/now.rb +++ b/lib/influx_db/arel/nodes/now.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Now < Node diff --git a/lib/influxdb/arel/nodes/ordering.rb b/lib/influx_db/arel/nodes/ordering.rb similarity index 94% rename from lib/influxdb/arel/nodes/ordering.rb rename to lib/influx_db/arel/nodes/ordering.rb index d61376a..11d9bdd 100644 --- a/lib/influxdb/arel/nodes/ordering.rb +++ b/lib/influx_db/arel/nodes/ordering.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Ordering < Unary diff --git a/lib/influxdb/arel/nodes/select_statement.rb b/lib/influx_db/arel/nodes/select_statement.rb similarity index 99% rename from lib/influxdb/arel/nodes/select_statement.rb rename to lib/influx_db/arel/nodes/select_statement.rb index 9957807..882fb28 100644 --- a/lib/influxdb/arel/nodes/select_statement.rb +++ b/lib/influx_db/arel/nodes/select_statement.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class SelectStatement < Node diff --git a/lib/influxdb/arel/nodes/sql_literal.rb b/lib/influx_db/arel/nodes/sql_literal.rb similarity index 96% rename from lib/influxdb/arel/nodes/sql_literal.rb rename to lib/influx_db/arel/nodes/sql_literal.rb index c618583..ddc8f91 100644 --- a/lib/influxdb/arel/nodes/sql_literal.rb +++ b/lib/influx_db/arel/nodes/sql_literal.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class SqlLiteral < String diff --git a/lib/influxdb/arel/nodes/table.rb b/lib/influx_db/arel/nodes/table.rb similarity index 94% rename from lib/influxdb/arel/nodes/table.rb rename to lib/influx_db/arel/nodes/table.rb index 2a81596..479c3d4 100644 --- a/lib/influxdb/arel/nodes/table.rb +++ b/lib/influx_db/arel/nodes/table.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Table < Unary diff --git a/lib/influxdb/arel/nodes/table_alias.rb b/lib/influx_db/arel/nodes/table_alias.rb similarity index 95% rename from lib/influxdb/arel/nodes/table_alias.rb rename to lib/influx_db/arel/nodes/table_alias.rb index c222177..75705b2 100644 --- a/lib/influxdb/arel/nodes/table_alias.rb +++ b/lib/influx_db/arel/nodes/table_alias.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class TableAlias < Binary diff --git a/lib/influxdb/arel/nodes/time.rb b/lib/influx_db/arel/nodes/time.rb similarity index 94% rename from lib/influxdb/arel/nodes/time.rb rename to lib/influx_db/arel/nodes/time.rb index d7acac0..1d0ef78 100644 --- a/lib/influxdb/arel/nodes/time.rb +++ b/lib/influx_db/arel/nodes/time.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Time < Unary diff --git a/lib/influxdb/arel/nodes/unary.rb b/lib/influx_db/arel/nodes/unary.rb similarity index 97% rename from lib/influxdb/arel/nodes/unary.rb rename to lib/influx_db/arel/nodes/unary.rb index 438da5b..afb7f52 100644 --- a/lib/influxdb/arel/nodes/unary.rb +++ b/lib/influx_db/arel/nodes/unary.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module Nodes class Unary < Node diff --git a/lib/influxdb/arel/quoter.rb b/lib/influx_db/arel/quoter.rb similarity index 99% rename from lib/influxdb/arel/quoter.rb rename to lib/influx_db/arel/quoter.rb index bf31277..5aa3270 100644 --- a/lib/influxdb/arel/quoter.rb +++ b/lib/influx_db/arel/quoter.rb @@ -1,6 +1,6 @@ require 'bigdecimal' -module Influxdb +module InfluxDB module Arel module Quoter extend self diff --git a/lib/influxdb/arel/select_manager.rb b/lib/influx_db/arel/select_manager.rb similarity index 99% rename from lib/influxdb/arel/select_manager.rb rename to lib/influx_db/arel/select_manager.rb index aada663..bada54d 100644 --- a/lib/influxdb/arel/select_manager.rb +++ b/lib/influx_db/arel/select_manager.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class SelectManager < Arel::TreeManager DIRECTIONS = [:asc, :desc].freeze diff --git a/lib/influxdb/arel/tree_manager.rb b/lib/influx_db/arel/tree_manager.rb similarity index 97% rename from lib/influxdb/arel/tree_manager.rb rename to lib/influx_db/arel/tree_manager.rb index 5c108f3..8167b45 100644 --- a/lib/influxdb/arel/tree_manager.rb +++ b/lib/influx_db/arel/tree_manager.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class TreeManager STRING_OR_SYMBOL_CLASS = [Symbol, String] diff --git a/lib/influxdb/arel/version.rb b/lib/influx_db/arel/version.rb similarity index 74% rename from lib/influxdb/arel/version.rb rename to lib/influx_db/arel/version.rb index 722da42..184ae8e 100644 --- a/lib/influxdb/arel/version.rb +++ b/lib/influx_db/arel/version.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel VERSION = '0.1.0' end diff --git a/lib/influxdb/arel/visitor.rb b/lib/influx_db/arel/visitor.rb similarity index 62% rename from lib/influxdb/arel/visitor.rb rename to lib/influx_db/arel/visitor.rb index 5bd97e7..9e55142 100644 --- a/lib/influxdb/arel/visitor.rb +++ b/lib/influx_db/arel/visitor.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class Visitor WHERE = ' WHERE ' @@ -26,47 +26,47 @@ def visit(object) retry end - def visit_Influxdb_Arel_Nodes_SelectStatement(object) + def visit_InfluxDB_Arel_Nodes_SelectStatement(object) SelectStatement.new(self).visit(object) end - def visit_Influxdb_Arel_Nodes_DeleteStatement(object) + def visit_InfluxDB_Arel_Nodes_DeleteStatement(object) DeleteStatement.new(self).visit(object) end - def visit_Influxdb_Arel_Nodes_Table(object) + def visit_InfluxDB_Arel_Nodes_Table(object) quote_table_name(object.name) end - def visit_Influxdb_Arel_Nodes_Join(object) + def visit_InfluxDB_Arel_Nodes_Join(object) visit_predication(object, 'INNER JOIN') end - def visit_Influxdb_Arel_Nodes_Merge(object) + def visit_InfluxDB_Arel_Nodes_Merge(object) visit_predication(object, 'MERGE') end - def visit_Influxdb_Arel_Nodes_Limit(object) + def visit_InfluxDB_Arel_Nodes_Limit(object) "LIMIT #{visit(object.expr)}" end - def visit_Influxdb_Arel_Nodes_Ordering(object) + def visit_InfluxDB_Arel_Nodes_Ordering(object) "ORDER #{object.value.upcase}" end - def visit_Influxdb_Arel_Nodes_Into(object) + def visit_InfluxDB_Arel_Nodes_Into(object) "INTO #{visit(object.expr)}" end - def visit_Influxdb_Arel_Nodes_Grouping(object) + def visit_InfluxDB_Arel_Nodes_Grouping(object) "(#{visit(object.expr)})" end - def visit_Influxdb_Arel_Nodes_Group(object) + def visit_InfluxDB_Arel_Nodes_Group(object) visit(object.expr) end - def visit_Influxdb_Arel_Nodes_TableAlias(object) + def visit_InfluxDB_Arel_Nodes_TableAlias(object) "#{visit(object.relation)} AS #{quote_table_name(object.name)}" end @@ -76,41 +76,41 @@ def function(object) "#{function_clause}(#{expressions})" end - alias :visit_Influxdb_Arel_Nodes_Count :function - alias :visit_Influxdb_Arel_Nodes_Sum :function - alias :visit_Influxdb_Arel_Nodes_Max :function - alias :visit_Influxdb_Arel_Nodes_Min :function - alias :visit_Influxdb_Arel_Nodes_Mean :function - alias :visit_Influxdb_Arel_Nodes_Mode :function - alias :visit_Influxdb_Arel_Nodes_Median :function - alias :visit_Influxdb_Arel_Nodes_Distinct :function - alias :visit_Influxdb_Arel_Nodes_Percentile :function - alias :visit_Influxdb_Arel_Nodes_Histogram :function - alias :visit_Influxdb_Arel_Nodes_Derivative :function - alias :visit_Influxdb_Arel_Nodes_Stddev :function - alias :visit_Influxdb_Arel_Nodes_First :function - alias :visit_Influxdb_Arel_Nodes_Last :function - alias :visit_Influxdb_Arel_Nodes_Difference :function - alias :visit_Influxdb_Arel_Nodes_Top :function - alias :visit_Influxdb_Arel_Nodes_Bottom :function - - def visit_Influxdb_Arel_Nodes_Fill(object) + alias :visit_InfluxDB_Arel_Nodes_Count :function + alias :visit_InfluxDB_Arel_Nodes_Sum :function + alias :visit_InfluxDB_Arel_Nodes_Max :function + alias :visit_InfluxDB_Arel_Nodes_Min :function + alias :visit_InfluxDB_Arel_Nodes_Mean :function + alias :visit_InfluxDB_Arel_Nodes_Mode :function + alias :visit_InfluxDB_Arel_Nodes_Median :function + alias :visit_InfluxDB_Arel_Nodes_Distinct :function + alias :visit_InfluxDB_Arel_Nodes_Percentile :function + alias :visit_InfluxDB_Arel_Nodes_Histogram :function + alias :visit_InfluxDB_Arel_Nodes_Derivative :function + alias :visit_InfluxDB_Arel_Nodes_Stddev :function + alias :visit_InfluxDB_Arel_Nodes_First :function + alias :visit_InfluxDB_Arel_Nodes_Last :function + alias :visit_InfluxDB_Arel_Nodes_Difference :function + alias :visit_InfluxDB_Arel_Nodes_Top :function + alias :visit_InfluxDB_Arel_Nodes_Bottom :function + + def visit_InfluxDB_Arel_Nodes_Fill(object) "fill(#{visit(object.expr)})" end - def visit_Influxdb_Arel_Nodes_Time(object) + def visit_InfluxDB_Arel_Nodes_Time(object) "time(#{visit(object.expr)})" end - def visit_Influxdb_Arel_Nodes_Duration(object) + def visit_InfluxDB_Arel_Nodes_Duration(object) "#{object.value}#{object.suffix}" end - def visit_Influxdb_Arel_Nodes_Now(object) + def visit_InfluxDB_Arel_Nodes_Now(object) "now()" end - def visit_Influxdb_Arel_Nodes_In(object) + def visit_InfluxDB_Arel_Nodes_In(object) if Array === object.right && object.right.empty? '1 = 0' else @@ -118,7 +118,7 @@ def visit_Influxdb_Arel_Nodes_In(object) end end - def visit_Influxdb_Arel_Nodes_GreaterThanOrEqual(object) + def visit_InfluxDB_Arel_Nodes_GreaterThanOrEqual(object) if object.left.is_a?(Nodes::Attribute) && object.left.time? right = object.right - 1 operator = '>' @@ -129,11 +129,11 @@ def visit_Influxdb_Arel_Nodes_GreaterThanOrEqual(object) visit_predication(object, operator, right) end - def visit_Influxdb_Arel_Nodes_GreaterThan(object) + def visit_InfluxDB_Arel_Nodes_GreaterThan(object) visit_predication(object, '>') end - def visit_Influxdb_Arel_Nodes_LessThanOrEqual(object) + def visit_InfluxDB_Arel_Nodes_LessThanOrEqual(object) if object.left.is_a?(Nodes::Attribute) && object.left.time? right = object.right + 1 operator = '<' @@ -144,39 +144,39 @@ def visit_Influxdb_Arel_Nodes_LessThanOrEqual(object) visit_predication(object, operator, right) end - def visit_Influxdb_Arel_Nodes_LessThan(object) + def visit_InfluxDB_Arel_Nodes_LessThan(object) visit_predication(object, '<') end - def visit_Influxdb_Arel_Nodes_NotEqual(object) + def visit_InfluxDB_Arel_Nodes_NotEqual(object) visit_predication(object, '<>') end - def visit_Influxdb_Arel_Nodes_Equality(object) + def visit_InfluxDB_Arel_Nodes_Equality(object) visit_predication(object, '=') end - def visit_Influxdb_Arel_Nodes_Matches(object) + def visit_InfluxDB_Arel_Nodes_Matches(object) visit_predication(object, '=~') end - def visit_Influxdb_Arel_Nodes_DoesNotMatch(object) + def visit_InfluxDB_Arel_Nodes_DoesNotMatch(object) visit_predication(object, '!~') end - def visit_Influxdb_Arel_Nodes_And(object) + def visit_InfluxDB_Arel_Nodes_And(object) object.children.map{|node| visit(node) }.join(AND) end - def visit_Influxdb_Arel_Nodes_Or(object) + def visit_InfluxDB_Arel_Nodes_Or(object) [visit(object.left), visit(object.right)].join(OR) end - def visit_Influxdb_Arel_Nodes_As(object) + def visit_InfluxDB_Arel_Nodes_As(object) visit_predication(object, 'AS') end - def visit_Influxdb_Arel_Nodes_Attribute(object) + def visit_InfluxDB_Arel_Nodes_Attribute(object) # if object.relation.table_alias # "#{quote_table_name(object.relation.table_alias)}.#{quote_column_name(object.name)}" # else @@ -190,7 +190,7 @@ def literal(object) object end - alias :visit_Influxdb_Arel_Nodes_SqlLiteral :literal + alias :visit_InfluxDB_Arel_Nodes_SqlLiteral :literal alias :visit_Bignum :literal alias :visit_Fixnum :literal @@ -214,14 +214,14 @@ def quoted(object) alias :visit_TrueClass :quoted alias :visit_Regexp :quoted - def visit_Influxdb_Arel_Nodes_InfixOperation(object) + def visit_InfluxDB_Arel_Nodes_InfixOperation(object) visit_predication(object, object.operator) end - alias :visit_Influxdb_Arel_Nodes_Addition :visit_Influxdb_Arel_Nodes_InfixOperation - alias :visit_Influxdb_Arel_Nodes_Subtraction :visit_Influxdb_Arel_Nodes_InfixOperation - alias :visit_Influxdb_Arel_Nodes_Multiplication :visit_Influxdb_Arel_Nodes_InfixOperation - alias :visit_Influxdb_Arel_Nodes_Division :visit_Influxdb_Arel_Nodes_InfixOperation + alias :visit_InfluxDB_Arel_Nodes_Addition :visit_InfluxDB_Arel_Nodes_InfixOperation + alias :visit_InfluxDB_Arel_Nodes_Subtraction :visit_InfluxDB_Arel_Nodes_InfixOperation + alias :visit_InfluxDB_Arel_Nodes_Multiplication :visit_InfluxDB_Arel_Nodes_InfixOperation + alias :visit_InfluxDB_Arel_Nodes_Division :visit_InfluxDB_Arel_Nodes_InfixOperation def visit_Array(object) object.map{|node| visit(node) }.join(COMMA) diff --git a/lib/influxdb/arel/visitor/delete_statement.rb b/lib/influx_db/arel/visitor/delete_statement.rb similarity index 97% rename from lib/influxdb/arel/visitor/delete_statement.rb rename to lib/influx_db/arel/visitor/delete_statement.rb index 3ca5c22..89f3d67 100644 --- a/lib/influxdb/arel/visitor/delete_statement.rb +++ b/lib/influx_db/arel/visitor/delete_statement.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class Visitor class DeleteStatement diff --git a/lib/influxdb/arel/visitor/select_statement.rb b/lib/influx_db/arel/visitor/select_statement.rb similarity index 98% rename from lib/influxdb/arel/visitor/select_statement.rb rename to lib/influx_db/arel/visitor/select_statement.rb index c756eb5..b4798d2 100644 --- a/lib/influxdb/arel/visitor/select_statement.rb +++ b/lib/influx_db/arel/visitor/select_statement.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class Visitor class SelectStatement diff --git a/lib/influxdb/arel/visitor/where_statement.rb b/lib/influx_db/arel/visitor/where_statement.rb similarity index 94% rename from lib/influxdb/arel/visitor/where_statement.rb rename to lib/influx_db/arel/visitor/where_statement.rb index 73bf08f..01a8f99 100644 --- a/lib/influxdb/arel/visitor/where_statement.rb +++ b/lib/influx_db/arel/visitor/where_statement.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel class Visitor module WhereStatement diff --git a/lib/influxdb-arel.rb b/lib/influxdb-arel.rb index ff1d739..a8523f1 100644 --- a/lib/influxdb-arel.rb +++ b/lib/influxdb-arel.rb @@ -1 +1 @@ -require 'influxdb' +require 'influx_db' diff --git a/lib/influxdb.rb b/lib/influxdb.rb deleted file mode 100644 index f28d7be..0000000 --- a/lib/influxdb.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'influxdb/arel' - -module Influxdb -end diff --git a/lib/influxdb/arel/clauses.rb b/lib/influxdb/arel/clauses.rb deleted file mode 100644 index 59313be..0000000 --- a/lib/influxdb/arel/clauses.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'influxdb/arel/clauses/base' -require 'influxdb/arel/clauses/expressions' -require 'influxdb/arel/clauses/select_clause' -require 'influxdb/arel/clauses/from_clause' -require 'influxdb/arel/clauses/where_clause' -require 'influxdb/arel/clauses/group_clause' diff --git a/lib/influxdb/arel/core_extensions.rb b/lib/influxdb/arel/core_extensions.rb deleted file mode 100644 index 8c100b0..0000000 --- a/lib/influxdb/arel/core_extensions.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Integer - def u - Influxdb::Arel::Nodes::Duration.new(self, 'u') - end - - def s - Influxdb::Arel::Nodes::Duration.new(self, 's') - end - - def m - Influxdb::Arel::Nodes::Duration.new(self, 'm') - end - - def h - Influxdb::Arel::Nodes::Duration.new(self, 'h') - end - - def d - Influxdb::Arel::Nodes::Duration.new(self, 'd') - end - - def w - Influxdb::Arel::Nodes::Duration.new(self, 'w') - end -end - -class Object - def safe_clone - self.clone - rescue SecurityError, TypeError => e - self - end -end diff --git a/lib/influxdb/arel/extensions.rb b/lib/influxdb/arel/extensions.rb deleted file mode 100644 index e294568..0000000 --- a/lib/influxdb/arel/extensions.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'influxdb/arel/extensions/expressions' -require 'influxdb/arel/extensions/boolean_predications' -require 'influxdb/arel/extensions/alias_predication' -require 'influxdb/arel/extensions/joining_merging' -require 'influxdb/arel/extensions/predications' -require 'influxdb/arel/extensions/math' diff --git a/lib/influxdb/arel/nodes.rb b/lib/influxdb/arel/nodes.rb deleted file mode 100644 index d0a683d..0000000 --- a/lib/influxdb/arel/nodes.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'influxdb/arel/nodes/node' -require 'influxdb/arel/nodes/unary' -require 'influxdb/arel/nodes/binary' -require 'influxdb/arel/nodes/now' -require 'influxdb/arel/nodes/select_statement' -require 'influxdb/arel/nodes/delete_statement' -require 'influxdb/arel/nodes/attribute' -require 'influxdb/arel/nodes/table' -require 'influxdb/arel/nodes/grouping' -require 'influxdb/arel/nodes/time' -require 'influxdb/arel/nodes/duration' -require 'influxdb/arel/nodes/equality' -require 'influxdb/arel/nodes/in' -require 'influxdb/arel/nodes/table_alias' -require 'influxdb/arel/nodes/infix_operation' -require 'influxdb/arel/nodes/and' -require 'influxdb/arel/nodes/function' -require 'influxdb/arel/nodes/sql_literal' -require 'influxdb/arel/nodes/ordering' -require 'influxdb/arel/nodes/merge' diff --git a/spec/lib/influxdb/arel/builder_spec.rb b/spec/lib/influx_db/arel/builder_spec.rb similarity index 83% rename from spec/lib/influxdb/arel/builder_spec.rb rename to spec/lib/influx_db/arel/builder_spec.rb index 7c61c1a..2e5517a 100644 --- a/spec/lib/influxdb/arel/builder_spec.rb +++ b/spec/lib/influx_db/arel/builder_spec.rb @@ -1,23 +1,23 @@ require 'spec_helper' -describe Influxdb::Arel::Builder do +describe InfluxDB::Arel::Builder do describe '#from' do subject{ builder(:events).from(:table) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, :table)]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table') } end describe '#merge' do subject{ builder(:events).merge(:errors) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events MERGE errors') } context 'when table as argument' do subject{ builder(:events).merge(node(:Table, :errors)) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events MERGE errors') } end @@ -34,7 +34,7 @@ context 'without argument with two tables' do subject{ builder.from(:events, :errors).merge } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events MERGE errors') } end @@ -42,14 +42,14 @@ describe '#join' do subject{ builder(:events).join(:errors) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events INNER JOIN errors') } context 'when table as argument' do subject{ builder(:events).join(node(:Table, :errors)) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events INNER JOIN errors') } end @@ -66,7 +66,7 @@ context 'without argument with two tables' do subject{ builder.from(:events, :errors).join } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, :events), node(:Table, :errors))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events INNER JOIN errors') } end @@ -75,28 +75,28 @@ describe '#order' do context 'when sort by ascending order' do subject{ builder(:events).order(:asc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end context 'when sort by ascending order' do subject{ builder(:events).order('asc') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end context 'when sort by descending order' do subject{ builder(:events).order(:desc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'desc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end context 'when sort by descending order' do subject{ builder(:events).order('desc') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'desc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -104,28 +104,28 @@ describe '#asc' do subject{ builder(:events).asc } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end describe '#desc' do subject{ builder(:events).desc } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'desc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end describe '#limit' do subject{ builder(:events).limit(100) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.limit_value).to eq(node(:Limit, 100)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events LIMIT 100') } end describe '#group' do subject{ builder(:events).group{ [time('1s'), 'name', :type] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Time, '1s'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -133,7 +133,7 @@ context 'chaining' do subject{ builder(:events).group{ time('1s') }.group('name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.groups).to eq([ node(:Time, '1s'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -143,13 +143,13 @@ describe '#where' do subject{ builder(:events).where("name = 'Undr'") } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([sql("name = 'Undr'")]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr'") } context 'chaining' do subject{ builder(:events).where("name = 'Undr'").where(sql("email = 'undr@gmail.com'")) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([sql("name = 'Undr'"), sql("email = 'undr@gmail.com'")]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr' AND email = 'undr@gmail.com'") } end @@ -157,13 +157,13 @@ describe '#select' do subject{ builder('events').select('name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq([node(:Attribute, 'name'), node(:Attribute, 'type')]) } specify{ expect(subject.to_sql).to eq('SELECT name, type FROM events') } context 'chaining' do subject{ builder('events').select{ time }.select('name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq( [node(:Attribute, 'time'), node(:Attribute, 'name'), node(:Attribute, 'type')] ) } diff --git a/spec/lib/influxdb/arel/core_extensions_spec.rb b/spec/lib/influx_db/arel/core_extensions_spec.rb similarity index 92% rename from spec/lib/influxdb/arel/core_extensions_spec.rb rename to spec/lib/influx_db/arel/core_extensions_spec.rb index 3863e08..4017865 100644 --- a/spec/lib/influxdb/arel/core_extensions_spec.rb +++ b/spec/lib/influx_db/arel/core_extensions_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -require './lib/influxdb/arel/core_extensions' +require './lib/influx_db/arel/core_extensions' describe Integer do describe '#u' do diff --git a/spec/lib/influxdb/arel/nodes/and_spec.rb b/spec/lib/influx_db/arel/nodes/and_spec.rb similarity index 93% rename from spec/lib/influxdb/arel/nodes/and_spec.rb rename to spec/lib/influx_db/arel/nodes/and_spec.rb index d3f4c23..d601dd3 100644 --- a/spec/lib/influxdb/arel/nodes/and_spec.rb +++ b/spec/lib/influx_db/arel/nodes/and_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::And do +describe InfluxDB::Arel::Nodes::And do let(:described_node){ node(:And, ['first', sql('second'), 'third']) } it_should_behave_like :node_to_sql, "'first' AND second AND 'third'" diff --git a/spec/lib/influxdb/arel/nodes/attribute_spec.rb b/spec/lib/influx_db/arel/nodes/attribute_spec.rb similarity index 93% rename from spec/lib/influxdb/arel/nodes/attribute_spec.rb rename to spec/lib/influx_db/arel/nodes/attribute_spec.rb index 31a405f..da0bd86 100644 --- a/spec/lib/influxdb/arel/nodes/attribute_spec.rb +++ b/spec/lib/influx_db/arel/nodes/attribute_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Attribute do +describe InfluxDB::Arel::Nodes::Attribute do let(:described_node){ node(:Attribute, 'value') } it_should_behave_like :unary_node, :Attribute, 'value' diff --git a/spec/lib/influxdb/arel/nodes/binary_spec.rb b/spec/lib/influx_db/arel/nodes/binary_spec.rb similarity index 61% rename from spec/lib/influxdb/arel/nodes/binary_spec.rb rename to spec/lib/influx_db/arel/nodes/binary_spec.rb index 12f4c0b..c3f5c5d 100644 --- a/spec/lib/influxdb/arel/nodes/binary_spec.rb +++ b/spec/lib/influx_db/arel/nodes/binary_spec.rb @@ -1,45 +1,45 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Binary do +describe InfluxDB::Arel::Nodes::Binary do it_should_behave_like :binary_node, :Binary end -describe Influxdb::Arel::Nodes::As do +describe InfluxDB::Arel::Nodes::As do it_should_behave_like :binary_node, :As, 'left AS right' end -describe Influxdb::Arel::Nodes::DoesNotMatch do +describe InfluxDB::Arel::Nodes::DoesNotMatch do it_should_behave_like :binary_node, :DoesNotMatch, 'left !~ right' end -describe Influxdb::Arel::Nodes::GreaterThan do +describe InfluxDB::Arel::Nodes::GreaterThan do it_should_behave_like :binary_node, :GreaterThan, 'left > right' end -describe Influxdb::Arel::Nodes::GreaterThanOrEqual do +describe InfluxDB::Arel::Nodes::GreaterThanOrEqual do it_should_behave_like :binary_node, :GreaterThanOrEqual, 'left >= right' end -describe Influxdb::Arel::Nodes::Join do +describe InfluxDB::Arel::Nodes::Join do it_should_behave_like :binary_node, :Join, 'left INNER JOIN right' end -describe Influxdb::Arel::Nodes::LessThan do +describe InfluxDB::Arel::Nodes::LessThan do it_should_behave_like :binary_node, :LessThan, 'left < right' end -describe Influxdb::Arel::Nodes::LessThanOrEqual do +describe InfluxDB::Arel::Nodes::LessThanOrEqual do it_should_behave_like :binary_node, :LessThanOrEqual, 'left <= right' end -describe Influxdb::Arel::Nodes::Matches do +describe InfluxDB::Arel::Nodes::Matches do it_should_behave_like :binary_node, :Matches, 'left =~ right' end -describe Influxdb::Arel::Nodes::NotEqual do +describe InfluxDB::Arel::Nodes::NotEqual do it_should_behave_like :binary_node, :NotEqual, 'left <> right' end -describe Influxdb::Arel::Nodes::Or do +describe InfluxDB::Arel::Nodes::Or do it_should_behave_like :binary_node, :Or, 'left OR right' end diff --git a/spec/lib/influxdb/arel/nodes/duration_spec.rb b/spec/lib/influx_db/arel/nodes/duration_spec.rb similarity index 97% rename from spec/lib/influxdb/arel/nodes/duration_spec.rb rename to spec/lib/influx_db/arel/nodes/duration_spec.rb index 00a7ce9..40a5699 100644 --- a/spec/lib/influxdb/arel/nodes/duration_spec.rb +++ b/spec/lib/influx_db/arel/nodes/duration_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Duration do +describe InfluxDB::Arel::Nodes::Duration do let(:described_node){ node(:Duration, 10, 'h') } it_should_behave_like :node_to_sql, '10h' diff --git a/spec/lib/influxdb/arel/nodes/equality_spec.rb b/spec/lib/influx_db/arel/nodes/equality_spec.rb similarity index 67% rename from spec/lib/influxdb/arel/nodes/equality_spec.rb rename to spec/lib/influx_db/arel/nodes/equality_spec.rb index e9d1664..a418aca 100644 --- a/spec/lib/influxdb/arel/nodes/equality_spec.rb +++ b/spec/lib/influx_db/arel/nodes/equality_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Equality do +describe InfluxDB::Arel::Nodes::Equality do it_should_behave_like :binary_node, :Equality, 'left = right' end diff --git a/spec/lib/influxdb/arel/nodes/function_spec.rb b/spec/lib/influx_db/arel/nodes/function_spec.rb similarity index 65% rename from spec/lib/influxdb/arel/nodes/function_spec.rb rename to spec/lib/influx_db/arel/nodes/function_spec.rb index 8898786..8cca3fd 100644 --- a/spec/lib/influxdb/arel/nodes/function_spec.rb +++ b/spec/lib/influx_db/arel/nodes/function_spec.rb @@ -1,69 +1,69 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Count do +describe InfluxDB::Arel::Nodes::Count do it_should_behave_like :function_node, :Count, 'COUNT(expression)' end -describe Influxdb::Arel::Nodes::Sum do +describe InfluxDB::Arel::Nodes::Sum do it_should_behave_like :function_node, :Sum, 'SUM(expression)' end -describe Influxdb::Arel::Nodes::Max do +describe InfluxDB::Arel::Nodes::Max do it_should_behave_like :function_node, :Max, 'MAX(expression)' end -describe Influxdb::Arel::Nodes::Min do +describe InfluxDB::Arel::Nodes::Min do it_should_behave_like :function_node, :Min, 'MIN(expression)' end -describe Influxdb::Arel::Nodes::Mean do +describe InfluxDB::Arel::Nodes::Mean do it_should_behave_like :function_node, :Mean, 'MEAN(expression)' end -describe Influxdb::Arel::Nodes::Mode do +describe InfluxDB::Arel::Nodes::Mode do it_should_behave_like :function_node, :Mode, 'MODE(expression)' end -describe Influxdb::Arel::Nodes::Median do +describe InfluxDB::Arel::Nodes::Median do it_should_behave_like :function_node, :Median, 'MEDIAN(expression)' end -describe Influxdb::Arel::Nodes::Distinct do +describe InfluxDB::Arel::Nodes::Distinct do it_should_behave_like :function_node, :Distinct, 'DISTINCT(expression)' end -describe Influxdb::Arel::Nodes::Percentile do +describe InfluxDB::Arel::Nodes::Percentile do it_should_behave_like :function_node, :Percentile, 'PERCENTILE(expression, 99)', [99] end -describe Influxdb::Arel::Nodes::Histogram do +describe InfluxDB::Arel::Nodes::Histogram do it_should_behave_like :function_node, :Histogram, 'HISTOGRAM(expression, 50)', [50] end -describe Influxdb::Arel::Nodes::Derivative do +describe InfluxDB::Arel::Nodes::Derivative do it_should_behave_like :function_node, :Derivative, 'DERIVATIVE(expression)' end -describe Influxdb::Arel::Nodes::Stddev do +describe InfluxDB::Arel::Nodes::Stddev do it_should_behave_like :function_node, :Stddev, 'STDDEV(expression)' end -describe Influxdb::Arel::Nodes::First do +describe InfluxDB::Arel::Nodes::First do it_should_behave_like :function_node, :First, 'FIRST(expression)' end -describe Influxdb::Arel::Nodes::Last do +describe InfluxDB::Arel::Nodes::Last do it_should_behave_like :function_node, :Last, 'LAST(expression)' end -describe Influxdb::Arel::Nodes::Difference do +describe InfluxDB::Arel::Nodes::Difference do it_should_behave_like :function_node, :Difference, 'DIFFERENCE(expression)' end -describe Influxdb::Arel::Nodes::Top do +describe InfluxDB::Arel::Nodes::Top do it_should_behave_like :function_node, :Top, 'TOP(expression, 10)', [10] end -describe Influxdb::Arel::Nodes::Bottom do +describe InfluxDB::Arel::Nodes::Bottom do it_should_behave_like :function_node, :Bottom, 'BOTTOM(expression, 10)', [10] end diff --git a/spec/lib/influxdb/arel/nodes/grouping_spec.rb b/spec/lib/influx_db/arel/nodes/grouping_spec.rb similarity index 86% rename from spec/lib/influxdb/arel/nodes/grouping_spec.rb rename to spec/lib/influx_db/arel/nodes/grouping_spec.rb index 4a98520..369ca71 100644 --- a/spec/lib/influxdb/arel/nodes/grouping_spec.rb +++ b/spec/lib/influx_db/arel/nodes/grouping_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Grouping do +describe InfluxDB::Arel::Nodes::Grouping do let(:described_node){ node(:Grouping, sql('value')) } it_should_behave_like :unary_node, :Grouping, '(value)' diff --git a/spec/lib/influxdb/arel/nodes/in_spec.rb b/spec/lib/influx_db/arel/nodes/in_spec.rb similarity index 93% rename from spec/lib/influxdb/arel/nodes/in_spec.rb rename to spec/lib/influx_db/arel/nodes/in_spec.rb index e03a830..7081d8f 100644 --- a/spec/lib/influxdb/arel/nodes/in_spec.rb +++ b/spec/lib/influx_db/arel/nodes/in_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::In do +describe InfluxDB::Arel::Nodes::In do let(:described_node){ node(:In, sql('left'), [1, 2, 3]) } it_should_behave_like :node_to_sql, 'left IN (1, 2, 3)' diff --git a/spec/lib/influxdb/arel/nodes/infix_operation_spec.rb b/spec/lib/influx_db/arel/nodes/infix_operation_spec.rb similarity index 64% rename from spec/lib/influxdb/arel/nodes/infix_operation_spec.rb rename to spec/lib/influx_db/arel/nodes/infix_operation_spec.rb index dc990c4..9527d5a 100644 --- a/spec/lib/influxdb/arel/nodes/infix_operation_spec.rb +++ b/spec/lib/influx_db/arel/nodes/infix_operation_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Multiplication do +describe InfluxDB::Arel::Nodes::Multiplication do it_should_behave_like :infix_operation_node, :Multiplication, 'left * right' end -describe Influxdb::Arel::Nodes::Division do +describe InfluxDB::Arel::Nodes::Division do it_should_behave_like :infix_operation_node, :Division, 'left / right' end -describe Influxdb::Arel::Nodes::Addition do +describe InfluxDB::Arel::Nodes::Addition do it_should_behave_like :infix_operation_node, :Addition, 'left + right' end -describe Influxdb::Arel::Nodes::Subtraction do +describe InfluxDB::Arel::Nodes::Subtraction do it_should_behave_like :infix_operation_node, :Subtraction, 'left - right' end diff --git a/spec/lib/influxdb/arel/nodes/merge_spec.rb b/spec/lib/influx_db/arel/nodes/merge_spec.rb similarity index 81% rename from spec/lib/influxdb/arel/nodes/merge_spec.rb rename to spec/lib/influx_db/arel/nodes/merge_spec.rb index 9d9ae4b..7e94186 100644 --- a/spec/lib/influxdb/arel/nodes/merge_spec.rb +++ b/spec/lib/influx_db/arel/nodes/merge_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Merge do +describe InfluxDB::Arel::Nodes::Merge do describe 'initialization' do let(:described_node){ node(:Merge, left, right) } @@ -8,16 +8,16 @@ let(:left){ node(:Table, 'left') } let(:right){ node(:Table, 'right') } - specify{ expect(described_node.left).to be_instance_of(Influxdb::Arel::Nodes::Table) } - specify{ expect(described_node.right).to be_instance_of(Influxdb::Arel::Nodes::Table) } + specify{ expect(described_node.left).to be_instance_of(InfluxDB::Arel::Nodes::Table) } + specify{ expect(described_node.right).to be_instance_of(InfluxDB::Arel::Nodes::Table) } end context 'with aliases' do let(:left){ node(:Table, 'left').as(:alias1) } let(:right){ node(:Table, 'right').as(:alias2) } - specify{ expect(described_node.left).to be_instance_of(Influxdb::Arel::Nodes::Table) } - specify{ expect(described_node.right).to be_instance_of(Influxdb::Arel::Nodes::Table) } + specify{ expect(described_node.left).to be_instance_of(InfluxDB::Arel::Nodes::Table) } + specify{ expect(described_node.right).to be_instance_of(InfluxDB::Arel::Nodes::Table) } end end diff --git a/spec/lib/influxdb/arel/nodes/now_spec.rb b/spec/lib/influx_db/arel/nodes/now_spec.rb similarity index 84% rename from spec/lib/influxdb/arel/nodes/now_spec.rb rename to spec/lib/influx_db/arel/nodes/now_spec.rb index a79f139..d0514ad 100644 --- a/spec/lib/influxdb/arel/nodes/now_spec.rb +++ b/spec/lib/influx_db/arel/nodes/now_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Now do +describe InfluxDB::Arel::Nodes::Now do let(:described_node){ node(:Now) } it_should_behave_like :node_to_sql, 'now()' diff --git a/spec/lib/influxdb/arel/nodes/ordering_spec.rb b/spec/lib/influx_db/arel/nodes/ordering_spec.rb similarity index 91% rename from spec/lib/influxdb/arel/nodes/ordering_spec.rb rename to spec/lib/influx_db/arel/nodes/ordering_spec.rb index 50e7b76..f4e58f4 100644 --- a/spec/lib/influxdb/arel/nodes/ordering_spec.rb +++ b/spec/lib/influx_db/arel/nodes/ordering_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Ordering do +describe InfluxDB::Arel::Nodes::Ordering do it_should_behave_like :unary_node, :Ordering, 'ORDER VALUE' describe '#invert' do diff --git a/spec/lib/influxdb/arel/nodes/sql_literal_spec.rb b/spec/lib/influx_db/arel/nodes/sql_literal_spec.rb similarity index 94% rename from spec/lib/influxdb/arel/nodes/sql_literal_spec.rb rename to spec/lib/influx_db/arel/nodes/sql_literal_spec.rb index 89b7dca..216e23b 100644 --- a/spec/lib/influxdb/arel/nodes/sql_literal_spec.rb +++ b/spec/lib/influx_db/arel/nodes/sql_literal_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::SqlLiteral do +describe InfluxDB::Arel::Nodes::SqlLiteral do let(:described_node){ node(:SqlLiteral, 'expressions') } describe '#to_sql' do diff --git a/spec/lib/influxdb/arel/nodes/table_alias_spec.rb b/spec/lib/influx_db/arel/nodes/table_alias_spec.rb similarity index 93% rename from spec/lib/influxdb/arel/nodes/table_alias_spec.rb rename to spec/lib/influx_db/arel/nodes/table_alias_spec.rb index 442db0a..052141c 100644 --- a/spec/lib/influxdb/arel/nodes/table_alias_spec.rb +++ b/spec/lib/influx_db/arel/nodes/table_alias_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::TableAlias do +describe InfluxDB::Arel::Nodes::TableAlias do let(:described_node){ node(:TableAlias, node(:Table, 'events'), 'alias') } subject{ described_node } diff --git a/spec/lib/influxdb/arel/nodes/table_spec.rb b/spec/lib/influx_db/arel/nodes/table_spec.rb similarity index 81% rename from spec/lib/influxdb/arel/nodes/table_spec.rb rename to spec/lib/influx_db/arel/nodes/table_spec.rb index 1b9a246..75588e0 100644 --- a/spec/lib/influxdb/arel/nodes/table_spec.rb +++ b/spec/lib/influx_db/arel/nodes/table_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Table do +describe InfluxDB::Arel::Nodes::Table do let(:described_node){ node(:Table, 'value') } it_should_behave_like :unary_node, :Table, 'value' diff --git a/spec/lib/influxdb/arel/nodes/time_spec.rb b/spec/lib/influx_db/arel/nodes/time_spec.rb similarity index 68% rename from spec/lib/influxdb/arel/nodes/time_spec.rb rename to spec/lib/influx_db/arel/nodes/time_spec.rb index 9b27062..692e424 100644 --- a/spec/lib/influxdb/arel/nodes/time_spec.rb +++ b/spec/lib/influx_db/arel/nodes/time_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Time do +describe InfluxDB::Arel::Nodes::Time do it_should_behave_like :unary_node, :Time, 'time(value)' end diff --git a/spec/lib/influxdb/arel/nodes/unary_spec.rb b/spec/lib/influx_db/arel/nodes/unary_spec.rb similarity index 61% rename from spec/lib/influxdb/arel/nodes/unary_spec.rb rename to spec/lib/influx_db/arel/nodes/unary_spec.rb index 6be237e..8120ed7 100644 --- a/spec/lib/influxdb/arel/nodes/unary_spec.rb +++ b/spec/lib/influx_db/arel/nodes/unary_spec.rb @@ -1,21 +1,21 @@ require 'spec_helper' -describe Influxdb::Arel::Nodes::Unary do +describe InfluxDB::Arel::Nodes::Unary do it_should_behave_like :unary_node, :Unary end -describe Influxdb::Arel::Nodes::Group do +describe InfluxDB::Arel::Nodes::Group do it_should_behave_like :unary_node, :Group, 'value' end -describe Influxdb::Arel::Nodes::Limit do +describe InfluxDB::Arel::Nodes::Limit do it_should_behave_like :unary_node, :Limit, 'LIMIT value' end -describe Influxdb::Arel::Nodes::Fill do +describe InfluxDB::Arel::Nodes::Fill do it_should_behave_like :unary_node, :Fill, 'fill(value)' end -describe Influxdb::Arel::Nodes::Into do +describe InfluxDB::Arel::Nodes::Into do it_should_behave_like :unary_node, :Into, 'INTO value' end diff --git a/spec/lib/influxdb/arel/quoter/repository_spec.rb b/spec/lib/influx_db/arel/quoter/repository_spec.rb similarity index 68% rename from spec/lib/influxdb/arel/quoter/repository_spec.rb rename to spec/lib/influx_db/arel/quoter/repository_spec.rb index c695193..706c9c3 100644 --- a/spec/lib/influxdb/arel/quoter/repository_spec.rb +++ b/spec/lib/influx_db/arel/quoter/repository_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Influxdb::Arel::Quoter::Repository do - subject{ Influxdb::Arel::Quoter::Repository.new } +describe InfluxDB::Arel::Quoter::Repository do + subject{ InfluxDB::Arel::Quoter::Repository.new } before{ subject.add(String){|value| "quoted #{value}" } } diff --git a/spec/lib/influxdb/arel/quoter_spec.rb b/spec/lib/influx_db/arel/quoter_spec.rb similarity index 96% rename from spec/lib/influxdb/arel/quoter_spec.rb rename to spec/lib/influx_db/arel/quoter_spec.rb index 0624389..75c8874 100644 --- a/spec/lib/influxdb/arel/quoter_spec.rb +++ b/spec/lib/influx_db/arel/quoter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel::Quoter do +describe InfluxDB::Arel::Quoter do describe '#quote' do context 'with String' do specify{ expect(subject.quote('string')).to eq("'string'") } diff --git a/spec/lib/influxdb/arel/select_manager_spec.rb b/spec/lib/influx_db/arel/select_manager_spec.rb similarity index 82% rename from spec/lib/influxdb/arel/select_manager_spec.rb rename to spec/lib/influx_db/arel/select_manager_spec.rb index e703715..d41e3df 100644 --- a/spec/lib/influxdb/arel/select_manager_spec.rb +++ b/spec/lib/influx_db/arel/select_manager_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe Influxdb::Arel::SelectManager do - let(:manager){ Influxdb::Arel::SelectManager.new(:events) } +describe InfluxDB::Arel::SelectManager do + let(:manager){ InfluxDB::Arel::SelectManager.new(:events) } describe '#group' do context 'without block' do subject{ manager.group('time(1s)', 'name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Attribute, 'time(1s)'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -17,7 +17,7 @@ context 'with block' do subject{ manager.group{ [time('1s'), name, :type] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Time, '1s'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -27,7 +27,7 @@ context 'chaining' do subject{ manager.group('time(1s)').group('name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Attribute, 'time(1s)'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -39,7 +39,7 @@ context 'without block' do subject{ manager.group!('time(1s)', 'name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Attribute, 'time(1s)'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -49,7 +49,7 @@ context 'with block' do subject{ manager.group!{ [time('1s'), name, :type] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([ node(:Time, '1s'), node(:Attribute, 'name'), node(:Attribute, 'type') ]) } @@ -59,7 +59,7 @@ context 'chaining' do subject{ manager.group('time(1s)').group!('name', :type) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.group_values).to eq([node(:Attribute, 'name'), node(:Attribute, 'type')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events GROUP BY name, type') } end @@ -69,7 +69,7 @@ context 'with empty groups' do subject{ manager.fill(0) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.fill).to eq(node(:Fill, 0)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events') } end @@ -77,7 +77,7 @@ context 'filling empty values with integer' do subject{ manager.group('time(1s)').fill(0) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.fill).to eq(node(:Fill, 0)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events GROUP BY time(1s) fill(0)') } end @@ -85,7 +85,7 @@ context 'filling empty values with string' do subject{ manager.group('time(1s)').fill('empty') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.fill).to eq(node(:Fill, 'empty')) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events GROUP BY time(1s) fill('empty')") } end @@ -93,7 +93,7 @@ context 'filling empty values with sql node' do subject{ manager.group('time(1s)').fill(sql('name')) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.fill).to eq(node(:Fill, sql('name'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events GROUP BY time(1s) fill(name)") } end @@ -103,7 +103,7 @@ context 'with symbol' do subject{ manager.from(:table) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table') } end @@ -111,7 +111,7 @@ context 'with string' do subject{ manager.from('table') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table') } end @@ -119,7 +119,7 @@ context 'with block' do subject{ manager.from{ table } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table') } end @@ -127,7 +127,7 @@ context 'with regexp' do subject{ manager.from(/events\..*/) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'events')]) } specify{ expect(subject.ast.regexp).to eq(node(:Table, /events\..*/)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM /events\..*/') } @@ -136,7 +136,7 @@ context 'with several regexps' do subject{ manager.from(/events\..*/, /logs\..*/) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'events')]) } specify{ expect(subject.ast.regexp).to eq(node(:Table, /events\..*/)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM /events\..*/') } @@ -145,7 +145,7 @@ context 'with nil' do subject{ manager.from(nil) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'events')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events') } end @@ -153,7 +153,7 @@ context 'with several tables' do subject{ manager.from(:table1){ [table2, :table3] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table1'), node(:Table, 'table2'), node(:Table, 'table3')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1, table2, table3') } end @@ -161,7 +161,7 @@ context 'with several non unique tables' do subject{ manager.from(:table1){ [table1, :table1] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table1')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1') } end @@ -169,7 +169,7 @@ context 'chaining' do subject{ manager.from(:table1).from(:table2) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.tables).to eq([node(:Table, 'table2')]) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table2') } end @@ -181,7 +181,7 @@ context do subject{ manager.from{ join(:table1, :table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2') } end @@ -189,7 +189,7 @@ context do subject{ manager.from{ join(table1, table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2') } end @@ -197,7 +197,7 @@ context do subject{ manager.from{ join(table1.as(:alias1), table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, alias1, alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 AS alias1 INNER JOIN table2 AS alias2') } end @@ -205,7 +205,7 @@ context do subject{ manager.from(:table1){ join(:table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2') } end @@ -213,7 +213,7 @@ context do subject{ manager.from(:table1){ join(table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2') } end @@ -221,7 +221,7 @@ context do subject{ manager.from(:table1){ join(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2 AS alias2') } end @@ -229,7 +229,7 @@ context do subject{ manager.from{ table1.join(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'table1'), alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 INNER JOIN table2 AS alias2') } end @@ -237,7 +237,7 @@ context do subject{ manager.from{ table1.as(:alias1).join(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, alias1, alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 AS alias1 INNER JOIN table2 AS alias2') } end @@ -250,7 +250,7 @@ context do subject{ manager.from{ merge(:table1, :table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -258,7 +258,7 @@ context do subject{ manager.from{ merge(table1, table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -266,7 +266,7 @@ context do subject{ manager.from{ merge(table1.as(:alias1), table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, alias1, alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -274,7 +274,7 @@ context do subject{ manager.from(:table1){ merge(:table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -282,7 +282,7 @@ context do subject{ manager.from(:table1){ merge(table2) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), node(:Table, 'table2'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -290,7 +290,7 @@ context do subject{ manager.from(:table1){ merge(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -298,7 +298,7 @@ context do subject{ manager.from{ table1.merge(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'table1'), alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -306,7 +306,7 @@ context do subject{ manager.from{ table1.as(:alias1).merge(table2.as(:alias2)) } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, alias1, alias2)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM table1 MERGE table2') } end @@ -317,18 +317,18 @@ context 'with one table' do subject{ manager.join(:errors) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events INNER JOIN errors') } end context 'with two table' do context do - let(:manager){ Influxdb::Arel::SelectManager.new } + let(:manager){ InfluxDB::Arel::SelectManager.new } subject{ manager.join(:errors, :logs) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'errors'), node(:Table, 'logs'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM errors INNER JOIN logs') } end @@ -348,7 +348,7 @@ context 'without argument but with many series' do subject{ manager.from(:user_events, :errors).join } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM user_events INNER JOIN errors') } end @@ -361,7 +361,7 @@ context 'with merging' do subject{ manager.from(:user_events, :errors).merge.join } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM user_events INNER JOIN errors') } @@ -372,18 +372,18 @@ context 'with one table' do subject{ manager.merge(:errors) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events MERGE errors') } end context 'with two table' do context do - let(:manager){ Influxdb::Arel::SelectManager.new } + let(:manager){ InfluxDB::Arel::SelectManager.new } subject{ manager.merge(:errors, :logs) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'errors'), node(:Table, 'logs'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM errors MERGE logs') } end @@ -403,7 +403,7 @@ context 'without argument but with many tables' do subject{ manager.from(:user_events, :errors).merge } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM user_events MERGE errors') } end @@ -416,7 +416,7 @@ context 'with joining' do subject{ manager.from(:user_events, :errors).join.merge } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.merge).to eq(node(:Merge, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.ast.join).to eq(node(:Join, node(:Table, 'user_events'), node(:Table, 'errors'))) } specify{ expect(subject.to_sql).to eq('SELECT * FROM user_events INNER JOIN errors') } @@ -428,14 +428,14 @@ subject{ manager.select(:time){ [name, :age] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq(nodes) } specify{ expect(subject.to_sql).to eq('SELECT time, name, age FROM events') } context 'chaining' do subject{ manager.select(:time).select{ [name, :age] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq(nodes) } specify{ expect(subject.to_sql).to eq('SELECT time, name, age FROM events') } end @@ -446,14 +446,14 @@ subject{ manager.select!(:time){ [name, :age] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq(nodes) } specify{ expect(subject.to_sql).to eq('SELECT time, name, age FROM events') } context 'chaining' do subject{ manager.select(:time).select!{ [name, :age] } } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.select_values).to eq([node(:Attribute, 'name'), node(:Attribute, 'age')]) } specify{ expect(subject.to_sql).to eq('SELECT name, age FROM events') } end @@ -466,7 +466,7 @@ context 'when sort by ascending order' do subject{ manager.order(:asc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(asc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -474,7 +474,7 @@ context 'when sort by ascending order' do subject{ manager.order('asc') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(asc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -482,7 +482,7 @@ context 'when sort by ascending order' do subject{ manager.order(asc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(asc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -490,7 +490,7 @@ context 'when sort by descending order' do subject{ manager.order(:desc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(desc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -498,7 +498,7 @@ context 'when sort by descending order' do subject{ manager.order('desc') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(desc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -506,7 +506,7 @@ context 'when sort by descending order' do subject{ manager.order(desc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(desc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -514,7 +514,7 @@ describe 'chaining' do subject{ manager.order(desc).order(asc) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(asc) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -523,7 +523,7 @@ describe '#asc' do subject{ manager.asc } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -531,7 +531,7 @@ describe '#desc' do subject{ manager.desc } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'desc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -540,7 +540,7 @@ context 'from native order' do subject{ manager.invert_order } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -548,7 +548,7 @@ context 'from asc to desc' do subject{ manager.asc.invert_order } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'desc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER DESC') } end @@ -556,7 +556,7 @@ context 'from desc to asc' do subject{ manager.desc.invert_order } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.order_value).to eq(node(:Ordering, 'asc')) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events ORDER ASC') } end @@ -565,14 +565,14 @@ describe '#limit' do subject{ manager.limit(100) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.limit_value).to eq(node(:Limit, 100)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events LIMIT 100') } context 'chaining' do subject{ manager.limit(100).limit(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.limit_value).to eq(node(:Limit, 1)) } specify{ expect(subject.to_sql).to eq('SELECT * FROM events LIMIT 1') } end @@ -585,7 +585,7 @@ context 'with conditions as string' do subject{ manager.where("name = 'Undr'") } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([sql("name = 'Undr'")]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr'") } end @@ -593,7 +593,7 @@ context 'with conditions as sql leteral' do subject{ manager.where(sql("name = 'Undr'")) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([sql("name = 'Undr'")]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr'") } end @@ -601,7 +601,7 @@ context 'with conditions as Hash' do subject{ manager.where(name: 'Undr', age: 20) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([node(:And, [equality1, equality2])]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr' AND age = 20") } end @@ -609,7 +609,7 @@ context 'chaining' do subject{ manager.where(name: 'Undr').where(age: 20) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.where_values).to eq([equality1, equality2]) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events WHERE name = 'Undr' AND age = 20") } end @@ -619,7 +619,7 @@ context 'with string as argument' do subject{ manager.into('events.all') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.into).to eq(node(:Into, sql('events.all'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events INTO events.all") } end @@ -627,7 +627,7 @@ context 'with symbol as argument' do subject{ manager.into(:'events.all') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.into).to eq(node(:Into, sql('events.all'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events INTO events.all") } end @@ -635,7 +635,7 @@ context 'with sql node as argument' do subject{ manager.into(sql('events.all')) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.into).to eq(node(:Into, sql('events.all'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events INTO events.all") } end @@ -643,7 +643,7 @@ context 'fanout placeholder' do subject{ manager.into('events.[host]') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.into).to eq(node(:Into, sql('events.[host]'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events INTO events.[host]") } end @@ -651,7 +651,7 @@ context 'many series placeholder' do subject{ manager.into('events.:series_name') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::SelectManager) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::SelectManager) } specify{ expect(subject.ast.into).to eq(node(:Into, sql('events.:series_name'))) } specify{ expect(subject.to_sql).to eq("SELECT * FROM events INTO events.:series_name") } end diff --git a/spec/lib/influxdb/arel_spec.rb b/spec/lib/influx_db/arel_spec.rb similarity index 97% rename from spec/lib/influxdb/arel_spec.rb rename to spec/lib/influx_db/arel_spec.rb index c0d736e..4f78cf2 100644 --- a/spec/lib/influxdb/arel_spec.rb +++ b/spec/lib/influx_db/arel_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Influxdb::Arel do +describe InfluxDB::Arel do describe '.sql' do specify{ expect(subject.sql('time(1s)')).to eq(sql('time(1s)')) } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4475baf..24e70bd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,14 +6,14 @@ require 'bundler' Bundler.require(:default, :test) -require './lib/influxdb' +require './lib/influx_db' Dir["./spec/support/**/*.rb"].each{|f| require f } RSpec.configure do |config| config.mock_with :rspec - config.include Influxdb::Arel::RspecHelper + config.include InfluxDB::Arel::RspecHelper config.around :each do |example| begin diff --git a/spec/support/examples/infix_operation_node.rb b/spec/support/examples/infix_operation_node.rb index 2690388..56f103b 100644 --- a/spec/support/examples/infix_operation_node.rb +++ b/spec/support/examples/infix_operation_node.rb @@ -9,7 +9,7 @@ describe '#as' do subject{ described_node.as(:alias) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::As) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::As) } specify{ expect(subject.to_sql).to eq("(#{node_sql}) AS alias") } end end diff --git a/spec/support/examples/node_as.rb b/spec/support/examples/node_as.rb index 0407958..8d58b81 100644 --- a/spec/support/examples/node_as.rb +++ b/spec/support/examples/node_as.rb @@ -2,7 +2,7 @@ describe '#as' do subject{ described_node.as('alias') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::As) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::As) } specify{ expect(subject.to_sql).to eq("#{node_sql} AS alias") } end end diff --git a/spec/support/examples/node_boolean_predications.rb b/spec/support/examples/node_boolean_predications.rb index 555b7be..7e593bd 100644 --- a/spec/support/examples/node_boolean_predications.rb +++ b/spec/support/examples/node_boolean_predications.rb @@ -4,7 +4,7 @@ subject{ described_node.and(another_node) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::And) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::And) } specify{ expect(subject.children).to eq([described_node, another_node]) } specify{ expect(subject.to_sql).to eq("#{node_sql} AND node") } end @@ -14,7 +14,7 @@ subject{ described_node.or(another_node) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.value).to eq(node(:Or, described_node, another_node)) } specify{ expect(subject.to_sql).to eq("(#{node_sql} OR node)") } end diff --git a/spec/support/examples/node_expressions.rb b/spec/support/examples/node_expressions.rb index 83a7c94..954d89c 100644 --- a/spec/support/examples/node_expressions.rb +++ b/spec/support/examples/node_expressions.rb @@ -2,7 +2,7 @@ describe '#count' do subject{ described_node.count } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Count) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Count) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("COUNT(#{node_sql})") } end @@ -10,7 +10,7 @@ describe '#sun' do subject{ described_node.sum } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Sum) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Sum) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("SUM(#{node_sql})") } end @@ -18,7 +18,7 @@ describe '#max' do subject{ described_node.max } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Max) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Max) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MAX(#{node_sql})") } end @@ -26,7 +26,7 @@ describe '#min' do subject{ described_node.min } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Min) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Min) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MIN(#{node_sql})") } end @@ -34,7 +34,7 @@ describe '#mean' do subject{ described_node.mean } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Mean) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Mean) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MEAN(#{node_sql})") } end @@ -42,7 +42,7 @@ describe '#mode' do subject{ described_node.mode } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Mode) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Mode) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MODE(#{node_sql})") } end @@ -50,7 +50,7 @@ describe '#median' do subject{ described_node.median } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Median) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Median) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MEDIAN(#{node_sql})") } end @@ -58,7 +58,7 @@ describe '#mode' do subject{ described_node.mode } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Mode) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Mode) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("MODE(#{node_sql})") } end @@ -66,7 +66,7 @@ describe '#distinct' do subject{ described_node.distinct } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Distinct) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Distinct) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("DISTINCT(#{node_sql})") } end @@ -74,7 +74,7 @@ describe '#percentile' do subject{ described_node.percentile(95) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Percentile) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Percentile) } specify{ expect(subject.expressions).to eq([described_node, 95]) } specify{ expect(subject.to_sql).to eq("PERCENTILE(#{node_sql}, 95)") } end @@ -82,7 +82,7 @@ describe '#histogram' do subject{ described_node.histogram(2) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Histogram) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Histogram) } specify{ expect(subject.expressions).to eq([described_node, 2]) } specify{ expect(subject.to_sql).to eq("HISTOGRAM(#{node_sql}, 2)") } end @@ -90,7 +90,7 @@ describe '#derivative' do subject{ described_node.derivative } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Derivative) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Derivative) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("DERIVATIVE(#{node_sql})") } end @@ -98,7 +98,7 @@ describe '#stddev' do subject{ described_node.stddev } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Stddev) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Stddev) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("STDDEV(#{node_sql})") } end @@ -106,7 +106,7 @@ describe '#first' do subject{ described_node.first } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::First) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::First) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("FIRST(#{node_sql})") } end @@ -114,7 +114,7 @@ describe '#last' do subject{ described_node.last } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Last) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Last) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("LAST(#{node_sql})") } end @@ -122,7 +122,7 @@ describe '#difference' do subject{ described_node.difference } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Difference) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Difference) } specify{ expect(subject.expressions).to eq([described_node]) } specify{ expect(subject.to_sql).to eq("DIFFERENCE(#{node_sql})") } end @@ -130,7 +130,7 @@ describe '#top' do subject{ described_node.top(10) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Top) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Top) } specify{ expect(subject.expressions).to eq([described_node, 10]) } specify{ expect(subject.to_sql).to eq("TOP(#{node_sql}, 10)") } end @@ -138,7 +138,7 @@ describe '#bottom' do subject{ described_node.bottom(10) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Bottom) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Bottom) } specify{ expect(subject.expressions).to eq([described_node, 10]) } specify{ expect(subject.to_sql).to eq("BOTTOM(#{node_sql}, 10)") } end diff --git a/spec/support/examples/node_joining_merging.rb b/spec/support/examples/node_joining_merging.rb index e50eaa5..3fe0250 100644 --- a/spec/support/examples/node_joining_merging.rb +++ b/spec/support/examples/node_joining_merging.rb @@ -3,7 +3,7 @@ context 'with string' do subject{ described_node.join('table') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Join) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") } end @@ -11,7 +11,7 @@ context 'with symbol' do subject{ described_node.join(:table) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Join) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") } end @@ -19,7 +19,7 @@ context 'with node' do subject{ described_node.join(node(:Table, 'table')) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Join) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") } end @@ -29,7 +29,7 @@ context 'with string' do subject{ described_node.merge('table') } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Merge) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") } end @@ -37,7 +37,7 @@ context 'with symbol' do subject{ described_node.merge(:table) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Merge) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") } end @@ -45,7 +45,7 @@ context 'with node' do subject{ described_node.merge(node(:Table, 'table')) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Merge) } specify{ expect(subject.right).to eq(node(:Table, 'table')) } specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") } end diff --git a/spec/support/examples/node_math.rb b/spec/support/examples/node_math.rb index d3d361e..ffee8ba 100644 --- a/spec/support/examples/node_math.rb +++ b/spec/support/examples/node_math.rb @@ -2,28 +2,28 @@ describe '#+' do subject{ described_node + 10 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} + 10)") } end describe '#-' do subject{ described_node - 10 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} - 10)") } end describe '#/' do subject{ described_node / 10 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Division) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Division) } specify{ expect(subject.to_sql).to eq("#{node_sql} / 10") } end describe '#*' do subject{ described_node * 10 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Multiplication) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Multiplication) } specify{ expect(subject.to_sql).to eq("#{node_sql} * 10") } end end diff --git a/spec/support/examples/node_predications.rb b/spec/support/examples/node_predications.rb index 99a92e8..4c02eb3 100644 --- a/spec/support/examples/node_predications.rb +++ b/spec/support/examples/node_predications.rb @@ -2,7 +2,7 @@ describe '#not_eq' do subject{ described_node.not_eq(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::NotEqual) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::NotEqual) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} <> 1") } @@ -11,21 +11,21 @@ describe '#not_eq_any' do subject{ described_node.not_eq_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} <> 1 OR #{node_sql} <> 2)") } end describe '#not_eq_all' do subject{ described_node.not_eq_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} <> 1 AND #{node_sql} <> 2)") } end describe '#eq' do subject{ described_node.eq(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Equality) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Equality) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} = 1") } @@ -34,21 +34,21 @@ describe '#eq_any' do subject{ described_node.eq_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} = 1 OR #{node_sql} = 2)") } end describe '#eq_all' do subject{ described_node.eq_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} = 1 AND #{node_sql} = 2)") } end describe '#matches' do subject{ described_node.matches(/.*/) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Matches) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Matches) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(/.*/) } specify{ expect(subject.to_sql).to eq("#{node_sql} =~ /.*/") } @@ -57,21 +57,21 @@ describe '#matches_any' do subject{ described_node.matches_any([/\w*/, /\d*/]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} =~ /\\w*/ OR #{node_sql} =~ /\\d*/)") } end describe '#matches_all' do subject{ described_node.matches_all([/\w*/, /\d*/]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} =~ /\\w*/ AND #{node_sql} =~ /\\d*/)") } end describe '#does_not_match' do subject{ described_node.does_not_match(/.*/) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::DoesNotMatch) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::DoesNotMatch) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(/.*/) } specify{ expect(subject.to_sql).to eq("#{node_sql} !~ /.*/") } @@ -80,21 +80,21 @@ describe '#does_not_match_any' do subject{ described_node.does_not_match_any([/\w*/, /\d*/]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} !~ /\\w*/ OR #{node_sql} !~ /\\d*/)") } end describe '#does_not_match_all' do subject{ described_node.does_not_match_all([/\w*/, /\d*/]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} !~ /\\w*/ AND #{node_sql} !~ /\\d*/)") } end describe '#gteq' do subject{ described_node.gteq(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::GreaterThanOrEqual) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::GreaterThanOrEqual) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} >= 1") } @@ -103,21 +103,21 @@ describe '#gteq_any' do subject{ described_node.gteq_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} >= 1 OR #{node_sql} >= 2)") } end describe '#gteq_all' do subject{ described_node.gteq_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} >= 1 AND #{node_sql} >= 2)") } end describe '#gt' do subject{ described_node.gt(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::GreaterThan) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::GreaterThan) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} > 1") } @@ -126,21 +126,21 @@ describe '#gt_any' do subject{ described_node.gt_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} > 1 OR #{node_sql} > 2)") } end describe '#gt_all' do subject{ described_node.gt_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} > 1 AND #{node_sql} > 2)") } end describe '#lt' do subject{ described_node.lt(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::LessThan) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::LessThan) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} < 1") } @@ -149,21 +149,21 @@ describe '#lt_any' do subject{ described_node.lt_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} < 1 OR #{node_sql} < 2)") } end describe '#lt_all' do subject{ described_node.lt_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} < 1 AND #{node_sql} < 2)") } end describe '#lteq' do subject{ described_node.lteq(1) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::LessThanOrEqual) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::LessThanOrEqual) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} <= 1") } @@ -172,14 +172,14 @@ describe '#lteq_any' do subject{ described_node.lteq_any([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} <= 1 OR #{node_sql} <= 2)") } end describe '#lteq_all' do subject{ described_node.lteq_all([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Grouping) } specify{ expect(subject.to_sql).to eq("(#{node_sql} <= 1 AND #{node_sql} <= 2)") } end @@ -189,7 +189,7 @@ context 'with infinity range' do let(:expr){ -Float::INFINITY..Float::INFINITY } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Equality) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::Equality) } specify{ expect(subject.left).to eq(1) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("1 = 1") } @@ -198,7 +198,7 @@ context 'with endless range' do let(:expr){ 1..Float::INFINITY } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::GreaterThanOrEqual) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::GreaterThanOrEqual) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} >= 1") } @@ -207,7 +207,7 @@ context 'with startless range' do let(:expr){ -Float::INFINITY..1 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::LessThanOrEqual) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::LessThanOrEqual) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} <= 1") } @@ -216,7 +216,7 @@ context 'with startless range with exclided end' do let(:expr){ -Float::INFINITY...1 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::LessThan) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::LessThan) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq(1) } specify{ expect(subject.to_sql).to eq("#{node_sql} < 1") } @@ -225,21 +225,21 @@ context 'with range' do let(:expr){ -1..1 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::And) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::And) } specify{ expect(subject.to_sql).to eq("#{node_sql} >= -1 AND #{node_sql} <= 1") } end context 'with range with exclided end' do let(:expr){ -1...1 } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::And) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::And) } specify{ expect(subject.to_sql).to eq("#{node_sql} >= -1 AND #{node_sql} < 1") } end context 'with array' do subject{ described_node.in([1, 2]) } - specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::In) } + specify{ expect(subject).to be_instance_of(InfluxDB::Arel::Nodes::In) } specify{ expect(subject.left).to eq(described_node) } specify{ expect(subject.right).to eq([1, 2]) } specify{ expect(subject.to_sql).to eq("#{node_sql} IN (1, 2)") } diff --git a/spec/support/fabrics.rb b/spec/support/fabrics.rb index aebd7b0..7e87aea 100644 --- a/spec/support/fabrics.rb +++ b/spec/support/fabrics.rb @@ -1,4 +1,4 @@ -module Influxdb +module InfluxDB module Arel module RspecHelper def sql(value) @@ -6,15 +6,15 @@ def sql(value) end def node(class_name, *args) - Influxdb::Arel::Nodes.const_get(class_name).new(*args) + InfluxDB::Arel::Nodes.const_get(class_name).new(*args) end def builder(name = nil) - Influxdb::Arel::Builder.new(name) + InfluxDB::Arel::Builder.new(name) end def visitor - Influxdb::Arel::Visitor.new + InfluxDB::Arel::Visitor.new end end end