This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
forked from measuredvoice/ringsail
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(The account namespace is a little irregular, but I think it covers the prominent special cases.) Shifted titles in the spec so errors make more sense. Closes #9.
- Loading branch information
1 parent
94971cb
commit ae26454
Showing
2 changed files
with
78 additions
and
6 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,44 @@ | ||
class InstagramService < Service | ||
def self.handles?(uri) | ||
# Exclude help.instagram.com, blog.instagram.com, etc. | ||
uri.host =~ /^instagram.com$/ | ||
end | ||
|
||
def self.shortname | ||
end | ||
|
||
def display_name | ||
"#{account} on Instagram" | ||
end | ||
|
||
def account | ||
/^\/(?<account>[\w-]+)/ =~ @uri.path | ||
|
||
|
||
@exclude = ['p', 'popular', 'developer', 'press', 'about'] | ||
if @exclude.any? {|stopword| account == stopword} | ||
account = nil | ||
end | ||
|
||
account | ||
end | ||
|
||
def service_url_example | ||
"http://instagram.com/username" | ||
end | ||
|
||
def service_url_canonical | ||
"http://instagram.com/#{account}" | ||
end | ||
|
||
private | ||
|
||
def fetch_details | ||
{ | ||
:account => account, | ||
} | ||
end | ||
end | ||
|
||
Service.register(:instagram, InstagramService) |
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