wbzyl-sinatra-static-assets 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 6
2
+ :patch: 7
3
3
  :major: 0
4
4
  :minor: 0
@@ -2,10 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
-
6
5
  <%= stylesheet_link_tag "/stylesheets/app1.css" %>
7
-
8
- <script src="/javascripts/app1.js" type="text/javascript"></script>
6
+ <%= javascript_script_tag "/javascripts/app1.js" %>
9
7
 
10
8
  <title><%= @title %></title>
11
9
  </head>
@@ -2,10 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
-
6
5
  <%= stylesheet_link_tag "/stylesheets/app2.css" %>
7
-
8
- <script src="/javascripts/app2.js" type="text/javascript"></script>
6
+ <%= javascript_script_tag "/javascripts/app2.js" %>
9
7
 
10
8
  <title><%= @title %></title>
11
9
  </head>
@@ -0,0 +1,18 @@
1
+ <VirtualHost *:80>
2
+ ServerName sinatra.local
3
+ DocumentRoot /srv/www/sinatra
4
+
5
+ RackBaseURI /app1
6
+ RackBaseURI /app2
7
+
8
+ #<Location /app1>
9
+ # PassengerAppRoot /path-to-app1-root
10
+ #</Location>
11
+ #
12
+ # or
13
+ #
14
+ #<Directory /app1>
15
+ # PassengerAppRoot /path-to-app1-root
16
+ #</Directory>
17
+
18
+ </VirtualHost>
@@ -0,0 +1,18 @@
1
+ #
2
+ # file borrowed from Ruby on Rails:
3
+ # activesupport/lib/active_support/core_ext/array/extract_options.rb
4
+ #
5
+ class Array
6
+ # Extracts options from a set of arguments. Removes and returns the last
7
+ # element in the array if it's a hash, otherwise returns a blank hash.
8
+ #
9
+ # def options(*args)
10
+ # args.extract_options!
11
+ # end
12
+ #
13
+ # options(1, 2) # => {}
14
+ # options(1, 2, :a => :b) # => {:a=>:b}
15
+ def extract_options!
16
+ last.is_a?(::Hash) ? pop : {}
17
+ end
18
+ end
@@ -11,7 +11,7 @@ module Sinatra
11
11
  #
12
12
  # option: html -> closed == false
13
13
  # option: xhtml -> closed == true
14
-
14
+ #
15
15
  # In HTML the <img> tag has no end tag:
16
16
  #
17
17
  # image_tag "/images/foo.png", :alt => "Foo itself"
@@ -41,7 +41,8 @@ module Sinatra
41
41
  end
42
42
 
43
43
  def javascript_script_tag(*sources)
44
- # TODO
44
+ list, options = extract_options(sources)
45
+ list.collect { |source| javascript_tag(source, options) }.join("\n")
45
46
  end
46
47
 
47
48
  private
@@ -65,7 +66,8 @@ module Sinatra
65
66
  end
66
67
 
67
68
  def javascript_tag(source, options)
68
- # append onto tag "</script>"
69
+ tag("script", { :type => "text/javascript", :charset => "utf-8",
70
+ :src => url_for(source) }.merge(options), false) + "</script>"
69
71
  end
70
72
 
71
73
  def extract_options(a)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{sinatra-static-assets}
5
- s.version = "0.0.6"
5
+ s.version = "0.0.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["W\305\202odek Bzyl"]
9
- s.date = %q{2009-05-23}
9
+ s.date = %q{2009-05-24}
10
10
  s.description = %q{Sinatra extension providing helper methods to output tags for static assets.}
11
11
  s.email = %q{matwb@univ.gda.pl}
12
12
  s.extra_rdoc_files = [
@@ -37,6 +37,8 @@ Gem::Specification.new do |s|
37
37
  "examples/app2/tmp/always_restart.txt",
38
38
  "examples/app2/views/index.erb",
39
39
  "examples/app2/views/layout.erb",
40
+ "examples/sinatra.conf",
41
+ "lib/sinatra/extract_options.rb",
40
42
  "lib/sinatra/static_assets.rb",
41
43
  "sinatra-static-assets.gemspec",
42
44
  "test/sinatra_static_assets_test.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbzyl-sinatra-static-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - "W\xC5\x82odek Bzyl"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-23 00:00:00 -07:00
12
+ date: 2009-05-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,8 @@ files:
55
55
  - examples/app2/tmp/always_restart.txt
56
56
  - examples/app2/views/index.erb
57
57
  - examples/app2/views/layout.erb
58
+ - examples/sinatra.conf
59
+ - lib/sinatra/extract_options.rb
58
60
  - lib/sinatra/static_assets.rb
59
61
  - sinatra-static-assets.gemspec
60
62
  - test/sinatra_static_assets_test.rb