sinatra-head 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -31,7 +31,7 @@ module Sinatra
31
31
  # Returns the title elements you've set, in reverse order, separated by ' | '. (You can override this with
32
32
  # a Sinatra option: `set :title_separator, ' <*> '`)
33
33
  def title_string
34
- title.reverse.join(settings.title_separator)
34
+ title.uniq.reverse.join(settings.title_separator)
35
35
  end
36
36
 
37
37
  # Exposes an array of stylesheets. Can be set at both the class and the instance (action) level.
@@ -50,7 +50,7 @@ module Sinatra
50
50
 
51
51
  # Spits out stylesheet tags for all declared stylesheets, one per line.
52
52
  def stylesheet_tags
53
- stylesheets.collect{|s| stylesheet_tag(s)}.join("\n")
53
+ stylesheets.uniq.collect{|s| stylesheet_tag(s)}.join("\n")
54
54
  end
55
55
 
56
56
  # Spits out a <script src='filename'> element for the given javascript file.
@@ -71,7 +71,7 @@ module Sinatra
71
71
 
72
72
  # Spits out javascript tags for all declared scripts, one per line.
73
73
  def javascript_tags
74
- javascripts.collect{|s| javascript_tag(s)}.join("\n")
74
+ javascripts.uniq.collect{|s| javascript_tag(s)}.join("\n")
75
75
  end
76
76
 
77
77
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-head}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stephen Eley"]
12
- s.date = %q{2010-05-20}
12
+ s.date = %q{2010-06-10}
13
13
  s.description = %q{Sinatra::Head provides class methods and helpers for dynamically controlling the fields in your <HEAD> element that are usually preset in your layout: the page title, stylesheet and javascript assets, etc. Asset lists are inherited throughout superclasses, subclasses, and within action methods, and basic asset path management is supported.}
14
14
  s.email = %q{sfeley@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -22,6 +22,7 @@ describe Sinatra::Head, "javascripts" do
22
22
  @instance.javascripts.should == ['main.js', 'secondary.js', 'specific.js']
23
23
  end
24
24
 
25
+
25
26
  it "leaves its superclass's value alone" do
26
27
  instance = DummyFixture::DummyApp.new
27
28
  instance.javascripts.should == ['main.js']
@@ -51,6 +52,11 @@ describe Sinatra::Head, "javascripts" do
51
52
  @instance.javascript_tags.should == "<script src='/things/javascript/main.js'></script>\n<script src='/things/javascript/secondary.js'></script>\n<script src='http://yahoo.com/yahoo_script.js'></script>"
52
53
  end
53
54
 
55
+ it "only shows a given element once" do
56
+ @instance.javascripts << 'main.js'
57
+ @instance.javascript_tags.should_not =~ /main\.js.*main\.js/m
58
+ end
59
+
54
60
  it "shows up in the header" do
55
61
  visit '/'
56
62
  within 'head' do
@@ -55,6 +55,11 @@ describe Sinatra::Head, "stylesheets" do
55
55
  @instance.stylesheet_tags.should == "<link rel='stylesheet' href='/stuff/stylesheets/main.css' />\n<link rel='stylesheet' href='/stuff/stylesheets/secondary.css' />\n<link rel='stylesheet' href='http://yahoo.com/yahoo_style.css' />"
56
56
  end
57
57
 
58
+ it "only shows a given element once" do
59
+ @instance.stylesheets << 'main.css'
60
+ @instance.stylesheet_tags.should_not =~ /main\.css.*main\.css/m
61
+ end
62
+
58
63
  it "shows up in the header" do
59
64
  visit '/'
60
65
  within 'head' do
@@ -20,7 +20,7 @@ describe Sinatra::Head, "titles" do
20
20
  @instance.title << 'Low Level'
21
21
  @instance.title.should == ['High Level', 'Mid-Level', 'Low Level']
22
22
  end
23
-
23
+
24
24
  it "can be overridden" do
25
25
  @instance.title = 'Kaboom!'
26
26
  @instance.title.should == ['Kaboom!']
@@ -36,6 +36,11 @@ describe Sinatra::Head, "titles" do
36
36
  @instance.title_string.should == 'Low Level | Mid-Level | High Level'
37
37
  end
38
38
 
39
+ it "only shows a given element once" do
40
+ @instance.title << 'Mid-Level'
41
+ @instance.title_string.should_not =~ /Mid-Level.*Mid-Level/
42
+ end
43
+
39
44
  it "can set a different title separator" do
40
45
  class DummyGrandkid < DummyFixture::DummyChild
41
46
  set :title_separator, ' <*> '
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-head
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stephen Eley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-20 00:00:00 -04:00
18
+ date: 2010-06-10 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency