rack-pipeline 0.0.6 → 0.0.7
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 +8 -8
- data/lib/rack-pipeline/base.rb +7 -6
- data/lib/rack-pipeline/version.rb +1 -1
- data/test/rack-pipeline_base_test.rb +12 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGMzODZiZDA2MWQwZmI0MjE3OGE1NDc2MGRhMjFhZDgzZjI5MDI5YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzA0ZGQ1NjU0ODA4YTFlMzcwOTcwYWI3MDBmYWVmN2VhY2M2NDU1NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDRhYzM1YjRjZDNkZTI3ZTczOWE5NTZhMzM1MTQ1YzUyZTg5Njg5N2YyYjRj
|
10
|
+
NDQ2OTBlODgzY2EzZTQwNTQwZGI4MzM1NjI0ZDk5Nzg4MGU3MGYyMmJjZDI3
|
11
|
+
NTQxOTNmMTMxNTUyZWE1ZjU2NmM0MWQyMmZhMzMwYTcyN2YxNjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWExNzc0YzRhZGNkZTlmZDgxMDMwZDY1MWMwMTM1OWI5NmY4ZjBjN2JhOWI1
|
14
|
+
YWQ2NThjYWFlOThhZDMwYjQ0NDIzMGRmYjFiZTY3NzIxOWQ5MjZiOGViNDNk
|
15
|
+
OTUxMDA4ZjNjZTMyMTVjZWExOTgyZTVjOWRjM2ZhNGQzNTg1OWY=
|
data/lib/rack-pipeline/base.rb
CHANGED
@@ -12,7 +12,8 @@ module RackPipeline
|
|
12
12
|
|
13
13
|
attr_accessor :assets, :settings
|
14
14
|
|
15
|
-
STATIC_TYPES
|
15
|
+
STATIC_TYPES = { '.js' => :js, '.css' => :css }.freeze
|
16
|
+
CONTENT_TYPES = { '.js' => 'application/javascript', '.css' => 'text/css' }.freeze
|
16
17
|
|
17
18
|
def assets_for( pipes, type, opts = {} )
|
18
19
|
Array(pipes).inject([]) do |all,pipe|
|
@@ -27,10 +28,6 @@ module RackPipeline
|
|
27
28
|
:temp => nil,
|
28
29
|
:compress => false,
|
29
30
|
:combine => false,
|
30
|
-
:content_type => {
|
31
|
-
'.css' => 'text/css',
|
32
|
-
'.js' => 'application/javascript',
|
33
|
-
},
|
34
31
|
:css => {
|
35
32
|
:app => 'assets/**/*.css',
|
36
33
|
},
|
@@ -68,7 +65,7 @@ module RackPipeline
|
|
68
65
|
[304, headers, []]
|
69
66
|
else
|
70
67
|
body = File.read file
|
71
|
-
headers['Content-Type'] = "#{
|
68
|
+
headers['Content-Type'] = "#{content_type(file)}; charset=#{body.encoding.to_s}"
|
72
69
|
headers['Content-Length'] = File.size(file).to_s
|
73
70
|
[200, headers, [body]]
|
74
71
|
end
|
@@ -84,6 +81,10 @@ module RackPipeline
|
|
84
81
|
end
|
85
82
|
end
|
86
83
|
|
84
|
+
def content_type( file )
|
85
|
+
CONTENT_TYPES[File.extname(file)] || 'text'
|
86
|
+
end
|
87
|
+
|
87
88
|
def prepare_pipe( path_info )
|
88
89
|
file = path_info.sub( /^\/(.*)\??.*$/, '\1' )
|
89
90
|
type = static_type(file) or return nil
|
@@ -3,10 +3,8 @@ require 'rack/test'
|
|
3
3
|
require 'rack-pipeline/base'
|
4
4
|
|
5
5
|
describe RackPipeline::Base do
|
6
|
-
SETTINGS_1 = {
|
7
|
-
}
|
8
|
-
SETTINGS_2 = {
|
9
|
-
}
|
6
|
+
SETTINGS_1 = {}
|
7
|
+
SETTINGS_2 = {}
|
10
8
|
|
11
9
|
before do
|
12
10
|
Dir.chdir File.dirname(__FILE__)
|
@@ -48,6 +46,16 @@ describe RackPipeline::Base do
|
|
48
46
|
response.body.must_include 'color: white'
|
49
47
|
end
|
50
48
|
|
49
|
+
it 'should have proper css content_type' do
|
50
|
+
response = @r1.get('/assets/stylesheets/a.css')
|
51
|
+
response.headers['Content-Type'].must_include 'text/css'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have proper js content_type' do
|
55
|
+
response = @r1.get('/app.js')
|
56
|
+
response.headers['Content-Type'].must_include 'application/javascript'
|
57
|
+
end
|
58
|
+
|
51
59
|
after do
|
52
60
|
FileUtils.rm_r( File.join( Dir.tmpdir, 'RackPipeline' ) )
|
53
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Bochkariov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,3 +142,4 @@ test_files:
|
|
142
142
|
- test/minitest_helper.rb
|
143
143
|
- test/rack-pipeline_base_test.rb
|
144
144
|
- test/rack-pipeline_test.rb
|
145
|
+
has_rdoc:
|