conred 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/conred.rb CHANGED
@@ -5,8 +5,5 @@ require "conred/video"
5
5
  require "conred/links"
6
6
  require "haml"
7
7
  module Conred
8
- def self.render_file(filename)
9
- contents = File.read(filename)
10
- Haml::Engine.new(contents).render
11
- end
8
+
12
9
  end
@@ -1,3 +1,3 @@
1
1
  module Conred
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/conred/video.rb CHANGED
@@ -32,12 +32,8 @@ module Conred
32
32
  if @video_url[/vimeo\.com\/([0-9]*)/]
33
33
  @vimeo_id = $1
34
34
  end
35
- vimeo_file = File.join(
36
- File.dirname(__FILE__),
37
- '..', 'views',
38
- 'video', 'vimeo_iframe.html.haml'
39
- )
40
- render_file(vimeo_file).html_safe
35
+ vimeo_file = "../views/video/vimeo_iframe"
36
+ render(vimeo_file, :vimeo_id => @vimeo_id, :height => @height, :width => @width).html_safe
41
37
  end
42
38
 
43
39
  def video_from_youtube_url
@@ -46,19 +42,17 @@ module Conred
46
42
  else
47
43
  @video_url[/(v=([A-Za-z0-9_]*))/]
48
44
  @youtube_id = $2
49
-
50
45
  end
51
- youtube_file = File.join(
52
- File.dirname(__FILE__),
53
- '..', 'views',
54
- 'video', 'youtube_iframe.html.haml'
55
- )
56
- render_file(youtube_file).html_safe
46
+ youtube_file = "../views/video/youtube_iframe"
47
+ render(youtube_file, :youtube_id => @youtube_id, :height => @height, :width => @width).html_safe
57
48
  end
58
49
 
59
- def render_file(filename)
60
- contents = File.read(filename)
61
- Haml::Engine.new(contents).render
50
+ def render(path_to_partial, locals = {})
51
+ path = File.join(
52
+ File.dirname(__FILE__),
53
+ path_to_partial.split("/")
54
+ )
55
+ Haml::Engine.new(File.read("#{path}.html.haml")).render(Object.new, locals)
62
56
  end
63
57
 
64
58
  end
@@ -1 +1 @@
1
- %iframe{:allowFullScreen => "", :frameborder => "0", :height => @height, :mozallowfullscreen => "", :src => "http://player.vimeo.com/video/#{@vimeo_id}", :webkitAllowFullScreen => "", :width => @width}
1
+ %iframe{:allowFullScreen => "", :frameborder => "0", :height => height, :mozallowfullscreen => "", :src => "http://player.vimeo.com/video/#{vimeo_id}", :webkitAllowFullScreen => "", :width => width}
@@ -1 +1 @@
1
- %iframe{:allowfullscreen => "", :frameborder => "0", :height => @height, :src => "http://www.youtube.com/embed/#{@youtube_id}?wmode=transparent", :title => "YouTube video player", :width => @width}
1
+ %iframe{:allowfullscreen => "", :frameborder => "0", :height => height, :src => "http://www.youtube.com/embed/#{youtube_id}?wmode=transparent", :title => "YouTube video player", :width => width}
@@ -4,22 +4,6 @@ describe Conred do
4
4
  describe Conred::Video do
5
5
  before do
6
6
 
7
- @vimeo_code = "49556689"
8
- vimeo_file = File.join(
9
- File.dirname(__FILE__),
10
- '..', '..', 'lib', 'views',
11
- 'video', 'vimeo_iframe.html.haml'
12
- )
13
- @vimeo_embed_code = Conred.render_file(vimeo_file).html_safe
14
-
15
- @youtube_id = "Lrj5Kxdzouc"
16
- youtube_file = File.join(
17
- File.dirname(__FILE__),
18
- '..', '..', 'lib', 'views',
19
- 'video', 'youtube_iframe.html.haml'
20
- )
21
- @youtube_embed_code = Conred.render_file(youtube_file).html_safe
22
-
23
7
  end
24
8
  it "should match youtube video" do
25
9
  Conred::Video.new("http://www.youtube.com/watch?v=SZt5RFzqEfY&feature=g-all-fbc").should be_youtube_video
@@ -39,9 +23,13 @@ describe Conred do
39
23
  Conred::Video.new("eeevil vimeo www.vimeo.com/12311233").youtube_video? == false
40
24
  end
41
25
  it "should return correct embed code" do
42
- Conred::Video.new("http://www.youtube.com/watch?NR=1&feature=endscreen&v=Lrj5Kxdzouc", 450, 300).code.should == @youtube_embed_code
43
- Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should == @youtube_embed_code
44
- Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should == @vimeo_embed_code
26
+ Conred::Video.new("http://www.youtube.com/watch?NR=1&feature=endscreen&v=Lrj5Kxdzouc", 450, 300).code.should match(/Lrj5Kxdzouc/)
27
+ Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/Lrj5Kxdzouc/)
28
+ Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/width='450'/)
29
+ Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/height='300'/)
30
+ Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/49556689/)
31
+ Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/width='450'/)
32
+ Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/height='300'/)
45
33
  Conred::Video.new("http://google.com/12311233", 450, 300, "Some mistake in url").code.should == "Some mistake in url"
46
34
  end
47
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conred
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: