turbo_dev_assets 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7d4fe006a1ccd7dc10ca5b69593651001b27a66a
4
+ data.tar.gz: 58a4e561e37807d3a7d36d70e8a623c6f7a804c4
5
+ SHA512:
6
+ metadata.gz: 00b37aaa4c572107578460b0d89cc40cac8d3d9af14e7660f095c394c238873ab33cad69ba1b79eb1d65cc9c758c81b6112cc25e145a9c8beb29bf0548869004
7
+ data.tar.gz: b95598c76122578b02829695ee9868f8cdcb1a651c0007014a990b58af70728e8a439e9405112ec40371c9fc9893984073d620f186f69de2e96eeb608dddedb2
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Sam Saffron, Robin Ward, Mark IJbema
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19
+ OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # TurboDevAssets
2
+
3
+ A gem to speed up asset serving in development in Rails.
4
+ When you use this middleware, all asset requests will bypass your
5
+ application and all other middlewares, and go straight to the
6
+ asset pipeline.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'turbo_dev_assets'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```
19
+ $ bundle
20
+ ```
21
+
22
+ Then add to the end of the config block in development.rb:
23
+
24
+ ```ruby
25
+ YourApplication.configure do
26
+
27
+ # ... other settings
28
+
29
+ config.middleware.insert 0, TurboDevAssets
30
+ end
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( http://github.com/markijbema/turbo_dev_assets/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
40
+
41
+ ## License
42
+
43
+ MIT License. See LICENSE.txt for details
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ class TurboDevAssets
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,36 @@
1
+ require "turbo_dev_assets/version"
2
+
3
+ # Cheat and bypass Rails in development mode if the client attempts to download a static asset
4
+ # that's already been downloaded.
5
+ #
6
+ # Also ensures that assets are not cached in development mode. Around Chrome 29, the behavior
7
+ # of `must-revalidate` changed and would often not request assets that had changed.
8
+ #
9
+ # To use, include in your project and add the following to development.rb:
10
+ #
11
+ # require 'middleware/turbo_dev'
12
+ # config.middleware.insert 0, Middleware::TurboDev
13
+ #
14
+ class TurboDevAssets
15
+ def initialize(app, settings={})
16
+ @app = app
17
+ end
18
+
19
+ def call(env)
20
+ is_asset = (env['REQUEST_PATH'] =~ /^\/assets\//)
21
+
22
+ # hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
23
+ if (etag = env['HTTP_IF_NONE_MATCH']) && is_asset
24
+ name = $'
25
+ etag = etag.gsub "\"", ""
26
+ asset = Rails.application.assets.find_asset(name)
27
+ if asset && asset.digest == etag
28
+ return [304,{},[]]
29
+ end
30
+ end
31
+
32
+ status, headers, response = @app.call(env)
33
+ headers['Cache-Control'] = 'no-cache' if is_asset
34
+ [status, headers, response]
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'turbo_dev_assets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "turbo_dev_assets"
8
+ spec.version = TurboDevAssets::VERSION
9
+ spec.authors = ["Mark IJbema", "Sam Saffron", "Robin Ward"]
10
+ spec.email = ["markijbema@gmail.com"]
11
+ spec.summary = %q{A gem to speed up asset serving in development in Rails.}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turbo_dev_assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark IJbema
8
+ - Sam Saffron
9
+ - Robin Ward
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2014-04-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.5'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ description: ''
44
+ email:
45
+ - markijbema@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/turbo_dev_assets.rb
56
+ - lib/turbo_dev_assets/version.rb
57
+ - turbo_dev_assets.gemspec
58
+ homepage: ''
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.0
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A gem to speed up asset serving in development in Rails.
82
+ test_files: []