sinatra-assetpack 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,22 @@
1
+ v0.0.11 - Feb 21, 2012
2
+ ----------------------
3
+
4
+ ### Added:
5
+ * Support for 'prebuild' to build on startup.
6
+ * Support for SVG files.
7
+ * Implement UglifyJS support. (#18)
8
+ * Implement ignored files. (#17)
9
+ * Added support classic-style Sinatra apps. (#22)
10
+
11
+ ### Changed:
12
+ * Built files from 'rake assetpack:build' now match the mtimes of their sources. (#12)
13
+ * Update the readme with a note on SASS compression.
14
+ * Use regular expression route matcher instead of splat pattern for Padrino compatibility. (#19)
15
+ * Made <link> and <script> tags (generated by helpers) be more HTML5-like.
16
+
17
+ ### Fixed:
18
+ * Sinatra >= 1.3.0 compatibility. Use 'public_folder' in Sinatra >=1.3.0. (#25)
19
+
1
20
  v0.0.10 - Sep 18, 2011
2
21
  ----------------------
3
22
 
@@ -0,0 +1,24 @@
1
+ $:.unshift File.expand_path('../../../lib', __FILE__)
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/assetpack'
5
+
6
+ assets do
7
+ # By default, Sinatra::AssetPack looks at ./app/css/, ./app/js/ and
8
+ # ./app/images. Let's change this to look at ./css.
9
+ serve '/css', from: 'css'
10
+
11
+ css :main, [
12
+ '/css/*.css'
13
+ ]
14
+ end
15
+
16
+ get "/" do
17
+ css :main
18
+ end
19
+
20
+ __END__
21
+
22
+ @@ index
23
+ <%= css :main %>
24
+ <h1>Hello!</h1>
@@ -0,0 +1 @@
1
+ body { color: red }
@@ -3,18 +3,13 @@ require 'rack/test'
3
3
  module Sinatra
4
4
  module AssetPack
5
5
  def self.registered(app)
6
- unless app.root?
7
- raise Error, "Please set :root in your Sinatra app."
8
- end
9
-
10
- app.extend ClassMethods
11
6
  app.helpers Helpers
12
7
  end
13
8
 
14
9
  # Returns a list of formats that can be served.
15
10
  # Anything not in this list will be rejected.
16
11
  def self.supported_formats
17
- @supported_formats ||= %w(css js png jpg gif otf eot ttf woff htc)
12
+ @supported_formats ||= %w(css js png jpg gif svg otf eot ttf woff htc)
18
13
  end
19
14
 
20
15
  # Returns a map of what MIME format each Tilt type returns.
@@ -54,8 +49,13 @@ module Sinatra
54
49
  autoload :Configurator, "#{PREFIX}/assetpack/configurator"
55
50
  autoload :HashArray, "#{PREFIX}/assetpack/hasharray"
56
51
 
52
+ include ClassMethods
53
+
57
54
  Error = Class.new(StandardError)
58
55
 
59
56
  require "#{PREFIX}/assetpack/version"
60
57
  end
58
+
59
+ # Autoload in Sinatra classic mode
60
+ register AssetPack
61
61
  end
@@ -38,7 +38,7 @@ module Sinatra
38
38
  # Add the routes for the individual files.
39
39
  def add_individual_routes!
40
40
  assets.served.each do |path, from|
41
- get "/#{path}/*".squeeze('/') do |file|
41
+ get %r{#{"^/#{path}/".squeeze('/')}(.*)$} do |file|
42
42
  fmt = File.extname(file)[1..-1]
43
43
 
44
44
  # Sanity checks
@@ -41,10 +41,19 @@ module Sinatra
41
41
  include Configurator
42
42
 
43
43
  def initialize(app, &blk)
44
+ unless app.root?
45
+ raise Error, "Please set :root in your Sinatra app."
46
+ end
47
+
44
48
  @app = app
45
49
  @js_compression = :jsmin
46
50
  @css_compression = :simple
47
- @output_path = app.public
51
+
52
+ begin
53
+ @output_path = app.public
54
+ rescue NoMethodError
55
+ @output_path = app.public_folder
56
+ end
48
57
 
49
58
  @js_compression_options = Hash.new
50
59
  @css_compression_options = Hash.new
@@ -106,9 +106,9 @@ module Sinatra
106
106
  private
107
107
  def link_tag(file, options={})
108
108
  if js?
109
- "<script type='text/javascript' src='#{e file}'#{kv options}></script>"
109
+ "<script src='#{e file}'#{kv options}></script>"
110
110
  elsif css?
111
- "<link rel='stylesheet' type='text/css' href='#{e file}'#{kv options} />"
111
+ "<link rel='stylesheet' href='#{e file}'#{kv options} />"
112
112
  end
113
113
  end
114
114
  end
@@ -1,7 +1,7 @@
1
1
  module Sinatra
2
2
  module AssetPack
3
3
  def self.version
4
- "0.0.10"
4
+ "0.0.11"
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  class BuildTest < UnitTest
4
4
  teardown do
5
- FileUtils.rm_rf app.public
5
+ FileUtils.rm_rf File.join(app.root, 'public')
6
6
  end
7
7
 
8
8
  test "build" do
@@ -5,7 +5,7 @@ class AppTest < UnitTest
5
5
  get '/js/hello.js'
6
6
  assert body == '$(function() { alert("Hello"); });'
7
7
  end
8
-
8
+
9
9
  test '/js/hi.js (coffeescript)' do
10
10
  get '/js/hi.js'
11
11
  assert body.include? 'yo'
@@ -33,7 +33,12 @@ class AppTest < UnitTest
33
33
  get '/js/hello.css'
34
34
  assert last_response.status == 404
35
35
  end
36
-
36
+
37
+ test 'matches only from the site root' do
38
+ get '/not-the-root/js/hello.js'
39
+ assert last_response.status == 404
40
+ end
41
+
37
42
  test 'wrong extension for dynamic coffeescript file' do
38
43
  get '/js/hi.css'
39
44
  assert last_response.status == 404
@@ -57,14 +62,14 @@ class AppTest < UnitTest
57
62
 
58
63
  test "helpers" do
59
64
  get '/index.html'
60
- assert body =~ /<script type='text\/javascript' src='\/js\/hello.[0-9]+.js'><\/script>/
61
- assert body =~ /<script type='text\/javascript' src='\/js\/hi.[0-9]+.js'><\/script>/
65
+ assert body =~ /<script src='\/js\/hello.[0-9]+.js'><\/script>/
66
+ assert body =~ /<script src='\/js\/hi.[0-9]+.js'><\/script>/
62
67
  end
63
68
 
64
69
  test "helpers in production (compressed html thingie)" do
65
70
  app.expects(:production?).returns(true)
66
71
  get '/index.html'
67
- assert body =~ /<script type='text\/javascript' src='\/js\/app.[0-9]+.js'><\/script>/
72
+ assert body =~ /<script src='\/js\/app.[0-9]+.js'><\/script>/
68
73
  end
69
74
 
70
75
  test "compressed js" do
@@ -91,6 +96,6 @@ class AppTest < UnitTest
91
96
 
92
97
  test "helpers css" do
93
98
  get '/helpers/css'
94
- assert body =~ %r{link rel='stylesheet' type='text/css' href='/css/screen.[0-9]+.css' media='screen'}
99
+ assert body =~ %r{link rel='stylesheet' href='/css/screen.[0-9]+.css' media='screen'}
95
100
  end
96
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-assetpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
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: 2011-09-17 00:00:00.000000000Z
12
+ date: 2012-02-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
16
- requirement: &2153561760 !ruby/object:Gem::Requirement
16
+ requirement: &2152651000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153561760
24
+ version_requirements: *2152651000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sinatra
27
- requirement: &2153561340 !ruby/object:Gem::Requirement
27
+ requirement: &2152650180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153561340
35
+ version_requirements: *2152650180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jsmin
38
- requirement: &2153560880 !ruby/object:Gem::Requirement
38
+ requirement: &2152649180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153560880
46
+ version_requirements: *2152649180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &2153560460 !ruby/object:Gem::Requirement
49
+ requirement: &2152648100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153560460
57
+ version_requirements: *2152648100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yui-compressor
60
- requirement: &2153560040 !ruby/object:Gem::Requirement
60
+ requirement: &2152646860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153560040
68
+ version_requirements: *2152646860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sass
71
- requirement: &2153559620 !ruby/object:Gem::Requirement
71
+ requirement: &2152645840 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153559620
79
+ version_requirements: *2152645840
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: haml
82
- requirement: &2153559200 !ruby/object:Gem::Requirement
82
+ requirement: &2152644700 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2153559200
90
+ version_requirements: *2152644700
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: coffee-script
93
- requirement: &2153558780 !ruby/object:Gem::Requirement
93
+ requirement: &2152643520 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2153558780
101
+ version_requirements: *2152643520
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: contest
104
- requirement: &2153558360 !ruby/object:Gem::Requirement
104
+ requirement: &2152639780 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2153558360
112
+ version_requirements: *2152639780
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: mocha
115
- requirement: &2153557940 !ruby/object:Gem::Requirement
115
+ requirement: &2152639140 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2153557940
123
+ version_requirements: *2152639140
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: stylus
126
- requirement: &2153557520 !ruby/object:Gem::Requirement
126
+ requirement: &2152638260 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2153557520
134
+ version_requirements: *2152638260
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: uglifier
137
- requirement: &2153557100 !ruby/object:Gem::Requirement
137
+ requirement: &2152637340 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2153557100
145
+ version_requirements: *2152637340
146
146
  description: Package your assets for Sinatra.
147
147
  email:
148
148
  - rico@sinefunc.com
@@ -166,6 +166,8 @@ files:
166
166
  - examples/basic/app/js/vendor/jquery.plugin.js
167
167
  - examples/basic/app/js/vendor/underscore.js
168
168
  - examples/basic/views/index.erb
169
+ - examples/classic/app.rb
170
+ - examples/classic/css/screen.scss
169
171
  - examples/compass/.gitignore
170
172
  - examples/compass/Rakefile
171
173
  - examples/compass/app.rb