bouncer-client 0.3 → 0.3.1

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: 59cc204eb7ca90c99260ced94f4374fc7a9b8d5a
4
- data.tar.gz: e663f9cf8930e7f8f1d01d3b36624345fdd48248
3
+ metadata.gz: 71349750645c6431c2cc2885a822adf6407cc7a6
4
+ data.tar.gz: 30e979346953bb2420ce72113f753093dff91acf
5
5
  SHA512:
6
- metadata.gz: f9c981c4264c48d9935c10ef42c7d3a216bd94abf551321814ca9a17a9e9ec152df5e8394a431cd4c29d4b11fff3d70a916676962730e84938615dbfa6cae0ee
7
- data.tar.gz: 68bfbdffd44df59c40d3a064ed3e8aa6a9ff4c5d46e24b72d2edcc74648a0c7679f9497666ad1d30992ed95b44121201644c5b8a17a3ea5654e015242b46cced
6
+ metadata.gz: 299e21f5dec93723d96d9d4000425d20392369409354bd1ff762bad1bea85088af809271e6d3ff1b019c1f0a6a5a59173fc064cc4e743f3b34091a4a1f9d3d49
7
+ data.tar.gz: 79683b32dba63e17e1c7105a0719e5f9dc30cc2d0f891d3ed6d190424ae9c905ef603798d06ab20c50e6d87cff3850129d294fec5736e96d46d02f18476a3591
data/.gitignore CHANGED
@@ -13,4 +13,5 @@
13
13
  *.so
14
14
  *.o
15
15
  *.a
16
+ *.gem
16
17
  mkmf.log
@@ -4,19 +4,17 @@ module Bouncer
4
4
 
5
5
  def self.from_id id
6
6
  client = Bouncer::Client.current
7
- client.jwt ENV['SERVICE_TOKEN']
7
+ client.jwt(ENV['SERVICE_TOKEN'] || '')
8
8
  raw = client.user id
9
9
  from_json raw.body['users'][0]
10
10
  end
11
11
 
12
12
  def self.from_json json
13
13
  user = User.new
14
- user.id = json['id']
15
- user.email = json['email']
16
- user.phone = json['phone']
17
- user.image = json['image']
18
- user.super_admin = json['super_admin']
19
- user.created_at = json['created_at']
14
+ json.keys.map do |key|
15
+ user.class.class_eval { attr_accessor key.to_sym }
16
+ user.send("#{key}=", json[key])
17
+ end
20
18
  user
21
19
  end
22
20
 
@@ -1,3 +1,3 @@
1
1
  module Bouncer
2
- VERSION = "0.3"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -8,4 +8,15 @@ describe Bouncer::User do
8
8
  expect(user.id).to eq uuid
9
9
  end
10
10
  end
11
+
12
+ it 'is created dynamically from a JSON payload' do
13
+ uuid = SecureRandom.uuid
14
+ VCR.use_cassette 'bouncer/user' do
15
+ user = Bouncer::User.from_json({ email: 'foo@example.com', super_admin: false, role: 'manager' })
16
+ expect(user).to respond_to :email
17
+ expect(user).to respond_to :super_admin
18
+ expect(user).to respond_to :role
19
+ expect(user).to_not respond_to :foo
20
+ end
21
+ end
11
22
  end
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,8 @@ require 'bouncer-client'
20
20
  # in ./support/ and its subdirectories.
21
21
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
22
22
 
23
+ ENV['BOUNCER_URL'] = 'https://bouncer-api.monsieur.co'
24
+
23
25
  RSpec.configure do |config|
24
26
  VCR.configure do |c|
25
27
  c.cassette_library_dir = 'spec/cassettes'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bouncer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurt Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-12 00:00:00.000000000 Z
11
+ date: 2015-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  version: '0'
277
277
  requirements: []
278
278
  rubyforge_project:
279
- rubygems_version: 2.2.2
279
+ rubygems_version: 2.4.6
280
280
  signing_key:
281
281
  specification_version: 4
282
282
  summary: Allows Rails to easily use a Bouncer instance for authentication