my-padrino-sprockets 0.0.4 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50bf49e1dfad0a3734833f8d1f2234b9ed14c71e
4
- data.tar.gz: 7f7eb05018af0c6183df0561a0c1b2f3536d9a5c
3
+ metadata.gz: 616adbdba63fc2b0559582943b1ab0d7fba2e3bd
4
+ data.tar.gz: 9ba5f2aa8cd7d631f8cfe7bb15d9a30c529c1898
5
5
  SHA512:
6
- metadata.gz: 63bb8d2719d1cffafe352a6dbc95d6e746d12f259900704802cedf29f9f47a762f8487c4d8ccd9c87672d039456c7459d1fb7c9290f73eef5f1d83031947fbe4
7
- data.tar.gz: c19f7b60991b94d9770b1fcd8e00c8c404ef4592366c73792ccfc38842e642e5ad8002543518cbfbfb21f7534200999a15141378b3ff88a44ef568dc89fae0e6
6
+ metadata.gz: 2af24233e896ba617f206a084f913d9d5a9170b79dbf8bd76fe64d762d2365646dc6026d8510976ac3da29446c031cb39d1e92f7bae7a6d9bcfbac430d150ca8
7
+ data.tar.gz: 9e82c908612653359ec0fc2a0bfc762788358ccad57e6f9ae0d48c49f1b6e17592488bd9a430eb58c41f28bfc7e283b6e36887967e15bca181b8578c190a2587
@@ -1,5 +1,5 @@
1
1
  module Padrino
2
2
  module Sprockets
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,17 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "sprockets"
3
- require "tilt"
4
-
5
- module Sprockets
6
- class JSMinifier < Tilt::Template
7
- def prepare
8
- end
9
-
10
- def evaluate(context, locals, &block)
11
- Uglifier.compile(data, :comments => :none)
12
- end
13
- end
14
- end
3
+ require 'fileutils'
4
+ require 'yui/compressor'
15
5
 
16
6
  module Padrino
17
7
  module Sprockets
@@ -51,6 +41,7 @@ module Padrino
51
41
  def initialize(app, options={})
52
42
  @app = app
53
43
  @root = options[:root]
44
+ @output = options[:output]
54
45
  url = options[:url] || 'assets'
55
46
  @matcher = /^\/#{url}\/*/
56
47
  setup_environment(options[:minify], options[:paths] || [])
@@ -60,19 +51,10 @@ module Padrino
60
51
  @assets = ::Sprockets::Environment.new(@root)
61
52
  @assets.append_path 'assets/javascripts'
62
53
  @assets.append_path 'assets/stylesheets'
63
- @assets.append_path 'assets/images'
64
54
 
65
55
  if minify
66
- if defined?(YUI)
67
- @assets.css_compressor = YUI::CssCompressor.new
68
- else
69
- puts "Add yui-compressor to your Gemfile to enable css compression"
70
- end
71
- if defined?(Uglifier)
72
- @assets.register_postprocessor "application/javascript", ::Sprockets::JSMinifier
73
- else
74
- puts "Add uglifier to your Gemfile to enable js minification"
75
- end
56
+ @assets.css_compressor = YUI::CssCompressor.new
57
+ @assets.js_compressor = YUI::JavaScriptCompressor.new
76
58
  end
77
59
 
78
60
  extra_paths.each do |sprocket_path|
@@ -80,6 +62,21 @@ module Padrino
80
62
  end
81
63
  end
82
64
 
65
+ def precompile(bundles)
66
+ output_dir = Pathname("#{@output}/assets")
67
+ bundles.each do |file|
68
+ tmp = file.to_s.split('/')
69
+ prefix, basename = tmp[0...-1].join("/"), tmp[-1]
70
+ path, dir = output_dir.join(prefix, basename), output_dir.join(prefix)
71
+ FileUtils.mkpath(dir) unless Dir.exist?(dir)
72
+ # clean up first
73
+ File.delete(path) if File.exist?(path)
74
+ # compile
75
+ asset = @assets.find_asset(file)
76
+ asset.write_to(path)
77
+ end
78
+ end
79
+
83
80
  def call(env)
84
81
  if @matcher =~ env["PATH_INFO"]
85
82
  env['PATH_INFO'].sub!(@matcher,'')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my-padrino-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Night Sailer, Matthias Günther
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yui-compressor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Padrino with Sprockets
28
42
  email:
29
43
  - nightsailer@gmail.com, matthias.guenther@wikimatze.de