sinatra-static-assets 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -6,6 +6,7 @@ Gem *sinatra-static-assets* implements the following helpers methods:
6
6
  * `stylesheet_link_tag`
7
7
  * `javascript_script_tag`
8
8
  * `link_to`
9
+ * `link_favicon_tag`
9
10
 
10
11
  To install it, run:
11
12
 
@@ -38,6 +38,19 @@ module Sinatra
38
38
  desc
39
39
  end
40
40
  end
41
+
42
+ def link_favicon_tag(source = nil, options = {})
43
+ source = "favicon.ico" if source.nil? or source.empty?
44
+ unless settings.xhtml
45
+ # html5 style like <link rel="icon" href="http://example.com/myicon.ico" />
46
+ options[:rel] = options[:rel] || "icon"
47
+ else
48
+ # xhtml style like <link rel="shortcut icon" href="http://example.com/myicon.ico" />
49
+ options[:rel] = "shortcut icon"
50
+ end
51
+ options[:href] = url_for(source)
52
+ tag("link", options)
53
+ end
41
54
 
42
55
  private
43
56
 
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "sinatra-static-assets"
7
- s.version = "1.0.3"
7
+ s.version = "1.0.4"
8
8
  s.authors = ["Włodek Bzyl"]
9
9
  s.email = ["matwb@ug.edu.pl"]
10
10
  s.homepage = ""
@@ -47,3 +47,24 @@ get "/link_to_tag" do
47
47
  #{link_to "Tatry Mountains Rescue Team", "/topr"}
48
48
  EOD
49
49
  end
50
+
51
+ get "/link_favicon_tag_empty" do
52
+ content_type "text/plain"
53
+ <<"EOD"
54
+ #{link_favicon_tag}
55
+ EOD
56
+ end
57
+
58
+ get "/link_favicon_tag_changing_filename" do
59
+ content_type "text/plain"
60
+ <<"EOD"
61
+ #{link_favicon_tag 'favicon2.ico'}
62
+ EOD
63
+ end
64
+
65
+ get "/link_favicon_tag_with_options" do
66
+ content_type "text/plain"
67
+ <<"EOD"
68
+ #{link_favicon_tag 'favicon.ico', :rel => "apple-touch-icon" }
69
+ EOD
70
+ end
@@ -18,5 +18,10 @@ module Sinatra
18
18
  content_type "text/plain"
19
19
  "#{stylesheet_link_tag("/stylesheets/winter.css")}"
20
20
  end
21
+
22
+ get '/link_favicon_tag' do
23
+ content_type "text/plain"
24
+ "#{link_favicon_tag("favicon.ico")}"
25
+ end
21
26
  end
22
27
  end
@@ -66,4 +66,29 @@ EOD
66
66
  EOD
67
67
  end
68
68
 
69
+
70
+ def test_link_tag_empty
71
+ get '/link_favicon_tag_empty', {}, 'SCRIPT_NAME' => '/bar'
72
+ assert last_response.ok?
73
+ assert_equal last_response.body, <<EOD
74
+ <link href="/bar/favicon.ico" rel="icon">
75
+ EOD
76
+ end
77
+
78
+ def test_link_favicon_changing_filename
79
+ get '/link_favicon_tag_changing_filename', {}, 'SCRIPT_NAME' => '/bar'
80
+ assert last_response.ok?
81
+ assert_equal last_response.body, <<EOD
82
+ <link href="/bar/favicon2.ico" rel="icon">
83
+ EOD
84
+ end
85
+
86
+ def test_link_favicon_tag_with_options
87
+ get '/link_favicon_tag_with_options', {}, 'SCRIPT_NAME' => '/bar'
88
+ assert last_response.ok?
89
+ assert_equal last_response.body, <<EOD
90
+ <link href="/bar/favicon.ico" rel="apple-touch-icon">
91
+ EOD
92
+ end
93
+
69
94
  end
@@ -23,4 +23,11 @@ class SintraStaticAssetsXHTMLTest < Test::Unit::TestCase
23
23
  "<link charset=\"utf-8\" href=\"/stylesheets/winter.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\"/>"
24
24
  end
25
25
 
26
+ def test_link_favicon_tag_closes
27
+ get '/link_favicon_tag', {}, 'SCRIPT_NAME' => '/bar'
28
+ assert last_response.ok?
29
+ assert_equal last_response.body,
30
+ '<link href="/bar/favicon.ico" rel="shortcut icon"/>'
31
+ end
32
+
26
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-static-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-01 00:00:00.000000000 Z
12
+ date: 2012-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &16409220 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16409220
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rack
27
- requirement: &16408580 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *16408580
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rack-test
38
- requirement: &16407840 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *16407840
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: ! "This Sinatra extensions provides following helper methods:\n -
48
63
  image_tag\n - stylesheet_link_tag\n - javascript_script_tag"
49
64
  email:
@@ -123,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
138
  version: '0'
124
139
  requirements: []
125
140
  rubyforge_project: sinatra-static-assets
126
- rubygems_version: 1.8.15
141
+ rubygems_version: 1.8.23
127
142
  signing_key:
128
143
  specification_version: 3
129
144
  summary: A Sinatra extension.