softwear-lib 1.5.5 → 1.5.6

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
  SHA1:
3
- metadata.gz: 6233f925080da3e48097c8a65a22c015a15b61c4
4
- data.tar.gz: 244bec492a43d14c59f318765c8d65283cac8071
3
+ metadata.gz: 557217d84e460a14db3f2e7fdaa3f8d23baab04b
4
+ data.tar.gz: 6ed4d9f028f3e2ff0ed9a82f0a881531d8f53be1
5
5
  SHA512:
6
- metadata.gz: 7d898e16f08b82ecca883f4adaa4056bb9ff3f3f3b0d5620900c0d363e85db1d200a7dcd0187900ebaf8d3d43babf2691167253cf50eb3861fa3dfd8e55d5ed7
7
- data.tar.gz: 633f91b96bcc356362db034f6876acf03d8edc9419a769958111e8cc0170b88e3f0883cec973bcb9d307d58d0f8f4f51346187a01c7333534b24900f01780879
6
+ metadata.gz: 50776b3c2a6b20ad8c6a817e9924b5ee183d39f887bab0106a763d8fdfa593bbefb0f8aa16e9dc8414f94f2c1a958f2ead01d686da635046afb40968dadc905b
7
+ data.tar.gz: 599f451f5d2102733836e5c43c3aade4b70e578dde3ee5db92e214295b82f22943cc976623cf465dfc2d57afaca6afbf99d5bbefdefb56046aa02411676787b9
@@ -161,7 +161,7 @@ module Softwear
161
161
  @default_socket.puts message
162
162
  end
163
163
 
164
- return default_socket.gets.chomp
164
+ return default_socket.gets.try(:chomp) || (raise AuthServerError, "Nil socket response?")
165
165
 
166
166
  rescue Errno::ECONNREFUSED => e
167
167
  raise AuthServerDown, "Unable to connect to the authentication server."
@@ -310,6 +310,26 @@ module Softwear
310
310
  end
311
311
  end
312
312
 
313
+ def filter_all(method, options)
314
+ all.send(method) do |user|
315
+ options.all? { |field, wanted_value| user.send(field) == wanted_value }
316
+ end
317
+ end
318
+
319
+ # ====================
320
+ # Finds a user with the given attributes (just queries for 'all' and uses ruby filters)
321
+ # ====================
322
+ def find_by(options)
323
+ filter_all(:find, options)
324
+ end
325
+
326
+ # ====================
327
+ # Finds users with the given attributes (just queries for 'all' and uses ruby filters)
328
+ # ====================
329
+ def where(options)
330
+ filter_all(:select, options)
331
+ end
332
+
313
333
  # ====================
314
334
  # Returns an array of all registered users
315
335
  # ====================
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Lib
3
- VERSION = "1.5.5"
3
+ VERSION = "1.5.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softwear-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler