-
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.
- Loading branch information
Showing
10 changed files
with
115 additions
and
47 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
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