pg_lock 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d4751ff801966253cdbd7662bf288c44251b0c50
4
- data.tar.gz: a826d5ee152d541b70dbd1a448cfabd005f6e100
2
+ SHA256:
3
+ metadata.gz: e285d50b50c70bd26a8e9ce0047cb874450ebc27dc5db28c903ef613540ecaed
4
+ data.tar.gz: 8a167c46ae260ac9b84e0dd442f821a7d3a9894a4a72f206cb5fd669fcbf4594
5
5
  SHA512:
6
- metadata.gz: 44720df9698d51ec531713d26faa8379df673b408b686892413af5122f32d8f1b7517561354bcacbc9ba0e323e4aa6b2a875cf49340f4d877b057757b14ee43e
7
- data.tar.gz: 073c50e4bd05804b57cc22d019b4ca5def74c21032e52d9a31d9fcff20ca49da3fc72e0098c1292fdde2f20b6eef6638a91dd634c0accc9013015cc5e6484af7
6
+ metadata.gz: 23e058530b6b4029df92d8733ab7828753360c85092113a1dac14afab03ff8de6a1c926c8399a7f6833811b3963febd75bb1aeaefdfb8827ab3e44c13964e7e4
7
+ data.tar.gz: 7346e5463867c3a5755203c6c8e397e863d1d2756eeda5db4614dc525693d758270e02a9bb4b6ec8e686565410cec011f7be1657d480f5fcf1d35314bb0366a2
@@ -1,5 +1,9 @@
1
1
  # A Log of Changes!
2
2
 
3
+ ## [0.1.2] - 2017-12-06
4
+
5
+ - Support Rails 5 and newer PG versions [#5]
6
+
3
7
  ## [0.1.1] - 2015-10-07
4
8
 
5
9
  - Allow setting default connection with constant.
data/README.md CHANGED
@@ -182,6 +182,12 @@ Where `DB` is to be your database connection.
182
182
 
183
183
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
184
184
 
185
+ To run tests you'll need a database:
186
+
187
+ ```
188
+ $ createdb pg_lock_test
189
+ ```
190
+
185
191
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
186
192
 
187
193
  ## Contributing
@@ -1,6 +1,8 @@
1
1
  class PgLock
2
2
  # Holds the logic to aquire a lock and parse if locking was successful
3
3
  class Locket
4
+ TRUE_VALUES = [true, "t"].freeze
5
+
4
6
  attr_accessor :args, :connection
5
7
  def initialize(connection, lock_args)
6
8
  self.connection = connection
@@ -18,13 +20,13 @@ class PgLock
18
20
  end
19
21
 
20
22
  def aquired?
21
- @lock[0]["pg_try_advisory_lock"] == "t"
23
+ TRUE_VALUES.include?(@lock[0]["pg_try_advisory_lock"])
22
24
  rescue
23
25
  false
24
26
  end
25
27
 
26
28
  def active?
27
- connection.exec(<<-eos, args).getvalue(0,0) == "t"
29
+ active = connection.exec(<<-eos, args).getvalue(0,0)
28
30
  SELECT granted
29
31
  FROM pg_locks
30
32
  WHERE locktype = 'advisory' AND
@@ -33,6 +35,8 @@ class PgLock
33
35
  classid = $1 AND
34
36
  objid = $2
35
37
  eos
38
+
39
+ TRUE_VALUES.include?(active)
36
40
  end
37
41
  end
38
- end
42
+ end
@@ -1,3 +1,3 @@
1
1
  class PgLock
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mikehale
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-10-07 00:00:00.000000000 Z
12
+ date: 2017-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.4.5.1
127
+ rubygems_version: 2.6.14
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Use Postgres advisory lock to isolate code execution across machines