slim_scrooge 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 1
4
4
  :minor: 0
5
5
  :build:
@@ -6,6 +6,7 @@ module SlimScrooge
6
6
  class Callsites
7
7
  CallsitesMutex = Mutex.new
8
8
  @@callsites = {}
9
+ ScroogeCallsiteSample = 1..16
9
10
 
10
11
  class << self
11
12
  # Whether we have encountered a callsite before
@@ -20,10 +21,20 @@ module SlimScrooge
20
21
  @@callsites[callsite_key]
21
22
  end
22
23
 
24
+ # Fallback if you can't compile extension for some reason
25
+ #
26
+ begin
27
+ callsite_hash
28
+ rescue NameError
29
+ def callsite_hash
30
+ caller[ScroogeCallsiteSample].hash
31
+ end
32
+ end
33
+
23
34
  # Generate a key string - uses the portion of the query before the WHERE
24
35
  # together with the callsite_hash generated by callsite_hash.c
25
36
  #
26
- def callsite_key(callsite_hash, sql)
37
+ def callsite_key(sql)
27
38
  callsite_hash + sql.gsub(/\sWHERE.*/i, "").hash
28
39
  end
29
40
 
@@ -12,7 +12,7 @@ module SlimScrooge
12
12
  module ClassMethods
13
13
  def find_by_sql_with_slim_scrooge(sql)
14
14
  return find_by_sql_without_slim_scrooge(sql) if sql.is_a?(Array) # don't mess with user's custom query
15
- callsite_key = SlimScrooge::Callsites.callsite_key(callsite_hash, sql)
15
+ callsite_key = SlimScrooge::Callsites.callsite_key(sql)
16
16
  if SlimScrooge::Callsites.has_key?(callsite_key)
17
17
  find_with_callsite_key(sql, callsite_key)
18
18
  elsif callsite = SlimScrooge::Callsites.create(sql, callsite_key, name) # new site that is scroogeable
data/lib/slim_scrooge.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Author: Stephen Sykes
2
2
 
3
- require 'callsite_hash'
3
+ begin; require 'callsite_hash'; rescue LoadError; end
4
4
  require 'slim_scrooge/simple_set'
5
5
  require 'slim_scrooge/callsites'
6
6
  require 'slim_scrooge/callsite'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_scrooge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-23 00:00:00 +02:00
12
+ date: 2009-11-26 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15