userbin 1.4.7 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -11
- data/lib/userbin.rb +9 -0
- data/lib/userbin/client.rb +2 -0
- data/lib/userbin/support/cookie_store.rb +16 -0
- data/lib/userbin/support/padrino.rb +20 -0
- data/lib/userbin/support/rails.rb +11 -0
- data/lib/{sinatra/userbin.rb → userbin/support/sinatra.rb} +3 -3
- data/lib/userbin/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb87601eef49b0f5d845aadecd86b36c2aa2a5a2
|
4
|
+
data.tar.gz: d35d0620253e7702afbdddd95b1a94c586018b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a7d1ad419f59374579ecff1a8d3038671da449fc9b7dd4a637ba8db300c711fe07394d6fc9d842e50a935c0055acc2c375d5a5f53f8610588b37371d581feb3
|
7
|
+
data.tar.gz: 2cda728dfc00d9c03288037a5b6039ff04b40d0d5a150994d4a329a7e34a40f7feaf844b8ec41f4540346548a10b04d69d58674262cc486a3ee7c7169104863f
|
data/README.md
CHANGED
@@ -43,17 +43,6 @@ require 'userbin'
|
|
43
43
|
Userbin.api_secret = "YOUR_API_SECRET"
|
44
44
|
```
|
45
45
|
|
46
|
-
Add a reference to the Userbin client in your main controller so that it's globally accessible throughout a request. The initializer takes a Rack **request** as argument from which it extracts details such as IP address and user agent and sends it along all API requests. The second argument is a reference to the **cookies** hash, used for storing the trusted device token.
|
47
|
-
|
48
|
-
```ruby
|
49
|
-
class ApplicationController < ActionController::Base
|
50
|
-
def userbin
|
51
|
-
@userbin ||= Userbin::Client.new(request, cookies)
|
52
|
-
end
|
53
|
-
# ...
|
54
|
-
end
|
55
|
-
```
|
56
|
-
|
57
46
|
## Setup User Monitoring
|
58
47
|
|
59
48
|
You should call `login` as soon as the user has logged in to your application. Pass a unique user identifier, and an *optional* hash of user properties which are used when searching for users in your dashboard. This will create a [Session](https://api.userbin.com/#POST--version-users--user_id-sessions---format-) resource and return a corresponding [session token](https://api.userbin.com/#session-tokens) which is stored in the Userbin client.
|
data/lib/userbin.rb
CHANGED
@@ -19,6 +19,15 @@ require 'userbin/utils'
|
|
19
19
|
require 'userbin/request'
|
20
20
|
require 'userbin/session_token'
|
21
21
|
|
22
|
+
require 'userbin/support/rails' if defined?(Rails::Railtie)
|
23
|
+
if defined?(Sinatra::Base)
|
24
|
+
if defined?(Padrino)
|
25
|
+
require 'userbin/support/padrino'
|
26
|
+
else
|
27
|
+
require 'userbin/support/sinatra'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
module Userbin
|
23
32
|
API = Userbin.setup_api
|
24
33
|
end
|
data/lib/userbin/client.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Userbin
|
2
|
+
class CookieStore
|
3
|
+
def initialize(request, response)
|
4
|
+
@request = request
|
5
|
+
@response = response
|
6
|
+
end
|
7
|
+
|
8
|
+
def [](key)
|
9
|
+
@request.cookies[key]
|
10
|
+
end
|
11
|
+
|
12
|
+
def []=(key, value)
|
13
|
+
@response.set_cookie key, value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'cookie_store'
|
2
|
+
|
3
|
+
module Padrino
|
4
|
+
class Application
|
5
|
+
module Userbin
|
6
|
+
module Helpers
|
7
|
+
def userbin
|
8
|
+
store = ::Userbin::CookieStore.new(request, response)
|
9
|
+
@userbin ||= ::Userbin::Client.new(request, store)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.registered(app)
|
14
|
+
app.helpers Helpers
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
register Userbin
|
19
|
+
end
|
20
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative 'cookie_store'
|
2
2
|
|
3
3
|
module Sinatra
|
4
4
|
module Userbin
|
5
5
|
module Helpers
|
6
6
|
def userbin
|
7
|
-
|
8
|
-
|
7
|
+
store = ::Userbin::CookieStore.new(request, response)
|
8
|
+
@userbin ||= ::Userbin::Client.new(request, store)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/lib/userbin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userbin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: her
|
@@ -172,7 +172,6 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- README.md
|
175
|
-
- lib/sinatra/userbin.rb
|
176
175
|
- lib/userbin.rb
|
177
176
|
- lib/userbin/client.rb
|
178
177
|
- lib/userbin/configuration.rb
|
@@ -192,6 +191,10 @@ files:
|
|
192
191
|
- lib/userbin/request.rb
|
193
192
|
- lib/userbin/session_store.rb
|
194
193
|
- lib/userbin/session_token.rb
|
194
|
+
- lib/userbin/support/cookie_store.rb
|
195
|
+
- lib/userbin/support/padrino.rb
|
196
|
+
- lib/userbin/support/rails.rb
|
197
|
+
- lib/userbin/support/sinatra.rb
|
195
198
|
- lib/userbin/trusted_token_store.rb
|
196
199
|
- lib/userbin/utils.rb
|
197
200
|
- lib/userbin/version.rb
|