rackamole 0.2.2 → 0.2.3

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.
data/HISTORY CHANGED
@@ -14,4 +14,9 @@
14
14
 
15
15
  0.2.2
16
16
  * NOTICE: Wrong docs and wrong configuration for mongo store initialization
17
- * Corrected docs and validation for mongo store init - changed :database to :db_name
17
+ * Corrected docs and validation for mongo store init - changed :database to :db_name
18
+
19
+ 0.2.3
20
+ * Bug fixes
21
+ * Fixed issue where session or param key falls under the format a.b.c which causes
22
+ validation problems in mongoDB. Thanks Rafael!
data/lib/rackamole.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Rackamole
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
  # :startdoc:
@@ -162,11 +162,23 @@ module Rackamole
162
162
  }
163
163
 
164
164
  args.each do |k,v|
165
- row[min_field(k)] = v if v
165
+ row[min_field(k)] = check_hash( v ) if v
166
166
  end
167
167
  logs.save( row )
168
168
  end
169
169
 
170
+ # Check for invalid key format - ie something that will choke mongo
171
+ # case a.b.c => a_b_c
172
+ def ensure_valid_key( key )
173
+ key.to_s.index( /\./ ) ? key.to_s.gsub( /\./, '_' ) : key
174
+ end
175
+
176
+ # Check
177
+ def check_hash( value )
178
+ return value unless value.is_a?( Hash )
179
+ value.keys.inject({}){ |h,k| h[ensure_valid_key(k)] = value[k];h }
180
+ end
181
+
170
182
  # For storage reason minify the json to save space...
171
183
  def min_field( field )
172
184
  field_map[field] || field
@@ -34,9 +34,9 @@ describe Rackamole::Store::MongoDb do
34
34
  @args[:session] = { :fred => 10.to_json }
35
35
  @args[:created_at] = @now.utc
36
36
  end
37
-
37
+
38
38
  it "should mole a context based feature correctly" do
39
- @store.mole( @args )
39
+ @store.mole( @args )
40
40
  @store.features.count.should == 1
41
41
  @store.logs.count.should == 1
42
42
 
@@ -75,6 +75,18 @@ describe Rackamole::Store::MongoDb do
75
75
  user['did'].should == '20091127'
76
76
  end
77
77
 
78
+ it "should convert a.b.c session keys correctly" do
79
+ @args[:session] = { 'a.b.c' => 10 }
80
+
81
+ @store.mole( @args )
82
+ @store.features.count.should == 1
83
+ @store.logs.count.should == 1
84
+
85
+ log = @store.logs.find_one()
86
+ log.should_not be_nil
87
+ log['ses'].should == { 'a_b_c' => 10 }
88
+ end
89
+
78
90
  it "should mole a rails feature correctly" do
79
91
  @args[:path] = '/fred/blee/duh'
80
92
  @args[:route_info] = { :controller => 'fred', :action => 'blee', :id => 'duh' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackamole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 -07:00
12
+ date: 2010-01-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency