Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fullpath_argument_for_annotation_tags
- Loading branch information
Showing
14 changed files
with
304 additions
and
62 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -15,3 +15,4 @@ spec/reports | ||
test/tmp | test/tmp | ||
test/version_tmp | test/version_tmp | ||
tmp | tmp | ||
integration/ |
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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,81 @@ | |||
module Ress | |||
|
|||
class Subdomain | |||
|
|||
# this class is a factory, don't instantiate it directly | |||
private_class_method :new | |||
|
|||
def self.create(subdomain) | |||
case subdomain | |||
when String | |||
StringSubdomain.new(subdomain) | |||
when Regexp | |||
RegexpSubdomain.new(subdomain) | |||
else | |||
NilSubdomain.new | |||
end | |||
end | |||
|
|||
class NilSubdomain | |||
def matches?(subdomain) | |||
subdomain.empty? | |||
end | |||
|
|||
def url(protocol, fullpath, subdomain) | |||
fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty? | |||
"#{protocol}#{fullpath}" | |||
end | |||
end | |||
|
|||
class StringSubdomain | |||
|
|||
attr_reader :subdomain | |||
|
|||
def initialize(subdomain) | |||
@subdomain = subdomain | |||
end | |||
|
|||
def matches?(subdomain) | |||
self.subdomain == subdomain | |||
end | |||
|
|||
def url(protocol, fullpath, subdomain) | |||
fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty? | |||
"#{protocol}#{self.subdomain}.#{fullpath}" | |||
end | |||
|
|||
end | |||
|
|||
# The main inspiration for this class is to match xip.io | |||
# subdomains for many devs working in development mode with | |||
# the same configuration. | |||
class RegexpSubdomain | |||
|
|||
attr_reader :subdomain | |||
|
|||
def initialize(subdomain) | |||
@subdomain = subdomain | |||
end | |||
|
|||
def matches?(subdomain) | |||
self.subdomain =~ subdomain | |||
end | |||
|
|||
def url(protocol, fullpath, subdomain) | |||
fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty? | |||
begin | |||
return build_url(protocol, subdomain, fullpath) if matches?(subdomain) | |||
end while( subdomain.slice!(/^[^\.]+\.?/) ) | |||
end | |||
|
|||
private | |||
|
|||
def build_url(protocol, subdomain, fullpath) | |||
subdomain.empty? ? "#{protocol}#{fullpath}" : "#{protocol}#{subdomain}.#{fullpath}" | |||
end | |||
|
|||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,3 @@ | |||
module Ress | module Ress | ||
VERSION = "0.0.6" | VERSION = "0.0.10" | ||
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
Oops, something went wrong.