funneler 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +3 -3
- data/lib/funneler/controller_methods.rb +1 -1
- data/lib/funneler/funnel.rb +7 -9
- data/lib/funneler/version.rb +1 -1
- data/lib/funneler.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f7dc39c6f13864d5cd77b31d51408228ac602f6a95e41d572b5c14cba9ea10cc
|
4
|
+
data.tar.gz: 1ab89dcbb940877f23369abe8539ff36828e45b3216817c2db0358c501d78d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f245f3ff37bf840e4ac697e31f20f43b612b511749f281bd52c244a7c3633fd4f7400c4a4b9def4b5ad20a9e9171008f1914bd1d1588c1e7c4fde83c64b83a6b
|
7
|
+
data.tar.gz: 9fd03787d987116a055d7ba9e186338a24d23cc156371c6cd12a343313dfc399ab0423fcf110902b4037c7f51a3135c90e846cf2a72e510e0904c7f5d03896f1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
funneler (1.
|
4
|
+
funneler (1.2.0)
|
5
5
|
jwt
|
6
6
|
|
7
7
|
GEM
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
byebug (8.2.1)
|
11
11
|
coderay (1.1.0)
|
12
12
|
diff-lcs (1.2.5)
|
13
|
-
jwt (1.
|
13
|
+
jwt (2.1.0)
|
14
14
|
method_source (0.8.2)
|
15
15
|
pry (0.10.3)
|
16
16
|
coderay (~> 1.1.0)
|
@@ -48,4 +48,4 @@ DEPENDENCIES
|
|
48
48
|
timecop
|
49
49
|
|
50
50
|
BUNDLED WITH
|
51
|
-
1.
|
51
|
+
1.16.4
|
data/lib/funneler/funnel.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Funneler
|
2
2
|
class Funnel
|
3
3
|
|
4
|
-
attr_reader :data
|
4
|
+
attr_reader :data, :current_page_index
|
5
5
|
|
6
|
-
def initialize(data = {})
|
6
|
+
def initialize(data = {}, current_page_index = 0)
|
7
7
|
@data = data
|
8
|
+
@current_page_index = data.fetch("current_page_index", nil) || current_page_index
|
8
9
|
@url_cache = Hash.new {|h, key| h[key] = generate_page_for_index(key) }
|
9
10
|
end
|
10
11
|
|
@@ -35,10 +36,6 @@ module Funneler
|
|
35
36
|
data['meta'] || {}
|
36
37
|
end
|
37
38
|
|
38
|
-
def current_page_index
|
39
|
-
data.fetch('current_page_index', 0)
|
40
|
-
end
|
41
|
-
|
42
39
|
def token
|
43
40
|
TokenHandler.generate_token(data: data)
|
44
41
|
end
|
@@ -49,7 +46,8 @@ module Funneler
|
|
49
46
|
return if bad_index?(index)
|
50
47
|
|
51
48
|
token = TokenHandler.generate_token(data: data.merge('current_page_index' => index))
|
52
|
-
add_params_to_url(routes[index], "funnel_token" => token)
|
49
|
+
path = add_params_to_url(routes[index], "funnel_token" => token )
|
50
|
+
add_params_to_url(path, "funnel_index" => index)
|
53
51
|
end
|
54
52
|
|
55
53
|
def add_params_to_url(path, new_params)
|
@@ -65,11 +63,11 @@ module Funneler
|
|
65
63
|
end
|
66
64
|
|
67
65
|
def next_index
|
68
|
-
current_page_index + 1
|
66
|
+
current_page_index.to_i + 1
|
69
67
|
end
|
70
68
|
|
71
69
|
def previous_index
|
72
|
-
index = current_page_index - 1
|
70
|
+
index = current_page_index.to_i - 1
|
73
71
|
index < 0 ? 0 : index
|
74
72
|
end
|
75
73
|
|
data/lib/funneler/version.rb
CHANGED
data/lib/funneler.rb
CHANGED
@@ -23,9 +23,9 @@ module Funneler
|
|
23
23
|
yield(configuration)
|
24
24
|
end
|
25
25
|
|
26
|
-
def from_token(token:)
|
26
|
+
def from_token(token:, current_page_index: 0)
|
27
27
|
data = Funneler::TokenHandler.extract_data_from(token)
|
28
|
-
Funneler::Funnel.new(data)
|
28
|
+
Funneler::Funnel.new(data, current_page_index)
|
29
29
|
rescue JWT::DecodeError => e
|
30
30
|
raise InvalidTokenError, "Invalid token '#{token}': #{e.message}"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: funneler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stawarz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.7.3
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: A light-weight approach for routing users through a pre-determined set of
|