-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from gewo/extract_session_data
Extract session data
- Loading branch information
Showing
11 changed files
with
117 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Documentation: | ||
Enabled: false | ||
AlignArray: | ||
Enabled: false | ||
AlignHash: | ||
Enabled: false | ||
AlignParameters: | ||
Enabled: false | ||
ModuleFunction: | ||
Enabled: false | ||
AllCops: | ||
Excludes: | ||
- spec/dummy/** | ||
- script/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module ReTrack | ||
module SessionData | ||
ATTRIBUTES = [ | ||
:referer_url, :first_url, :user_agent, :first_visited_at, :ip, | ||
:accept_language, :forwarded_ip | ||
] | ||
|
||
def to_hash(request) | ||
@request = request | ||
Hash[ATTRIBUTES.map { |k, v| [k, send(k)] }] | ||
end | ||
|
||
private | ||
|
||
def referer_url | ||
@request.headers['HTTP_REFERER'].presence || 'none' | ||
end | ||
|
||
def first_url | ||
@request.url | ||
end | ||
|
||
def user_agent | ||
@request.env['HTTP_USER_AGENT'] | ||
end | ||
|
||
def first_visited_at | ||
Time.now | ||
end | ||
|
||
def ip | ||
@request.remote_ip | ||
end | ||
|
||
def accept_language | ||
@request.env['HTTP_ACCEPT_LANGUAGE'] | ||
end | ||
|
||
def forwarded_ip | ||
@request.env['HTTP_X_FORWARDED_FOR'] || @request.env['HTTP_CLIENT_IP'] | ||
end | ||
|
||
extend self | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ReTrack | ||
VERSION = '0.5.0' | ||
VERSION = '0.5.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters