thumblemonks-chicago 0.1.2 → 0.1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/chicago.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "chicago"
3
- s.version = "0.1.2"
3
+ s.version = "0.1.2.1"
4
4
  s.date = "2008-12-05"
5
5
  s.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
6
6
  s.email = %w[gus@gusg.us gabriel.gironda@gmail.com]
@@ -8,18 +8,24 @@ module Thumblemonks
8
8
  end
9
9
 
10
10
  def stylesheet_include(name, options={})
11
- defaults = {:href => "/stylesheets/#{name}.css", :media => "screen",
11
+ name = "/stylesheets/#{name}.css" unless remote_asset?(name)
12
+ defaults = {:href => name, :media => "screen",
12
13
  :rel => "stylesheet", :type => "text/css"}
13
14
  options_str = hash_to_attributes(defaults.merge(options))
14
15
  %Q[<link #{options_str}/>]
15
16
  end
16
17
 
17
18
  def javascript_include(name, options={})
18
- defaults = {:src => "/javascripts/#{name}.js", :type => "text/javascript"}
19
+ name = "/javascripts/#{name}.js" unless remote_asset?(name)
20
+ defaults = {:src => name, :type => "text/javascript"}
19
21
  options_str = hash_to_attributes(defaults.merge(options))
20
22
  %Q[<script #{options_str}></script>]
21
23
  end
22
24
  private
25
+ def remote_asset?(uri)
26
+ uri =~ %r[^\w+://.+]
27
+ end
28
+
23
29
  def hash_to_attributes(options)
24
30
  options.map {|k,v| "#{k}=\"#{v}\""}.join(' ')
25
31
  end
data/test/helpers_test.rb CHANGED
@@ -18,6 +18,10 @@ class HelpersTest < Test::Unit::TestCase
18
18
  assert_match %r[type="text/css"], @response.body
19
19
  assert_match %r[baz="boo"], @response.body
20
20
  end
21
+
22
+ should_invoke_helper(:stylesheet_include, 'http://example.com') do
23
+ assert_match %r[href="http://example.com"], @response.body
24
+ end
21
25
  end # including stylesheets
22
26
 
23
27
  context "including javascript" do
@@ -33,6 +37,10 @@ class HelpersTest < Test::Unit::TestCase
33
37
  assert_match %r[type="text/blarg"], @response.body
34
38
  assert_match %r[gus="nice"], @response.body
35
39
  end
40
+
41
+ should_invoke_helper(:javascript_include, 'http://example.com') do
42
+ assert_match %r[src="http://example.com"], @response.body
43
+ end
36
44
  end # including javascript
37
45
 
38
46
  context "using an anchor" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thumblemonks-chicago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Knowlden