sinatra-asset-snack 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/lib/sinatra/asset_snack/asset_snack.rb +13 -9
- data/lib/sinatra/asset_snack/version.rb +1 -1
- data/test/asset_snack_test.rb +9 -3
- data/test/compilers/coffee_script_compiler_test.rb +1 -3
- data/test/test_helper.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzY2NGVjNTU1NDAxOGY5N2FlYTllZmE2YWEwY2JiMzEyOTYxZTA3NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjI2ZjExZTdmMTRlYjlhMDQ2YmJkY2VkYzU0Mjc0ZTNiZTVkZGM4Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDJiNTNmOGE4NzI1NmM1NTEwNGU4ODA4MmZlMTA2NGIwNWUwOWNjYzI0NmRm
|
10
|
+
Y2M0MWU4Yjc0NmFlNThiZTg4MDZjZTQzNDA3MjQ1MTVjN2JjNDJjYWViMWNm
|
11
|
+
ODJkOWI2NDBiYTA3NzRjYTkxNWVhY2QzN2UwN2I1N2ExNTFkMWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDc3MjMzZWFkYzVjODY2NjM4NzRiNDg3MmU0N2JiMmUzN2M5ODdhZDIwNTU3
|
14
|
+
NGEzZTFmNTlmZjgwNDcxODFkNDRjOTQ5ZDE0ODgzYjFhMzhhNWE1YWVlMzE2
|
15
|
+
NmYzM2Y5NWEyNmUyOGEyNWZhY2VlMjM2NWI1Mzc3NDk1YTM1MDA=
|
data/Gemfile.lock
CHANGED
@@ -3,16 +3,14 @@ module Sinatra
|
|
3
3
|
class << self
|
4
4
|
attr_reader :compilers, :configuration
|
5
5
|
|
6
|
-
def registered(app)
|
6
|
+
def registered(app, &block)
|
7
|
+
@configuration = Configuration.new
|
8
|
+
|
7
9
|
app.extend ClassMethods
|
8
10
|
app.send(:include, InstanceMethods)
|
9
11
|
app.send(:helpers, Helpers)
|
10
12
|
end
|
11
13
|
|
12
|
-
def configure(&block)
|
13
|
-
@configuration = Configuration.new(&block)
|
14
|
-
end
|
15
|
-
|
16
14
|
def register_compiler(compiler, handled_extensions)
|
17
15
|
@compilers ||= {}
|
18
16
|
handled_extensions.each do |ext|
|
@@ -24,10 +22,16 @@ module Sinatra
|
|
24
22
|
ext = (File.extname(file_path) || '.').downcase[1..-1]
|
25
23
|
@compilers[ext.to_sym]
|
26
24
|
end
|
25
|
+
|
26
|
+
def assets
|
27
|
+
@assets ||= []
|
28
|
+
end
|
27
29
|
end # self
|
28
30
|
|
29
31
|
module ClassMethods
|
30
32
|
def asset_map(route, paths)
|
33
|
+
AssetSnack.assets << {route: route, paths: paths}
|
34
|
+
|
31
35
|
self.get route do
|
32
36
|
content = compile paths
|
33
37
|
[200, {'Content-Type' => content[:mime_type]}, content[:body]]
|
@@ -37,7 +41,7 @@ module Sinatra
|
|
37
41
|
|
38
42
|
module InstanceMethods
|
39
43
|
def compile(paths)
|
40
|
-
expand(paths).reduce({body: ''}) do |content, path|
|
44
|
+
expand(paths).reduce({body: '', mime_type: 'text/plain'}) do |content, path|
|
41
45
|
next unless File.exists?(path)
|
42
46
|
|
43
47
|
if compiler = AssetSnack.compiler_for(path)
|
@@ -48,7 +52,7 @@ module Sinatra
|
|
48
52
|
end
|
49
53
|
|
50
54
|
{
|
51
|
-
mime_type: content_type || content[:mime_type]
|
55
|
+
mime_type: content_type || content[:mime_type],
|
52
56
|
body: content[:body] + "\n\n/** #{File.basename path} **/\n\n" + compiled
|
53
57
|
}
|
54
58
|
end
|
@@ -57,6 +61,6 @@ module Sinatra
|
|
57
61
|
def expand(paths)
|
58
62
|
paths.reduce([]) { |file_list, path| file_list + Dir.glob(path) }.uniq
|
59
63
|
end
|
60
|
-
end #InstanceMethods
|
64
|
+
end # InstanceMethods
|
61
65
|
end # AssetSnack
|
62
|
-
end #Sinatra
|
66
|
+
end # Sinatra
|
data/test/asset_snack_test.rb
CHANGED
@@ -21,12 +21,18 @@ module Sinatra
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should allow compiler configuration' do
|
24
|
-
Sinatra::AssetSnack.
|
25
|
-
config.compilers[:coffee_script] = {bare: true}
|
26
|
-
end
|
24
|
+
Sinatra::AssetSnack.configuration.compilers[:coffee_script] = {bare: true}
|
27
25
|
|
28
26
|
get '/javascript/application.js'
|
29
27
|
last_response.body.wont_include ').call(this);'
|
30
28
|
end
|
29
|
+
|
30
|
+
it 'should remember each mapped asset' do
|
31
|
+
js_assets = {route: '/javascript/application.js', paths: ['test/fixtures/**/*.coffee']}
|
32
|
+
css_assets = {route: '/stylesheets/application.css', paths: ['test/fixtures/**/*.scss']}
|
33
|
+
|
34
|
+
Sinatra::AssetSnack.assets.must_include js_assets
|
35
|
+
Sinatra::AssetSnack.assets.must_include css_assets
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
data/test/test_helper.rb
CHANGED
@@ -9,10 +9,8 @@ require './lib/sinatra/asset_snack'
|
|
9
9
|
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
|
10
10
|
|
11
11
|
class App < Sinatra::Base
|
12
|
-
Sinatra::AssetSnack.configure do |config|
|
13
|
-
config.compilers[:coffee_script] = {bare: true}
|
14
|
-
end
|
15
12
|
register Sinatra::AssetSnack
|
13
|
+
|
16
14
|
asset_map '/javascript/application.js', ['test/fixtures/**/*.coffee']
|
17
15
|
asset_map '/stylesheets/application.css', ['test/fixtures/**/*.scss']
|
18
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-asset-snack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Kitzelman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|