softwear-lib 1.7.7 → 1.7.8

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
2
  SHA1:
3
- metadata.gz: 67b2cd04a5074e0b928b7b081a1ba825412b8d41
4
- data.tar.gz: 63b3aa50f5b38ff1d29fa1bc528a25210db623e7
3
+ metadata.gz: b19079fbdf0658fa027def56170d17accd293772
4
+ data.tar.gz: fd0592d957dbd00895076c797d0f4ac89a9cb89b
5
5
  SHA512:
6
- metadata.gz: 85a2bc038fd6326c9fc5cf76b7704636d5585b96ab82443a63a65a6fab77d77e5813d1c124a4fdc713e39809dd3beb07eaab81452cd41d4bf321f1b27b9bcd57
7
- data.tar.gz: beb6b05b05484ef31faac798e32ceeaa66c6e2ecf0a14a04c38e56ab299d0d2041c087abe40c3cf386bec98615cd91969fb943485f3a8631b40bc1a277006495
6
+ metadata.gz: a2a77ccde36a526ad4c2a30f4702795eb6a6acc9f57f3913dd82a7bbd8c385a7490085447e6c0e21bfc224be64f755bbb3d2547668757a83c0a1fb2bcf2e6620
7
+ data.tar.gz: 9f797b18c44428930fbffc6e5a9198f47f929e376c6feb18578912964e376c0a277fc7448bf16039ff8126a4cd3c9ef081bfe6c4326d17d6c497e2b6a9dab980
@@ -373,7 +373,19 @@ module Softwear
373
373
 
374
374
  objects = JSON.parse(json).map(&method(:new))
375
375
  objects.each { |u| u.instance_variable_set(:@persisted, true) }
376
- objects
376
+ end
377
+
378
+ # ====================
379
+ # Returns array of all users with the given roles
380
+ # ====================
381
+ def of_role(*roles)
382
+ roles = Array(roles)
383
+ return [] if roles.empty?
384
+
385
+ json = validate_response query "ofrole #{roles.split(' ')}"
386
+
387
+ objects = JSON.parse(json).map(&method(:new))
388
+ objects.each { |u| u.instance_variable_set(:@persisted, true) }
377
389
  end
378
390
 
379
391
  # ====================
@@ -25,6 +25,9 @@ users:
25
25
  ricky@annarbortees.com:
26
26
  first_name: Ricky
27
27
  last_name: Winowiecki
28
+ roles:
29
+ - developer
30
+ - administrator
28
31
  =end
29
32
  # Changes in this .yml file will be reflected live, without restarting your
30
33
  # server.
@@ -84,6 +87,11 @@ users:
84
87
  users_yml[:users].to_a.map(&method(:yml_entry))
85
88
  end
86
89
 
90
+ def of_role(*roles)
91
+ roles = Array(roles)
92
+ all.select { |u| !u.roles.nil? && roles.any? { |r| u.roles.include?(r) } }
93
+ end
94
+
87
95
  def auth(_token)
88
96
  signed_in = users_yml[:signed_in]
89
97
 
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Lib
3
- VERSION = "1.7.7"
3
+ VERSION = "1.7.8"
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.7.7
4
+ version: 1.7.8
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-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler