occams-record 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18a298de4e4ba5a69fc0a6d1b3fb3faa2aa87fff6521b646a247276047a19881
4
- data.tar.gz: 01b292cfd25ab7343d817e58dfca09b5bf78f49a91ec3db7686dda5d83e840b5
3
+ metadata.gz: 59a1532b7b4de439a549008362dcc631ee79bfbd069c76a322e7df01c7f8d7f9
4
+ data.tar.gz: 765fe5f325d60a9d9830960be99028aa6215b166d9b2ef13bab84d074e9ede5c
5
5
  SHA512:
6
- metadata.gz: a403135e27531126a476472f8a8480598a1ed62c08657f6fa6541548d312a2d67707806620771d79ece5c8731f5f2b5e09e645676578b4018df69af0a1187437
7
- data.tar.gz: e154b22a69dd39051be5ef604f64ee9c86c80f9cf332cc1b26f6019ed2f599701f562f47537b39bc3c40433166200f554b819a949578f0c3acc483ab2ea1d847
6
+ metadata.gz: d3a1bebbc0996c1b5b1efe59dfe2b47f14491b8a426eba7bea2e8269693ad7e0ff579c860bcf9031eb7c2ed18f7f4ce525c854d61d8444ed4505fd366fcb6050
7
+ data.tar.gz: a315b65a3a5c1750a09956ea9330c68b83d10bcd943cb9edf32fe94f47b54b9f9af016abb6f524f7567bd424c74d5cc661b836db6dbeb324e94f7f8222f444a5
@@ -1,33 +1,22 @@
1
1
  module OccamsRecord
2
2
  module BindsConverter
3
- # @private
4
- WORD = /\w/
5
-
6
3
  #
7
4
  # Converts Rails-style named binds (:foo) into native Ruby format (%{foo}).
8
5
  #
9
- class Named < Abstract
6
+ class Named
10
7
  def initialize(sql)
11
- super(sql, ":".freeze)
8
+ @sql = sql
12
9
  end
13
10
 
14
- protected
15
-
16
- def get_bind
17
- old_i = @i
18
- @i += 1
19
- @start_i = @i
20
-
21
- until @i > @end or @sql[@i] !~ WORD
22
- @i += 1
23
- end
24
-
25
- if @i > @start_i
26
- name = @sql[@start_i..@i - 1]
27
- @start_i = @i
28
- "%{#{name}}"
29
- else
30
- @sql[old_i]
11
+ def to_s
12
+ @sql.gsub(/([:\\]?):([a-zA-Z]\w*)/) do |match|
13
+ if $1 == ":".freeze # skip PostgreSQL casts
14
+ match # return the whole match
15
+ elsif $1 == "\\".freeze # escaped literal colon
16
+ match[1..-1] # return match with escaping backslash char removed
17
+ else
18
+ "%{#{$2}}"
19
+ end
31
20
  end
32
21
  end
33
22
  end
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module OccamsRecord
5
5
  # @private
6
- VERSION = "1.11.0".freeze
6
+ VERSION = "1.11.1".freeze
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occams-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger