clickhouse 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +172 -0
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/clickhouse.gemspec +27 -0
- data/lib/clickhouse.rb +42 -0
- data/lib/clickhouse/connection.rb +23 -0
- data/lib/clickhouse/connection/client.rb +65 -0
- data/lib/clickhouse/connection/logger.rb +12 -0
- data/lib/clickhouse/connection/query.rb +160 -0
- data/lib/clickhouse/connection/query/result_row.rb +18 -0
- data/lib/clickhouse/connection/query/result_set.rb +101 -0
- data/lib/clickhouse/connection/query/table.rb +50 -0
- data/lib/clickhouse/error.rb +18 -0
- data/lib/clickhouse/version.rb +7 -0
- data/script/console +58 -0
- data/test/test_helper.rb +15 -0
- data/test/test_helper/coverage.rb +16 -0
- data/test/test_helper/minitest.rb +13 -0
- data/test/test_helper/simple_connection.rb +12 -0
- data/test/unit/connection/query/test_result_row.rb +36 -0
- data/test/unit/connection/query/test_result_set.rb +196 -0
- data/test/unit/connection/query/test_table.rb +39 -0
- data/test/unit/connection/test_client.rb +131 -0
- data/test/unit/connection/test_logger.rb +35 -0
- data/test/unit/connection/test_query.rb +391 -0
- data/test/unit/test_clickhouse.rb +91 -0
- data/test/unit/test_connection.rb +44 -0
- metadata +199 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
class TestClickhouse < MiniTest::Test
|
5
|
+
|
6
|
+
describe Clickhouse do
|
7
|
+
it "has the current version" do
|
8
|
+
version = File.read(path("VERSION")).strip
|
9
|
+
assert_equal version, Clickhouse::VERSION
|
10
|
+
assert File.read(path "CHANGELOG.md").include?("Version #{version} ")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".logger=" do
|
14
|
+
it "stores the passed value as the instance variable :@logger" do
|
15
|
+
Clickhouse.logger = (logger = mock)
|
16
|
+
assert_equal logger, Clickhouse.instance_variable_get(:@logger)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".logger" do
|
21
|
+
it "returns its instance variable :@logger" do
|
22
|
+
Clickhouse.instance_variable_set :@logger, (logger = mock)
|
23
|
+
assert_equal logger, Clickhouse.logger
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".configurations=" do
|
28
|
+
it "stores the passed hash as the instance variable :@configurations" do
|
29
|
+
Clickhouse.configurations = (configurations = {})
|
30
|
+
assert_equal configurations, Clickhouse.instance_variable_get(:@configurations)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "stringifies the passed hash" do
|
34
|
+
Clickhouse.configurations = {:a => "b"}
|
35
|
+
assert_equal({"a" => "b"}, Clickhouse.instance_variable_get(:@configurations))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".configurations" do
|
40
|
+
it "returns its instance variable :@configurations" do
|
41
|
+
Clickhouse.instance_variable_set :@configurations, (configurations = mock)
|
42
|
+
assert_equal configurations, Clickhouse.configurations
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe ".establish_connection" do
|
47
|
+
describe "when valid" do
|
48
|
+
before do
|
49
|
+
@connection = mock
|
50
|
+
@connection.expects(:connect!)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "accepts configuration hashes" do
|
54
|
+
config = {"host" => "localhost"}
|
55
|
+
Clickhouse::Connection.expects(:new).with(config).returns(@connection)
|
56
|
+
Clickhouse.establish_connection config
|
57
|
+
end
|
58
|
+
|
59
|
+
it "accepts configuration names" do
|
60
|
+
config = {"host" => "localhost"}
|
61
|
+
Clickhouse.instance_variable_set(:@configurations, {"foo" => config})
|
62
|
+
Clickhouse::Connection.expects(:new).with(config).returns(@connection)
|
63
|
+
Clickhouse.establish_connection "foo"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "when invalid" do
|
68
|
+
it "denies non-configuration arguments" do
|
69
|
+
assert_raises Clickhouse::InvalidConnectionError do
|
70
|
+
Clickhouse.establish_connection 123
|
71
|
+
end
|
72
|
+
assert_raises Clickhouse::InvalidConnectionError do
|
73
|
+
Clickhouse.establish_connection true
|
74
|
+
end
|
75
|
+
assert_raises Clickhouse::InvalidConnectionError do
|
76
|
+
Clickhouse.establish_connection "foo"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".connection" do
|
83
|
+
it "returns its instance variable :@connection" do
|
84
|
+
Clickhouse.instance_variable_set :@connection, (connection = mock)
|
85
|
+
assert_equal connection, Clickhouse.connection
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
class TestConnection < MiniTest::Test
|
5
|
+
|
6
|
+
describe Clickhouse::Connection do
|
7
|
+
before do
|
8
|
+
@connection = Clickhouse::Connection.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "included modules" do
|
12
|
+
it "includes all Clickhouse::Connection modules" do
|
13
|
+
assert_equal true, @connection.class.included_modules.include?(Clickhouse::Connection::Client)
|
14
|
+
assert_equal true, @connection.class.included_modules.include?(Clickhouse::Connection::Logger)
|
15
|
+
assert_equal true, @connection.class.included_modules.include?(Clickhouse::Connection::Query)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#initialize" do
|
20
|
+
describe "when not passing a configuration" do
|
21
|
+
it "uses a default configuration" do
|
22
|
+
assert_equal({
|
23
|
+
:scheme => "http",
|
24
|
+
:host => "localhost",
|
25
|
+
:port => 8123
|
26
|
+
}, @connection.instance_variable_get(:@config))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "when passing a configuration" do
|
31
|
+
it "overrides the default configuration" do
|
32
|
+
connection = Clickhouse::Connection.new :scheme => "https", "host" => "19.82.8.1"
|
33
|
+
assert_equal({
|
34
|
+
:scheme => "https",
|
35
|
+
:host => "19.82.8.1",
|
36
|
+
:port => 8123
|
37
|
+
}, connection.instance_variable_get(:@config))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clickhouse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Engel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dotenv
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mocha
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A Ruby database driver for Clickhouse
|
126
|
+
email:
|
127
|
+
- pm_engel@icloud.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
134
|
+
- CHANGELOG.md
|
135
|
+
- Gemfile
|
136
|
+
- MIT-LICENSE
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- VERSION
|
140
|
+
- clickhouse.gemspec
|
141
|
+
- lib/clickhouse.rb
|
142
|
+
- lib/clickhouse/connection.rb
|
143
|
+
- lib/clickhouse/connection/client.rb
|
144
|
+
- lib/clickhouse/connection/logger.rb
|
145
|
+
- lib/clickhouse/connection/query.rb
|
146
|
+
- lib/clickhouse/connection/query/result_row.rb
|
147
|
+
- lib/clickhouse/connection/query/result_set.rb
|
148
|
+
- lib/clickhouse/connection/query/table.rb
|
149
|
+
- lib/clickhouse/error.rb
|
150
|
+
- lib/clickhouse/version.rb
|
151
|
+
- script/console
|
152
|
+
- test/test_helper.rb
|
153
|
+
- test/test_helper/coverage.rb
|
154
|
+
- test/test_helper/minitest.rb
|
155
|
+
- test/test_helper/simple_connection.rb
|
156
|
+
- test/unit/connection/query/test_result_row.rb
|
157
|
+
- test/unit/connection/query/test_result_set.rb
|
158
|
+
- test/unit/connection/query/test_table.rb
|
159
|
+
- test/unit/connection/test_client.rb
|
160
|
+
- test/unit/connection/test_logger.rb
|
161
|
+
- test/unit/connection/test_query.rb
|
162
|
+
- test/unit/test_clickhouse.rb
|
163
|
+
- test/unit/test_connection.rb
|
164
|
+
homepage: https://github.com/archan937/clickhouse
|
165
|
+
licenses: []
|
166
|
+
metadata: {}
|
167
|
+
post_install_message:
|
168
|
+
rdoc_options: []
|
169
|
+
require_paths:
|
170
|
+
- lib
|
171
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
requirements: []
|
182
|
+
rubyforge_project:
|
183
|
+
rubygems_version: 2.4.5.1
|
184
|
+
signing_key:
|
185
|
+
specification_version: 4
|
186
|
+
summary: A Ruby database driver for Clickhouse
|
187
|
+
test_files:
|
188
|
+
- test/test_helper.rb
|
189
|
+
- test/test_helper/coverage.rb
|
190
|
+
- test/test_helper/minitest.rb
|
191
|
+
- test/test_helper/simple_connection.rb
|
192
|
+
- test/unit/connection/query/test_result_row.rb
|
193
|
+
- test/unit/connection/query/test_result_set.rb
|
194
|
+
- test/unit/connection/query/test_table.rb
|
195
|
+
- test/unit/connection/test_client.rb
|
196
|
+
- test/unit/connection/test_logger.rb
|
197
|
+
- test/unit/connection/test_query.rb
|
198
|
+
- test/unit/test_clickhouse.rb
|
199
|
+
- test/unit/test_connection.rb
|