riakpb 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  require 'riak'
2
2
  require 'set'
3
3
 
4
- module Riak
5
- # Parent class of all object types supported by ripple. {Riak::RObject} represents
6
- # the data and metadata stored in a bucket/key pair in the Riak database.
7
- class RiakContent
4
+ module Riakpb
5
+ # Parent class of all object types supported by ripple. {Riakpb::RObject} represents
6
+ # the data and metadata stored in a bucket/key pair in the Riakpb database.
7
+ class Content
8
8
  include Util::Translation
9
9
  include Util::MessageCode
10
10
 
11
- # @return [Key] the key in which this RiakContent is stored.
11
+ # @return [Key] the key in which this Content is stored.
12
12
  attr_accessor :key
13
13
 
14
- # @return [String] the data stored in Riak at this object's key. Varies in format by content-type.
14
+ # @return [String] the data stored in Riakpb at this object's key. Varies in format by content-type.
15
15
  attr_accessor :value
16
16
  alias_attribute :data, :value
17
17
 
@@ -27,7 +27,7 @@ module Riak
27
27
  # @return [String] the vtag of the object
28
28
  attr_accessor :vtag
29
29
 
30
- # @return [Set<Link>] an Set of {Riak::Link} objects for relationships between this object and other resources
30
+ # @return [Set<Link>] an Set of {Riakpb::Link} objects for relationships between this object and other resources
31
31
  attr_accessor :links
32
32
 
33
33
  # @return [Time] the Last-Modified header from the most recent HTTP response, useful for caching and reloading
@@ -42,95 +42,127 @@ module Riak
42
42
  attr_accessor :usermeta
43
43
  alias_attribute :meta, :usermeta
44
44
 
45
- # Create a new riak_content object manually
46
- # @param [Riak::Key] key Key instance that owns this RiakContent (really, you should use the Key to get this)
45
+ attr_accessor :options
46
+
47
+ # Create a new riak_content object manually
48
+ # @param [Riakpb::Key] key Key instance that owns this Content (really, you should use the Key to get this)
47
49
  # @param [Hash] contents Any contents to initialize this instance with
48
50
  # @see Key#content
49
- # @see RiakContent#load
50
- def initialize(key, contents={})
51
+ # @see Content#load
52
+ def initialize(key, options={})
51
53
  @key = key unless key.nil?
52
54
  @links = Hash.new{|k,v| k[v] = []}
53
- @_links = []
54
55
  @usermeta = {}
56
+ @options = options
55
57
 
56
- load(contents) unless contents.empty?
58
+ self.last_mod = Time.now
57
59
 
58
60
  yield self if block_given?
59
61
  end
60
62
 
61
- # Load information for the content from the response object, Riak::RpbContent.
62
- #
63
+ def [](attribute)
64
+ instance_variable_get "@#{attribute}"
65
+ end
66
+
67
+ # Load information for the content from the response object, Riakpb::RpbContent.
63
68
  # @param [RpbContent/Hash] contents an RpbContent object or a Hash.
64
- # @return [RiakContent] self
65
- def load(contents)
66
- if contents.is_a?(Riak::RpbContent) or contents.is_a?(Hash)
67
- @content_type = contents[:content_type] unless contents[:content_type].blank?
68
- @charset = contents[:charset] unless contents[:charset].blank?
69
- @content_encoding = contents[:content_encoding] unless contents[:content_encoding].blank?
70
- @vtag = contents[:vtag] unless contents[:vtag].blank?
71
- self.links = contents[:links] unless contents[:links].blank?
72
- @last_mod = contents[:last_mod]
73
- @last_mod_usecs = contents[:last_mod_usecs]
74
- self.usermeta = contents[:usermeta] unless contents[:usermeta].blank?
75
-
76
- unless contents[:value].blank?
69
+ # @return [Content] self
70
+ def load(content)
71
+ case content
72
+ when Riakpb::RpbContent, Hash, Riakpb::Content
73
+ last_mod = content[:last_mod]
74
+ last_mod_usecs = content[:last_mod_usecs]
75
+
76
+ if not (last_mod.blank? or last_mod_usecs.blank?)
77
+ self.last_mod = Time.at "#{last_mod}.#{last_mod_usecs}".to_f
78
+ end
79
+
80
+ @content_type = content[:content_type] unless content[:content_type].blank?
81
+ @charset = content[:charset] unless content[:charset].blank?
82
+ @content_encoding = content[:content_encoding] unless content[:content_encoding].blank?
83
+ @vtag = content[:vtag] unless content[:vtag].blank?
84
+ self.links = content[:links] unless content[:links].blank?
85
+ self.usermeta = content[:usermeta] unless content[:usermeta].blank?
86
+
87
+ unless content[:value].blank?
77
88
  case @content_type
78
89
  when /json/
79
- @value = ActiveSupport::JSON.decode(contents[:value])
90
+ @value = ActiveSupport::JSON.decode(content[:value])
80
91
  when /octet/
81
- @value = Marshal.load(contents[:value])
92
+ @value = Marshal.load(content[:value])
82
93
  else
83
- @value = contents[:value]
94
+ @value = content[:value]
84
95
  end
85
96
  end
86
-
87
- return(self)
97
+ else raise ArgumentError, t("riak_content_type")
88
98
  end
89
99
 
90
- raise ArgumentError, t("riak_content_type")
100
+ return(self)
91
101
  end
92
102
 
93
- # Save the RiakContent instance in riak.
103
+ def merge(content)
104
+ @links.merge(
105
+ self.links = content[:links]
106
+ ) unless content[:links].blank?
107
+
108
+ @usermega.merge(
109
+ self.usermeta = content[:usermeta]
110
+ ) unless content[:usermeta].blank?
111
+
112
+ @content_type = content[:content_type] unless content[:content_type].blank?
113
+ @value = content[:value]
114
+ @charset = content[:charset] unless content[:charset].blank?
115
+ @content_encoding = content[:content_encoding] unless content[:content_encoding].blank?
116
+ @vtag = content[:vtag] unless content[:vtag].blank?
117
+ @last_mod = content[:last_mod]
118
+ @last_mod_usecs = content[:last_mod_usecs]
119
+
120
+ return(self)
121
+ end
122
+
123
+ # Save the Content instance in riak.
94
124
  # @option options [Fixnum] w (write quorum) how many replicas to write to before returning a successful response
95
125
  # @option options [Fixnum] dw how many replicas to commit to durable storage before returning a successful response
96
126
  # @option options [true/false] return_body whether or not to have riak return the key, once saved. default = true
97
127
  def save(options={})
98
128
  begin
99
- save!(options)
129
+ self.save!(options)
100
130
  rescue FailedRequest
101
131
  return(false)
102
132
  end
103
133
  return(true)
104
134
  end
105
135
 
106
- # Save the RiakContent instance in riak. Raise/do not rescue on failure.
136
+ # Save the Content instance in riak. Raise/do not rescue on failure.
107
137
  # @option options [Fixnum] w (write quorum) how many replicas to write to before returning a successful response
108
138
  # @option options [Fixnum] dw how many replicas to commit to durable storage before returning a successful response
109
139
  # @option options [true/false] return_body whether or not to have riak return the key, once saved. default = true
110
140
  def save!(options={})
111
141
  options[:content] = self
142
+ options = @options.merge(options)
143
+
112
144
  return(true) if @key.save(options)
113
145
  return(false) # Create and raise Error message for this? Extend "Failed Request"?
114
146
  end
115
147
 
148
+
116
149
  # Internalizes a link to a Key, which will be saved on next call to... uh, save
117
150
  # @param [Hash] tags name of the tag, pointing to a Key instance, or an array ["bucket", "key"]
118
- # @return [Hash] links that this RiakContent points to
151
+ # @return [Hash] links that this Content points to
119
152
  def link_key(tags)
120
- raise TypeError.new t('invalid_tag') unless tag.is_a?(Hash)
153
+ raise TypeError.new t('invalid_tag') unless tags.is_a?(Hash) or tags.is_a?(Array)
154
+
121
155
  tags.each do |tag, link|
122
156
  case link
123
157
  when Array
124
- bucket ||= link[0]
125
- key ||= link[1]
126
- raise TypeError.new t('invalid_tag') if bucket.nil? or key.nil?
127
-
128
- get_link ||= @key.get_linked(bucket, key, {:safely => true})
129
- raise RuntimeError.new t('invalid_key') if get_link.nil?
158
+ newlink = Riakpb::RpbLink.new
159
+ newlink[:bucket] = link[0]
160
+ newlink[:key] = link[1]
161
+ raise ArgumentError.new t('invalid_tag') if link[0].nil? or link[1].nil?
130
162
 
131
- @links[tag.to_s] << get_link
163
+ @links[tag.to_s] << newlink
132
164
 
133
- when Riak::Key
165
+ when Riakpb::Key
134
166
  @links[tag.to_s] << link
135
167
 
136
168
  else
@@ -142,35 +174,59 @@ module Riak
142
174
 
143
175
  # Set the links to other Key in riak.
144
176
  # @param [RpbGetResp, RpbPutResp] contains the tag/bucket/key of a given link
145
- # @return [Set] links that this RiakContent points to
177
+ # @return [Set] links that this Content points to
146
178
  def links=(pb_links)
147
179
  @links.clear
148
180
 
149
- pb_links.each do |pb_link|
150
- @links[pb_link.tag] << @key.get_linked(pb_link.bucket, pb_link.key, {:safely => true})
181
+ case pb_links
182
+ when Hash
183
+ pb_links.each do |k, v|
184
+ raise TypeError.new unless k.is_a?(String)
185
+
186
+ if v.is_a?(Array)
187
+ @links[k] += v
188
+ else
189
+ @links[k] << v
190
+ end
191
+ end
192
+
193
+ when Array, Protobuf::Field::FieldArray
194
+ pb_links.each do |pb_link|
195
+ @links[pb_link.tag] << @key.get_linked(pb_link.bucket, pb_link.key, {:safely => true})
196
+ end
197
+ else
198
+ raise TypeError.new
151
199
  end
152
200
 
153
201
  return(@links)
154
202
  end
155
203
 
156
- # @return [Riak::RpbContent] An instance of a RpbContent, suitable for protobuf exchange
157
- def to_pb
158
- raise TypeError.new t('value_empty') if @value.nil?
159
204
 
160
- rpb_content = Riak::RpbContent.new
205
+ def last_mod=(time_mod)
206
+ @last_mod = Time.at time_mod
207
+ end
208
+
209
+ # @return [Riakpb::RpbContent] An instance of a RpbContent, suitable for protobuf exchange
210
+ def to_pb
211
+ rpb_content = Riakpb::RpbContent.new
161
212
  rpb_links = []
162
213
 
163
214
  @links.each do |tag, links|
164
215
  links.each do |link|
165
- pb_link = link.to_pb_link
166
- pb_link.tag = tag
167
- rpb_links << pb_link
216
+ case link
217
+ when Riakpb::RpbLink
218
+ rpb_links << hlink
219
+ when Riakpb::Key
220
+ pb_link = link.to_pb_link
221
+ pb_link.tag = tag
222
+ rpb_links << pb_link
223
+ end
168
224
  end
169
225
  end
170
226
 
171
227
  usermeta = []
172
228
  @usermeta.each do |key,value|
173
- pb_pair = Riak::RpbPair.new
229
+ pb_pair = Riakpb::RpbPair.new
174
230
  pb_pair[:key] = key
175
231
  pb_pair[:value] = value
176
232
  usermeta << pb_pair
@@ -179,30 +235,29 @@ module Riak
179
235
  catch(:redo) do
180
236
  case @content_type
181
237
  when /octet/
182
- rpb_content.value = Marshal.dump(@value)
238
+ rpb_content.value = Marshal.dump(@value) unless @value.blank?
183
239
  when /json/
184
- rpb_content.value = ActiveSupport::JSON.encode(@value)
240
+ rpb_content.value = ActiveSupport::JSON.encode(@value) unless @value.blank?
185
241
  when "", nil
186
242
  @content_type = "application/json"
187
243
  redo
188
244
  else
189
- rpb_content.value = @value.to_s
245
+ rpb_content.value = @value.to_s unless @value.blank?
190
246
  end
191
247
  end
192
248
 
193
- rpb_content.content_type = @content_type unless @content_type.nil?
194
- rpb_content.charset = @charset unless @charset.nil? # || @charset.empty?
195
- rpb_content.content_encoding = @content_encoding unless @content_encoding.nil? # || @content_encoding.empty?
196
- rpb_content.vtag = @vtag unless @vtag.nil?
197
- rpb_content.links = rpb_links unless rpb_links.nil?
198
- rpb_content.usermeta = usermeta unless usermeta.nil?
249
+ rpb_content.content_type = @content_type unless @content_type.blank?
250
+ rpb_content.charset = @charset unless @charset.blank? # || @charset.empty?
251
+ rpb_content.content_encoding = @content_encoding unless @content_encoding.blank? # || @content_encoding.empty?
252
+ rpb_content.links = rpb_links unless rpb_links.blank?
253
+ rpb_content.usermeta = usermeta unless usermeta.blank?
199
254
 
200
255
  return(rpb_content)
201
256
  end
202
257
 
203
258
  # @return [String] A representation suitable for IRB and debugging output
204
259
  def inspect
205
- "#<#Riak::RiakContent " + [
260
+ "#<#Riakpb::Content " + [
206
261
  (@value.nil?) ? nil : "value=#{@value.inspect}",
207
262
  (@content_type.nil?) ? nil : "content_type=#{@content_type.inspect}",
208
263
  (@charset.nil?) ? nil : "charset=#{@charset.inspect}",
@@ -218,5 +273,5 @@ module Riak
218
273
 
219
274
  private
220
275
 
221
- end # class RiakContent
222
- end # module Riak
276
+ end # class Content
277
+ end # module Riakpb
@@ -1,7 +1,7 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
4
- # Exception raised when the expected response code from Riak
3
+ module Riakpb
4
+ # Exception raised when the expected response code from Riakpb
5
5
  # fails to match the actual response code.
6
6
  class FailedExchange < StandardError
7
7
  include Util::Translation
@@ -1,10 +1,10 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
4
- # Exception raised when the expected response code from Riak
3
+ module Riakpb
4
+ # Exception raised when the expected response code from Riakpb
5
5
  # fails to match the actual response code.
6
6
  class FailedRequest < StandardError
7
- include Riak::Util::Translation
7
+ include Riakpb::Util::Translation
8
8
 
9
9
  attr_reader :expected
10
10
  attr_reader :actual
data/lib/riak/key.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
4
- # Represents and encapsulates operations on a Riak bucket. You may retrieve a bucket
3
+ module Riakpb
4
+ # Represents and encapsulates operations on a Riakpb bucket. You may retrieve a bucket
5
5
  # using {Client#bucket}, or create it manually and retrieve its meta-information later.
6
6
  class Key
7
7
  include Util::Translation
8
8
  include Util::MessageCode
9
9
 
10
- # @return [Riak::Client] the associated client
10
+ # @return [Riakpb::Client] the associated client
11
11
  attr_reader :bucket
12
12
 
13
13
  # @return [String] the bucket name
@@ -16,25 +16,25 @@ module Riak
16
16
  # @return [String] the bucket name
17
17
  attr_reader :vclock
18
18
 
19
- # Create a Riak bucket manually.
19
+ # Create a Riakpb bucket manually.
20
20
  # @param [Bucket] bucket the Bucket object within which this Key exists
21
21
  # @option options [String] name the name assigned to this Key entity
22
22
  # @option options [Fixnum] vclock Careful! Do not set this unless you have a reason to
23
- # @option options [RiakContent] content a content object, that's to be inserted in this Key
23
+ # @option options [Content] content a content object, that's to be inserted in this Key
24
24
  def initialize(bucket, key, get_response=nil)
25
25
  # options.assert_valid_keys(:name, :vclock, :content)
26
26
 
27
27
  self.bucket = bucket
28
28
  self.name = key
29
29
 
30
- @contents = Hash.new{|k,v| k[v] = Riak::RiakContent.new(self)}
30
+ @contents = Hash.new{|k,v| k[v] = Riakpb::Content.new(self)}
31
31
 
32
32
  # @contents[:new]
33
33
 
34
34
  load(get_response) unless get_response.nil?
35
35
  end
36
36
 
37
- # Load information for the key from the response object, Riak::RpbGetResp.
37
+ # Load information for the key from the response object, Riakpb::RpbGetResp.
38
38
  #
39
39
  # @param [RpbGetResp/Hash] response an RpbGetResp/RpbPutResp object or a Hash.
40
40
  # @return [Key] self
@@ -53,12 +53,12 @@ module Riak
53
53
  return(self)
54
54
  end
55
55
 
56
- # Load information for the key from Riak::RpbGetResp object.
56
+ # Load information for the key from Riakpb::RpbGetResp object.
57
57
  #
58
58
  # @param [RpbGetResp/Hash] response an RpbGetResp/RpbPutResp object or a Hash.
59
59
  # @return [Key] self
60
60
  def load!(response)
61
- raise ArgumentError, t("response_type") unless response.is_a?(Riak::RpbGetResp)
61
+ raise ArgumentError, t("response_type") unless response.is_a?(Riakpb::RpbGetResp)
62
62
 
63
63
  if response.has_field?(:vclock) and response.has_field?(:content)
64
64
 
@@ -89,8 +89,8 @@ module Riak
89
89
 
90
90
  end
91
91
 
92
- # Retrieves any Keys that are linked to, inside RiakContent elements.
93
- # @return [Key] the Key to which the RiakContent is linked (may be empty if it does not exist)
92
+ # Retrieves any Keys that are linked to, inside Content elements.
93
+ # @return [Key] the Key to which the Content is linked (may be empty if it does not exist)
94
94
  def get_linked(bucket, key, options={})
95
95
  @bucket.get_linked(bucket, key, options)
96
96
  end
@@ -98,7 +98,7 @@ module Riak
98
98
  # Sets the name attribute for this Key object
99
99
  # @param [String] key_name sets the name of the Key
100
100
  # @return [Hash] the properties that were accepted
101
- # @raise [FailedRequest] if the new properties were not accepted by the Riak server
101
+ # @raise [FailedRequest] if the new properties were not accepted by the Riakpb server
102
102
  def name=(key_name)
103
103
  raise ArgumentError, t("key_name_type") unless key_name.is_a?(String)
104
104
 
@@ -107,9 +107,9 @@ module Riak
107
107
 
108
108
  # Sets the content object for this Key. I do not yet support siblings in this method and, therefore,
109
109
  # you may or may not destroy them if you use this and are not careful.
110
- # @param [Riak::RiakContent] content a RiakContent instance that should be contained within this Key
111
- # @return [Riak::RiakContent] the RiakContent instance that was just set
112
- # @raise [ArgumentError] will yell at you if the supplied riak_content is not of the RiakContent class
110
+ # @param [Riakpb::Content] content a Content instance that should be contained within this Key
111
+ # @return [Riakpb::Content] the Content instance that was just set
112
+ # @raise [ArgumentError] will yell at you if the supplied riak_content is not of the Content class
113
113
  def content=(riak_contents)
114
114
 
115
115
  if riak_contents.is_a?(Protobuf::Field::FieldArray)
@@ -122,7 +122,7 @@ module Riak
122
122
  end
123
123
 
124
124
  return(true)
125
- elsif riak_contents.is_a?(Riak::RiakContent)
125
+ elsif riak_contents.is_a?(Riakpb::Content)
126
126
 
127
127
  @contents.clear
128
128
 
@@ -137,9 +137,9 @@ module Riak
137
137
 
138
138
  end # def content=
139
139
 
140
- # "@contents" is an array of RiakContent objects, though only contains more than one in the event that
140
+ # "@contents" is an array of Content objects, though only contains more than one in the event that
141
141
  # there are siblings.
142
- # @return [Riak::RiakContent] the content of this Key instance's value (ie, key/value)
142
+ # @return [Riakpb::Content] the content of this Key instance's value (ie, key/value)
143
143
  def content
144
144
  case @contents.size
145
145
  when 0 then @contents[:new]
@@ -148,8 +148,8 @@ module Riak
148
148
  end
149
149
  end
150
150
 
151
- # "@contents" is an array of RiakContent objects. This gives you that entire array.
152
- # @return [Array<Riak::RiakContent>] the contents of this Key instance's value and its siblings, if any
151
+ # "@contents" is an array of Content objects. This gives you that entire array.
152
+ # @return [Array<Riakpb::Content>] the contents of this Key instance's value and its siblings, if any
153
153
  def contents
154
154
  retr_c = []
155
155
 
@@ -158,8 +158,8 @@ module Riak
158
158
  return(retr_c)
159
159
  end
160
160
 
161
- # Save the Key+RiakContent instance in riak.
162
- # @option options [RiakContent] content RiakContent instance to be saved in this Key. Must be specified if there are siblings.
161
+ # Save the Key+Content instance in riak.
162
+ # @option options [Content] content Content instance to be saved in this Key. Must be specified if there are siblings.
163
163
  # @option options [Fixnum] w (write quorum) how many replicas to write to before returning a successful response
164
164
  # @option options [Fixnum] dw how many replicas to commit to durable storage before returning a successful response
165
165
  # @option options [Boolean] return_body whether or not to have riak return the key, once saved. default = true
@@ -175,8 +175,8 @@ module Riak
175
175
  end
176
176
  end
177
177
 
178
- options[:content] = rcontent.to_pb if rcontent.is_a?(Riak::RiakContent)
179
- options[:content] = rcontent if rcontent.is_a?(Riak::RpbContent)
178
+ options[:content] = rcontent.to_pb if rcontent.is_a?(Riakpb::Content)
179
+ options[:content] = rcontent if rcontent.is_a?(Riakpb::RpbContent)
180
180
  options[:key] = @name
181
181
  options[:vclock] = @vclock unless @vclock.nil?
182
182
 
@@ -190,7 +190,7 @@ module Riak
190
190
  end
191
191
  end
192
192
 
193
- # Save the RiakContent instance in riak. Raise/do not rescue on failure.
193
+ # Save the Content instance in riak. Raise/do not rescue on failure.
194
194
  # @option options [Fixnum] w (write quorum) how many replicas to write to before returning a successful response
195
195
  # @option options [Fixnum] dw how many replicas to commit to durable storage before returning a successful response
196
196
  # @option options [Boolean] return_body whether or not to have riak return the key, once saved. default = true
@@ -208,7 +208,7 @@ module Riak
208
208
  # @option options [Fixnum] w (write quorum) how many replicas to write to before returning a successful response
209
209
  # @option options [Fixnum] dw how many replicas to commit to durable storage before returning a successful response
210
210
  # @option options [Boolean] return_body whether or not to have riak return the key, once saved. default = true
211
- # @return [Riak::RpbPutReq]
211
+ # @return [Riakpb::RpbPutReq]
212
212
  def to_pb_put(options={})
213
213
  rcontent = options[:content]
214
214
 
@@ -220,26 +220,26 @@ module Riak
220
220
  end
221
221
  end
222
222
 
223
- pb_put_req = Riak::RpbPutReq.new
223
+ pb_put_req = Riakpb::RpbPutReq.new
224
224
  pb_put_req.key = @name
225
- pb_put_req.content = rcontent.to_pb if rcontent.is_a?(Riak::RiakContent)
226
- pb_put_req.content = rcontent if rcontent.is_a?(Riak::RpbContent)
225
+ pb_put_req.content = rcontent.to_pb if rcontent.is_a?(Riakpb::Content)
226
+ pb_put_req.content = rcontent if rcontent.is_a?(Riakpb::RpbContent)
227
227
  pb_put_req.vclock = @vclock unless @vclock.nil?
228
228
 
229
229
  return(pb_put_req)
230
230
  end
231
231
 
232
- # "@contents" is an array of RiakContent objects. This gives you that entire array.
233
- # @return [Riak::RpbLink]
232
+ # "@contents" is an array of Content objects. This gives you that entire array.
233
+ # @return [Riakpb::RpbLink]
234
234
  def to_pb_link
235
- pb_link = Riak::RpbLink.new
235
+ pb_link = Riakpb::RpbLink.new
236
236
  pb_link[:bucket] = @bucket.name
237
237
  pb_link[:key] = @name
238
238
 
239
239
  return(pb_link)
240
240
  end
241
241
 
242
- # Converts this Key into an array, that can be used by a RiakContent, if desired.
242
+ # Converts this Key into an array, that can be used by a Content, if desired.
243
243
  # @return [Array] contains the name of the bucket and the name of the key
244
244
  def to_link
245
245
  [@bucket.name, @name]
@@ -255,7 +255,7 @@ module Riak
255
255
 
256
256
  # @return [String] a representation suitable for IRB and debugging output
257
257
  def inspect
258
- "#<Riak::Key name=#{@name.inspect}, vclock=#{@vclock.inspect}, contents=#{contents.inspect}>"
258
+ "#<Riakpb::Key name=#{@name.inspect}, vclock=#{@vclock.inspect}, contents=#{contents.inspect}>"
259
259
  end
260
260
 
261
261
  private
@@ -263,14 +263,14 @@ module Riak
263
263
  # Sets the name attribute for this Key object
264
264
  # @param [String] key_name sets the name of the Key
265
265
  # @return [Hash] the properties that were accepted
266
- # @raise [FailedRequest] if the new properties were not accepted by the Riak server
266
+ # @raise [FailedRequest] if the new properties were not accepted by the Riakpb server
267
267
  def bucket=(bucket)
268
- raise ArgumentError, t("invalid_bucket") unless bucket.is_a?(Riak::Bucket)
268
+ raise ArgumentError, t("invalid_bucket") unless bucket.is_a?(Riakpb::Bucket)
269
269
 
270
270
  @bucket ||= bucket
271
271
  end
272
272
 
273
- # Sets the vclock attribute for this Key, which was supplied by the Riak node (if you're doing it right)
273
+ # Sets the vclock attribute for this Key, which was supplied by the Riakpb node (if you're doing it right)
274
274
  # @param [Fixnum] vclock the vector clock
275
275
  # @return [Fixnum] the vector clock
276
276
  # @raise [ArgumentError] if you failed at this task, you'll be instructed to place your head on the keyboard
@@ -281,4 +281,4 @@ module Riak
281
281
  end
282
282
 
283
283
  end # class Key
284
- end # module Riak
284
+ end # module Riakpb
@@ -1,14 +1,14 @@
1
1
  en:
2
2
  riak:
3
- client_type: "invalid argument {{client}} is not a Riak::Client"
3
+ client_type: "invalid argument {{client}} is not a Riakpb::Client"
4
4
  string_type: "invalid_argument {{string}} is not a String"
5
5
  loading_bucket: "while loading bucket '{{name}}'"
6
6
  invalid_bucket: "the specified bucket is invalid"
7
7
  invalid_key: "the specified key is invalid or does not exist"
8
8
  siblings_disallowed: "the specified bucket does not allow siblings. Set allow_mult in props to do this."
9
9
  value_empty: "a value must be set in order to serialize into a protocol buffer"
10
- failed_request: "Expected message code {{expected}} from Riak but received {{actual}}. {{output}}"
11
- decode_error: "Riak reported a message length of {{expected}} but length was {{actual}}. {{output}}"
10
+ failed_request: "Expected message code {{expected}} from Riakpb but received {{actual}}. {{output}}"
11
+ decode_error: "Riakpb reported a message length of {{expected}} but length was {{actual}}. {{output}}"
12
12
  save_resp_siblings: "The save operation has resulted in unresolved siblings. {{output}}"
13
13
  save_resp_err: "The attempted save operation resulted in an error response from riak."
14
14
  failed_rx: "You might have discovered a bug. {{failure}}"
@@ -1,6 +1,6 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
3
+ module Riakpb
4
4
  # Class for invoking map-reduce jobs using the HTTP interface.
5
5
  class MapReduce
6
6
  include Util::Translation
@@ -15,7 +15,7 @@ module Riak
15
15
  attr_accessor :query
16
16
 
17
17
  # Creates a new map-reduce job.
18
- # @param [Client] client the Riak::Client interface
18
+ # @param [Client] client the Riakpb::Client interface
19
19
  # @yield [self] helpful for initializing the job
20
20
  def initialize(client)
21
21
  @client, @inputs, @query = client, [], []
@@ -44,16 +44,16 @@ module Riak
44
44
  when 1
45
45
  p = params.first
46
46
  case p
47
- when Riak::Bucket
47
+ when Riakpb::Bucket
48
48
  @inputs = p.name
49
- when Riak::Key
49
+ when Riakpb::Key
50
50
  @inputs << p.to_input
51
51
  when String
52
52
  @inputs = p
53
53
  end
54
54
  when 2..3
55
55
  bucket = params.shift
56
- bucket = bucket.name if Riak::Bucket === bucket
56
+ bucket = bucket.name if Riakpb::Bucket === bucket
57
57
  @inputs << params.unshift(bucket)
58
58
  end
59
59
  self
@@ -135,7 +135,7 @@ module Riak
135
135
  # @return [Symbol] the type of phase - :map, :reduce, or :link
136
136
  attr_accessor :type
137
137
 
138
- # @return [String, Array<String, String>, Hash, WalkSpec] For :map and :reduce types, the Javascript function to run (as a string or hash with bucket/key), or the module + function in Erlang to run. For a :link type, a {Riak::WalkSpec} or an equivalent hash.
138
+ # @return [String, Array<String, String>, Hash, WalkSpec] For :map and :reduce types, the Javascript function to run (as a string or hash with bucket/key), or the module + function in Erlang to run. For a :link type, a {Riakpb::WalkSpec} or an equivalent hash.
139
139
  attr_accessor :function
140
140
 
141
141
  # @return [String] the language of the phase's function - "javascript" or "erlang". Meaningless for :link type phases.
@@ -1,10 +1,10 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
4
- # Exception raised when the expected response code from Riak
3
+ module Riakpb
4
+ # Exception raised when the expected response code from Riakpb
5
5
  # fails to match the actual response code.
6
6
  class SiblingError < StandardError
7
- include Riak::Util::Translation
7
+ include Riakpb::Util::Translation
8
8
 
9
9
  attr_reader :key
10
10
 
@@ -1,6 +1,6 @@
1
1
  require 'riak'
2
2
 
3
- module Riak
3
+ module Riakpb
4
4
  module Util
5
5
 
6
6
  module Decode