influxdb-arel 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/Gemfile +1 -0
  4. data/README.md +218 -124
  5. data/lib/influxdb/arel.rb +25 -16
  6. data/lib/influxdb/arel/builder.rb +209 -0
  7. data/lib/influxdb/arel/clauses.rb +6 -0
  8. data/lib/influxdb/arel/clauses/base.rb +34 -0
  9. data/lib/influxdb/arel/clauses/expressions.rb +75 -0
  10. data/lib/influxdb/arel/clauses/from_clause.rb +45 -0
  11. data/lib/influxdb/arel/clauses/group_clause.rb +34 -0
  12. data/lib/influxdb/arel/clauses/select_clause.rb +37 -0
  13. data/lib/influxdb/arel/clauses/where_clause.rb +102 -0
  14. data/lib/influxdb/arel/core_extensions.rb +5 -21
  15. data/lib/influxdb/arel/delete_manager.rb +50 -0
  16. data/lib/influxdb/arel/extensions.rb +6 -0
  17. data/lib/influxdb/arel/extensions/alias_predication.rb +11 -0
  18. data/lib/influxdb/arel/extensions/boolean_predications.rb +15 -0
  19. data/lib/influxdb/arel/extensions/expressions.rb +75 -0
  20. data/lib/influxdb/arel/extensions/joining_merging.rb +21 -0
  21. data/lib/influxdb/arel/extensions/math.rb +23 -0
  22. data/lib/influxdb/arel/extensions/predications.rb +144 -0
  23. data/lib/influxdb/arel/nodes.rb +7 -14
  24. data/lib/influxdb/arel/nodes/attribute.rb +20 -0
  25. data/lib/influxdb/arel/nodes/binary.rb +4 -3
  26. data/lib/influxdb/arel/nodes/delete_statement.rb +37 -0
  27. data/lib/influxdb/arel/nodes/duration.rb +3 -3
  28. data/lib/influxdb/arel/nodes/function.rb +2 -2
  29. data/lib/influxdb/arel/nodes/grouping.rb +3 -3
  30. data/lib/influxdb/arel/nodes/infix_operation.rb +11 -4
  31. data/lib/influxdb/arel/nodes/merge.rb +13 -0
  32. data/lib/influxdb/arel/nodes/node.rb +18 -6
  33. data/lib/influxdb/arel/nodes/now.rb +1 -1
  34. data/lib/influxdb/arel/nodes/ordering.rb +15 -0
  35. data/lib/influxdb/arel/nodes/select_statement.rb +10 -8
  36. data/lib/influxdb/arel/nodes/sql_literal.rb +5 -8
  37. data/lib/influxdb/arel/nodes/table.rb +19 -0
  38. data/lib/influxdb/arel/nodes/table_alias.rb +2 -4
  39. data/lib/influxdb/arel/nodes/unary.rb +6 -1
  40. data/lib/influxdb/arel/quoter.rb +85 -0
  41. data/lib/influxdb/arel/select_manager.rb +111 -64
  42. data/lib/influxdb/arel/tree_manager.rb +15 -5
  43. data/lib/influxdb/arel/version.rb +1 -1
  44. data/lib/influxdb/arel/visitor.rb +96 -126
  45. data/lib/influxdb/arel/visitor/delete_statement.rb +32 -0
  46. data/lib/influxdb/arel/visitor/select_statement.rb +59 -0
  47. data/lib/influxdb/arel/visitor/where_statement.rb +14 -0
  48. data/spec/lib/influxdb/arel/builder_spec.rb +173 -0
  49. data/spec/lib/influxdb/arel/core_extensions_spec.rb +0 -21
  50. data/spec/lib/influxdb/arel/nodes/and_spec.rb +6 -9
  51. data/spec/lib/influxdb/arel/nodes/attribute_spec.rb +21 -0
  52. data/spec/lib/influxdb/arel/nodes/binary_spec.rb +0 -4
  53. data/spec/lib/influxdb/arel/nodes/duration_spec.rb +1 -0
  54. data/spec/lib/influxdb/arel/nodes/in_spec.rb +1 -0
  55. data/spec/lib/influxdb/arel/nodes/infix_operation_spec.rb +17 -0
  56. data/spec/lib/influxdb/arel/nodes/merge_spec.rb +25 -0
  57. data/spec/lib/influxdb/arel/nodes/now_spec.rb +1 -0
  58. data/spec/lib/influxdb/arel/nodes/ordering_spec.rb +19 -0
  59. data/spec/lib/influxdb/arel/nodes/sql_literal_spec.rb +1 -5
  60. data/spec/lib/influxdb/arel/nodes/table_alias_spec.rb +3 -10
  61. data/spec/lib/influxdb/arel/nodes/table_spec.rb +8 -0
  62. data/spec/lib/influxdb/arel/nodes/unary_spec.rb +0 -4
  63. data/spec/lib/influxdb/arel/quoter/repository_spec.rb +10 -0
  64. data/spec/lib/influxdb/arel/quoter_spec.rb +33 -0
  65. data/spec/lib/influxdb/arel/select_manager_spec.rb +356 -156
  66. data/spec/lib/influxdb/arel_spec.rb +22 -0
  67. data/spec/spec_helper.rb +15 -0
  68. data/spec/support/examples/binary_node.rb +1 -0
  69. data/spec/support/examples/function_node.rb +1 -0
  70. data/spec/support/examples/infix_operation_node.rb +15 -0
  71. data/spec/support/examples/node_boolean_predications.rb +21 -0
  72. data/spec/support/examples/node_joining_merging.rb +53 -0
  73. data/spec/support/examples/unary_node.rb +1 -0
  74. data/spec/support/fabrics.rb +3 -3
  75. metadata +49 -11
  76. data/lib/influxdb/arel/alias_predication.rb +0 -9
  77. data/lib/influxdb/arel/attributes.rb +0 -1
  78. data/lib/influxdb/arel/attributes/attribute.rb +0 -74
  79. data/lib/influxdb/arel/expressions.rb +0 -73
  80. data/lib/influxdb/arel/math.rb +0 -21
  81. data/lib/influxdb/arel/predications.rb +0 -137
  82. data/lib/influxdb/arel/table.rb +0 -219
  83. data/spec/lib/influxdb/arel/table_spec.rb +0 -193
@@ -8,4 +8,26 @@ describe Influxdb::Arel do
8
8
  describe '.star' do
9
9
  specify{ expect(subject.star).to eq(sql('*')) }
10
10
  end
11
+
12
+ describe '.arelize' do
13
+ let(:array){ ['string', :symbol, node(:Now)] }
14
+
15
+ context 'without block' do
16
+ specify{ expect(subject.arelize('string')).to eq(sql('string')) }
17
+ specify{ expect(subject.arelize(:symbol)).to eq(sql(:symbol)) }
18
+ specify{ expect(subject.arelize(node(:Now))).to eq(node(:Now)) }
19
+ specify{ expect(subject.arelize(array)).to eq([sql('string'), sql(:symbol), node(:Now)]) }
20
+ end
21
+
22
+ context 'with block' do
23
+ let(:block){ ->(e){ node(:Table, e) } }
24
+
25
+ specify{ expect(subject.arelize('string', &block)).to eq(node(:Table, 'string')) }
26
+ specify{ expect(subject.arelize(:symbol, &block)).to eq(node(:Table, :symbol)) }
27
+ specify{ expect(subject.arelize(node(:Now), &block)).to eq(node(:Now)) }
28
+ specify{
29
+ expect(subject.arelize(array, &block)).to eq([node(:Table, 'string'), node(:Table, :symbol), node(:Now)])
30
+ }
31
+ end
32
+ end
11
33
  end
@@ -1,6 +1,12 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
1
6
  require 'bundler'
2
7
  Bundler.require(:default, :test)
3
8
 
9
+
4
10
  Dir["./spec/support/**/*.rb"].each { |f| require f }
5
11
 
6
12
  RSpec.configure do |config|
@@ -8,6 +14,15 @@ RSpec.configure do |config|
8
14
 
9
15
  config.include Influxdb::Arel::RspecHelper
10
16
 
17
+ config.around :each do |example|
18
+ begin
19
+ old_tz, ENV['TZ'] = ENV['TZ'], 'Europe/Moscow'
20
+ example.run
21
+ ensure
22
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
23
+ end
24
+ end
25
+
11
26
  config.around :each, time_freeze: ->(v){ v.is_a?(Date) || v.is_a?(Time) || v.is_a?(String) } do |example|
12
27
  datetime = if example.metadata[:time_freeze].is_a?(String)
13
28
  DateTime.parse(example.metadata[:time_freeze])
@@ -2,6 +2,7 @@ shared_examples_for :binary_node do |klass, node_sql = nil|
2
2
  let(:described_node){ node(klass, sql('left'), sql('right')) }
3
3
 
4
4
  it_should_behave_like :node_to_sql, node_sql if node_sql
5
+ it_should_behave_like :node_boolean_predications, node_sql if node_sql
5
6
 
6
7
  describe '#eql?' do
7
8
  specify{ expect(described_node.eql?(node(klass, sql('left'), sql('right')))).to be_truthy }
@@ -6,6 +6,7 @@ shared_examples_for :function_node do |klass, node_sql, args = []|
6
6
  it_should_behave_like :node_to_sql, node_sql
7
7
  it_should_behave_like :node_as, node_sql
8
8
  it_should_behave_like :node_math, node_sql
9
+ it_should_behave_like :node_boolean_predications, node_sql
9
10
 
10
11
  describe '#eql?' do
11
12
  specify{ expect(described_node.eql?(node(klass, expressions))).to be_truthy }
@@ -0,0 +1,15 @@
1
+ shared_examples_for :infix_operation_node do |klass, node_sql|
2
+ let(:described_node){ node(klass, sql('left'), sql('right')) }
3
+
4
+ it_should_behave_like :binary_node, klass, node_sql
5
+ it_should_behave_like :node_expressions, node_sql
6
+ it_should_behave_like :node_predications, node_sql
7
+ it_should_behave_like :node_math, node_sql
8
+
9
+ describe '#as' do
10
+ subject{ described_node.as(:alias) }
11
+
12
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::As) }
13
+ specify{ expect(subject.to_sql).to eq("(#{node_sql}) AS alias") }
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ shared_examples_for :node_boolean_predications do |node_sql|
2
+ describe '#and' do
3
+ let(:another_node){ sql('node') }
4
+
5
+ subject{ described_node.and(another_node) }
6
+
7
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::And) }
8
+ specify{ expect(subject.children).to eq([described_node, another_node]) }
9
+ specify{ expect(subject.to_sql).to eq("#{node_sql} AND node") }
10
+ end
11
+
12
+ describe '#or' do
13
+ let(:another_node){ sql('node') }
14
+
15
+ subject{ described_node.or(another_node) }
16
+
17
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Grouping) }
18
+ specify{ expect(subject.value).to eq(node(:Or, described_node, another_node)) }
19
+ specify{ expect(subject.to_sql).to eq("(#{node_sql} OR node)") }
20
+ end
21
+ end
@@ -0,0 +1,53 @@
1
+ shared_examples_for :node_joining_merging do |node_sql|
2
+ describe '#join' do
3
+ context 'with string' do
4
+ subject{ described_node.join('table') }
5
+
6
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) }
7
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
8
+ specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") }
9
+ end
10
+
11
+ context 'with symbol' do
12
+ subject{ described_node.join(:table) }
13
+
14
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) }
15
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
16
+ specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") }
17
+ end
18
+
19
+ context 'with node' do
20
+ subject{ described_node.join(node(:Table, 'table')) }
21
+
22
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Join) }
23
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
24
+ specify{ expect(subject.to_sql).to eq("#{node_sql} INNER JOIN table") }
25
+ end
26
+ end
27
+
28
+ describe '#merge' do
29
+ context 'with string' do
30
+ subject{ described_node.merge('table') }
31
+
32
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) }
33
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
34
+ specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") }
35
+ end
36
+
37
+ context 'with symbol' do
38
+ subject{ described_node.merge(:table) }
39
+
40
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) }
41
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
42
+ specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") }
43
+ end
44
+
45
+ context 'with node' do
46
+ subject{ described_node.merge(node(:Table, 'table')) }
47
+
48
+ specify{ expect(subject).to be_instance_of(Influxdb::Arel::Nodes::Merge) }
49
+ specify{ expect(subject.right).to eq(node(:Table, 'table')) }
50
+ specify{ expect(subject.to_sql).to eq("#{node_sql} MERGE table") }
51
+ end
52
+ end
53
+ end
@@ -2,6 +2,7 @@ shared_examples_for :unary_node do |klass, node_sql = nil|
2
2
  let(:described_node){ node(klass, sql('value')) }
3
3
 
4
4
  it_should_behave_like :node_to_sql, node_sql if node_sql
5
+ it_should_behave_like :node_boolean_predications, node_sql if node_sql
5
6
 
6
7
  describe '#eql?' do
7
8
  specify{ expect(described_node.eql?(node(klass, sql('value')))).to be_truthy }
@@ -2,15 +2,15 @@ module Influxdb
2
2
  module Arel
3
3
  module RspecHelper
4
4
  def sql(value)
5
- node('SqlLiteral', value)
5
+ node('SqlLiteral', value.to_s)
6
6
  end
7
7
 
8
8
  def node(class_name, *args)
9
9
  Influxdb::Arel::Nodes.const_get(class_name).new(*args)
10
10
  end
11
11
 
12
- def table(name)
13
- Influxdb::Arel::Table.new(name)
12
+ def builder(name = nil)
13
+ Influxdb::Arel::Builder.new(name)
14
14
  end
15
15
 
16
16
  def visitor
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb-arel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - undr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,55 +70,83 @@ files:
70
70
  - lib/influxdb-arel.rb
71
71
  - lib/influxdb.rb
72
72
  - lib/influxdb/arel.rb
73
- - lib/influxdb/arel/alias_predication.rb
74
- - lib/influxdb/arel/attributes.rb
75
- - lib/influxdb/arel/attributes/attribute.rb
73
+ - lib/influxdb/arel/builder.rb
74
+ - lib/influxdb/arel/clauses.rb
75
+ - lib/influxdb/arel/clauses/base.rb
76
+ - lib/influxdb/arel/clauses/expressions.rb
77
+ - lib/influxdb/arel/clauses/from_clause.rb
78
+ - lib/influxdb/arel/clauses/group_clause.rb
79
+ - lib/influxdb/arel/clauses/select_clause.rb
80
+ - lib/influxdb/arel/clauses/where_clause.rb
76
81
  - lib/influxdb/arel/core_extensions.rb
77
- - lib/influxdb/arel/expressions.rb
78
- - lib/influxdb/arel/math.rb
82
+ - lib/influxdb/arel/delete_manager.rb
83
+ - lib/influxdb/arel/extensions.rb
84
+ - lib/influxdb/arel/extensions/alias_predication.rb
85
+ - lib/influxdb/arel/extensions/boolean_predications.rb
86
+ - lib/influxdb/arel/extensions/expressions.rb
87
+ - lib/influxdb/arel/extensions/joining_merging.rb
88
+ - lib/influxdb/arel/extensions/math.rb
89
+ - lib/influxdb/arel/extensions/predications.rb
79
90
  - lib/influxdb/arel/nodes.rb
80
91
  - lib/influxdb/arel/nodes/and.rb
92
+ - lib/influxdb/arel/nodes/attribute.rb
81
93
  - lib/influxdb/arel/nodes/binary.rb
94
+ - lib/influxdb/arel/nodes/delete_statement.rb
82
95
  - lib/influxdb/arel/nodes/duration.rb
83
96
  - lib/influxdb/arel/nodes/equality.rb
84
97
  - lib/influxdb/arel/nodes/function.rb
85
98
  - lib/influxdb/arel/nodes/grouping.rb
86
99
  - lib/influxdb/arel/nodes/in.rb
87
100
  - lib/influxdb/arel/nodes/infix_operation.rb
101
+ - lib/influxdb/arel/nodes/merge.rb
88
102
  - lib/influxdb/arel/nodes/node.rb
89
103
  - lib/influxdb/arel/nodes/now.rb
104
+ - lib/influxdb/arel/nodes/ordering.rb
90
105
  - lib/influxdb/arel/nodes/select_statement.rb
91
106
  - lib/influxdb/arel/nodes/sql_literal.rb
107
+ - lib/influxdb/arel/nodes/table.rb
92
108
  - lib/influxdb/arel/nodes/table_alias.rb
93
109
  - lib/influxdb/arel/nodes/time.rb
94
110
  - lib/influxdb/arel/nodes/unary.rb
95
- - lib/influxdb/arel/predications.rb
111
+ - lib/influxdb/arel/quoter.rb
96
112
  - lib/influxdb/arel/select_manager.rb
97
- - lib/influxdb/arel/table.rb
98
113
  - lib/influxdb/arel/tree_manager.rb
99
114
  - lib/influxdb/arel/version.rb
100
115
  - lib/influxdb/arel/visitor.rb
116
+ - lib/influxdb/arel/visitor/delete_statement.rb
117
+ - lib/influxdb/arel/visitor/select_statement.rb
118
+ - lib/influxdb/arel/visitor/where_statement.rb
119
+ - spec/lib/influxdb/arel/builder_spec.rb
101
120
  - spec/lib/influxdb/arel/core_extensions_spec.rb
102
121
  - spec/lib/influxdb/arel/nodes/and_spec.rb
122
+ - spec/lib/influxdb/arel/nodes/attribute_spec.rb
103
123
  - spec/lib/influxdb/arel/nodes/binary_spec.rb
104
124
  - spec/lib/influxdb/arel/nodes/duration_spec.rb
105
125
  - spec/lib/influxdb/arel/nodes/equality_spec.rb
106
126
  - spec/lib/influxdb/arel/nodes/function_spec.rb
107
127
  - spec/lib/influxdb/arel/nodes/grouping_spec.rb
108
128
  - spec/lib/influxdb/arel/nodes/in_spec.rb
129
+ - spec/lib/influxdb/arel/nodes/infix_operation_spec.rb
130
+ - spec/lib/influxdb/arel/nodes/merge_spec.rb
109
131
  - spec/lib/influxdb/arel/nodes/now_spec.rb
132
+ - spec/lib/influxdb/arel/nodes/ordering_spec.rb
110
133
  - spec/lib/influxdb/arel/nodes/sql_literal_spec.rb
111
134
  - spec/lib/influxdb/arel/nodes/table_alias_spec.rb
135
+ - spec/lib/influxdb/arel/nodes/table_spec.rb
112
136
  - spec/lib/influxdb/arel/nodes/time_spec.rb
113
137
  - spec/lib/influxdb/arel/nodes/unary_spec.rb
138
+ - spec/lib/influxdb/arel/quoter/repository_spec.rb
139
+ - spec/lib/influxdb/arel/quoter_spec.rb
114
140
  - spec/lib/influxdb/arel/select_manager_spec.rb
115
- - spec/lib/influxdb/arel/table_spec.rb
116
141
  - spec/lib/influxdb/arel_spec.rb
117
142
  - spec/spec_helper.rb
118
143
  - spec/support/examples/binary_node.rb
119
144
  - spec/support/examples/function_node.rb
145
+ - spec/support/examples/infix_operation_node.rb
120
146
  - spec/support/examples/node_as.rb
147
+ - spec/support/examples/node_boolean_predications.rb
121
148
  - spec/support/examples/node_expressions.rb
149
+ - spec/support/examples/node_joining_merging.rb
122
150
  - spec/support/examples/node_math.rb
123
151
  - spec/support/examples/node_predications.rb
124
152
  - spec/support/examples/node_to_sql.rb
@@ -149,27 +177,37 @@ signing_key:
149
177
  specification_version: 4
150
178
  summary: Influxdb SQL AST manager.
151
179
  test_files:
180
+ - spec/lib/influxdb/arel/builder_spec.rb
152
181
  - spec/lib/influxdb/arel/core_extensions_spec.rb
153
182
  - spec/lib/influxdb/arel/nodes/and_spec.rb
183
+ - spec/lib/influxdb/arel/nodes/attribute_spec.rb
154
184
  - spec/lib/influxdb/arel/nodes/binary_spec.rb
155
185
  - spec/lib/influxdb/arel/nodes/duration_spec.rb
156
186
  - spec/lib/influxdb/arel/nodes/equality_spec.rb
157
187
  - spec/lib/influxdb/arel/nodes/function_spec.rb
158
188
  - spec/lib/influxdb/arel/nodes/grouping_spec.rb
159
189
  - spec/lib/influxdb/arel/nodes/in_spec.rb
190
+ - spec/lib/influxdb/arel/nodes/infix_operation_spec.rb
191
+ - spec/lib/influxdb/arel/nodes/merge_spec.rb
160
192
  - spec/lib/influxdb/arel/nodes/now_spec.rb
193
+ - spec/lib/influxdb/arel/nodes/ordering_spec.rb
161
194
  - spec/lib/influxdb/arel/nodes/sql_literal_spec.rb
162
195
  - spec/lib/influxdb/arel/nodes/table_alias_spec.rb
196
+ - spec/lib/influxdb/arel/nodes/table_spec.rb
163
197
  - spec/lib/influxdb/arel/nodes/time_spec.rb
164
198
  - spec/lib/influxdb/arel/nodes/unary_spec.rb
199
+ - spec/lib/influxdb/arel/quoter/repository_spec.rb
200
+ - spec/lib/influxdb/arel/quoter_spec.rb
165
201
  - spec/lib/influxdb/arel/select_manager_spec.rb
166
- - spec/lib/influxdb/arel/table_spec.rb
167
202
  - spec/lib/influxdb/arel_spec.rb
168
203
  - spec/spec_helper.rb
169
204
  - spec/support/examples/binary_node.rb
170
205
  - spec/support/examples/function_node.rb
206
+ - spec/support/examples/infix_operation_node.rb
171
207
  - spec/support/examples/node_as.rb
208
+ - spec/support/examples/node_boolean_predications.rb
172
209
  - spec/support/examples/node_expressions.rb
210
+ - spec/support/examples/node_joining_merging.rb
173
211
  - spec/support/examples/node_math.rb
174
212
  - spec/support/examples/node_predications.rb
175
213
  - spec/support/examples/node_to_sql.rb
@@ -1,9 +0,0 @@
1
- module Influxdb
2
- module Arel
3
- module AliasPredication
4
- def as(other)
5
- Nodes::As.new(self, Arel.sql(other.to_s))
6
- end
7
- end
8
- end
9
- end
@@ -1 +0,0 @@
1
- require 'influxdb/arel/attributes/attribute'
@@ -1,74 +0,0 @@
1
- module Influxdb
2
- module Arel
3
- module Attributes
4
- class Attribute < Struct.new(:relation, :name)
5
- include Expressions
6
- include Predications
7
- include AliasPredication
8
- include Math
9
-
10
- def self.encode(value)
11
- "'#{value.to_s}'"
12
- end
13
- end
14
-
15
- class Time < Attribute
16
- def self.encode(value)
17
- value.to_i * 1_000_000
18
- end
19
- end
20
-
21
- class Date < Time; end
22
- class DateTime < Time; end
23
-
24
- class BigDecimal < Attribute
25
- def self.encode(value)
26
- value.to_s('F')
27
- end
28
- end
29
-
30
- class Boolean < Attribute
31
- def self.encode(value)
32
- value.inspect
33
- end
34
- end
35
-
36
- class FalseClass < Boolean; end
37
- class TrueClass < Boolean; end
38
-
39
- class Float < Attribute
40
- def self.encode(value)
41
- value
42
- end
43
- end
44
-
45
- class Integer < Attribute
46
- def self.encode(value)
47
- value
48
- end
49
- end
50
-
51
- class Regexp < Attribute
52
- def self.encode(value)
53
- value.inspect
54
- end
55
- end
56
-
57
- class Hash < Attribute
58
- def self.encode(value)
59
- value = value.to_json if value.respond_to?(:to_json)
60
- super(value)
61
- end
62
- end
63
-
64
- class NilClass < Attribute
65
- def self.encode(value)
66
- 'null'
67
- end
68
- end
69
- end
70
-
71
- Attribute = Attributes::Attribute
72
- end
73
- end
74
-
@@ -1,73 +0,0 @@
1
- module Influxdb
2
- module Arel
3
- module Expressions
4
- def count
5
- Nodes::Count.new([self])
6
- end
7
-
8
- def sum
9
- Nodes::Sum.new([self])
10
- end
11
-
12
- def max
13
- Nodes::Max.new([self])
14
- end
15
-
16
- def min
17
- Nodes::Min.new([self])
18
- end
19
-
20
- def mean
21
- Nodes::Mean.new([self])
22
- end
23
-
24
- def mode
25
- Nodes::Mode.new([self])
26
- end
27
-
28
- def median
29
- Nodes::Median.new([self])
30
- end
31
-
32
- def distinct
33
- Nodes::Distinct.new([self])
34
- end
35
-
36
- def percentile(nth)
37
- Nodes::Percentile.new([self, nth])
38
- end
39
-
40
- def histogram(bucket_size = nil)
41
- Nodes::Histogram.new([self, bucket_size || 1.0])
42
- end
43
-
44
- def derivative
45
- Nodes::Derivative.new([self])
46
- end
47
-
48
- def stddev
49
- Nodes::Stddev.new([self])
50
- end
51
-
52
- def first
53
- Nodes::First.new([self])
54
- end
55
-
56
- def last
57
- Nodes::Last.new([self])
58
- end
59
-
60
- def difference
61
- Nodes::Difference.new([self])
62
- end
63
-
64
- def top(size)
65
- Nodes::Top.new([self, size])
66
- end
67
-
68
- def bottom(size)
69
- Nodes::Bottom.new([self, size])
70
- end
71
- end
72
- end
73
- end