prelaunch 0.0.5 → 0.0.6

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTI3ZjY3NzNlNzM2MzUwOGYxMjZlMTlmNDE4MjlmNzdlZTY0NGIwZg==
4
+ ZTMxMGRmMWZjZTYyODJhMzFkZmE1N2NiMmEzZTYxYzMyNjU2NGEzYQ==
5
5
  data.tar.gz: !binary |-
6
- MTNhZTAxNGU5MzMzMmI1MzcxZWYzYTNkNzk2ZTg1NDU2MmI1NDhjNA==
6
+ YWEzYTA2Mjk0OWZjMDg1NjFhNWVlNzc2ODkzZjA4NGYwOGM1YWVlNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDkxMTQ4ZGI1NGE5NGQyNWIwNGZmNDZlZjBjY2RjOTEzZWZiNjcxZDMwY2Nm
10
- ZTllZWUxNGE2YTU0NTJmZjA1ZDYxNTU5NzZjNWM3ZjBjZmMzM2E0ZDgwMzVh
11
- Nzk1NTZiMTE4MzhkZmUxY2Y4OTljYTA1MzFkNDE4M2U0NjQyOGM=
9
+ NDMxYjUyOTM3YzNjM2E4M2U2ODAyNmY4YmFlNmEwOTg5YWRlYWI1NmIwMzhk
10
+ N2I3M2QxMTk3N2M5ZDVkNTk5MTkyMDkyZTgxYTdmZmY1ODQyNWNmOGQ5MzZj
11
+ YWUyM2RlMGFkYWIxZTUwMDk4NTY4NjRmZmRjNzBmNzM5ODUzNDM=
12
12
  data.tar.gz: !binary |-
13
- M2NiNjJiYTliNTMyYjUyZGFkZmE2MGE4MzJhNzUzNjkzZWIxNGZhMzEwYTFh
14
- OTFiODU0YjExOWNhY2UwYzVkNzkzNjg3M2VmNTU3OTgwMDdhZWQ4MWJlZTEx
15
- MGQ5ZTQ3YWYwMmJiZTdmYzkyMmYxZWE0MzllNWU4MDBjZWM1YjU=
13
+ MDM0ZmUxN2FmNTM4NTdlMmQ0MDYyMWE0MTYwNzJkODAxOGVkOWE2MmNjNjk3
14
+ NTA4NzM5ZjRiODgwMjJmMjhjOTIzNTA2YWNiZGViYjg2MDg5YjhkMTkyNWI4
15
+ OWRmYzc1YjRlZDhkYzhlZGRiYWY0YzFjNTM3OGNhMzdhYzViODY=
@@ -13,9 +13,7 @@ module Prelaunch
13
13
  end
14
14
 
15
15
  def verify
16
- if Prelaunch::valid? params[:token]
17
- session[:prelaunch_token] = params[:token]
18
- end
16
+ session[:prelaunch_token] = params[:token]
19
17
 
20
18
  redirect_to '/'
21
19
  end
@@ -0,0 +1,18 @@
1
+ module Prelaunch
2
+ class SessionConstraint
3
+ def matches? request
4
+ not Prelaunch::valid? request.session[:prelaunch_token]
5
+ end
6
+ end
7
+
8
+ class TokenConstraint
9
+ def matches? request
10
+ path = Prelaunch::strip_slashes(Prelaunch.path)
11
+ match = request.fullpath.match(/^#{path}\/([A-Za-z0-9]*)([\/\?])?/)
12
+
13
+ return false if match.nil?
14
+
15
+ Prelaunch::valid? match[1]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module Prelaunch
2
+ protected
3
+ def self.strip_slashes string
4
+ result = string.gsub(/^(\/|\\)+/, '').gsub(/(\/|\\)+$/, '')
5
+
6
+ result.length > 0 ? '/' + result : result
7
+ end
8
+ end
@@ -3,7 +3,8 @@ module Prelaunch
3
3
  def prelaunch_logout_link name = nil, html_options = nil, &block
4
4
  return unless Prelaunch::valid_env?
5
5
 
6
- url = "#{strip_slashes(Prelaunch.path)}/logout"
6
+ path = Prelaunch::strip_slashes(Prelaunch.path)
7
+ url = "#{path}/logout"
7
8
 
8
9
  html_options = name if block_given?
9
10
  html_options ||= {}
@@ -12,12 +13,5 @@ module Prelaunch
12
13
 
13
14
  content_tag(:a, name || url, html_options, &block)
14
15
  end
15
-
16
- private
17
- def strip_slashes string
18
- result = string.gsub(/^(\/|\\)+/, '').gsub(/(\/|\\)+$/, '')
19
-
20
- result.length > 0 ? '/' + result : result
21
- end
22
16
  end
23
17
  end
@@ -3,10 +3,12 @@ module ActionDispatch::Routing
3
3
  def prelaunch_routes
4
4
  return unless Prelaunch.valid_env?
5
5
 
6
- contraint = Prelaunch::Constraint.new
6
+ token = Prelaunch::TokenConstraint.new
7
7
 
8
8
  get "#{Prelaunch.path}/logout", to: 'prelaunch/prelaunch#logout', as: ''
9
- get "#{Prelaunch.path}/:token", to: 'prelaunch/prelaunch#verify', constraints: contraint
9
+ get "#{Prelaunch.path}/:token", to: 'prelaunch/prelaunch#verify', constraints: token
10
+
11
+ contraint = Prelaunch::SessionConstraint.new
10
12
 
11
13
  get '*path', to: 'prelaunch/prelaunch#redirect', constraints: contraint
12
14
  get '/' , to: 'prelaunch/prelaunch#index' , constraints: contraint
@@ -1,3 +1,3 @@
1
1
  module Prelaunch
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/lib/prelaunch.rb CHANGED
@@ -1,6 +1,7 @@
1
- require 'prelaunch/routing'
2
- require 'prelaunch/constraint'
3
1
  require 'prelaunch/engine'
2
+ require 'prelaunch/functions'
3
+ require 'prelaunch/constraints'
4
+ require 'prelaunch/routing'
4
5
  require 'prelaunch/helpers'
5
6
 
6
7
  module Prelaunch
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prelaunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Chernetsov
@@ -49,8 +49,9 @@ files:
49
49
  - lib/generators/prelaunch/view_generator.rb
50
50
  - lib/generators/templates/prelaunch.rb
51
51
  - lib/prelaunch.rb
52
- - lib/prelaunch/constraint.rb
52
+ - lib/prelaunch/constraints.rb
53
53
  - lib/prelaunch/engine.rb
54
+ - lib/prelaunch/functions.rb
54
55
  - lib/prelaunch/helpers.rb
55
56
  - lib/prelaunch/routing.rb
56
57
  - lib/prelaunch/version.rb
@@ -1,7 +0,0 @@
1
- module Prelaunch
2
- class Constraint
3
- def matches? request
4
- not Prelaunch::valid? request.session[:prelaunch_token]
5
- end
6
- end
7
- end