egov_utils 0.1.23 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/egov_utils/user.rb +2 -2
- data/lib/bootstrap_form/fileuid.rb +0 -1
- data/lib/egov_utils/fileuid.rb +21 -8
- data/lib/egov_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a523079b611c16cb2d396f77d105946a0f82359afc2bdf264c8eca9ead5b54
|
4
|
+
data.tar.gz: 83d00e43acb7ac7d1a1996214ebf417601085642629575c13bc5ce8a650fd183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2382de5425cb8f9399b933057b3bace3e2ded8cbf66c4f4a65b29ebdaf8c1582afbd72e6bc3feccb8a69abc512af21f68d2c7b2ba010a624b1e8a7e00a8bef
|
7
|
+
data.tar.gz: 69e22c0e7132b03f8fa34ceb14619bdbdd6419f8b13e7fb7a878a8d2dc95a7c947022db81b377b0f53079869e228b8965bffdc4f33210075a47cd14625c03558
|
@@ -116,12 +116,12 @@ module EgovUtils
|
|
116
116
|
|
117
117
|
def ldap_groups
|
118
118
|
if provider.present?
|
119
|
-
group_ids = Rails.cache.read("#{cache_key}/ldap_group_ids", expires_in: 30.minutes)
|
119
|
+
group_ids = persisted? && Rails.cache.read("#{cache_key}/ldap_group_ids", expires_in: 30.minutes)
|
120
120
|
if group_ids
|
121
121
|
groups = EgovUtils::Group.where(id: group_ids).to_a
|
122
122
|
else
|
123
123
|
groups = EgovUtils::Group.where(provider: provider).to_a.select{|g| auth_source.member?(ldap_dn, g.external_uid) }
|
124
|
-
Rails.cache.write("#{cache_key}/ldap_group_ids", groups.collect(&:id), expires_in: 30.minutes)
|
124
|
+
Rails.cache.write("#{cache_key}/ldap_group_ids", groups.collect(&:id), expires_in: 30.minutes) if persisted?
|
125
125
|
end
|
126
126
|
groups
|
127
127
|
end
|
data/lib/egov_utils/fileuid.rb
CHANGED
@@ -89,13 +89,21 @@ module EgovUtils
|
|
89
89
|
}
|
90
90
|
|
91
91
|
# Used for `serialize` method in ActiveRecord
|
92
|
-
class
|
93
|
-
|
94
|
-
|
92
|
+
class Coder
|
93
|
+
|
94
|
+
def initialize(attr_name, type)
|
95
|
+
@attr_name = attr_name
|
96
|
+
@type = type
|
97
|
+
end
|
98
|
+
|
99
|
+
def dump(obj)
|
100
|
+
return if obj.nil?
|
101
|
+
obj = Fileuid.new(obj, type: @type) if obj.is_a?(String)
|
102
|
+
unless obj.is_a?(Fileuid)
|
95
103
|
raise ::ActiveRecord::SerializationTypeMismatch,
|
96
104
|
"Attribute was supposed to be a #{self}, but was a #{obj.class}. -- #{obj.inspect}"
|
97
105
|
end
|
98
|
-
|
106
|
+
obj.invalid? ? nil : obj.to_s
|
99
107
|
end
|
100
108
|
|
101
109
|
def load(source)
|
@@ -103,8 +111,13 @@ module EgovUtils
|
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
106
|
-
|
114
|
+
AVAILABLE_ATTRIBUTES = [:bc, :agenda, :senat, :year, :document_number]
|
107
115
|
|
116
|
+
attr_accessor *AVAILABLE_ATTRIBUTES
|
117
|
+
|
118
|
+
def ==(other)
|
119
|
+
other.is_a?(Fileuid) && AVAILABLE_ATTRIBUTES.all?{|a| self.public_send(a) == other.public_send(a) }
|
120
|
+
end
|
108
121
|
|
109
122
|
def type
|
110
123
|
@type ||= @options['type']
|
@@ -115,18 +128,18 @@ module EgovUtils
|
|
115
128
|
end
|
116
129
|
|
117
130
|
def invalid?
|
118
|
-
@invalid
|
131
|
+
!type || @invalid
|
119
132
|
end
|
120
133
|
|
121
134
|
def initialize(str_val, **options)
|
122
135
|
@options = options.stringify_keys
|
136
|
+
@str_val = str_val
|
123
137
|
parse_str!(str_val) if str_val.is_a?(String)
|
124
138
|
end
|
125
139
|
|
126
140
|
def parse_str!(str_val, type=self.type)
|
127
141
|
type ||= determine_type(str_val)
|
128
142
|
@type = type
|
129
|
-
@invalid = true unless type
|
130
143
|
return if invalid?
|
131
144
|
match_data = str_val.match(type_definition.to_regex)
|
132
145
|
if match_data
|
@@ -140,7 +153,7 @@ module EgovUtils
|
|
140
153
|
TYPES.each do |k, type|
|
141
154
|
return k if str_val =~ type.to_regex
|
142
155
|
end
|
143
|
-
|
156
|
+
nil
|
144
157
|
end
|
145
158
|
|
146
159
|
def as_json(**options)
|
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|