skydb 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +165 -1
- data/lib/skydb.rb +18 -61
- data/lib/skydb/client.rb +186 -186
- data/lib/skydb/event.rb +47 -76
- data/lib/skydb/property.rb +34 -67
- data/lib/skydb/table.rb +121 -41
- data/lib/skydb/version.rb +1 -1
- data/test/integration/client_test.rb +88 -0
- data/test/test_helper.rb +3 -51
- data/test/unit/client_test.rb +135 -32
- metadata +17 -278
- data/bin/sky +0 -89
- data/lib/ext/hash.rb +0 -11
- data/lib/ext/string.rb +0 -11
- data/lib/ext/treetop.rb +0 -19
- data/lib/skydb/action.rb +0 -76
- data/lib/skydb/import.rb +0 -7
- data/lib/skydb/import/importer.rb +0 -435
- data/lib/skydb/import/transforms/apache.yml +0 -4
- data/lib/skydb/import/transforms/sky.yml +0 -28
- data/lib/skydb/import/transforms/snowplow.yml +0 -1
- data/lib/skydb/import/translator.rb +0 -119
- data/lib/skydb/message.rb +0 -146
- data/lib/skydb/message/add_action.rb +0 -53
- data/lib/skydb/message/add_event.rb +0 -72
- data/lib/skydb/message/add_property.rb +0 -55
- data/lib/skydb/message/create_table.rb +0 -64
- data/lib/skydb/message/delete_table.rb +0 -66
- data/lib/skydb/message/get_action.rb +0 -55
- data/lib/skydb/message/get_actions.rb +0 -38
- data/lib/skydb/message/get_properties.rb +0 -38
- data/lib/skydb/message/get_property.rb +0 -55
- data/lib/skydb/message/get_table.rb +0 -74
- data/lib/skydb/message/get_tables.rb +0 -43
- data/lib/skydb/message/lookup.rb +0 -79
- data/lib/skydb/message/lua/aggregate.rb +0 -63
- data/lib/skydb/message/multi.rb +0 -57
- data/lib/skydb/message/next_actions.rb +0 -55
- data/lib/skydb/message/ping.rb +0 -32
- data/lib/skydb/property/type.rb +0 -40
- data/lib/skydb/query.rb +0 -183
- data/lib/skydb/query/after_condition.rb +0 -104
- data/lib/skydb/query/ast/selection_field_syntax_node.rb +0 -26
- data/lib/skydb/query/ast/selection_fields_syntax_node.rb +0 -16
- data/lib/skydb/query/ast/selection_group_syntax_node.rb +0 -16
- data/lib/skydb/query/ast/selection_groups_syntax_node.rb +0 -16
- data/lib/skydb/query/condition.rb +0 -113
- data/lib/skydb/query/on_condition.rb +0 -53
- data/lib/skydb/query/selection.rb +0 -398
- data/lib/skydb/query/selection_field.rb +0 -99
- data/lib/skydb/query/selection_fields_grammar.treetop +0 -46
- data/lib/skydb/query/selection_fields_parse_error.rb +0 -30
- data/lib/skydb/query/selection_group.rb +0 -78
- data/lib/skydb/query/selection_groups_grammar.treetop +0 -31
- data/lib/skydb/query/selection_groups_parse_error.rb +0 -30
- data/lib/skydb/query/validation_error.rb +0 -8
- data/lib/skydb/timestamp.rb +0 -22
- data/test/integration/query_test.rb +0 -102
- data/test/unit/event_test.rb +0 -32
- data/test/unit/import/importer_test.rb +0 -208
- data/test/unit/import/translator_test.rb +0 -88
- data/test/unit/message/add_action_message_test.rb +0 -34
- data/test/unit/message/add_event_message_test.rb +0 -35
- data/test/unit/message/add_property_message_test.rb +0 -41
- data/test/unit/message/create_table_message_test.rb +0 -34
- data/test/unit/message/delete_table_message_test.rb +0 -34
- data/test/unit/message/get_action_message_test.rb +0 -34
- data/test/unit/message/get_actions_message_test.rb +0 -18
- data/test/unit/message/get_properties_message_test.rb +0 -18
- data/test/unit/message/get_property_message_test.rb +0 -34
- data/test/unit/message/get_table_message_test.rb +0 -19
- data/test/unit/message/get_tables_message_test.rb +0 -18
- data/test/unit/message/lookup_message_test.rb +0 -27
- data/test/unit/message/lua_aggregate_message_test.rb +0 -19
- data/test/unit/message/multi_message_test.rb +0 -22
- data/test/unit/message/next_action_message_test.rb +0 -34
- data/test/unit/message/ping_message_test.rb +0 -18
- data/test/unit/message_test.rb +0 -15
- data/test/unit/query/after_test.rb +0 -89
- data/test/unit/query/on_test.rb +0 -71
- data/test/unit/query/selection_test.rb +0 -273
- data/test/unit/query_test.rb +0 -182
- data/test/unit/skydb_test.rb +0 -20
data/lib/skydb/version.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: binary
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class TestClient < MiniTest::Unit::TestCase
|
5
|
+
##############################################################################
|
6
|
+
#
|
7
|
+
# Setup / Teardown
|
8
|
+
#
|
9
|
+
##############################################################################
|
10
|
+
|
11
|
+
def setup
|
12
|
+
# SkyDB.debug = true
|
13
|
+
WebMock.disable!
|
14
|
+
@client = SkyDB::Client.new()
|
15
|
+
begin; @client.delete_table(:name => 'sky-rb-integration'); rescue; end
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
begin; @client.delete_table(:name => 'sky-rb-integration'); rescue; end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
##############################################################################
|
24
|
+
#
|
25
|
+
# Tests
|
26
|
+
#
|
27
|
+
##############################################################################
|
28
|
+
|
29
|
+
def test_event_management
|
30
|
+
table = @client.create_table(:name => 'sky-rb-integration')
|
31
|
+
table.create_property(:name => 'action', :transient => true, :data_type => 'factor')
|
32
|
+
table.create_property(:name => 'age', :data_type => 'integer')
|
33
|
+
|
34
|
+
table.add_event("obj0", :timestamp => DateTime.iso8601('2013-01-01T00:00:00Z'), :data => {'action' => "A0"})
|
35
|
+
table.add_event("obj0", :timestamp => DateTime.iso8601('2013-01-01T00:00:01Z'), :data => {'action' => "A1"})
|
36
|
+
table.add_event("obj0", :timestamp => DateTime.iso8601('2013-01-01T00:00:01Z'), :data => {'age' => 12})
|
37
|
+
table.add_event("obj0", :timestamp => DateTime.iso8601('2013-01-01T00:00:02Z'), :data => {'action' => "A2"})
|
38
|
+
table.delete_event("obj0", :timestamp => DateTime.iso8601('2013-01-01T00:00:02Z'))
|
39
|
+
|
40
|
+
table.add_event("obj1", :timestamp => DateTime.iso8601('2013-01-01T01:00:00Z'), :data => {'action' => "A1"})
|
41
|
+
table.add_event("obj1", {:timestamp => DateTime.iso8601('2013-01-01T01:00:00Z'), :data => {'age' => 50}}, :method => :replace)
|
42
|
+
|
43
|
+
assert_equal({"timestamp"=>"2013-01-01T01:00:00.000000Z", "data"=>{"age" => 50}}, table.get_event("obj1", DateTime.parse("2013-01-01T01:00:00Z")).to_hash)
|
44
|
+
assert_equal([
|
45
|
+
{"timestamp"=>"2013-01-01T00:00:00.000000Z", "data"=>{"action"=>1}},
|
46
|
+
{"timestamp"=>"2013-01-01T00:00:01.000000Z", "data"=>{"action"=>2, "age" => 12}}
|
47
|
+
], table.get_events("obj0").map{|e| e.to_hash})
|
48
|
+
|
49
|
+
@client.delete_table(table)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_simple_count_query
|
53
|
+
table = @client.create_table(:name => 'sky-rb-integration')
|
54
|
+
table.create_property(:name => 'action', :transient => true, :data_type => 'factor')
|
55
|
+
table.add_event("count0", :timestamp => DateTime.iso8601('2013-01-01T00:00:00Z'), :data => {'action' => "A0"})
|
56
|
+
table.add_event("count0", :timestamp => DateTime.iso8601('2013-01-01T00:00:01Z'), :data => {'action' => "A1"})
|
57
|
+
table.add_event("count0", :timestamp => DateTime.iso8601('2013-01-01T00:00:02Z'), :data => {'action' => "A2"})
|
58
|
+
table.add_event("count1", :timestamp => DateTime.iso8601('2013-01-01T00:00:00Z'), :data => {'action' => "A1"})
|
59
|
+
table.add_event("count1", :timestamp => DateTime.iso8601('2013-01-01T00:00:05Z'), :data => {'action' => "A2"})
|
60
|
+
results = table.query({steps:[{:type => 'selection', :fields => [:name => 'count', :expression => 'count()']}]})
|
61
|
+
@client.delete_table(table)
|
62
|
+
assert_equal({'count' => 5}, results)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_funnel_query
|
66
|
+
table = @client.create_table(:name => 'sky-rb-integration')
|
67
|
+
table.create_property(:name => 'action', :transient => true, :data_type => 'factor')
|
68
|
+
table.add_event("fun0", :timestamp => DateTime.iso8601('2013-01-01T00:00:00Z'), :data => {'action' => "A0"})
|
69
|
+
table.add_event("fun0", :timestamp => DateTime.iso8601('2013-01-01T00:00:01Z'), :data => {'action' => "A1"})
|
70
|
+
table.add_event("fun0", :timestamp => DateTime.iso8601('2013-01-01T00:00:02Z'), :data => {'action' => "A2"})
|
71
|
+
table.add_event("fun1", :timestamp => DateTime.iso8601('2013-01-01T00:00:00Z'), :data => {'action' => "A0"})
|
72
|
+
table.add_event("fun1", :timestamp => DateTime.iso8601('2013-01-01T00:00:05Z'), :data => {'action' => "A1"})
|
73
|
+
table.add_event("fun1", :timestamp => DateTime.iso8601('2013-01-01T00:00:10Z'), :data => {'action' => "A3"})
|
74
|
+
results = table.query({
|
75
|
+
steps:[
|
76
|
+
{:type => 'condition', :expression => 'action == "A0"', :steps => [
|
77
|
+
{:type => 'condition', :expression => 'action == "A1"', :within => [1,1], :steps => [
|
78
|
+
{:type => 'condition', :expression => 'true', :within => [1,1], :steps => [
|
79
|
+
{:type => 'selection', :dimensions => ['action'], :fields => [:name => 'count', :expression => 'count()']}
|
80
|
+
]}
|
81
|
+
]}
|
82
|
+
]}
|
83
|
+
]
|
84
|
+
})
|
85
|
+
@client.delete_table(table)
|
86
|
+
assert_equal({"action"=>{"A2"=>{"count"=>1}, "A3"=>{"count"=>1}}}, results)
|
87
|
+
end
|
88
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,56 +1,8 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
SimpleCov.start
|
3
|
-
add_group "Query", "skydb/query"
|
4
|
-
end
|
5
|
-
|
2
|
+
SimpleCov.start
|
6
3
|
require 'bundler/setup'
|
7
4
|
require 'minitest/autorun'
|
8
|
-
require 'mocha'
|
5
|
+
require 'mocha/setup'
|
6
|
+
require 'webmock/minitest'
|
9
7
|
require 'unindentable'
|
10
|
-
require "stringio"
|
11
8
|
require 'skydb'
|
12
|
-
require 'skydb/import'
|
13
|
-
|
14
|
-
class MiniTest::Unit::TestCase
|
15
|
-
# The name of the table to import into.
|
16
|
-
def default_table_name; "sky-integration-tests"; end
|
17
|
-
|
18
|
-
def assert_bytes exp, act, msg = nil
|
19
|
-
exp = exp.to_hex
|
20
|
-
act = act.string.to_hex
|
21
|
-
assert_equal(exp, act, msg)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Captures STDIN & STDERR and returns them as strings.
|
25
|
-
def capture_io
|
26
|
-
_stdout, $stdout = $stdout, StringIO.new
|
27
|
-
_stderr, $stderr = $stderr, StringIO.new
|
28
|
-
yield
|
29
|
-
[$stdout.string, $stderr.string]
|
30
|
-
ensure
|
31
|
-
$stdout = _stdout
|
32
|
-
$stderr = _stderr
|
33
|
-
end
|
34
|
-
|
35
|
-
def import(filename, options={})
|
36
|
-
# Default options.
|
37
|
-
options = {
|
38
|
-
:table_name => default_table_name,
|
39
|
-
:transform => 'sky'
|
40
|
-
}.merge(options)
|
41
|
-
|
42
|
-
# Prepend fixture directory.
|
43
|
-
filename = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures", filename))
|
44
|
-
|
45
|
-
# Delete the table if it exists.
|
46
|
-
table = SkyDB.get_table(options[:table_name])
|
47
|
-
SkyDB.delete_table(SkyDB::Table.new(options[:table_name])) unless table.nil?
|
48
|
-
SkyDB.create_table(SkyDB::Table.new(options[:table_name]))
|
49
|
-
|
50
|
-
# Import.
|
51
|
-
importer = SkyDB::Import::Importer.new()
|
52
|
-
importer.table_name = options[:table_name]
|
53
|
-
importer.load_transform_file(options[:transform]) unless options[:transform].nil?
|
54
|
-
importer.import([filename], :progress_bar => false)
|
55
|
-
end
|
56
|
-
end
|
data/test/unit/client_test.rb
CHANGED
@@ -2,70 +2,173 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
class TestClient < MiniTest::Unit::TestCase
|
5
|
+
##############################################################################
|
6
|
+
#
|
7
|
+
# Setup / Teardown
|
8
|
+
#
|
9
|
+
##############################################################################
|
10
|
+
|
5
11
|
def setup
|
6
|
-
@client = SkyDB::Client.new(
|
7
|
-
@
|
12
|
+
@client = SkyDB::Client.new()
|
13
|
+
@table = SkyDB::Table.new(:name => 'foo', :client => @client)
|
8
14
|
end
|
15
|
+
|
9
16
|
|
10
17
|
######################################
|
11
|
-
#
|
18
|
+
# Table API
|
12
19
|
######################################
|
13
20
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
@client.
|
21
|
+
def test_get_tables
|
22
|
+
stub_request(:get, "http://localhost:8585/tables")
|
23
|
+
.to_return(:status => 200, :body => '[{"name":"foo"},{"name":"bar"}]')
|
24
|
+
tables = @client.get_tables()
|
25
|
+
assert_equal(2, tables.length)
|
26
|
+
assert_equal("foo", tables[0].name)
|
27
|
+
assert_equal("bar", tables[1].name)
|
18
28
|
end
|
19
29
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
30
|
+
def test_get_table
|
31
|
+
stub_request(:get, "http://localhost:8585/tables/foo")
|
32
|
+
.to_return(:status => 200, :body => '{"name":"foo"}')
|
33
|
+
table = @client.get_table("foo")
|
34
|
+
assert_equal("foo", table.name)
|
23
35
|
end
|
24
36
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
37
|
+
def test_create_table
|
38
|
+
stub_request(:post, "http://localhost:8585/tables")
|
39
|
+
.with(:body => '{"name":"foo"}')
|
40
|
+
.to_return(:status => 200, :body => '{"name":"foo"}')
|
41
|
+
|
42
|
+
table = @client.create_table(SkyDB::Table.new(:name => 'foo'))
|
43
|
+
assert_equal("foo", table.name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_delete_table
|
47
|
+
stub_request(:delete, "http://localhost:8585/tables/foo").to_return(:status => 200)
|
48
|
+
@client.delete_table(SkyDB::Table.new(:name => 'foo'))
|
28
49
|
end
|
29
50
|
|
30
51
|
|
31
52
|
######################################
|
32
|
-
# Property
|
53
|
+
# Property API
|
33
54
|
######################################
|
34
55
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
@
|
56
|
+
def test_get_properties
|
57
|
+
stub_request(:get, "http://localhost:8585/tables/foo/properties")
|
58
|
+
.to_return(:status => 200, :body => '[{"id":-1,"name":"action","transient":true,"dataType":"string"},{"id":1,"name":"first_name","transient":false,"dataType":"integer"}]')
|
59
|
+
properties = @table.get_properties()
|
60
|
+
assert_equal(2, properties.length)
|
61
|
+
assert_equal("action", properties[0].name)
|
62
|
+
assert_equal("first_name", properties[1].name)
|
39
63
|
end
|
40
64
|
|
41
65
|
def test_get_property
|
42
|
-
|
43
|
-
|
66
|
+
stub_request(:get, "http://localhost:8585/tables/foo/properties/action")
|
67
|
+
.to_return(:status => 200, :body => '{"id":-1,"name":"action","transient":true,"dataType":"string"}')
|
68
|
+
property = @table.get_property("action")
|
69
|
+
assert_equal("action", property.name)
|
44
70
|
end
|
45
71
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
72
|
+
def test_create_property
|
73
|
+
stub_request(:post, "http://localhost:8585/tables/foo/properties")
|
74
|
+
.with(:body => '{"name":"action","transient":true,"dataType":"string"}')
|
75
|
+
.to_return(:status => 200, :body => '{"id":-1,"name":"action","transient":true,"dataType":"string"}')
|
76
|
+
property = @table.create_property(SkyDB::Property.new(:name => 'action', :transient => true, :data_type => 'string'))
|
77
|
+
assert_equal("action", property.name)
|
78
|
+
assert_equal(true, property.transient)
|
79
|
+
assert_equal("string", property.data_type)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_update_property
|
83
|
+
stub_request(:patch, "http://localhost:8585/tables/foo/properties/action2")
|
84
|
+
.with(:body => '{"name":"action2","transient":true,"dataType":"string","id":-1}')
|
85
|
+
.to_return(:status => 200, :body => '{"id":-1,"name":"action2","transient":true,"dataType":"string"}')
|
86
|
+
property = @table.update_property(SkyDB::Property.new(:id => -1, :name => 'action2', :transient => true, :data_type => 'string'))
|
87
|
+
assert_equal("action2", property.name)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_delete_property
|
91
|
+
stub_request(:delete, "http://localhost:8585/tables/foo/properties/action")
|
92
|
+
.to_return(:status => 200)
|
93
|
+
@table.delete_property(SkyDB::Property.new(:name => 'action'))
|
49
94
|
end
|
50
95
|
|
51
96
|
|
52
97
|
######################################
|
53
|
-
# Event
|
98
|
+
# Event API
|
54
99
|
######################################
|
55
100
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
@
|
101
|
+
def test_get_events
|
102
|
+
stub_request(:get, "http://localhost:8585/tables/foo/objects/xxx/events")
|
103
|
+
.to_return(:status => 200, :body => '[{"timestamp":"1970-01-01T00:00:00Z","data":{"action":"/home"}},{"timestamp":"1970-01-01T00:00:00.5Z","data":{"action":"/pricing"}}]')
|
104
|
+
events = @table.get_events("xxx")
|
105
|
+
assert_equal(2, events.length)
|
106
|
+
assert_equal("1970-01-01T00:00:00.000000Z", events[0].formatted_timestamp)
|
107
|
+
assert_equal({'action' => '/home'}, events[0].data)
|
108
|
+
assert_equal("1970-01-01T00:00:00.500000Z", events[1].formatted_timestamp)
|
109
|
+
assert_equal({'action' => '/pricing'}, events[1].data)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_get_event
|
113
|
+
stub_request(:get, "http://localhost:8585/tables/foo/objects/xxx/events/1970-01-01T00:00:00.000000Z")
|
114
|
+
.to_return(:status => 200, :body => '{"timestamp":"1970-01-01T00:00:00.000000Z","data":{"action":"/home"}}')
|
115
|
+
event = @table.get_event("xxx", DateTime.iso8601('1970-01-01T00:00:00Z'))
|
116
|
+
assert_equal("1970-01-01T00:00:00.000000Z", event.formatted_timestamp)
|
117
|
+
assert_equal({'action' => '/home'}, event.data)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_replace_event
|
121
|
+
stub_request(:put, "http://localhost:8585/tables/foo/objects/xxx/events/1970-01-01T00:00:00.000000Z")
|
122
|
+
.with(:body => '{"timestamp":"1970-01-01T00:00:00.000000Z","data":{"action":"/home"}}')
|
123
|
+
.to_return(:status => 200, :body => '{"timestamp":"1970-01-01T00:00:00.000000Z","data":{"action":"/home"}}')
|
124
|
+
event = SkyDB::Event.new(:timestamp => DateTime.iso8601('1970-01-01T00:00:00Z'), :data => {'action' => '/home'})
|
125
|
+
event = @table.add_event("xxx", event, :method => :replace)
|
126
|
+
assert_equal("1970-01-01T00:00:00.000000Z", event.formatted_timestamp)
|
127
|
+
assert_equal({'action' => '/home'}, event.data)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_merge_event
|
131
|
+
stub_request(:patch, "http://localhost:8585/tables/foo/objects/xxx/events/1970-01-01T00:00:00.000000Z")
|
132
|
+
.with(:body => '{"timestamp":"1970-01-01T00:00:00.000000Z","data":{"action":"/home"}}')
|
133
|
+
.to_return(:status => 200, :body => '{"timestamp":"1970-01-01T00:00:00.000000Z","data":{"action":"/home","first_name":"bob"}}')
|
134
|
+
event = SkyDB::Event.new(:timestamp => DateTime.iso8601('1970-01-01T00:00:00Z'), :data => {'action' => '/home'})
|
135
|
+
event = @table.add_event("xxx", event, :method => :merge)
|
136
|
+
assert_equal("1970-01-01T00:00:00.000000Z", event.formatted_timestamp)
|
137
|
+
assert_equal({'action' => '/home', 'first_name' => 'bob'}, event.data)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_delete_event
|
141
|
+
stub_request(:delete, "http://localhost:8585/tables/foo/objects/xxx/events/1970-01-01T00:00:00.000000Z")
|
142
|
+
.to_return(:status => 200)
|
143
|
+
@table.delete_event("xxx", SkyDB::Event.new(:timestamp => DateTime.iso8601('1970-01-01T00:00:00Z')))
|
60
144
|
end
|
61
145
|
|
62
146
|
|
63
147
|
######################################
|
64
|
-
# Query
|
148
|
+
# Query API
|
65
149
|
######################################
|
66
150
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
151
|
+
def test_query
|
152
|
+
stub_request(:post, "http://localhost:8585/tables/foo/query")
|
153
|
+
.with(:body => '{"steps":[{"type":"selection","fields":[{"name":"count","expression":"count()"}]}]}')
|
154
|
+
.to_return(:status => 200, :body => '{"count":5}'+"\n")
|
155
|
+
results = @table.query([{:type => 'selection', :fields => [{:name => 'count', :expression => 'count()'}]}])
|
156
|
+
assert_equal({'count' => 5}, results)
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
######################################
|
161
|
+
# Utility API
|
162
|
+
######################################
|
163
|
+
|
164
|
+
def test_successful_ping
|
165
|
+
stub_request(:get, "http://localhost:8585/ping")
|
166
|
+
.to_return(:status => 200, :body => '{"message":"ok"}')
|
167
|
+
assert(@client.ping())
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_unsuccessful_ping
|
171
|
+
stub_request(:get, "http://localhost:8585/ping").to_timeout
|
172
|
+
refute(@client.ping())
|
70
173
|
end
|
71
174
|
end
|
metadata
CHANGED
@@ -1,212 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skydb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ben Johnson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-02
|
11
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: msgpack
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.4.7
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.4.7
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: commander
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 4.1.3
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 4.1.3
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: ruby-progressbar
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 1.0.2
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.2
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: chronic
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.9.0
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.9.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: treetop
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.4.12
|
86
|
-
type: :runtime
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 1.4.12
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: yajl-ruby
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 1.1.0
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 1.1.0
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: bzip2-ruby
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.2.7
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 0.2.7
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: apachelogregex
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 0.1.0
|
134
|
-
type: :runtime
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 0.1.0
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: useragent
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 0.4.16
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ~>
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 0.4.16
|
158
13
|
- !ruby/object:Gem::Dependency
|
159
14
|
name: rake
|
160
15
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
16
|
requirements:
|
163
17
|
- - ~>
|
164
18
|
- !ruby/object:Gem::Version
|
165
|
-
version: 0.
|
19
|
+
version: 10.0.4
|
166
20
|
type: :development
|
167
21
|
prerelease: false
|
168
22
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
23
|
requirements:
|
171
24
|
- - ~>
|
172
25
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
26
|
+
version: 10.0.4
|
174
27
|
- !ruby/object:Gem::Dependency
|
175
28
|
name: minitest
|
176
29
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
30
|
requirements:
|
179
31
|
- - ~>
|
180
32
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
33
|
+
version: 4.7.0
|
182
34
|
type: :development
|
183
35
|
prerelease: false
|
184
36
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
37
|
requirements:
|
187
38
|
- - ~>
|
188
39
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
40
|
+
version: 4.7.0
|
190
41
|
- !ruby/object:Gem::Dependency
|
191
42
|
name: mocha
|
192
43
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
44
|
requirements:
|
195
45
|
- - ~>
|
196
46
|
- !ruby/object:Gem::Version
|
197
|
-
version: 0.
|
47
|
+
version: 0.13.3
|
198
48
|
type: :development
|
199
49
|
prerelease: false
|
200
50
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
51
|
requirements:
|
203
52
|
- - ~>
|
204
53
|
- !ruby/object:Gem::Version
|
205
|
-
version: 0.
|
54
|
+
version: 0.13.3
|
206
55
|
- !ruby/object:Gem::Dependency
|
207
56
|
name: unindentable
|
208
57
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
58
|
requirements:
|
211
59
|
- - ~>
|
212
60
|
- !ruby/object:Gem::Version
|
@@ -214,7 +62,6 @@ dependencies:
|
|
214
62
|
type: :development
|
215
63
|
prerelease: false
|
216
64
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
65
|
requirements:
|
219
66
|
- - ~>
|
220
67
|
- !ruby/object:Gem::Version
|
@@ -222,7 +69,6 @@ dependencies:
|
|
222
69
|
- !ruby/object:Gem::Dependency
|
223
70
|
name: simplecov
|
224
71
|
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
72
|
requirements:
|
227
73
|
- - ~>
|
228
74
|
- !ruby/object:Gem::Version
|
@@ -230,172 +76,65 @@ dependencies:
|
|
230
76
|
type: :development
|
231
77
|
prerelease: false
|
232
78
|
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
79
|
requirements:
|
235
80
|
- - ~>
|
236
81
|
- !ruby/object:Gem::Version
|
237
82
|
version: 0.7.1
|
238
83
|
- !ruby/object:Gem::Dependency
|
239
|
-
name:
|
84
|
+
name: webmock
|
240
85
|
requirement: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
86
|
requirements:
|
243
87
|
- - ~>
|
244
88
|
- !ruby/object:Gem::Version
|
245
|
-
version: 1.
|
89
|
+
version: 1.11.0
|
246
90
|
type: :development
|
247
91
|
prerelease: false
|
248
92
|
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
93
|
requirements:
|
251
94
|
- - ~>
|
252
95
|
- !ruby/object:Gem::Version
|
253
|
-
version: 1.
|
96
|
+
version: 1.11.0
|
254
97
|
description:
|
255
98
|
email:
|
256
99
|
- benbjohnson@yahoo.com
|
257
|
-
executables:
|
258
|
-
- sky
|
100
|
+
executables: []
|
259
101
|
extensions: []
|
260
102
|
extra_rdoc_files: []
|
261
103
|
files:
|
262
|
-
- lib/ext/hash.rb
|
263
|
-
- lib/ext/string.rb
|
264
|
-
- lib/ext/treetop.rb
|
265
|
-
- lib/skydb/action.rb
|
266
104
|
- lib/skydb/client.rb
|
267
105
|
- lib/skydb/event.rb
|
268
|
-
- lib/skydb/import/importer.rb
|
269
|
-
- lib/skydb/import/transforms/apache.yml
|
270
|
-
- lib/skydb/import/transforms/sky.yml
|
271
|
-
- lib/skydb/import/transforms/snowplow.yml
|
272
|
-
- lib/skydb/import/translator.rb
|
273
|
-
- lib/skydb/import.rb
|
274
|
-
- lib/skydb/message/add_action.rb
|
275
|
-
- lib/skydb/message/add_event.rb
|
276
|
-
- lib/skydb/message/add_property.rb
|
277
|
-
- lib/skydb/message/create_table.rb
|
278
|
-
- lib/skydb/message/delete_table.rb
|
279
|
-
- lib/skydb/message/get_action.rb
|
280
|
-
- lib/skydb/message/get_actions.rb
|
281
|
-
- lib/skydb/message/get_properties.rb
|
282
|
-
- lib/skydb/message/get_property.rb
|
283
|
-
- lib/skydb/message/get_table.rb
|
284
|
-
- lib/skydb/message/get_tables.rb
|
285
|
-
- lib/skydb/message/lookup.rb
|
286
|
-
- lib/skydb/message/lua/aggregate.rb
|
287
|
-
- lib/skydb/message/multi.rb
|
288
|
-
- lib/skydb/message/next_actions.rb
|
289
|
-
- lib/skydb/message/ping.rb
|
290
|
-
- lib/skydb/message.rb
|
291
|
-
- lib/skydb/property/type.rb
|
292
106
|
- lib/skydb/property.rb
|
293
|
-
- lib/skydb/query/after_condition.rb
|
294
|
-
- lib/skydb/query/ast/selection_field_syntax_node.rb
|
295
|
-
- lib/skydb/query/ast/selection_fields_syntax_node.rb
|
296
|
-
- lib/skydb/query/ast/selection_group_syntax_node.rb
|
297
|
-
- lib/skydb/query/ast/selection_groups_syntax_node.rb
|
298
|
-
- lib/skydb/query/condition.rb
|
299
|
-
- lib/skydb/query/on_condition.rb
|
300
|
-
- lib/skydb/query/selection.rb
|
301
|
-
- lib/skydb/query/selection_field.rb
|
302
|
-
- lib/skydb/query/selection_fields_grammar.treetop
|
303
|
-
- lib/skydb/query/selection_fields_parse_error.rb
|
304
|
-
- lib/skydb/query/selection_group.rb
|
305
|
-
- lib/skydb/query/selection_groups_grammar.treetop
|
306
|
-
- lib/skydb/query/selection_groups_parse_error.rb
|
307
|
-
- lib/skydb/query/validation_error.rb
|
308
|
-
- lib/skydb/query.rb
|
309
107
|
- lib/skydb/table.rb
|
310
|
-
- lib/skydb/timestamp.rb
|
311
108
|
- lib/skydb/version.rb
|
312
109
|
- lib/skydb.rb
|
313
110
|
- README.md
|
314
|
-
- test/integration/
|
111
|
+
- test/integration/client_test.rb
|
315
112
|
- test/test_helper.rb
|
316
113
|
- test/unit/client_test.rb
|
317
|
-
- test/unit/event_test.rb
|
318
|
-
- test/unit/import/importer_test.rb
|
319
|
-
- test/unit/import/translator_test.rb
|
320
|
-
- test/unit/message/add_action_message_test.rb
|
321
|
-
- test/unit/message/add_event_message_test.rb
|
322
|
-
- test/unit/message/add_property_message_test.rb
|
323
|
-
- test/unit/message/create_table_message_test.rb
|
324
|
-
- test/unit/message/delete_table_message_test.rb
|
325
|
-
- test/unit/message/get_action_message_test.rb
|
326
|
-
- test/unit/message/get_actions_message_test.rb
|
327
|
-
- test/unit/message/get_properties_message_test.rb
|
328
|
-
- test/unit/message/get_property_message_test.rb
|
329
|
-
- test/unit/message/get_table_message_test.rb
|
330
|
-
- test/unit/message/get_tables_message_test.rb
|
331
|
-
- test/unit/message/lookup_message_test.rb
|
332
|
-
- test/unit/message/lua_aggregate_message_test.rb
|
333
|
-
- test/unit/message/multi_message_test.rb
|
334
|
-
- test/unit/message/next_action_message_test.rb
|
335
|
-
- test/unit/message/ping_message_test.rb
|
336
|
-
- test/unit/message_test.rb
|
337
|
-
- test/unit/query/after_test.rb
|
338
|
-
- test/unit/query/on_test.rb
|
339
|
-
- test/unit/query/selection_test.rb
|
340
|
-
- test/unit/query_test.rb
|
341
|
-
- test/unit/skydb_test.rb
|
342
|
-
- bin/sky
|
343
114
|
homepage: http://github.com/skydb/sky.rb
|
344
115
|
licenses: []
|
116
|
+
metadata: {}
|
345
117
|
post_install_message:
|
346
118
|
rdoc_options: []
|
347
119
|
require_paths:
|
348
120
|
- lib
|
349
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
350
|
-
none: false
|
351
122
|
requirements:
|
352
123
|
- - ! '>='
|
353
124
|
- !ruby/object:Gem::Version
|
354
125
|
version: '0'
|
355
|
-
segments:
|
356
|
-
- 0
|
357
|
-
hash: -3253768369424236185
|
358
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
|
-
none: false
|
360
127
|
requirements:
|
361
128
|
- - ! '>='
|
362
129
|
- !ruby/object:Gem::Version
|
363
130
|
version: '0'
|
364
|
-
segments:
|
365
|
-
- 0
|
366
|
-
hash: -3253768369424236185
|
367
131
|
requirements: []
|
368
132
|
rubyforge_project:
|
369
|
-
rubygems_version:
|
133
|
+
rubygems_version: 2.0.3
|
370
134
|
signing_key:
|
371
|
-
specification_version:
|
135
|
+
specification_version: 4
|
372
136
|
summary: A Ruby client for the Sky database
|
373
137
|
test_files:
|
374
|
-
- test/integration/
|
138
|
+
- test/integration/client_test.rb
|
375
139
|
- test/test_helper.rb
|
376
140
|
- test/unit/client_test.rb
|
377
|
-
- test/unit/event_test.rb
|
378
|
-
- test/unit/import/importer_test.rb
|
379
|
-
- test/unit/import/translator_test.rb
|
380
|
-
- test/unit/message/add_action_message_test.rb
|
381
|
-
- test/unit/message/add_event_message_test.rb
|
382
|
-
- test/unit/message/add_property_message_test.rb
|
383
|
-
- test/unit/message/create_table_message_test.rb
|
384
|
-
- test/unit/message/delete_table_message_test.rb
|
385
|
-
- test/unit/message/get_action_message_test.rb
|
386
|
-
- test/unit/message/get_actions_message_test.rb
|
387
|
-
- test/unit/message/get_properties_message_test.rb
|
388
|
-
- test/unit/message/get_property_message_test.rb
|
389
|
-
- test/unit/message/get_table_message_test.rb
|
390
|
-
- test/unit/message/get_tables_message_test.rb
|
391
|
-
- test/unit/message/lookup_message_test.rb
|
392
|
-
- test/unit/message/lua_aggregate_message_test.rb
|
393
|
-
- test/unit/message/multi_message_test.rb
|
394
|
-
- test/unit/message/next_action_message_test.rb
|
395
|
-
- test/unit/message/ping_message_test.rb
|
396
|
-
- test/unit/message_test.rb
|
397
|
-
- test/unit/query/after_test.rb
|
398
|
-
- test/unit/query/on_test.rb
|
399
|
-
- test/unit/query/selection_test.rb
|
400
|
-
- test/unit/query_test.rb
|
401
|
-
- test/unit/skydb_test.rb
|