fume-nav 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aba276c3a271855176f938a0b663078ace6992bb
4
- data.tar.gz: e0281343d40d77b8a512efc957726f70265a50fc
3
+ metadata.gz: 0c45ffe7e4c5812fe2a4927b7d808ac629eb77ee
4
+ data.tar.gz: 6cd9c66ed7c1eab12fdce55d45f01b34d159eb2d
5
5
  SHA512:
6
- metadata.gz: 44396e8065b4bb657c15d1513881c39f1ebd6773aca8cca339eabf6b36b5c376c71daee67c6e640f6b6828e8b6e80d981dbe9f42420c100115fde98f1e9dc64e
7
- data.tar.gz: b81df80c8103299acc58ecffa2ef26528eb056894455e0969b50290cd513f0338b6b3ecdecbf9024a006a17d4522ca9f275094513764e522e41d2140042331a8
6
+ metadata.gz: db5506d36fb10b07af80eb7ff98e89d6031ed89ca1a769e472e1ffd3ca938c645ee9025040e392c2a48d12e1c2e7a743f69728f67262f8c7568f936ab16835b0
7
+ data.tar.gz: 57fbd2557badcbfc3c81317284b13db85e6438470e2799951d4e29ce24f195f7d39912153ce5ef825ed27ea7affb9287ebfac99d9072390c59c1610a6ed74123
data/README.md CHANGED
@@ -35,8 +35,8 @@ view.erb
35
35
  <%= fume_nav @current do |n| %>
36
36
  <div class="dropdown">
37
37
  <%= n.link_to :show, "link_1", root_path, class: "link" %>
38
- <%= n.apply :edit do |cls| %>
39
- <%= link_to "link_2", root_path, class: "link #{cls}" %>
38
+ <%= n.apply_content :edit do |active_class| %>
39
+ <%= link_to "link_2", root_path, class: "link #{active_class || 'default'}" %>
40
40
  <% end %>
41
41
  </div>
42
42
  <% end %>
@@ -38,11 +38,10 @@ module Fume
38
38
  end
39
39
  end
40
40
 
41
+ @empty = false
41
42
  end
42
43
 
43
44
  def apply(value, &block)
44
- @empty = false
45
-
46
45
  result = case value
47
46
  when Regexp
48
47
  value.match(current)
@@ -50,8 +49,15 @@ module Fume
50
49
  value.to_s == current.to_s
51
50
  end
52
51
 
53
- block.call(active_class) if result && block
54
- result
52
+ block.call(result ? active_class : nil)
53
+ end
54
+
55
+ def apply_content(value, &block)
56
+ @empty = false
57
+
58
+ apply(value) do |cls|
59
+ helper.capture(cls, &block)
60
+ end
55
61
  end
56
62
  end
57
63
  end
@@ -1,5 +1,5 @@
1
1
  module Fume
2
2
  module Nav
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -29,4 +29,17 @@ RSpec.describe Fume::Nav::NavTag do
29
29
  before { expect(context).to receive(:link_to).with("TEXT", [:root], hash_excluding(class: "active")) }
30
30
  it { subject.link_to :foo, "TEXT", [:root] }
31
31
  end
32
+
33
+ describe "#apply_content" do
34
+ context "then match" do
35
+ let(:current) { :foo }
36
+ before { expect(context).to receive(:capture).with("active") }
37
+ it { subject.apply_content(:foo) { |cls| } }
38
+ end
39
+
40
+ context "then not match" do
41
+ before { expect(context).to receive(:capture).with(nil) }
42
+ it { subject.apply_content(:foo) { |cls| } }
43
+ end
44
+ end
32
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fume-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sunteya