auto_html 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -99,4 +99,4 @@ Specify the gem in Gemfile of the project
99
99
  ## Credits
100
100
 
101
101
  Author: [Dejan Simic](http://github.com/dejan)<br/>
102
- Contributors: [Claudio Perez Gamayo](https://github.com/crossblaim), [Matt Polito](https://github.com/mattpolito), [Ryan Heneise](https://github.com/mysmallidea), [Caleb Wright](https://github.com/fabrikagency), [Derrick Camerino](https://github.com/robustdj), [Daniel Weinmann](https://github.com/danielweinmann), [Edgars Beigarts](https://github.com/ebeigarts), [Henning Thies](https://github.com/henningthies), [rbq](https://github.com/rbq), [Kir Shatrov](https://github.com/kirs) ([Evrone Company](https://github.com/evrone)), [Demange Anthony](https://github.com/tinoutinou), [Hinrik Örn Sigurðsson](https://github.com/hinrik)
102
+ Contributors: https://github.com/dejan/auto_html/contributors
data/Rakefile CHANGED
@@ -9,8 +9,13 @@ Rake::TestTask.new(:test) do |t|
9
9
  end
10
10
 
11
11
  desc 'Test with recent versions of Rails'
12
- task :test_with_recent do
13
- versions = ['2.1.0', '2.2.2', '2.3.8', '3.0.3', '3.0.9']
12
+ task :test_wit_all_rails_versions do
13
+ versions = ['2.1.2',
14
+ '2.2.3',
15
+ # '2.3.14',
16
+ '3.0.11',
17
+ '3.1.3',
18
+ '3.2.1']
14
19
  versions.each do |v|
15
20
  puts "\n###### TESTING WITH RAILS #{v}"
16
21
  ENV['RAILS_VERSION'] = v
@@ -26,7 +26,8 @@ module AutoHtmlFor
26
26
 
27
27
  [raw_attrs].flatten.each do |raw_attr|
28
28
  define_method("#{raw_attr}#{suffix}=") do |val|
29
- write_attribute("#{raw_attr}#{suffix}", val)
29
+ a = "#{raw_attr}#{suffix}"
30
+ write_attribute(a, val) if attributes[a]
30
31
  end
31
32
  define_method("#{raw_attr}#{suffix}") do
32
33
  result = read_attribute("#{raw_attr}#{suffix}") || send("auto_html_prepare_#{raw_attr}")
@@ -35,8 +36,9 @@ module AutoHtmlFor
35
36
  result
36
37
  end
37
38
  define_method("auto_html_prepare_#{raw_attr}") do
38
- self.send(raw_attr.to_s + suffix + "=",
39
- auto_html(self.send(raw_attr), &proc))
39
+ result = auto_html(self.send(raw_attr), &proc)
40
+ self.send(raw_attr.to_s + suffix + "=", result)
41
+ result
40
42
  end
41
43
  end
42
44
  end
@@ -0,0 +1,9 @@
1
+ AutoHtml.add_filter(:gist).with({}) do |text, options|
2
+ # E.g. https://gist.github.com/1710276
3
+ regex = /https:\/\/gist\.github\.com\/(\d+)/
4
+ text.gsub(regex) do
5
+ gist_id = $1
6
+ %{<script src="https://gist.github.com/#{gist_id}.js"></script>}
7
+ end
8
+ end
9
+
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+ AutoHtml.add_filter(:google_map).with(:width => 420, :height => 315, :style => "color:#000;text-align:left", :link_text => "View Larger Map") do |text, options|
3
+ regex = /(https?):\/\/maps\.google\.co(.*)\/maps\?(.*)/
4
+ text.gsub(regex) do
5
+ domain_country = $2
6
+ map_query = $3
7
+ width = options[:width]
8
+ height = options[:height]
9
+ style = options[:style]
10
+ link_text = options[:link_text]
11
+ %{<iframe width="#{width}" height="#{height}" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co#{domain_country}/maps?f=q&amp;source=s_q&amp;#{map_query}&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co#{domain_country}/maps?f=q&amp;source=embed&amp;#{map_query}" style="#{style}">#{link_text}</a></small>}
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil) do |text, options|
2
- regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]*)(\&\S+)?.*/
2
+ regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]*)(\&\S+)?(\S)*/
3
3
  text.gsub(regex) do
4
4
  protocol = $1
5
5
  youtube_id = $4
@@ -25,6 +25,6 @@ namespace :auto_html do
25
25
  item.save
26
26
  i += 1
27
27
  end
28
- puts "Done! Processed #{pluralize(i, 'item')}."
28
+ puts "Done! Processed #{i} items."
29
29
  end
30
30
  end
data/test/test_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
 
3
3
  rails_version = ENV['RAILS_VERSION']
4
4
  if rails_version
5
+ gem "activesupport", rails_version
5
6
  gem "activerecord", rails_version
6
7
  gem "actionpack", rails_version
7
8
  end
@@ -0,0 +1,10 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class GistTest < Test::Unit::TestCase
4
+
5
+ def test_transform
6
+ result = auto_html('https://gist.github.com/1710276') { gist }
7
+ assert_equal '<script src="https://gist.github.com/1710276.js"></script>', result
8
+ end
9
+
10
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class GoogleMapTest < Test::Unit::TestCase
4
+
5
+ def test_transform
6
+ result = auto_html('http://maps.google.co.kr/maps?q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A') { google_map }
7
+ assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.kr/maps?f=q&amp;source=s_q&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.kr/maps?f=q&amp;source=embed&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A" style="color:#000;text-align:left">View Larger Map</a></small>', result
8
+ end
9
+
10
+ def test_transform_2
11
+ result = auto_html('http://maps.google.com/maps?hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl') { google_map }
12
+ assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl" style="color:#000;text-align:left">View Larger Map</a></small>', result
13
+ end
14
+ end
@@ -16,6 +16,11 @@ class YouTubeTest < Test::Unit::TestCase
16
16
  result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube }
17
17
  assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
18
18
  end
19
+
20
+ def test_transform3
21
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube }
22
+ assert_equal 'foo <iframe width="420" height="315" src="http://www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe> bar', result
23
+ end
19
24
 
20
25
  def test_transform_url_without_www
21
26
  result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 0
10
- version: 1.5.0
9
+ - 1
10
+ version: 1.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dejan Simic
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-08 00:00:00 +01:00
18
+ date: 2012-02-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,8 @@ files:
66
66
  - lib/auto_html/capistrano.rb
67
67
  - lib/auto_html/filter.rb
68
68
  - lib/auto_html/filters/dailymotion.rb
69
+ - lib/auto_html/filters/gist.rb
70
+ - lib/auto_html/filters/google_map.rb
69
71
  - lib/auto_html/filters/google_video.rb
70
72
  - lib/auto_html/filters/html_escape.rb
71
73
  - lib/auto_html/filters/image.rb
@@ -90,6 +92,8 @@ files:
90
92
  - test/test_helper.rb
91
93
  - test/unit/auto_html_test.rb
92
94
  - test/unit/filters/dailymotion_test.rb
95
+ - test/unit/filters/gist_test.rb
96
+ - test/unit/filters/google_map_test.rb
93
97
  - test/unit/filters/google_video_test.rb
94
98
  - test/unit/filters/html_escape_test.rb
95
99
  - test/unit/filters/image_test.rb