lti_roles 0.0.2 → 0.0.3

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: c1b5dce00823fac8ca28996f3f40eea2466eb476
4
- data.tar.gz: '029ba3f785b0342e4e913822a392a8c789258e9d'
3
+ metadata.gz: f6bb3dfd0cddf026cb1a18a4b87a95d09bbdc166
4
+ data.tar.gz: 9d940e9ad7709f14e8333e0146bc52349b6105e8
5
5
  SHA512:
6
- metadata.gz: '049a21c00354302dde67ff06325ec4dae51f7e1c05de4b283c7c8bc30d0651cf8d01e4452968ed9bd2d7d76acfaedb1fd1adfcc18a256f6f8ff00052704cb2af'
7
- data.tar.gz: bc845141f1327b88b7212a2a99d32c3e8ab12085ac41a2faf4bd674a5e9a461fed2972d967bea0f867349dc4ee4845b0a5ea447f3a4ecd306e7557f17bbabeab
6
+ metadata.gz: 7d278152e45f9b2f742f8dd9574101867918b130d708140398ee0d55cec9d993eb27c558984393d0c185c1e320456579dc2b4a8d12aaa19de50d182637e1f1f1
7
+ data.tar.gz: 7837d3a8a5c05e687cffb29b1206b5f19d5b287f5943e487762453bcc4fcfd8bbfd4d95e49157e27eba3a60f041c0d46ab7b6bfcfaf8a494c25319126bb82004
data/README.md CHANGED
@@ -27,7 +27,10 @@ Example:
27
27
  roles = LTIRoles::RoleManager.new('urn:lti:instrole:ims/lis/Instructor,urn:lti:instrole:ims/lis/Student,urn:lti:role:ims/lis/Instructor,urn:lti:sysrole:ims/lis/User')
28
28
 
29
29
  roles.institution_roles
30
- => [:instructor, :student]
30
+ => ['instructor', 'student']
31
+
32
+ roles.context_roles
33
+ => ['instructor']
31
34
  ```
32
35
 
33
36
  ## Usage with CanCanCan
@@ -8,21 +8,37 @@ module LTIRoles
8
8
  ContextRoleURN = 'urn:lti:role:ims/lis/'.freeze
9
9
 
10
10
  class RoleManager
11
- attr_accessor :roles, :context_types, :system_roles, :institution_roles, :context_roles
11
+ attr_accessor :roles, :context_types, :system_roles, :institution_roles, :context_roles, :other_roles
12
12
 
13
13
  def initialize(roles = '')
14
14
  @roles = roles
15
- @context_types = map_roles(ContextTypeURN)
16
- @system_roles = map_roles(SystemRoleURN)
17
- @institution_roles = map_roles(InstitutionRoleURN)
18
- @context_roles = map_roles(ContextRoleURN)
15
+ @context_types = []#map_roles(ContextTypeURN)
16
+ @system_roles = []#map_roles(SystemRoleURN)
17
+ @institution_roles = []#map_roles(InstitutionRoleURN)
18
+ @context_roles = []#map_roles(ContextRoleURN)
19
+ @other_roles = []
20
+ map_roles
19
21
  end
20
22
 
21
- def map_roles(urn_prefix)
22
- roles.split(',').map do |role|
23
- next unless role.include?(urn_prefix)
24
- role.gsub(urn_prefix, '').gsub('/', '').underscore
25
- end.compact
23
+ def map_roles
24
+ roles.split(',').each do |role|
25
+ case
26
+ when role.downcase.include?(ContextTypeURN)
27
+ context_types << clean_role(ContextTypeURN, role)
28
+ when role.downcase.include?(SystemRoleURN)
29
+ system_roles << clean_role(SystemRoleURN, role)
30
+ when role.downcase.include?(InstitutionRoleURN)
31
+ institution_roles << clean_role(InstitutionRoleURN, role)
32
+ when role.downcase.include?(ContextRoleURN)
33
+ context_roles << clean_role(ContextRoleURN, role)
34
+ else
35
+ other_roles << role
36
+ end
37
+ end
38
+ end
39
+
40
+ def clean_role(urn_prefix, role)
41
+ role.gsub(urn_prefix, '').gsub('/', '').underscore
26
42
  end
27
43
 
28
44
  def to_h
@@ -1,3 +1,3 @@
1
1
  module LTIRoles
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lti_roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Tanner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport