simple_record 1.4.18 → 1.4.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +10 -0
- data/lib/simple_record/active_sdb.rb +7 -1
- data/test/test_base.rb +1 -0
- metadata +3 -3
data/lib/simple_record.rb
CHANGED
@@ -49,22 +49,32 @@ module SimpleRecord
|
|
49
49
|
@@logging = false
|
50
50
|
@@s3 = nil
|
51
51
|
@@auto_close_s3 = false
|
52
|
+
@@logger = Logger.new(STDOUT)
|
53
|
+
@@logger.level = Logger::INFO
|
52
54
|
|
53
55
|
class << self;
|
54
56
|
attr_accessor :aws_access_key, :aws_secret_key
|
55
57
|
|
58
|
+
# Deprecated
|
56
59
|
def enable_logging
|
57
60
|
@@logging = true
|
61
|
+
@@logger.level = Logger::DEBUG
|
58
62
|
end
|
59
63
|
|
64
|
+
# Deprecated
|
60
65
|
def disable_logging
|
61
66
|
@@logging = false
|
62
67
|
end
|
63
68
|
|
69
|
+
# Deprecated
|
64
70
|
def logging?
|
65
71
|
@@logging
|
66
72
|
end
|
67
73
|
|
74
|
+
def logger
|
75
|
+
@@logger
|
76
|
+
end
|
77
|
+
|
68
78
|
# This can be used to log queries and what not to a file.
|
69
79
|
# Params:
|
70
80
|
# :select=>{:filename=>"file_to_write_to", :format=>"csv"}
|
@@ -360,6 +360,9 @@ module SimpleRecord
|
|
360
360
|
|
361
361
|
protected
|
362
362
|
|
363
|
+
def logger
|
364
|
+
SimpleRecord.logger
|
365
|
+
end
|
363
366
|
# Select
|
364
367
|
|
365
368
|
def select_from_ids(args, options) # :nodoc:
|
@@ -403,16 +406,18 @@ module SimpleRecord
|
|
403
406
|
@next_token = options[:next_token]
|
404
407
|
@consistent_read = options[:consistent_read]
|
405
408
|
select_expression = build_select(options)
|
409
|
+
logger.debug 'SELECT=' + select_expression
|
406
410
|
# request items
|
407
411
|
query_result = self.connection.select(select_expression, @next_token, @consistent_read)
|
408
412
|
# puts 'QR=' + query_result.inspect
|
413
|
+
@next_token = query_result[:next_token]
|
409
414
|
ret = {}
|
410
415
|
if count
|
411
416
|
ret[:count] = query_result.delete(:items)[0]["Domain"]["Count"][0].to_i
|
412
417
|
ret.merge!(query_result)
|
413
418
|
return ret
|
414
419
|
end
|
415
|
-
|
420
|
+
|
416
421
|
items = query_result.delete(:items).map do |hash|
|
417
422
|
id, attributes = hash.shift
|
418
423
|
new_item = self.new()
|
@@ -626,6 +631,7 @@ module SimpleRecord
|
|
626
631
|
rx = /\b(\w*)[\s|>=|<=|!=|=|>|<|like]/
|
627
632
|
fields = conditions[0].scan(rx)
|
628
633
|
# puts 'condition_fields = ' + fields.inspect
|
634
|
+
fields[0]
|
629
635
|
end
|
630
636
|
|
631
637
|
end
|
data/test/test_base.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 1.4.
|
8
|
+
- 19
|
9
|
+
version: 1.4.19
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-29 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|