rails_serve_static_assets 0.0.1 → 0.0.2

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: c97acc1ac0ac5b35f8df33a199194a56c965b460
4
- data.tar.gz: 9a7cfad2603853e8226686e5a17d8bbe20f898e5
3
+ metadata.gz: d4b9e2f685ac142d180ca674e23d1a3f1cbf73dd
4
+ data.tar.gz: 99269b8768c5692012850dd727f085bf9df1de6a
5
5
  SHA512:
6
- metadata.gz: c918f58c01c40382422babdcda8dbf34212bb3d58736a78453bef1ad98c68982bedf54315d652835658f3ee3eef6c5bc2ec3dfb430b1cb269c910854de725792
7
- data.tar.gz: 7646f45633f778039876d5db8acaf90ef5f14d7ed773c988f0cf3c8bb3e5d92bcddae26709455d8b65454df2718f606a6a1e9b78aaeded63866d02c6f048ca24
6
+ metadata.gz: 5a7b1e8a9a74fecdd138432b3b6cd26e0d8b4e8a90ce8c91e2178f088b0d76fefdc15e1cf295ee4af1a578fde629a5dd525f8116022e85fa324bdff84d12f203
7
+ data.tar.gz: 9843941d471bf55ea7e5312958eb229c18d58eb2dbb5ce55526972007d927a761fae835f4e78c16a9bc95e077757fe14154bd7a4fa0a2ee782f27aa1f6b191b8
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011, Heroku
1
+ Copyright (c) 2013, Heroku
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -8,9 +8,6 @@ modification, are permitted provided that the following conditions are met:
8
8
  * Redistributions in binary form must reproduce the above copyright
9
9
  notice, this list of conditions and the following disclaimer in the
10
10
  documentation and/or other materials provided with the distribution.
11
- * Neither the name of the WAL-E project nor the
12
- names of its contributors may be used to endorse or promote products
13
- derived from this software without specific prior written permission.
14
11
 
15
12
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -0,0 +1,62 @@
1
+ # Serve Static Assets
2
+
3
+ Rails gem to enable serving of static assets
4
+
5
+ Supports:
6
+
7
+ - Rails 3
8
+ - Rails 4
9
+
10
+ ## What
11
+
12
+ This gem enables serving assets in production, required with Rails4.
13
+
14
+ ## Install
15
+
16
+ In your `Gemfile` add:
17
+
18
+ ```
19
+ gem 'rails_serve_static_assets'
20
+ ```
21
+
22
+ Then run
23
+
24
+ ```
25
+ $ bundle install`
26
+ ```
27
+
28
+ You also need the `rails_stdout_logging` gem. You can get both of them together by installing `rails_on_heroku` gem.
29
+
30
+ ## Rails 4 Serve Static Assets
31
+
32
+ In the default Rails development environment assets are served through a middleware called [sprockets](https://github.com/sstephenson/sprockets). In production however most one off Rails deployments will put their ruby server behind reverse HTTP proxy server such as Nginx which can load balance their sites and can serve static files directly. When Nginx sees a request for an asset such as `/assets/rails.png` it will grab it from disk at `/public/assets/rails.png` and serve it. The Rails server will never even sees the request.
33
+
34
+ On a 12factor platform, Nginx is not required to run your application. Your app should be capable of handling requests directly, or through a [routing layer](https://devcenter.heroku.com/articles/http-routing) that may handles load balancing while you scale out horizontally. The caching behavior of Nginx is not needed if your application is serving static assets through an [edge caching CDN](https://en.wikipedia.org/wiki/Content_delivery_network).
35
+
36
+ By default Rails4 will return a 404 if an asset is not handled via an external proxy such as Nginx. While this default behavior may help you debug your Nginx configuration, it makes a default Rails app with assets unusable on a 12factor platform. To fix this we've released a gem `rails_serve_static_assets`.
37
+
38
+ This gem, `rails_serve_static_assets`, enables your Rails server to deliver your assets instead of returning a 404. You can use this to populate an edge cache CDN, or serve files directly from your web app. This gives your app total control and allows you to do things like redirects, or setting headers in your Ruby code. To enable this behavior in your app we only need to set two configuration options through this gem:
39
+
40
+ ```
41
+ config.serve_static_assets = true
42
+ config.action_dispatch.x_sendfile_header = nil
43
+ ```
44
+
45
+ Note: this gem will set these values for you, you don't need to change any configuration manually.
46
+
47
+ All you need to do to get this functionality of both gems is add the `rails_12factor` gem to your project.
48
+
49
+ ## Why Didn't I need this before?
50
+
51
+ Why do you need to include this gem in Rails 4 and not Rails 3? Rails4 is getting rid of the concept of plugins. Before libraries were easily distributed as Gems and in the form of Engines, Rails had a folder `vendor/plugins`. Any code you put there would be initialized much like a Gem is today. This was a very simple and easy way to share and use libraries, but it wasn't very maintainable. You could use a library, and make a change locally and then deploy which makes your version incompatible from future versions. Even worse there was no concept of versioning aside from source control, so semantic versioning was out of the question. For these reasons and more Rails3 deprecated plugins. With Rails4 plugins have been removed completely. Why does this affect your app on Heroku?
52
+
53
+ In the past Heroku has used plugins as a safe way to configure your application where code was needed. While we advocate [separating config from code](http://12factor.net), this was the only option if we wanted your apps to work with no changes from you. With Rails3 Heroku will add the asset serving and standardout logging plugins to your app automatically. With Rails4, Heroku needs you to add these libraries to your Gemfile.
54
+
55
+ It is important to note that unlike Gems, plugins do not have a dependency resolution phase like what happens when you run `bundle install`. Heroku does not and will not add anything to your Gemfile on compilation.
56
+
57
+
58
+ ## The Future
59
+
60
+ We will be working with Rails and the Rails core team to make future versions of Rails work on Heroku out of the box. Until then you'll need to add this gem to your project.
61
+
62
+
@@ -2,6 +2,7 @@ module RailsServeStaticAssets
2
2
  class Railtie < Rails::Railtie
3
3
  config.before_initialize do
4
4
  ::Rails.configuration.serve_static_assets = true
5
+ ::Rails.configuration.action_dispatch.x_sendfile_header = nil
5
6
  end
6
7
  end
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module RailsServeStaticAssets
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -14,4 +14,5 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "rails_serve_static_assets"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = RailsServeStaticAssets::VERSION
17
+ gem.license = 'LICENSE'
17
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_serve_static_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Belo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-12 00:00:00.000000000 Z
12
+ date: 2013-12-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Force Rails to serve static assets
15
15
  email:
@@ -22,14 +22,15 @@ files:
22
22
  - .gitignore
23
23
  - Gemfile
24
24
  - LICENSE
25
- - README.markdown
25
+ - README.md
26
26
  - Rakefile
27
27
  - lib/rails_serve_static_assets.rb
28
28
  - lib/rails_serve_static_assets/railtie.rb
29
29
  - lib/rails_serve_static_assets/version.rb
30
30
  - rails_serve_static_assets.gemspec
31
31
  homepage: https://github.com/heroku/rails_serve_static_assets
32
- licenses: []
32
+ licenses:
33
+ - LICENSE
33
34
  metadata: {}
34
35
  post_install_message:
35
36
  rdoc_options: []
@@ -47,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
48
  version: '0'
48
49
  requirements: []
49
50
  rubyforge_project:
50
- rubygems_version: 2.0.2
51
+ rubygems_version: 2.0.14
51
52
  signing_key:
52
53
  specification_version: 4
53
54
  summary: Sets serve_static_assets to true so Rails will sere your static assets
@@ -1,8 +0,0 @@
1
- # Serve Static Assets
2
-
3
- Rails gem to enable serving of static assets
4
-
5
- Supports:
6
-
7
- - Rails 3
8
- - Rails 4