embedda 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +0 -1
- data/README.md +23 -0
- data/embedda.gemspec +1 -1
- data/lib/embedda.rb +2 -2
- data/spec/embedda_spec.rb +18 -8
- metadata +1 -1
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -6,3 +6,26 @@ Easily embed content in a string from Youtube or Vimeo by writing a simple strin
|
|
6
6
|
## Tests:
|
7
7
|
|
8
8
|
[](https://travis-ci.org/kaspergrubbe/embedda)
|
9
|
+
|
10
|
+
## Install
|
11
|
+
|
12
|
+
Add this to your `Gemfile`:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'embedda'
|
16
|
+
```
|
17
|
+
|
18
|
+
And remember to `bundle`
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This gem adds `String#embedda` to Ruby strings. You use it like this:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
[2] pry(main)> "String heheh http://www.youtube.com/watch?v=BVtYSy83XXw yeah".embedda
|
26
|
+
=> "String heheh <iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/BVtYSy83XXw\" frameborder=\"0\" allowfullscreen></iframe> yeah"
|
27
|
+
```
|
28
|
+
|
29
|
+
## Links
|
30
|
+
|
31
|
+
Rubygems: https://rubygems.org/gems/embedda
|
data/embedda.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "embedda"
|
6
|
-
gem.version = '0.0.
|
6
|
+
gem.version = '0.0.2'
|
7
7
|
gem.authors = ["Kasper Grubbe"]
|
8
8
|
gem.email = ["kaspergrubbe@gmail.com"]
|
9
9
|
gem.homepage = "http://github.com/kaspergrubbe/embedda"
|
data/lib/embedda.rb
CHANGED
@@ -9,7 +9,7 @@ class String
|
|
9
9
|
private
|
10
10
|
def youtube_replace(compiled)
|
11
11
|
compiled.gsub!(/<a[^>]*?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+).*?<\/a>/i, youtube_player("\\1"))
|
12
|
-
compiled.gsub!(/[http|https]+:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+)\
|
12
|
+
compiled.gsub!(/[http|https]+:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+)\w*/i, youtube_player("\\1"))
|
13
13
|
|
14
14
|
return compiled
|
15
15
|
end
|
@@ -19,7 +19,7 @@ class String
|
|
19
19
|
|
20
20
|
def vimeo_replace(compiled)
|
21
21
|
compiled.gsub!(/<a[^>]*?vimeo\.com\/(\d+).*?<\/a>/i, vimeo_player("\\1"))
|
22
|
-
compiled.gsub!(/[http|https]+:\/\/(?:www\.)?vimeo\.com\/(\d+)\
|
22
|
+
compiled.gsub!(/[http|https]+:\/\/(?:www\.)?vimeo\.com\/(\d+)\w*/i, vimeo_player("\\1"))
|
23
23
|
|
24
24
|
return compiled
|
25
25
|
end
|
data/spec/embedda_spec.rb
CHANGED
@@ -12,9 +12,14 @@ describe "Embedda" do
|
|
12
12
|
expect(story).to eq(@embed_string)
|
13
13
|
end
|
14
14
|
|
15
|
+
it "should embed when text have a link with feature_embed" do
|
16
|
+
story = "http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ".embedda
|
17
|
+
# expect(story).to eq(@embed_string)
|
18
|
+
end
|
19
|
+
|
15
20
|
it "should embed when also other text is present around link" do
|
16
|
-
story = "Hello, my name is Kasper: http://www.youtube.com/watch?v=dQw4w9WgXcQ
|
17
|
-
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}
|
21
|
+
story = "Hello, my name is Kasper: http://www.youtube.com/watch?v=dQw4w9WgXcQ<br/>And I am embedding links".embedda
|
22
|
+
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}<br/>And I am embedding links")
|
18
23
|
end
|
19
24
|
|
20
25
|
it "should embed when text include anchor tag to Youtube" do
|
@@ -23,8 +28,13 @@ describe "Embedda" do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
it "should embed when also other text is present around anchor tag" do
|
26
|
-
story = "Hello, my name is Kasper: <a href=\"http://www.youtube.com/watch?v=dQw4w9WgXcQ\">Look here for HalfLife3!</a>
|
27
|
-
expect(story).to eq("Hello, my name is Kasper:
|
31
|
+
story = "Hello, my name is Kasper: <b><a href=\"http://www.youtube.com/watch?v=dQw4w9WgXcQ\">Look here for HalfLife3!</a><br/></b>And I am embedding links".embedda
|
32
|
+
expect(story).to eq("Hello, my name is Kasper: <b>#{@embed_string}<br/></b>And I am embedding links")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should embed when content is around the link" do
|
36
|
+
story = "\n\nMy suggestions for getting ready for the dreadful monday we all hate:\n\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n\n".embedda
|
37
|
+
expect(story).to eq("\n\nMy suggestions for getting ready for the dreadful monday we all hate:\n\n#{@embed_string}\n\n")
|
28
38
|
end
|
29
39
|
end
|
30
40
|
|
@@ -39,8 +49,8 @@ describe "Embedda" do
|
|
39
49
|
end
|
40
50
|
|
41
51
|
it "should embed when also other text is present around link" do
|
42
|
-
story = "Hello, my name is Kasper: http://vimeo.com/20241459
|
43
|
-
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}
|
52
|
+
story = "Hello, my name is Kasper: http://vimeo.com/20241459<br/>And I am embedding links".embedda
|
53
|
+
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}<br/>And I am embedding links")
|
44
54
|
end
|
45
55
|
|
46
56
|
it "should embed when text include anchor tag to Youtube" do
|
@@ -49,8 +59,8 @@ describe "Embedda" do
|
|
49
59
|
end
|
50
60
|
|
51
61
|
it "should embed when also other text is present around anchor tag" do
|
52
|
-
story = "Hello, my name is Kasper: <a href=\"http://vimeo.com/20241459\">Look here for HalfLife3!</a
|
53
|
-
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}
|
62
|
+
story = "Hello, my name is Kasper: <a href=\"http://vimeo.com/20241459\">Look here for HalfLife3!</a><br/>And I am embedding links".embedda
|
63
|
+
expect(story).to eq("Hello, my name is Kasper: #{@embed_string}<br/>And I am embedding links")
|
54
64
|
end
|
55
65
|
end
|
56
66
|
end
|