roda-sprocket_assets 0.0.2

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: 9794983b3881a77af1c4f42f13036b0bfe613609
4
+ data.tar.gz: 5f54613742dce3e2e63e91fc48a7bbe66716ab7c
5
+ SHA512:
6
+ metadata.gz: 5ecb9079cf589b687f6ef3196436871624c75de26104d9e636ceba7c39e2efc5d298a7e7f3ceea035acbd5605e7fe42216b2c07a6f20466149bf6dc228d16eb8
7
+ data.tar.gz: 0284afa018b622150ae83ae09e026879bf93f18344044b9733504ea9b60002788187535820135b1d66fd4569d128234117b7241ddda129a32f357613a9525c0b
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roda-sprocket_assets.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 cj
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Roda::SprocketAssets
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'roda-sprocket_assets'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install roda-sprocket_assets
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/roda-sprocket_assets/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,101 @@
1
+ require 'roda'
2
+ require 'sprockets'
3
+ require 'sprockets-helpers'
4
+
5
+ class Roda
6
+ module RodaPlugins
7
+ module SprocketAssets
8
+ DEFAULTS = {
9
+ sprockets: Sprockets::Environment.new,
10
+ precompile: %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2),
11
+ prefix: %w(assets vendor/assets),
12
+ root: Dir.pwd,
13
+ path: -> { File.join(public_folder, 'assets') },
14
+ path_prefix: nil,
15
+ protocol: :http,
16
+ css_compressor: nil,
17
+ js_compressor: nil,
18
+ host: nil,
19
+ digest: true,
20
+ debug: false
21
+ }.freeze
22
+
23
+ def self.load_dependencies(app, _opts = nil)
24
+ app.plugin :environments
25
+ end
26
+
27
+ def self.configure(app, plugin_opts = {})
28
+ app.opts[:sprocket_assets] ? app.opts[:sprocket_assets].merge!(plugin_opts) : app.opts[:sprocket_assets] = plugin_opts.dup
29
+ opts = app.opts[:sprocket_assets].merge! plugin_opts
30
+ DEFAULTS.each { |k, v| opts[k] = v unless opts.key?(k) }
31
+
32
+ opts[:prefix].each do |prefix|
33
+ # Support absolute asset paths
34
+ # https://github.com/kalasjocke/sinatra-asset-pipeline/pull/54
35
+ paths = if Pathname.new(prefix).absolute?
36
+ Dir[File.join(prefix, '*')]
37
+ else
38
+ Dir[File.join(opts[:root], prefix, '*')]
39
+ end
40
+ paths.each { |path| opts[:sprockets].append_path path }
41
+ end
42
+
43
+ Sprockets::Helpers.configure do |config|
44
+ config.environment = opts[:sprockets]
45
+ config.digest = opts[:digest]
46
+ config.prefix = opts[:path_prefix] unless opts[:path_prefix].nil?
47
+ config.debug = opts[:debug]
48
+ end
49
+
50
+ app.configure :staging, :production do
51
+ opts[:sprockets].css_compressor = opts[:css_compressor] unless opts[:css_compressor].nil?
52
+ opts[:sprockets].js_compressor = opts[:js_compressor] unless opts[:js_compressor].nil?
53
+
54
+ Sprockets::Helpers.configure do |config|
55
+ config.manifest = Sprockets::Manifest.new(opts[:sprockets], opts[:path])
56
+ config.prefix = opts[:path_prefix] unless opts[:path_prefix].nil?
57
+ config.protocol = opts[:protocol]
58
+ config.asset_host = opts[:host] unless opts[:host].nil?
59
+ end
60
+ end
61
+ end
62
+
63
+ module ClassMethods
64
+ def sprocket_assets_opts
65
+ opts[:sprocket_assets]
66
+ end
67
+ end
68
+
69
+ module InstanceMethods
70
+ include Sprockets::Helpers
71
+
72
+ def sprocket_assets_opts
73
+ self.class.sprocket_assets_opts
74
+ end
75
+ end
76
+
77
+ module RequestClassMethods
78
+ def sprocket_assets_regexp
79
+ %r{#{Sprockets::Helpers.prefix[1..-1]}/(.*)}
80
+ end
81
+ end
82
+
83
+ module RequestMethods
84
+ def sprocket_assets
85
+ scope.class.configure :test, :development do
86
+ get self.class.sprocket_assets_regexp do |path|
87
+ env_sprockets = scope.request.env.dup
88
+ env_sprockets['PATH_INFO'] = path
89
+ status, headers, response = scope.sprocket_assets_opts[:sprockets].call env_sprockets
90
+ scope.response.status = status
91
+ scope.response.headers.merge! headers
92
+ response.is_a?(Array) ? response.join('\n') : response.to_s
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ register_plugin :sprocket_assets, SprocketAssets
100
+ end
101
+ end
@@ -0,0 +1 @@
1
+ require "roda/plugins/sprocket_assets"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "roda-sprocket_assets"
7
+ spec.version = '0.0.2'
8
+ spec.authors = ["cj"]
9
+ spec.email = ["cjlazell@gmail.com"]
10
+ spec.summary = %q{Use sprockets to serve assets in roda.}
11
+ spec.description = %q{Use sprockets to serve assets in roda.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'roda', '~> 2'
21
+ spec.add_dependency 'sprockets', '~> 3'
22
+ spec.add_dependency 'sprockets-helpers', '~> 1.2.1'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roda-sprocket_assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - cj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: roda
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sprockets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sprockets-helpers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Use sprockets to serve assets in roda.
84
+ email:
85
+ - cjlazell@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/roda/plugins/sprocket_assets.rb
96
+ - lib/roda/sprocket_assets.rb
97
+ - roda-sprocket_assets.gemspec
98
+ homepage: ''
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Use sprockets to serve assets in roda.
122
+ test_files: []