dassets 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.md +56 -2
  2. data/bin/dassets +7 -0
  3. data/dassets.gemspec +9 -3
  4. data/lib/dassets/asset_file.rb +65 -0
  5. data/lib/dassets/cli.rb +109 -0
  6. data/lib/dassets/digests_file.rb +70 -0
  7. data/lib/dassets/root_path.rb +12 -0
  8. data/lib/dassets/runner/cache_command.rb +46 -0
  9. data/lib/dassets/runner/digest_command.rb +65 -0
  10. data/lib/dassets/runner.rb +42 -0
  11. data/lib/dassets/server/request.rb +48 -0
  12. data/lib/dassets/server/response.rb +36 -0
  13. data/lib/dassets/server.rb +37 -0
  14. data/lib/dassets/version.rb +1 -1
  15. data/lib/dassets.rb +32 -2
  16. data/test/helper.rb +3 -1
  17. data/test/support/app/assets/.digests +4 -0
  18. data/test/support/app/assets/public/file1.txt +1 -0
  19. data/test/support/app/assets/public/file2.txt +1 -0
  20. data/test/support/app/assets/public/grumpy_cat.jpg +0 -0
  21. data/test/support/app/assets/public/nested/file3.txt +0 -0
  22. data/test/support/app.rb +10 -0
  23. data/test/support/app_public/.gitkeep +0 -0
  24. data/test/support/config/assets.rb +7 -0
  25. data/test/support/example.digests +3 -0
  26. data/test/support/public/file1-daa05c683a4913b268653f7a7e36a5b4.txt +1 -0
  27. data/test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt +1 -0
  28. data/test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg +0 -0
  29. data/test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt +0 -0
  30. data/test/system/rack_tests.rb +78 -0
  31. data/test/unit/asset_file_tests.rb +76 -0
  32. data/test/unit/config_tests.rb +27 -0
  33. data/test/unit/dassets_tests.rb +49 -0
  34. data/test/unit/digests_file_tests.rb +90 -0
  35. data/test/unit/runner/cache_command_tests.rb +62 -0
  36. data/test/unit/runner/digest_command_tests.rb +83 -0
  37. data/test/unit/runner_tests.rb +29 -0
  38. data/test/unit/server/request_tests.rb +76 -0
  39. data/test/unit/server/response_tests.rb +70 -0
  40. data/test/unit/server_tests.rb +17 -0
  41. metadata +130 -10
@@ -0,0 +1,70 @@
1
+ require 'assert'
2
+ require 'rack/utils'
3
+ require 'dassets/server/response'
4
+
5
+ class Dassets::Server::Response
6
+
7
+ class BaseTests < Assert::Context
8
+ desc "Dassets::Server::Response"
9
+ setup do
10
+ @resp = file_response(Dassets::AssetFile.new('', ''))
11
+ end
12
+ subject{ @resp }
13
+
14
+ should have_readers :asset_file, :status, :headers, :body
15
+ should have_imeths :to_rack
16
+
17
+ should "handle not modified files" do
18
+ af = Dassets['file1.txt']
19
+ mtime = File.mtime(af.files_path).httpdate.to_s
20
+ resp = file_response(af, 'HTTP_IF_MODIFIED_SINCE' => mtime)
21
+
22
+ assert_equal 304, resp.status
23
+ assert_equal [], resp.body
24
+ assert_equal Rack::Utils::HeaderHash.new, resp.headers
25
+ assert_equal [ 304, {}, [] ], resp.to_rack
26
+ end
27
+
28
+ should "handle found files" do
29
+ af = Dassets['file1.txt']
30
+ resp = file_response(af)
31
+ exp_headers = {
32
+ 'Content-Type' => 'text/plain',
33
+ 'Content-Length' => File.size?(af.files_path).to_s,
34
+ 'Last-Modified' => File.mtime(af.files_path).httpdate.to_s
35
+ }
36
+
37
+ assert_equal 200, resp.status
38
+ assert_equal [ af.content ], resp.body
39
+ assert_equal exp_headers, resp.headers
40
+ assert_equal [ 200, exp_headers, [ af.content ] ], resp.to_rack
41
+ end
42
+
43
+ should "have an empty body for found files with a HEAD request" do
44
+ af = Dassets['file1.txt']
45
+ resp = file_response(af, 'REQUEST_METHOD' => 'HEAD')
46
+
47
+ assert_equal 200, resp.status
48
+ assert_equal [], resp.body
49
+ end
50
+
51
+ should "handle not found files" do
52
+ af = Dassets['not-found-file.txt']
53
+ resp = file_response(af)
54
+
55
+ assert_equal 404, resp.status
56
+ assert_equal [], resp.body
57
+ assert_equal Rack::Utils::HeaderHash.new, resp.headers
58
+ assert_equal [ 404, {}, [] ], resp.to_rack
59
+ end
60
+
61
+ protected
62
+
63
+ def file_response(asset_file, env={})
64
+ require 'dassets/server/response'
65
+ Dassets::Server::Response.new(env, asset_file)
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,17 @@
1
+ require 'assert'
2
+ require 'dassets/server'
3
+
4
+ class Dassets::Server
5
+
6
+ class BaseTests < Assert::Context
7
+ desc "Dassets::Server"
8
+ setup do
9
+ @server = Dassets::Server.new('a rack app goes here')
10
+ end
11
+ subject{ @server }
12
+
13
+ should have_imeths :call, :call!
14
+
15
+ end
16
+
17
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dassets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-04-12 00:00:00 Z
19
+ date: 2013-04-18 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: assert
@@ -24,20 +24,81 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  hash: 3
30
30
  segments:
31
+ - 2
31
32
  - 0
32
- version: "0"
33
+ version: "2.0"
33
34
  type: :development
34
35
  version_requirements: *id001
35
- description: Digest and serve asset files
36
+ - !ruby/object:Gem::Dependency
37
+ name: assert-rack-test
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: sinatra
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 1
62
+ - 4
63
+ version: "1.4"
64
+ type: :development
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: ns-options
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 13
75
+ segments:
76
+ - 1
77
+ - 1
78
+ version: "1.1"
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: rack
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 15
90
+ segments:
91
+ - 1
92
+ - 0
93
+ version: "1.0"
94
+ type: :runtime
95
+ version_requirements: *id005
96
+ description: Digest and serve HTML asset files
36
97
  email:
37
98
  - kelly@kellyredding.com
38
99
  - collin.redding@me.com
39
- executables: []
40
-
100
+ executables:
101
+ - dassets
41
102
  extensions: []
42
103
 
43
104
  extra_rdoc_files: []
@@ -48,11 +109,46 @@ files:
48
109
  - LICENSE.txt
49
110
  - README.md
50
111
  - Rakefile
112
+ - bin/dassets
51
113
  - dassets.gemspec
52
114
  - lib/dassets.rb
115
+ - lib/dassets/asset_file.rb
116
+ - lib/dassets/cli.rb
117
+ - lib/dassets/digests_file.rb
118
+ - lib/dassets/root_path.rb
119
+ - lib/dassets/runner.rb
120
+ - lib/dassets/runner/cache_command.rb
121
+ - lib/dassets/runner/digest_command.rb
122
+ - lib/dassets/server.rb
123
+ - lib/dassets/server/request.rb
124
+ - lib/dassets/server/response.rb
53
125
  - lib/dassets/version.rb
54
126
  - log/.gitkeep
55
127
  - test/helper.rb
128
+ - test/support/app.rb
129
+ - test/support/app/assets/.digests
130
+ - test/support/app/assets/public/file1.txt
131
+ - test/support/app/assets/public/file2.txt
132
+ - test/support/app/assets/public/grumpy_cat.jpg
133
+ - test/support/app/assets/public/nested/file3.txt
134
+ - test/support/app_public/.gitkeep
135
+ - test/support/config/assets.rb
136
+ - test/support/example.digests
137
+ - test/support/public/file1-daa05c683a4913b268653f7a7e36a5b4.txt
138
+ - test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt
139
+ - test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg
140
+ - test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt
141
+ - test/system/rack_tests.rb
142
+ - test/unit/asset_file_tests.rb
143
+ - test/unit/config_tests.rb
144
+ - test/unit/dassets_tests.rb
145
+ - test/unit/digests_file_tests.rb
146
+ - test/unit/runner/cache_command_tests.rb
147
+ - test/unit/runner/digest_command_tests.rb
148
+ - test/unit/runner_tests.rb
149
+ - test/unit/server/request_tests.rb
150
+ - test/unit/server/response_tests.rb
151
+ - test/unit/server_tests.rb
56
152
  - tmp/.gitkeep
57
153
  homepage: http://github.com/redding/dassets
58
154
  licenses: []
@@ -86,6 +182,30 @@ rubyforge_project:
86
182
  rubygems_version: 1.8.24
87
183
  signing_key:
88
184
  specification_version: 3
89
- summary: Digested Assets
185
+ summary: Digested asset files
90
186
  test_files:
91
187
  - test/helper.rb
188
+ - test/support/app.rb
189
+ - test/support/app/assets/.digests
190
+ - test/support/app/assets/public/file1.txt
191
+ - test/support/app/assets/public/file2.txt
192
+ - test/support/app/assets/public/grumpy_cat.jpg
193
+ - test/support/app/assets/public/nested/file3.txt
194
+ - test/support/app_public/.gitkeep
195
+ - test/support/config/assets.rb
196
+ - test/support/example.digests
197
+ - test/support/public/file1-daa05c683a4913b268653f7a7e36a5b4.txt
198
+ - test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt
199
+ - test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg
200
+ - test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt
201
+ - test/system/rack_tests.rb
202
+ - test/unit/asset_file_tests.rb
203
+ - test/unit/config_tests.rb
204
+ - test/unit/dassets_tests.rb
205
+ - test/unit/digests_file_tests.rb
206
+ - test/unit/runner/cache_command_tests.rb
207
+ - test/unit/runner/digest_command_tests.rb
208
+ - test/unit/runner_tests.rb
209
+ - test/unit/server/request_tests.rb
210
+ - test/unit/server/response_tests.rb
211
+ - test/unit/server_tests.rb