astro 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +23 -0
- data/astro.gemspec +6 -3
- data/lib/assets/stylesheets/astro.css +11 -0
- data/lib/astro/assets.rb +8 -3
- data/lib/astro/middleware/sprockets.rb +1 -0
- data/lib/astro/server.rb +9 -1
- data/lib/astro/version.rb +1 -1
- data/lib/astro/views/error.css.erb +4 -0
- data/lib/astro/views/{error.erb → error.js.erb} +0 -0
- data/spec/assets/stylesheets/bar.css +5 -0
- data/spec/assets/stylesheets/foo.css +1 -0
- data/spec/astro/middleware/sprockets_spec.rb +5 -2
- data/spec/astro/server_spec.rb +40 -8
- data/spec/astro/server_spec/astro_server/stylesheets/bar/body.css +16 -0
- data/spec/astro/server_spec/astro_server/stylesheets/bar/headers.txt +5 -0
- data/spec/astro/server_spec/astro_server/stylesheets/baz/body.css +6 -0
- data/spec/astro/server_spec/astro_server/stylesheets/baz/headers.txt +5 -0
- data/spec/astro/server_spec/astro_server/stylesheets/empty/body.css +11 -0
- data/spec/astro/server_spec/astro_server/stylesheets/empty/headers.txt +5 -0
- data/spec/astro/server_spec/astro_server/stylesheets/foo/body.css +12 -0
- data/spec/astro/server_spec/astro_server/stylesheets/foo/headers.txt +5 -0
- metadata +75 -5
data/README.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
Astro is your DIY asset distribution web service.
|
4
4
|
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'astro'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install astro
|
18
|
+
|
5
19
|
## TODOs
|
6
20
|
|
7
21
|
- Asset versioning.
|
@@ -14,3 +28,12 @@ Astro is your DIY asset distribution web service.
|
|
14
28
|
- Deploy to heroku.
|
15
29
|
- Release on rubygems.
|
16
30
|
- Make sure astro can be mounted within a rails app.
|
31
|
+
- Command-line tool.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
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
|
data/astro.gemspec
CHANGED
@@ -18,15 +18,18 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'sinatra',
|
22
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'sinatra', '~> 1.4.3'
|
22
|
+
spec.add_dependency 'sinatra-contrib', '~> 1.4.0'
|
23
|
+
spec.add_dependency 'sprockets', '~> 2.10.0'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'rake'
|
25
26
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
27
|
spec.add_development_dependency 'rspec', '~> 2.13.0'
|
27
28
|
spec.add_development_dependency 'rack-test', '~> 0.6.2'
|
28
|
-
spec.add_development_dependency 'git-approvals', '~> 0.
|
29
|
+
spec.add_development_dependency 'git-approvals', '~> 0.4.0'
|
29
30
|
spec.add_development_dependency 'uglifier', '~> 2.1.1'
|
31
|
+
spec.add_development_dependency 'awesome_print', '~> 1.1.0'
|
32
|
+
spec.add_development_dependency 'sass', '~> 3.2.9'
|
30
33
|
spec.add_development_dependency 'guard-rspec', '~> 3.0.1'
|
31
34
|
spec.add_development_dependency 'pry', '~> 0.9.12.2'
|
32
35
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* ______ __
|
3
|
+
* /\ _ \ /\ \__ __
|
4
|
+
* \ \ \L\ \ ____\ \ ,_\ _ __ ___ /\_\ ____
|
5
|
+
* \ \ __ \ /',__\\ \ \/ /\`'__\/ __`\ \/\ \ /',__\
|
6
|
+
* \ \ \/\ \/\__, `\\ \ \_\ \ \//\ \L\ \__ \ \ \/\__, `\
|
7
|
+
* \ \_\ \_\/\____/ \ \__\\ \_\\ \____/\_\_\ \ \/\____/
|
8
|
+
* \/_/\/_/\/___/ \/__/ \/_/ \/___/\/_/\ \_\ \/___/
|
9
|
+
* \ \____/
|
10
|
+
* \/___/
|
11
|
+
*/
|
data/lib/astro/assets.rb
CHANGED
@@ -23,6 +23,7 @@ module Astro
|
|
23
23
|
app.configure :development, :production do |app|
|
24
24
|
app.before do
|
25
25
|
assets.append_path 'app/assets/javascripts'
|
26
|
+
assets.append_path 'app/assets/stylesheets'
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -30,13 +31,12 @@ module Astro
|
|
30
31
|
app.configure :test do |app|
|
31
32
|
app.before do
|
32
33
|
assets.append_path 'spec/assets/javascripts'
|
34
|
+
assets.append_path 'spec/assets/stylesheets'
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
app.before do
|
37
|
-
|
38
|
-
'application/javascript', :astro do |context, data|
|
39
|
-
|
39
|
+
processor = lambda do |context, data|
|
40
40
|
##
|
41
41
|
# If we're processing the root asset, require all of
|
42
42
|
# the assets in the assets list and return the data
|
@@ -50,6 +50,11 @@ module Astro
|
|
50
50
|
|
51
51
|
data
|
52
52
|
end
|
53
|
+
|
54
|
+
assets.register_preprocessor \
|
55
|
+
'application/javascript', :astro, &processor
|
56
|
+
assets.register_preprocessor \
|
57
|
+
'text/css', :astro, &processor
|
53
58
|
end
|
54
59
|
|
55
60
|
end
|
data/lib/astro/server.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
+
require 'sinatra/respond_with'
|
2
3
|
|
3
4
|
module Astro
|
4
5
|
class Server < Sinatra::Base
|
5
6
|
|
6
7
|
register Astro::Assets
|
8
|
+
register Sinatra::RespondWith
|
7
9
|
|
8
10
|
use Astro::Middleware::QueryString
|
9
11
|
use Astro::Middleware::Sprockets
|
@@ -11,17 +13,23 @@ module Astro
|
|
11
13
|
##
|
12
14
|
# TODO docs
|
13
15
|
error Sprockets::FileNotFound do
|
14
|
-
|
16
|
+
status 404
|
17
|
+
respond_with :error
|
15
18
|
end
|
16
19
|
|
17
20
|
##
|
18
21
|
# TODO docs
|
19
22
|
before( '/javascripts' ){ content_type 'application/javascript' }
|
23
|
+
before( '/stylesheets' ){ content_type 'text/css' }
|
20
24
|
|
21
25
|
##
|
22
26
|
# TODO docs
|
23
27
|
get( '/javascripts' ){ assets[ 'astro.js' ].to_s }
|
24
28
|
|
29
|
+
##
|
30
|
+
# TODO docs
|
31
|
+
get( '/stylesheets' ){ assets[ 'astro.css' ].to_s }
|
32
|
+
|
25
33
|
# TODO get /javascripts/:name
|
26
34
|
# - display available versions?
|
27
35
|
# - 3xx if found, 4xx if missing?
|
data/lib/astro/version.rb
CHANGED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
/* foo.css */
|
@@ -14,9 +14,12 @@ describe Astro::Middleware::Sprockets do
|
|
14
14
|
subject { last_request.env[ 'astro.sprockets' ] }
|
15
15
|
|
16
16
|
it { should be_a( Sprockets::Environment ) }
|
17
|
-
it { should have(
|
17
|
+
it { should have( 2 ).paths }
|
18
18
|
|
19
|
-
it 'has the
|
19
|
+
it 'has the javascripts directory in the path' do
|
20
20
|
subject.paths[ 0 ].should =~ /lib\/assets\/javascripts$/
|
21
21
|
end
|
22
|
+
it 'has the stylesheets directory in the path' do
|
23
|
+
subject.paths[ 1 ].should =~ /lib\/assets\/stylesheets$/
|
24
|
+
end
|
22
25
|
end
|
data/spec/astro/server_spec.rb
CHANGED
@@ -14,29 +14,61 @@ describe Astro::Server do
|
|
14
14
|
context 'empty' do
|
15
15
|
before { get '/javascripts' }
|
16
16
|
its( :status ){ should == 200 }
|
17
|
-
example( 'headers' ){ verify { subject.headers } }
|
18
|
-
example( 'body' ){ verify( :format => :js
|
17
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
18
|
+
example( 'body' ){ verify( :format => :js ){ subject.body } }
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'foo' do
|
22
22
|
before { get '/javascripts?foo' }
|
23
23
|
its( :status ){ should == 200 }
|
24
|
-
example( 'headers' ){ verify { subject.headers } }
|
25
|
-
example( 'body' ){ verify( :format => :js
|
24
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
25
|
+
example( 'body' ){ verify( :format => :js ){ subject.body } }
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'bar' do
|
29
29
|
before { get '/javascripts?bar' }
|
30
30
|
its( :status ){ should == 200 }
|
31
|
-
example( 'headers' ){ verify { subject.headers } }
|
32
|
-
example( 'body' ){ verify( :format => :js
|
31
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
32
|
+
example( 'body' ){ verify( :format => :js ){ subject.body } }
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'baz' do
|
36
36
|
before { get '/javascripts?baz' }
|
37
37
|
its( :status ){ should == 404 }
|
38
|
-
example( 'headers' ){ verify { subject.headers } }
|
39
|
-
example( 'body' ){ verify( :format => :js
|
38
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
39
|
+
example( 'body' ){ verify( :format => :js ){ subject.body } }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'stylesheets' do
|
44
|
+
subject { last_response }
|
45
|
+
|
46
|
+
context 'empty' do
|
47
|
+
before { get '/stylesheets' }
|
48
|
+
its( :status ){ should == 200 }
|
49
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
50
|
+
example( 'body' ){ verify( :format => :css ){ subject.body } }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'foo' do
|
54
|
+
before { get '/stylesheets?foo' }
|
55
|
+
its( :status ){ should == 200 }
|
56
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
57
|
+
example( 'body' ){ verify( :format => :css ){ subject.body } }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'bar' do
|
61
|
+
before { get '/stylesheets?bar' }
|
62
|
+
its( :status ){ should == 200 }
|
63
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
64
|
+
example( 'body' ){ verify( :format => :css ){ subject.body } }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'baz' do
|
68
|
+
before { get '/stylesheets?baz' }
|
69
|
+
its( :status ){ should == 404 }
|
70
|
+
example( 'headers' ){ verify( :format => :txt ){ subject.headers } }
|
71
|
+
example( 'body' ){ verify( :format => :css ){ subject.body } }
|
40
72
|
end
|
41
73
|
end
|
42
74
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/* foo.css */
|
2
|
+
/*
|
3
|
+
|
4
|
+
*/
|
5
|
+
/* bar.css */
|
6
|
+
/**
|
7
|
+
* ______ __
|
8
|
+
* /\ _ \ /\ \__ __
|
9
|
+
* \ \ \L\ \ ____\ \ ,_\ _ __ ___ /\_\ ____
|
10
|
+
* \ \ __ \ /',__\ \ \/ /\`'__\/ __`\ \/\ \ /',__\
|
11
|
+
* \ \ \/\ \/\__, `\ \ \_\ \ \//\ \L\ \__ \ \ \/\__, `\
|
12
|
+
* \ \_\ \_\/\____/ \ \__\ \_\ \____/\_\_\ \ \/\____/
|
13
|
+
* \/_/\/_/\/___/ \/__/ \/_/ \/___/\/_/\ \_\ \/___/
|
14
|
+
* \ \____/
|
15
|
+
* \/___/
|
16
|
+
*/
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* ______ __
|
3
|
+
* /\ _ \ /\ \__ __
|
4
|
+
* \ \ \L\ \ ____\ \ ,_\ _ __ ___ /\_\ ____
|
5
|
+
* \ \ __ \ /',__\ \ \/ /\`'__\/ __`\ \/\ \ /',__\
|
6
|
+
* \ \ \/\ \/\__, `\ \ \_\ \ \//\ \L\ \__ \ \ \/\__, `\
|
7
|
+
* \ \_\ \_\/\____/ \ \__\ \_\ \____/\_\_\ \ \/\____/
|
8
|
+
* \/_/\/_/\/___/ \/__/ \/_/ \/___/\/_/\ \_\ \/___/
|
9
|
+
* \ \____/
|
10
|
+
* \/___/
|
11
|
+
*/
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/* foo.css */
|
2
|
+
/**
|
3
|
+
* ______ __
|
4
|
+
* /\ _ \ /\ \__ __
|
5
|
+
* \ \ \L\ \ ____\ \ ,_\ _ __ ___ /\_\ ____
|
6
|
+
* \ \ __ \ /',__\ \ \/ /\`'__\/ __`\ \/\ \ /',__\
|
7
|
+
* \ \ \/\ \/\__, `\ \ \_\ \ \//\ \L\ \__ \ \ \/\__, `\
|
8
|
+
* \ \_\ \_\/\____/ \ \__\ \_\ \____/\_\_\ \ \/\____/
|
9
|
+
* \/_/\/_/\/___/ \/__/ \/_/ \/___/\/_/\ \_\ \/___/
|
10
|
+
* \ \____/
|
11
|
+
* \/___/
|
12
|
+
*/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.4.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sinatra-contrib
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.4.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: sprockets
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +130,7 @@ dependencies:
|
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
133
|
+
version: 0.4.0
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +138,7 @@ dependencies:
|
|
122
138
|
requirements:
|
123
139
|
- - ~>
|
124
140
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
141
|
+
version: 0.4.0
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
143
|
name: uglifier
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +155,38 @@ dependencies:
|
|
139
155
|
- - ~>
|
140
156
|
- !ruby/object:Gem::Version
|
141
157
|
version: 2.1.1
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: awesome_print
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.1.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.1.0
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: sass
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ~>
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 3.2.9
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ~>
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 3.2.9
|
142
190
|
- !ruby/object:Gem::Dependency
|
143
191
|
name: guard-rspec
|
144
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,15 +240,19 @@ files:
|
|
192
240
|
- astro.gemspec
|
193
241
|
- config.ru
|
194
242
|
- lib/assets/javascripts/astro.js
|
243
|
+
- lib/assets/stylesheets/astro.css
|
195
244
|
- lib/astro.rb
|
196
245
|
- lib/astro/assets.rb
|
197
246
|
- lib/astro/middleware/query_string.rb
|
198
247
|
- lib/astro/middleware/sprockets.rb
|
199
248
|
- lib/astro/server.rb
|
200
249
|
- lib/astro/version.rb
|
201
|
-
- lib/astro/views/error.erb
|
250
|
+
- lib/astro/views/error.css.erb
|
251
|
+
- lib/astro/views/error.js.erb
|
202
252
|
- spec/assets/javascripts/bar.js
|
203
253
|
- spec/assets/javascripts/foo.js
|
254
|
+
- spec/assets/stylesheets/bar.css
|
255
|
+
- spec/assets/stylesheets/foo.css
|
204
256
|
- spec/astro/middleware/query_string_spec.rb
|
205
257
|
- spec/astro/middleware/sprockets_spec.rb
|
206
258
|
- spec/astro/server_spec.rb
|
@@ -212,6 +264,14 @@ files:
|
|
212
264
|
- spec/astro/server_spec/astro_server/javascripts/empty/headers.txt
|
213
265
|
- spec/astro/server_spec/astro_server/javascripts/foo/body.js
|
214
266
|
- spec/astro/server_spec/astro_server/javascripts/foo/headers.txt
|
267
|
+
- spec/astro/server_spec/astro_server/stylesheets/bar/body.css
|
268
|
+
- spec/astro/server_spec/astro_server/stylesheets/bar/headers.txt
|
269
|
+
- spec/astro/server_spec/astro_server/stylesheets/baz/body.css
|
270
|
+
- spec/astro/server_spec/astro_server/stylesheets/baz/headers.txt
|
271
|
+
- spec/astro/server_spec/astro_server/stylesheets/empty/body.css
|
272
|
+
- spec/astro/server_spec/astro_server/stylesheets/empty/headers.txt
|
273
|
+
- spec/astro/server_spec/astro_server/stylesheets/foo/body.css
|
274
|
+
- spec/astro/server_spec/astro_server/stylesheets/foo/headers.txt
|
215
275
|
- spec/spec_helper.rb
|
216
276
|
- spec/support/approvals.rb
|
217
277
|
- spec/support/pry.rb
|
@@ -243,6 +303,8 @@ summary: Your DIY asset distribution web service.
|
|
243
303
|
test_files:
|
244
304
|
- spec/assets/javascripts/bar.js
|
245
305
|
- spec/assets/javascripts/foo.js
|
306
|
+
- spec/assets/stylesheets/bar.css
|
307
|
+
- spec/assets/stylesheets/foo.css
|
246
308
|
- spec/astro/middleware/query_string_spec.rb
|
247
309
|
- spec/astro/middleware/sprockets_spec.rb
|
248
310
|
- spec/astro/server_spec.rb
|
@@ -254,6 +316,14 @@ test_files:
|
|
254
316
|
- spec/astro/server_spec/astro_server/javascripts/empty/headers.txt
|
255
317
|
- spec/astro/server_spec/astro_server/javascripts/foo/body.js
|
256
318
|
- spec/astro/server_spec/astro_server/javascripts/foo/headers.txt
|
319
|
+
- spec/astro/server_spec/astro_server/stylesheets/bar/body.css
|
320
|
+
- spec/astro/server_spec/astro_server/stylesheets/bar/headers.txt
|
321
|
+
- spec/astro/server_spec/astro_server/stylesheets/baz/body.css
|
322
|
+
- spec/astro/server_spec/astro_server/stylesheets/baz/headers.txt
|
323
|
+
- spec/astro/server_spec/astro_server/stylesheets/empty/body.css
|
324
|
+
- spec/astro/server_spec/astro_server/stylesheets/empty/headers.txt
|
325
|
+
- spec/astro/server_spec/astro_server/stylesheets/foo/body.css
|
326
|
+
- spec/astro/server_spec/astro_server/stylesheets/foo/headers.txt
|
257
327
|
- spec/spec_helper.rb
|
258
328
|
- spec/support/approvals.rb
|
259
329
|
- spec/support/pry.rb
|