socialmux 0.0.1 → 0.0.2

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: 4feb9f255148e3abc9a97d01afe6a156bbfa80e8
4
- data.tar.gz: fb8b815274c1aaee7ead7c86a9132ca6c1c80cb1
3
+ metadata.gz: 51b2002d26d31cc138b58b1c29b19d53a64af0d6
4
+ data.tar.gz: 00febd49fbced62dad8f9c0bc97271426306da53
5
5
  SHA512:
6
- metadata.gz: 7768d1a811be1d8f5dd570e74692ef26e3f97d3a3c40467f5ff103a92c800b545388c83cfe0425df3bfbcdf166d28aa3b9e633ee1a006270e55c3f4fd16b7c7d
7
- data.tar.gz: d064285e28aaeb95718e11a38ca81609d22433e3cfe9042b80568c73826334b4ec864420ccdd37a498ae87239d0274944d6d232581a810ff9e1fa75925d8f5d5
6
+ metadata.gz: cbcea12213bbb1d1bb203ba62488f0eb30203bf60fcf6139795b934465df0504796ca39d56c7f1e89c942ce8fff96fe55454f9970557420c288fdd49b09925ca
7
+ data.tar.gz: 5dd497622b49420b6e6a675d9887516729296817d2c8ab74a5e7ce77a14ab0c3b5e77a68a424d81afc7493f1a28c1f101f24ffd6ea39f8c65ba76d4ee3eff7d6
@@ -1,4 +1,5 @@
1
1
  require 'hashie'
2
+ require 'active_support/inflector'
2
3
 
3
4
  require 'socialmux/auth_mapper/base'
4
5
  require 'socialmux/auth_mapper/guess_name'
@@ -15,11 +16,12 @@ module Socialmux
15
16
  def self.init_with_data(data)
16
17
  data = Hashie::Mash.new(data)
17
18
 
18
- klass_name = "Social::AuthMapper::#{data.provider.classify}"
19
+ klass_name = "Socialmux::AuthMapper::#{data.provider.classify}"
19
20
  klass = klass_name.constantize
20
21
  klass.new(data)
22
+
21
23
  rescue NameError
22
- raise NotFound, "Mapper #{klass_name} for provider #{data.provider} not found!"
24
+ raise NotFound, "Mapper for provider #{data.provider} not found!"
23
25
  end
24
26
  end
25
27
  end
@@ -1,4 +1,4 @@
1
1
  module Socialmux
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
4
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ module Socialmux
4
+ describe AuthMapper do
5
+ describe ".init_with_data" do
6
+ it "dinamically finds the mapper class and instanciates it" do
7
+ data = { provider: 'facebook' }
8
+ mapper = AuthMapper.init_with_data(data)
9
+ expect(mapper).to be_a AuthMapper::Facebook
10
+ end
11
+
12
+ it "raises NotFound if not found" do
13
+ data = { provider: 'foobar' }
14
+ expect do
15
+ AuthMapper.init_with_data(data)
16
+ end.to raise_error AuthMapper::NotFound
17
+ end
18
+ end
19
+ end
20
+ end
21
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialmux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
@@ -161,6 +161,7 @@ files:
161
161
  - spec/lib/auth_mapper/google_oauth2_spec.rb
162
162
  - spec/lib/auth_mapper/linkedin_spec.rb
163
163
  - spec/lib/auth_mapper/twitter_spec.rb
164
+ - spec/lib/auth_mapper_spec.rb
164
165
  - spec/lib/result_spec.rb
165
166
  - spec/lib/strategy_spec.rb
166
167
  - spec/spec_helper.rb
@@ -203,6 +204,7 @@ test_files:
203
204
  - spec/lib/auth_mapper/google_oauth2_spec.rb
204
205
  - spec/lib/auth_mapper/linkedin_spec.rb
205
206
  - spec/lib/auth_mapper/twitter_spec.rb
207
+ - spec/lib/auth_mapper_spec.rb
206
208
  - spec/lib/result_spec.rb
207
209
  - spec/lib/strategy_spec.rb
208
210
  - spec/spec_helper.rb