my-padrino-sprockets 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50bf49e1dfad0a3734833f8d1f2234b9ed14c71e
4
+ data.tar.gz: 7f7eb05018af0c6183df0561a0c1b2f3536d9a5c
5
+ SHA512:
6
+ metadata.gz: 63bb8d2719d1cffafe352a6dbc95d6e746d12f259900704802cedf29f9f47a762f8487c4d8ccd9c87672d039456c7459d1fb7c9290f73eef5f1d83031947fbe4
7
+ data.tar.gz: c19f7b60991b94d9770b1fcd8e00c8c404ef4592366c73792ccfc38842e642e5ad8002543518cbfbfb21f7534200999a15141378b3ff88a44ef568dc89fae0e6
@@ -0,0 +1,5 @@
1
+ module Padrino
2
+ module Sprockets
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,99 @@
1
+ # encoding: utf-8
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
15
+
16
+ module Padrino
17
+ module Sprockets
18
+ module Helpers
19
+ module ClassMethods
20
+ def sprockets(options={})
21
+ url = options[:url] || 'assets'
22
+ _root = options[:root] || root
23
+ paths = options[:paths] || []
24
+ set :sprockets_url, url
25
+ options[:root] = _root
26
+ options[:url] = url
27
+ options[:paths] = paths
28
+ use Padrino::Sprockets::App, options
29
+ end
30
+ end
31
+
32
+ module AssetTagHelpers
33
+ # Change the folders to /assets/
34
+ def asset_folder_name(kind)
35
+ case kind
36
+ when :css,:js,:images then 'assets'
37
+ else kind.to_s
38
+ end
39
+ end
40
+ end # AssetTagHelpers
41
+
42
+ def self.included(base)
43
+ base.send(:include, AssetTagHelpers)
44
+ base.extend ClassMethods
45
+ end
46
+ end #Helpers
47
+
48
+ class App
49
+ attr_reader :assets
50
+
51
+ def initialize(app, options={})
52
+ @app = app
53
+ @root = options[:root]
54
+ url = options[:url] || 'assets'
55
+ @matcher = /^\/#{url}\/*/
56
+ setup_environment(options[:minify], options[:paths] || [])
57
+ end
58
+
59
+ def setup_environment(minify=false, extra_paths=[])
60
+ @assets = ::Sprockets::Environment.new(@root)
61
+ @assets.append_path 'assets/javascripts'
62
+ @assets.append_path 'assets/stylesheets'
63
+ @assets.append_path 'assets/images'
64
+
65
+ 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
76
+ end
77
+
78
+ extra_paths.each do |sprocket_path|
79
+ @assets.append_path sprocket_path
80
+ end
81
+ end
82
+
83
+ def call(env)
84
+ if @matcher =~ env["PATH_INFO"]
85
+ env['PATH_INFO'].sub!(@matcher,'')
86
+ @assets.call(env)
87
+ else
88
+ @app.call(env)
89
+ end
90
+ end
91
+ end
92
+
93
+ class << self
94
+ def registered(app)
95
+ app.helpers Padrino::Sprockets::Helpers
96
+ end
97
+ end
98
+ end #Sprockets
99
+ end #Padrino
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: my-padrino-sprockets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Night Sailer, Matthias Günther
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Padrino with Sprockets
28
+ email:
29
+ - nightsailer@gmail.com, matthias.guenther@wikimatze.de
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/padrino/sprockets-version.rb
35
+ - lib/padrino/sprockets.rb
36
+ homepage: https://github.com/nightsailer/padrino-sprockets
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.2.2
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Padrino with Sprockets
60
+ test_files: []