savagery 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/savagery/ember.js +22 -7
- data/lib/savagery/helpers.rb +1 -1
- data/lib/savagery/helpers/rails.rb +3 -2
- data/lib/savagery/version.rb +1 -1
- data/spec/helpers/rails_spec.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff15b495554457834c9e15b3845f20dbf65ffe62
|
4
|
+
data.tar.gz: 33699d14a9332feb5182ac980ca03da60b0b2478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe64ee9325fdf0f87640eef19f82ee490946b78097df2fb1f7882ed83f999e3a4f5db7b4231c4da59100f8c1375ebb512c9b493fad9d7e56ef7a5a1a308c5da
|
7
|
+
data.tar.gz: 7c2473e8efd8721d888070b094b6909026a5aad79c4e4f46b849d58ba7a576ffc9a7ab6c45f82851bb549c7614a2ea1576dc186d402eb281706d3fc71db87248
|
@@ -13,12 +13,23 @@ Savagery = {
|
|
13
13
|
|
14
14
|
svgSpriteUse: function(basename, cssClass) {
|
15
15
|
cssClass = cssClass || basename;
|
16
|
-
|
16
|
+
var absolutePath = window.location.href
|
17
|
+
absolutePath = absolutePath.replace(window.location.hash, '');
|
18
|
+
absolutePath = absolutePath + "#" + basename;
|
19
|
+
return '<svg class="' + cssClass + '"><use xlink:href="' + absolutePath + '"></use></svg>';
|
17
20
|
},
|
18
21
|
|
19
22
|
_svgSpritesIncluded: {},
|
23
|
+
};
|
24
|
+
|
25
|
+
Ember.Application.initializer({
|
26
|
+
name: "savagery-helpers",
|
27
|
+
|
28
|
+
initialize: function(application) {
|
29
|
+
application.register("helper:svg-sprite-use", Ember.Helper.helper(this.svgSpriteUseHelper));
|
30
|
+
},
|
20
31
|
|
21
|
-
|
32
|
+
svgSpriteUseHelper: function(params, hash) {
|
22
33
|
var name = params[0];
|
23
34
|
var names = name.split("/");
|
24
35
|
var dirname = names[0];
|
@@ -29,13 +40,17 @@ Savagery = {
|
|
29
40
|
var html = Savagery.svgSpriteUse(basename, cssClass);
|
30
41
|
return new Ember.Handlebars.SafeString(html);
|
31
42
|
}
|
32
|
-
};
|
43
|
+
});
|
33
44
|
|
34
45
|
Ember.Application.initializer({
|
35
|
-
name: "
|
36
|
-
|
37
|
-
initialize: function(
|
38
|
-
application.register("helper:
|
46
|
+
name: "ember-rails-assets-helpers",
|
47
|
+
|
48
|
+
initialize: function(application) {
|
49
|
+
application.register("helper:asset-path", Ember.Helper.helper(function(params, hash) {
|
50
|
+
var name = params[0];
|
51
|
+
var path = window.ASSETS.path(name);
|
52
|
+
return new Ember.Handlebars.SafeString(path);
|
53
|
+
}));
|
39
54
|
}
|
40
55
|
});
|
41
56
|
|
data/lib/savagery/helpers.rb
CHANGED
@@ -10,7 +10,7 @@ module Savagery
|
|
10
10
|
def svg_sprite_use name, options={}
|
11
11
|
dirname, basename = name.split("/")
|
12
12
|
sprite = svg_sprite_include(dirname) unless svg_sprites_included.include?(dirname)
|
13
|
-
use = %(<svg class="#{options[:class] || basename}"><use xlink:href="##{basename}"></use></svg>)
|
13
|
+
use = %(<svg class="#{options[:class] || basename}"><use xlink:href="#{options[:current_url]}##{basename}"></use></svg>)
|
14
14
|
[sprite, use].join
|
15
15
|
end
|
16
16
|
|
@@ -7,8 +7,9 @@ module Savagery
|
|
7
7
|
raw _svg_sprite_helper.svg_sprite_include(*args)
|
8
8
|
end
|
9
9
|
|
10
|
-
def svg_sprite_use
|
11
|
-
|
10
|
+
def svg_sprite_use name, options={}
|
11
|
+
options[:current_url] = request.path
|
12
|
+
raw _svg_sprite_helper.svg_sprite_use(name, options)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
data/lib/savagery/version.rb
CHANGED
data/spec/helpers/rails_spec.rb
CHANGED
@@ -25,12 +25,17 @@ describe Savagery::Helpers::Rails do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "#svg_sprite_use" do
|
28
|
-
|
29
|
-
|
28
|
+
let(:request) { double(path: "/omg/wtf") }
|
29
|
+
|
30
|
+
before { subject.stub(request: request) }
|
31
|
+
|
32
|
+
it "delegates to helpers with current_url set to request.path" do
|
33
|
+
helpers.should_receive(:svg_sprite_use).with("test", current_url: "/omg/wtf")
|
34
|
+
subject.svg_sprite_use("test").should == "<svg_sprite_use />"
|
30
35
|
end
|
31
36
|
|
32
37
|
it "is marked as safe to embed" do
|
33
|
-
subject.svg_sprite_use.should be_html_safe
|
38
|
+
subject.svg_sprite_use(double).should be_html_safe
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savagery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ember-rails-assets
|