skydb 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,12 +33,12 @@ class SkyDB
33
33
  CLIENT_PASSTHROUGH = [
34
34
  :host, :host=, :port, :port=,
35
35
  :table, :table=,
36
- :multi,
36
+ :multi, :ping,
37
37
  :add_event,
38
38
  :add_action, :get_action, :get_actions,
39
39
  :add_property, :get_property, :get_properties,
40
40
  :next_actions,
41
- :map_reduce
41
+ :aggregate
42
42
  ]
43
43
 
44
44
 
@@ -121,15 +121,32 @@ class SkyDB
121
121
  end
122
122
 
123
123
 
124
+ ####################################
125
+ # Ping
126
+ ####################################
127
+
128
+ # Checks if the server is up and running.
129
+ #
130
+ # @returns [Boolean] a flag stating if the server is running.
131
+ def ping(options={})
132
+ begin
133
+ send_message(SkyDB::Message::Ping.new(options))
134
+ return true
135
+ rescue
136
+ return false
137
+ end
138
+ end
139
+
140
+
124
141
  ####################################
125
142
  # Lua Messages
126
143
  ####################################
127
144
 
128
- # Executes a Lua map/reduce job on the server and returns the results.
145
+ # Executes a Lua aggregation job on the server and returns the results.
129
146
  #
130
147
  # @param [String] source the Lua source code to execute
131
- def map_reduce(source, options={})
132
- return send_message(SkyDB::Message::Lua::MapReduce.new(source, options))
148
+ def aggregate(source, options={})
149
+ return send_message(SkyDB::Message::Lua::Aggregate.new(source, options))
133
150
  end
134
151
 
135
152
 
@@ -60,10 +60,15 @@ class SkyDB
60
60
  # Validation
61
61
  ####################################
62
62
 
63
+ # A flag stating if the table is required for this type of message.
64
+ def require_table?
65
+ return true
66
+ end
67
+
63
68
  # Validates that the message is ready to be sent. If any validation issues
64
69
  # are found then an error is raised.
65
70
  def validate!
66
- if table.nil? || table.empty?
71
+ if require_table? && (table.nil? || table.empty?)
67
72
  raise SkyDB::TableRequiredError.new('Table required')
68
73
  end
69
74
  end
@@ -129,6 +134,7 @@ require 'skydb/message/get_properties'
129
134
  require 'skydb/message/add_event'
130
135
  require 'skydb/message/next_actions'
131
136
 
132
- require 'skydb/message/lua/map_reduce'
137
+ require 'skydb/message/lua/aggregate'
133
138
 
139
+ require 'skydb/message/ping'
134
140
  require 'skydb/message/multi'
@@ -1,18 +1,18 @@
1
1
  class SkyDB
2
2
  class Message
3
3
  class Lua
4
- class MapReduce < SkyDB::Message
4
+ class Aggregate < SkyDB::Message
5
5
  ########################################################################
6
6
  #
7
7
  # Constructor
8
8
  #
9
9
  ########################################################################
10
10
 
11
- # Initializes the 'lua::map_reduce' message.
11
+ # Initializes the 'lua::aggregate' message.
12
12
  #
13
13
  # @param [String] source the Lua source to execute.
14
14
  def initialize(source=nil, options={})
15
- super('lua::map_reduce')
15
+ super('lua::aggregate')
16
16
  self.source = source
17
17
  end
18
18
 
@@ -0,0 +1,32 @@
1
+ class SkyDB
2
+ class Message
3
+ class Ping < SkyDB::Message
4
+ ########################################################################
5
+ #
6
+ # Constructor
7
+ #
8
+ ########################################################################
9
+
10
+ # Initializes the 'ping' message.
11
+ def initialize(options={})
12
+ super('ping')
13
+ end
14
+
15
+
16
+ ########################################################################
17
+ #
18
+ # Methods
19
+ #
20
+ ########################################################################
21
+
22
+ ##################################
23
+ # Validation
24
+ ##################################
25
+
26
+ # A flag stating if the table is required for this type of message.
27
+ def require_table?
28
+ return false
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  class SkyDB
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,19 @@
1
+ # encoding: binary
2
+ require 'test_helper'
3
+
4
+ class TestMessageLuaAggregate < MiniTest::Unit::TestCase
5
+ def setup
6
+ @message = SkyDB::Message::Lua::Aggregate.new()
7
+ end
8
+
9
+ ######################################
10
+ # Encoding
11
+ ######################################
12
+
13
+ def test_encode
14
+ buffer = StringIO.new
15
+ @message.source = "function aggregate(cursor, data) return {} end"
16
+ @message.encode(buffer)
17
+ assert_bytes "\x93\x01\xaelua::aggregate\xa0\x81\xa6source\xda\x00\x2e" + "function aggregate(cursor, data) return {} end", buffer
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: binary
2
+ require 'test_helper'
3
+
4
+ class TestMessagePing < MiniTest::Unit::TestCase
5
+ def setup
6
+ @message = SkyDB::Message::Ping.new()
7
+ end
8
+
9
+ ######################################
10
+ # Encoding
11
+ ######################################
12
+
13
+ def test_encode
14
+ buffer = StringIO.new
15
+ @message.encode(buffer)
16
+ assert_bytes "\x93\x01\xa4ping\xa0", buffer
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skydb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-12 00:00:00.000000000 Z
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
@@ -93,9 +93,10 @@ files:
93
93
  - lib/skydb/message/get_actions.rb
94
94
  - lib/skydb/message/get_properties.rb
95
95
  - lib/skydb/message/get_property.rb
96
- - lib/skydb/message/lua/map_reduce.rb
96
+ - lib/skydb/message/lua/aggregate.rb
97
97
  - lib/skydb/message/multi.rb
98
98
  - lib/skydb/message/next_actions.rb
99
+ - lib/skydb/message/ping.rb
99
100
  - lib/skydb/message.rb
100
101
  - lib/skydb/property/type.rb
101
102
  - lib/skydb/property.rb
@@ -112,9 +113,10 @@ files:
112
113
  - test/message/get_actions_message_test.rb
113
114
  - test/message/get_properties_message_test.rb
114
115
  - test/message/get_property_message_test.rb
115
- - test/message/lua_map_reduce_message_test.rb
116
+ - test/message/lua_aggregate_message_test.rb
116
117
  - test/message/multi_message_test.rb
117
118
  - test/message/next_action_message_test.rb
119
+ - test/message/ping_message_test.rb
118
120
  - test/message_test.rb
119
121
  - test/skydb_test.rb
120
122
  - test/test_helper.rb
@@ -130,18 +132,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
132
  - - ! '>='
131
133
  - !ruby/object:Gem::Version
132
134
  version: '0'
133
- segments:
134
- - 0
135
- hash: 521903292973127112
136
135
  required_rubygems_version: !ruby/object:Gem::Requirement
137
136
  none: false
138
137
  requirements:
139
138
  - - ! '>='
140
139
  - !ruby/object:Gem::Version
141
140
  version: '0'
142
- segments:
143
- - 0
144
- hash: 521903292973127112
145
141
  requirements: []
146
142
  rubyforge_project:
147
143
  rubygems_version: 1.8.24
@@ -158,9 +154,10 @@ test_files:
158
154
  - test/message/get_actions_message_test.rb
159
155
  - test/message/get_properties_message_test.rb
160
156
  - test/message/get_property_message_test.rb
161
- - test/message/lua_map_reduce_message_test.rb
157
+ - test/message/lua_aggregate_message_test.rb
162
158
  - test/message/multi_message_test.rb
163
159
  - test/message/next_action_message_test.rb
160
+ - test/message/ping_message_test.rb
164
161
  - test/message_test.rb
165
162
  - test/skydb_test.rb
166
163
  - test/test_helper.rb
@@ -1,19 +0,0 @@
1
- # encoding: binary
2
- require 'test_helper'
3
-
4
- class TestMessageLuaMapReduce < MiniTest::Unit::TestCase
5
- def setup
6
- @message = SkyDB::Message::Lua::MapReduce.new()
7
- end
8
-
9
- ######################################
10
- # Encoding
11
- ######################################
12
-
13
- def test_encode
14
- buffer = StringIO.new
15
- @message.source = "function map(cursor) return {} end"
16
- @message.encode(buffer)
17
- assert_bytes "\x93\x01\xaflua::map_reduce\xa0\x81\xa6source\xda\x00\x22" + "function map(cursor) return {} end", buffer
18
- end
19
- end