-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7a70ad8
commit 2837012
Showing
18 changed files
with
388 additions
and
304 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
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,4 +1,4 @@ | ||
module Errapi::Validators | ||
module Errapi::Locations | ||
end | ||
|
||
Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib } |
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,29 @@ | ||
module Errapi | ||
|
||
class Locations::Dotted | ||
|
||
def initialize location = nil | ||
@location = location.to_s.sub /^\./, '' unless location.nil? | ||
end | ||
|
||
def relative parts | ||
if @location.nil? | ||
self.class.new parts | ||
else | ||
self.class.new "#{@location}.#{parts.to_s.sub(/^\./, '')}" | ||
end | ||
end | ||
|
||
def error_options | ||
@location.nil? ? {} : { location: @location, location_type: :dotted } | ||
end | ||
|
||
def serialize | ||
@location.nil? ? nil : @location | ||
end | ||
|
||
def to_s | ||
@location.to_s | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Errapi | ||
|
||
class Locations::Json | ||
|
||
def initialize location = nil | ||
@location = location.nil? ? '' : location.to_s.sub(/^\//, '').sub(/\/$/, '') | ||
end | ||
|
||
def relative parts | ||
if @location.nil? | ||
self.class.new parts | ||
else | ||
self.class.new "#{@location}/#{parts.to_s.sub(/^\./, '').sub(/\/$/, '')}" | ||
end | ||
end | ||
|
||
def error_options | ||
{ location: @location, location_type: :json } | ||
end | ||
|
||
def serialize | ||
@location | ||
end | ||
|
||
def to_s | ||
@location | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'singleton' | ||
|
||
module Errapi | ||
|
||
class Locations::None | ||
include Singleton | ||
|
||
def relative parts | ||
self | ||
end | ||
|
||
def error_options | ||
{} | ||
end | ||
|
||
def serialize | ||
nil | ||
end | ||
|
||
def to_s | ||
LOCATION_STRING | ||
end | ||
|
||
private | ||
|
||
LOCATION_STRING = '' | ||
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
Oops, something went wrong.