trusty 0.2.6 → 0.2.7

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: 57e1e69812a9eff269cfb035d3581c7c54b4aa85
4
- data.tar.gz: 8e0a6b6d11ef2f74565ecd417ec5163353775bd6
3
+ metadata.gz: c138b9fca14a52e0c321c4704aea6f7391766662
4
+ data.tar.gz: 5757a65d2ca71592cfaa24cd5c683133c77b3be6
5
5
  SHA512:
6
- metadata.gz: fbd241c9a26ec21105da1a400da7ae367750bffc81aba9f82f18da4a34de22d0e7b57dbf89ca1eb101dacab14effeef1294973f385543852cdad81fe393315de
7
- data.tar.gz: 8e3f8dfc7b0d7661d489a994ff3186843fb11d204934a8852558202f69b5e96652e27f5cc38cb3fe2489691f14aa5d6cbe935bfa241c48253fa757d5eee5d1d0
6
+ metadata.gz: f5bf1bceee74c2fffeb430902453acb09805ca3e12d54e69f5a451f8ed288fd0fc84ed262bc211f67a791d35d520516fa1f42928d4da521e5bf4cec1e76ef1bb
7
+ data.tar.gz: fd5462f1db6d72d9f4bcb643145fb0f71ca30271002d0b43f2cc69c3e0f1dfdefd1fd14177b15ebf6684388439762c47bf29b82d3ba4046afdcbf54362f99b13
@@ -2,14 +2,14 @@ module Trusty
2
2
  module Omniauth
3
3
  module MappingHelpers
4
4
  def clean(value, *filters, &default_value)
5
- default_value ||= lambda{ nil }
6
-
5
+ default_value ||= ->{ nil }
6
+
7
7
  filters.each do |method_name|
8
8
  value = value.to_s.send(method_name)
9
9
  end
10
-
10
+
11
11
  value.blank? ? default_value.call : value
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -101,7 +101,6 @@ module Trusty
101
101
  def stringify_keys(original_hash)
102
102
  original_hash.each_with_object({}){|(key, value), hash| hash[key.to_s] = value}
103
103
  end
104
-
105
104
  end
106
105
  end
107
106
  end
@@ -122,11 +122,7 @@ module Trusty
122
122
 
123
123
  def attributes(*filter_attribute_names)
124
124
  unless @attributes
125
- raw_info = provider_attributes['extra']['raw_info'] || provider_attributes['extra']
126
- info = provider_attributes.fetch('info', raw_info)
127
- credentials = provider_attributes['credentials']
128
-
129
- name = clean(info['name']) { [info['first_name'], info['last_name']].join(" ").strip }
125
+ name = clean(info['name']) { info.values_at('first_name', 'last_name').join(' ').strip }
130
126
  first_name = clean(info['first_name']) { name.split(/\s+/, 2).first }
131
127
  last_name = clean(info['last_name']) { name.split(/\s+/, 2).last }
132
128
  urls = info.fetch('urls', {})
@@ -137,14 +133,14 @@ module Trusty
137
133
  :name => name,
138
134
  :company => info['company'] || raw_info['company'],
139
135
  :email => clean(info['email'], :downcase, :strip),
140
- :verified => !!(raw_info['verified_email'] || raw_info['verified']),
136
+ :verified => !!first_for(raw_info, %w{verified_email email_verified verified confirmed verified_account}),
141
137
  :username => clean(info['nickname']),
142
138
  :first_name => first_name,
143
139
  :middle_name => clean(info['middle_name']),
144
140
  :last_name => last_name,
145
141
  :phone => clean(info['phone'] || raw_info['sms_number']),
146
142
  :image_url => info['image'],
147
- :profile_url => urls['public_profile'] || urls['GitHub'] || raw_info['blog'],
143
+ :profile_url => first_for(urls, %w{profile public_profile GitHub}) || first_for(raw_info, %w{url blog}),
148
144
  :token_type => clean(credentials['token_type']),
149
145
  :token => clean(credentials['token']),
150
146
  :secret => clean(credentials['secret']),
@@ -169,6 +165,25 @@ module Trusty
169
165
  end
170
166
  end
171
167
 
168
+ private
169
+
170
+ def raw_info
171
+ @raw_info ||= provider_attributes['extra']['raw_info'] || provider_attributes['extra']
172
+ end
173
+
174
+ def info
175
+ @info ||= provider_attributes.fetch('info', raw_info)
176
+ end
177
+
178
+ def credentials
179
+ provider_attributes['credentials']
180
+ end
181
+
182
+ def first_for(hash, *names)
183
+ key = names.flatten.find{ |name| hash[name] }
184
+
185
+ hash[key]
186
+ end
172
187
  end
173
188
  end
174
189
  end
@@ -1,3 +1,3 @@
1
1
  module Trusty
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Van Horn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-26 00:00:00.000000000 Z
11
+ date: 2017-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler