-
Notifications
You must be signed in to change notification settings - Fork 2
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
d915b61
commit fad6d85
Showing
4 changed files
with
48 additions
and
0 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,2 @@ | ||
--color | ||
--format progress |
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 @@ | ||
1.9.3-p385 |
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,18 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.name = "embedda" | ||
gem.version = '0.0.1' | ||
gem.authors = ["Kasper Grubbe"] | ||
gem.email = ["[email protected]"] | ||
gem.homepage = "http://github.com/kaspergrubbe/embedda" | ||
gem.summary = %q{Embed content strings in your strings, and turn it to embed HTML!} | ||
gem.description = %q{Embed content strings in your strings, and turn it to embed HTML!} | ||
|
||
gem.files = `git ls-files`.split("\n") | ||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
gem.require_paths = ["lib"] | ||
|
||
#gem.add_runtime_dependency 'bundler' | ||
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,27 @@ | ||
class String | ||
def embedda | ||
youtube_replace! | ||
vimeo_replace! | ||
end | ||
|
||
private | ||
def youtube_replace! | ||
self.gsub(/[http|https]+:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+)\S*/, youtube_player("\\1")) | ||
self.gsub(/<a[^>]*?youtube\.com\/watch\?sv=([a-zA-Z0-9\-\_]+).*?<\/a>/, youtube_player("\\1")) | ||
end | ||
def youtube_player(token) | ||
return <<-END | ||
<iframe width="560" height="315" src="http://www.youtube.com/embed/#{token}" frameborder="0" allowfullscreen></iframe> | ||
END | ||
end | ||
|
||
def vimeo_replace! | ||
self.gsub(/[http|https]+:\/\/(?:www\.)?vimeo\.com\/(\d+)\S*/, vimeo_player("\\1")) | ||
self.gsub(/<a[^>]*?vimeo\.com\/(\d+).*?<\/a>/, vimeo_player("\\1")) | ||
end | ||
def vimeo_player(token) | ||
return <<-END | ||
<iframe src="http://player.vimeo.com/video/#{token}" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> | ||
END | ||
end | ||
end |