mercury 0.9.9 → 0.9.10
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/lib/mercury/helpers.rb +13 -10
- data/spec/lib/mercury/helpers_spec.rb +10 -2
- data/spec/lib/mercury/images_spec.rb +1 -1
- metadata +2 -2
data/lib/mercury/helpers.rb
CHANGED
@@ -25,20 +25,16 @@ module Sinatra
|
|
25
25
|
end
|
26
26
|
|
27
27
|
|
28
|
-
def css(cssfile)
|
29
|
-
|
28
|
+
def css(cssfile, mediatype="all")
|
29
|
+
render_style open_file(find_file(cssfile, CSS)), mediatype
|
30
30
|
end
|
31
31
|
|
32
|
-
def sass(sassfile)
|
33
|
-
|
34
|
-
Sass::Engine.new(open_file(find_file(sassfile, SASS))).render,
|
35
|
-
"</style>\n"].join("\n")
|
32
|
+
def sass(sassfile, mediatype="all")
|
33
|
+
render_style Sass::Engine.new(open_file(find_file(sassfile, SASS))).render, mediatype
|
36
34
|
end
|
37
35
|
|
38
|
-
def scss(scssfile)
|
39
|
-
|
40
|
-
Sass::Engine.new(open_file(find_file(scssfile, SCSS)), :syntax => :scss).render,
|
41
|
-
"</style>\n"].join("\n")
|
36
|
+
def scss(scssfile, mediatype="all")
|
37
|
+
render_style Sass::Engine.new(open_file(find_file(scssfile, SCSS)), :syntax => :scss).render, mediatype
|
42
38
|
end
|
43
39
|
|
44
40
|
def javascript(jsfile)
|
@@ -61,6 +57,13 @@ module Sinatra
|
|
61
57
|
"</script>\n"].join("\n")
|
62
58
|
end
|
63
59
|
|
60
|
+
def render_style(text, mediatype="all")
|
61
|
+
["<style type='text/css' media='#{mediatype}' >",
|
62
|
+
text,
|
63
|
+
"</style>\n"].join("\n")
|
64
|
+
end
|
65
|
+
|
66
|
+
|
64
67
|
|
65
68
|
def find_file(filename, ext)
|
66
69
|
Dir.glob(File.join(options.views, "**/*.#{ext}")).select { |extfile| extfile.downcase =~ /\/#{filename.to_s.downcase}.#{ext}$/ }.first
|
@@ -8,10 +8,18 @@ describe "helpers" do
|
|
8
8
|
Mercury
|
9
9
|
end
|
10
10
|
|
11
|
+
before(:all) do
|
12
|
+
app.extend(Sinatra::MercuryHelpers)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
11
16
|
it "should return js file" do
|
12
|
-
|
13
|
-
#app.css(:hello).should =~ /^<script(.*)<\/script>$/
|
17
|
+
app.render_script("Hello World", "javascript").should == "<script type='text/javascript'>\nHello World\n</script>\n"
|
14
18
|
end
|
15
19
|
|
20
|
+
it "should return style for all media" do
|
21
|
+
app.render_style("Hello World").should == "<style type='text/css' media='all' >\nHello World\n</style>\n"
|
22
|
+
end
|
23
|
+
|
16
24
|
|
17
25
|
end
|
@@ -11,7 +11,7 @@ describe "images" do
|
|
11
11
|
it "should return gif" do
|
12
12
|
File.stub!(:open).and_return('foobar')
|
13
13
|
get "/hello.gif"
|
14
|
-
|
14
|
+
last_response.body.should == 'foobar'
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return correct file content type for gif" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Wilson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-12 00:00:00 -04:00
|
13
13
|
default_executable: mercury
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|