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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69b7ef6036d3496e74700f2cf41b5a81f4a4121a
4
- data.tar.gz: a44c03cdcaeef64b60f2bd8d4284822d9f562d7e
3
+ metadata.gz: ff15b495554457834c9e15b3845f20dbf65ffe62
4
+ data.tar.gz: 33699d14a9332feb5182ac980ca03da60b0b2478
5
5
  SHA512:
6
- metadata.gz: a01bc693bfa897b445814430601206699f9b832a6a6f0cbdc6966e3c16d53139665a683ef25a104c00248f403f9ab8fd270e2696baaa42e49410a7418c35352f
7
- data.tar.gz: 8b3d30ec446df9d21aaece3ce7f38349bfc07d6e9f7309286e803b1458b4dc6d52a435992ac502f62b3aa688dba9525fcb009258d3217d131198cfc6849ff7fa
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
- return '<svg class="' + cssClass + '"><use xlink:href="#' + basename + '"></use></svg>';
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
- emberHelper: function(params, hash) {
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: "savagery-helpers",
36
-
37
- initialize: function(container, application) {
38
- application.register("helper:svg-sprite-use", Ember.Helper.helper(Savagery.emberHelper));
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
 
@@ -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 *args
11
- raw _svg_sprite_helper.svg_sprite_use(*args)
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
@@ -1,3 +1,3 @@
1
1
  module Savagery
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -25,12 +25,17 @@ describe Savagery::Helpers::Rails do
25
25
  end
26
26
 
27
27
  describe "#svg_sprite_use" do
28
- it "delegates to helpers" do
29
- subject.svg_sprite_use.should == "<svg_sprite_use />"
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.1
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: 2015-08-25 00:00:00.000000000 Z
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