assette 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -6,20 +6,20 @@ GEM
6
6
  execjs
7
7
  coffee-script-source (1.1.1)
8
8
  diff-lcs (1.1.2)
9
- execjs (1.0.0)
9
+ execjs (1.1.3)
10
10
  multi_json (~> 1.0)
11
11
  git (1.2.5)
12
12
  jeweler (1.5.2)
13
13
  bundler (~> 1.0.0)
14
14
  git (>= 1.2.5)
15
15
  rake
16
- json (1.5.1)
16
+ json (1.5.2)
17
17
  mime-types (1.16)
18
18
  multi_json (1.0.3)
19
19
  rack (1.3.0)
20
20
  rack-test (0.6.0)
21
21
  rack (>= 1.0)
22
- rake (0.9.0)
22
+ rake (0.9.2)
23
23
  rcov (0.9.9)
24
24
  rspec (2.4.0)
25
25
  rspec-core (~> 2.4.0)
@@ -29,7 +29,7 @@ GEM
29
29
  rspec-expectations (2.4.0)
30
30
  diff-lcs (~> 1.1.2)
31
31
  rspec-mocks (2.4.0)
32
- sass (3.1.1)
32
+ sass (3.1.2)
33
33
  thor (0.14.6)
34
34
  yard (0.6.8)
35
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/assette.gemspec CHANGED
@@ -5,15 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{assette}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tal Atlas"]
12
- s.date = %q{2011-06-14}
13
- s.default_executable = %q{assette}
11
+ s.authors = [%q{Tal Atlas}]
12
+ s.date = %q{2011-11-22}
14
13
  s.description = %q{Renders all asset types (coffeescript/sass/scss) as equals}
15
14
  s.email = %q{me@tal.by}
16
- s.executables = ["assette"]
15
+ s.executables = [%q{assette}]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
19
18
  "README.rdoc"
@@ -30,11 +29,14 @@ Gem::Specification.new do |s|
30
29
  "VERSION",
31
30
  "assette.gemspec",
32
31
  "bin/assette",
32
+ "examples/.asset_key",
33
+ "examples/.assette_pid",
33
34
  "examples/config/assets.rb",
34
35
  "examples/myapp/templates/bar/index.html.mustache",
35
36
  "examples/myapp/templates/foo/_partial.html.mustache",
36
37
  "examples/myapp/templates/foo/index.html.mustache",
37
38
  "examples/public/images/test.pdf",
39
+ "examples/public/index.html",
38
40
  "examples/public/javascripts/foo.js",
39
41
  "examples/public/javascripts/handlebars.js",
40
42
  "examples/public/javascripts/one.js",
@@ -79,9 +81,9 @@ Gem::Specification.new do |s|
79
81
  "test/test_server.rb"
80
82
  ]
81
83
  s.homepage = %q{http://github.com/Talby/assette}
82
- s.licenses = ["MIT"]
83
- s.require_paths = ["lib"]
84
- s.rubygems_version = %q{1.5.0}
84
+ s.licenses = [%q{MIT}]
85
+ s.require_paths = [%q{lib}]
86
+ s.rubygems_version = %q{1.8.8}
85
87
  s.summary = %q{Treat all assets as equal}
86
88
  s.test_files = [
87
89
  "examples/config/assets.rb",
data/bin/assette CHANGED
@@ -6,4 +6,9 @@ require 'assette/cli'
6
6
  require 'assette/server'
7
7
 
8
8
 
9
+ if ARGV.include?('--trace')
10
+ Assette.logger = Logger.new(STDOUT)
11
+ end
12
+
13
+ Assette::CLI.source_root(Dir.pwd)
9
14
  Assette::CLI.start
@@ -0,0 +1 @@
1
+ 111121_203209
@@ -0,0 +1 @@
1
+ 9709
@@ -12,7 +12,7 @@ template_partial 'Handlebars.registerPartial({*path*},{*template*});'
12
12
 
13
13
  template_format 'GC.foo.t[{*path*}] = Handlebars.compile({*template*});'
14
14
 
15
- cache_method 'param'
15
+ cache_method 'path'
16
16
 
17
17
  after_compile do
18
18
  a = 1
@@ -0,0 +1,12 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" type="text/css" href="/stylesheets/two2.css?dev"/>
4
+ </head>
5
+
6
+
7
+ <body>
8
+
9
+
10
+ <script src="/javascripts/test.js?dev"></script>
11
+ </body>
12
+ </html>
@@ -10,4 +10,4 @@
10
10
 
11
11
  #foo3 {
12
12
  background: url(/images/mystuff/go_at.se)
13
- }
13
+ }
data/lib/assette/cli.rb CHANGED
@@ -36,6 +36,7 @@ module Assette
36
36
  include Thor::Actions
37
37
  DEFAULT_PID_FILE = '.assette_pid'
38
38
  class_option :'config-file', :desc => 'config file to use', :type => :string
39
+ class_option :trace, :type => :boolean, :default => false
39
40
 
40
41
  map "-v" => :version
41
42
 
@@ -112,8 +113,6 @@ module Assette
112
113
 
113
114
  files = files.collect {|f| Assette::File.open(f)}
114
115
 
115
- File.open("assets/version","w") {|f| f.write(sha)}
116
-
117
116
  container = if Assette.config.cache_method.to_s == 'path'
118
117
  File.join(Assette.config.build_target,sha)
119
118
  else
@@ -125,28 +124,37 @@ module Assette
125
124
  say "Compiling all asset files to #{container}"
126
125
 
127
126
  files.each do |file|
128
- target_path = file.target_path
127
+ target_path = file.relative_target_path
129
128
 
130
129
  Assette.config.file_paths.each do |p|
131
- target_path.gsub!(p,'')
130
+ # target_path.gsub!(p,'')
132
131
  end
133
132
 
134
133
  new_path = File.join(container,target_path)
135
134
 
135
+ Assette.logger.debug("Compiling file") {"#{file.path} -> #{new_path}"}
136
136
  create_file(new_path, file.all_code)
137
137
  end
138
138
 
139
139
  say "\nCopying all non-compiled assets to #{container}"
140
140
  not_compiled.each do |file|
141
+ next if File.directory?(file)
141
142
  target_path = file.dup
143
+
142
144
  Assette.config.file_paths.each do |p|
143
- target_path.gsub!(p,'')
145
+ target_path.gsub!(Regexp.new(p+'/'),'')
144
146
  end
145
147
 
146
148
  new_path = File.join(container,target_path)
147
149
 
148
- copy_file(new_path, file)
150
+ Assette.logger.debug("Copying file") {"#{file} -> #{new_path}"}
151
+ copy_file(file,new_path)
149
152
  end
153
+
154
+
155
+ version_file = '.asset_key' # 'assets/version'
156
+ File.delete(version_file) if File.exist?(version_file)
157
+ create_file(version_file,sha)
150
158
  end
151
159
 
152
160
  def initialize(*)
@@ -175,4 +183,4 @@ module Assette
175
183
  end
176
184
  end
177
185
 
178
- end
186
+ end
data/lib/assette/file.rb CHANGED
@@ -219,12 +219,20 @@ class Assette::File < ::File
219
219
 
220
220
  resp[:generation_time] = Time.now-start
221
221
 
222
- return [200,{"Content-Type" => 'text/javascript'}, [resp.to_json]]
222
+ return [200,{"Content-Type" => 'application/json'}, [resp.to_json]]
223
223
  end
224
224
 
225
225
  if opts[:nodep]
226
226
  code = [f.code]
227
227
  type = f.target_class.mime_type
228
+ elsif opts[:dev]
229
+
230
+ code = f.path_array.collect do |path|
231
+ f.target_class.include(path)
232
+ end
233
+
234
+ type = f.target_class.mime_type
235
+
228
236
  else
229
237
  code = f.all_code_array
230
238
  type = f.target_class.mime_type
@@ -34,6 +34,13 @@ class Assette::Reader::Css < Assette::Reader(:css)
34
34
  <link href="#{path}" rel="stylesheet" type="text/css" media="all" />
35
35
  HTML
36
36
  end
37
+
38
+ def include path
39
+ <<-CSS
40
+ #{comment_str % path}
41
+ @import url("#{path}?nodep");
42
+ CSS
43
+ end
37
44
 
38
45
  end
39
46
  end
@@ -27,5 +27,16 @@ class Assette::Reader::Js < Assette::Reader(:js)
27
27
  <script src="#{path}" type="text/javascript"></script>
28
28
  HTML
29
29
  end
30
+
31
+ def include path
32
+ <<-JS
33
+ (function() {
34
+ var e = document.createElement('script'); e.async = false;
35
+ e.src = '#{path}?nodep';
36
+ document.getElementsByTagName('head')[0].appendChild(e);
37
+ }());
38
+
39
+ JS
40
+ end
30
41
  end
31
42
  end
@@ -74,7 +74,7 @@ module Assette
74
74
  end
75
75
 
76
76
  def looking_for_template?
77
- m = path.match /__templates\/(.+)/
77
+ m = path.match(/__templates\/(.+)/)
78
78
  m[1].gsub(/.js$/,'').split(':') if m
79
79
  end
80
80
 
data/lib/assette.rb CHANGED
@@ -22,7 +22,7 @@ module Assette
22
22
  VERSION = File.open(File.expand_path(File.dirname(__FILE__)+'/../VERSION')).read.freeze
23
23
 
24
24
  def logger
25
- @logger ||= Logger.new(STDOUT)
25
+ @logger ||= Logger.new('/dev/null')
26
26
  end
27
27
 
28
28
  def logger=(l)
data/test/test_server.rb CHANGED
@@ -119,6 +119,26 @@ class ServerTest < Test::Unit::TestCase
119
119
  assert_equal json['target_type'], 'text/css'
120
120
  assert_equal json['dependencies'], ['/stylesheets/one.css','/stylesheets/two.css']
121
121
  end
122
+
123
+ def test_getting_include_file_css
124
+ get '/stylesheets/two2.css?dev'
125
+
126
+ is_css?
127
+ assert last_response.ok?
128
+ assert last_response.body.include?('/stylesheets/two2.css?nodep')
129
+ end
130
+
131
+ def test_getting_include_file_js
132
+ get "/javascripts/test.js?dev"
133
+
134
+ is_js?
135
+
136
+ assert last_response.ok?
137
+ assert last_response.body.include?('/__templates/foo?nodep')
138
+ assert last_response.body.include?('/javascripts/one.js?nodep')
139
+ assert last_response.body.include?('/javascripts/test.js?nodep')
140
+ assert_equal last_response.body, ''
141
+ end
122
142
 
123
143
  private
124
144
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assette
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,11 +15,9 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-14 00:00:00 -04:00
19
- default_executable: assette
18
+ date: 2011-11-22 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: rack
23
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
@@ -29,11 +27,11 @@ dependencies:
29
27
  segments:
30
28
  - 1
31
29
  version: "1"
30
+ name: rack
32
31
  prerelease: false
33
32
  type: :runtime
34
33
  requirement: *id001
35
34
  - !ruby/object:Gem::Dependency
36
- name: thor
37
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
@@ -43,11 +41,11 @@ dependencies:
43
41
  segments:
44
42
  - 0
45
43
  version: "0"
44
+ name: thor
46
45
  prerelease: false
47
46
  type: :runtime
48
47
  requirement: *id002
49
48
  - !ruby/object:Gem::Dependency
50
- name: json
51
49
  version_requirements: &id003 !ruby/object:Gem::Requirement
52
50
  none: false
53
51
  requirements:
@@ -58,11 +56,11 @@ dependencies:
58
56
  - 1
59
57
  - 4
60
58
  version: "1.4"
59
+ name: json
61
60
  prerelease: false
62
61
  type: :runtime
63
62
  requirement: *id003
64
63
  - !ruby/object:Gem::Dependency
65
- name: sass
66
64
  version_requirements: &id004 !ruby/object:Gem::Requirement
67
65
  none: false
68
66
  requirements:
@@ -73,11 +71,11 @@ dependencies:
73
71
  - 3
74
72
  - 1
75
73
  version: "3.1"
74
+ name: sass
76
75
  prerelease: false
77
76
  type: :runtime
78
77
  requirement: *id004
79
78
  - !ruby/object:Gem::Dependency
80
- name: mime-types
81
79
  version_requirements: &id005 !ruby/object:Gem::Requirement
82
80
  none: false
83
81
  requirements:
@@ -88,11 +86,11 @@ dependencies:
88
86
  - 1
89
87
  - 16
90
88
  version: "1.16"
89
+ name: mime-types
91
90
  prerelease: false
92
91
  type: :runtime
93
92
  requirement: *id005
94
93
  - !ruby/object:Gem::Dependency
95
- name: git
96
94
  version_requirements: &id006 !ruby/object:Gem::Requirement
97
95
  none: false
98
96
  requirements:
@@ -102,11 +100,11 @@ dependencies:
102
100
  segments:
103
101
  - 0
104
102
  version: "0"
103
+ name: git
105
104
  prerelease: false
106
105
  type: :runtime
107
106
  requirement: *id006
108
107
  - !ruby/object:Gem::Dependency
109
- name: coffee-script
110
108
  version_requirements: &id007 !ruby/object:Gem::Requirement
111
109
  none: false
112
110
  requirements:
@@ -116,11 +114,11 @@ dependencies:
116
114
  segments:
117
115
  - 2
118
116
  version: "2"
117
+ name: coffee-script
119
118
  prerelease: false
120
119
  type: :runtime
121
120
  requirement: *id007
122
121
  - !ruby/object:Gem::Dependency
123
- name: rspec
124
122
  version_requirements: &id008 !ruby/object:Gem::Requirement
125
123
  none: false
126
124
  requirements:
@@ -132,11 +130,11 @@ dependencies:
132
130
  - 4
133
131
  - 0
134
132
  version: 2.4.0
133
+ name: rspec
135
134
  prerelease: false
136
135
  type: :development
137
136
  requirement: *id008
138
137
  - !ruby/object:Gem::Dependency
139
- name: yard
140
138
  version_requirements: &id009 !ruby/object:Gem::Requirement
141
139
  none: false
142
140
  requirements:
@@ -148,11 +146,11 @@ dependencies:
148
146
  - 6
149
147
  - 0
150
148
  version: 0.6.0
149
+ name: yard
151
150
  prerelease: false
152
151
  type: :development
153
152
  requirement: *id009
154
153
  - !ruby/object:Gem::Dependency
155
- name: bundler
156
154
  version_requirements: &id010 !ruby/object:Gem::Requirement
157
155
  none: false
158
156
  requirements:
@@ -164,11 +162,11 @@ dependencies:
164
162
  - 0
165
163
  - 0
166
164
  version: 1.0.0
165
+ name: bundler
167
166
  prerelease: false
168
167
  type: :development
169
168
  requirement: *id010
170
169
  - !ruby/object:Gem::Dependency
171
- name: jeweler
172
170
  version_requirements: &id011 !ruby/object:Gem::Requirement
173
171
  none: false
174
172
  requirements:
@@ -180,11 +178,11 @@ dependencies:
180
178
  - 5
181
179
  - 2
182
180
  version: 1.5.2
181
+ name: jeweler
183
182
  prerelease: false
184
183
  type: :development
185
184
  requirement: *id011
186
185
  - !ruby/object:Gem::Dependency
187
- name: rcov
188
186
  version_requirements: &id012 !ruby/object:Gem::Requirement
189
187
  none: false
190
188
  requirements:
@@ -194,11 +192,11 @@ dependencies:
194
192
  segments:
195
193
  - 0
196
194
  version: "0"
195
+ name: rcov
197
196
  prerelease: false
198
197
  type: :development
199
198
  requirement: *id012
200
199
  - !ruby/object:Gem::Dependency
201
- name: rack-test
202
200
  version_requirements: &id013 !ruby/object:Gem::Requirement
203
201
  none: false
204
202
  requirements:
@@ -208,11 +206,11 @@ dependencies:
208
206
  segments:
209
207
  - 0
210
208
  version: "0"
209
+ name: rack-test
211
210
  prerelease: false
212
211
  type: :development
213
212
  requirement: *id013
214
213
  - !ruby/object:Gem::Dependency
215
- name: rack
216
214
  version_requirements: &id014 !ruby/object:Gem::Requirement
217
215
  none: false
218
216
  requirements:
@@ -222,11 +220,11 @@ dependencies:
222
220
  segments:
223
221
  - 1
224
222
  version: "1"
223
+ name: rack
225
224
  prerelease: false
226
225
  type: :runtime
227
226
  requirement: *id014
228
227
  - !ruby/object:Gem::Dependency
229
- name: thor
230
228
  version_requirements: &id015 !ruby/object:Gem::Requirement
231
229
  none: false
232
230
  requirements:
@@ -236,11 +234,11 @@ dependencies:
236
234
  segments:
237
235
  - 0
238
236
  version: "0"
237
+ name: thor
239
238
  prerelease: false
240
239
  type: :runtime
241
240
  requirement: *id015
242
241
  - !ruby/object:Gem::Dependency
243
- name: json
244
242
  version_requirements: &id016 !ruby/object:Gem::Requirement
245
243
  none: false
246
244
  requirements:
@@ -251,11 +249,11 @@ dependencies:
251
249
  - 1
252
250
  - 4
253
251
  version: "1.4"
252
+ name: json
254
253
  prerelease: false
255
254
  type: :runtime
256
255
  requirement: *id016
257
256
  - !ruby/object:Gem::Dependency
258
- name: sass
259
257
  version_requirements: &id017 !ruby/object:Gem::Requirement
260
258
  none: false
261
259
  requirements:
@@ -266,11 +264,11 @@ dependencies:
266
264
  - 3
267
265
  - 1
268
266
  version: "3.1"
267
+ name: sass
269
268
  prerelease: false
270
269
  type: :runtime
271
270
  requirement: *id017
272
271
  - !ruby/object:Gem::Dependency
273
- name: coffee-script
274
272
  version_requirements: &id018 !ruby/object:Gem::Requirement
275
273
  none: false
276
274
  requirements:
@@ -280,11 +278,11 @@ dependencies:
280
278
  segments:
281
279
  - 2
282
280
  version: "2"
281
+ name: coffee-script
283
282
  prerelease: false
284
283
  type: :runtime
285
284
  requirement: *id018
286
285
  - !ruby/object:Gem::Dependency
287
- name: mime-types
288
286
  version_requirements: &id019 !ruby/object:Gem::Requirement
289
287
  none: false
290
288
  requirements:
@@ -295,6 +293,7 @@ dependencies:
295
293
  - 1
296
294
  - 16
297
295
  version: "1.16"
296
+ name: mime-types
298
297
  prerelease: false
299
298
  type: :runtime
300
299
  requirement: *id019
@@ -319,11 +318,14 @@ files:
319
318
  - VERSION
320
319
  - assette.gemspec
321
320
  - bin/assette
321
+ - examples/.asset_key
322
+ - examples/.assette_pid
322
323
  - examples/config/assets.rb
323
324
  - examples/myapp/templates/bar/index.html.mustache
324
325
  - examples/myapp/templates/foo/_partial.html.mustache
325
326
  - examples/myapp/templates/foo/index.html.mustache
326
327
  - examples/public/images/test.pdf
328
+ - examples/public/index.html
327
329
  - examples/public/javascripts/foo.js
328
330
  - examples/public/javascripts/handlebars.js
329
331
  - examples/public/javascripts/one.js
@@ -366,7 +368,6 @@ files:
366
368
  - spec/template_spec.rb
367
369
  - test/helper.rb
368
370
  - test/test_server.rb
369
- has_rdoc: true
370
371
  homepage: http://github.com/Talby/assette
371
372
  licenses:
372
373
  - MIT
@@ -396,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
396
397
  requirements: []
397
398
 
398
399
  rubyforge_project:
399
- rubygems_version: 1.5.0
400
+ rubygems_version: 1.8.8
400
401
  signing_key:
401
402
  specification_version: 3
402
403
  summary: Treat all assets as equal