fume-nav 0.0.3 → 0.1.0

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: 905bb9b15d89dff0a4094c794b3feb81e4f77f07
4
- data.tar.gz: 94672d65dd227cf69054690ec5d257493ea59d0b
3
+ metadata.gz: 9673016d7ce66521de73be340874b04a36c79cab
4
+ data.tar.gz: edb83bfbe56e7b9d3b5468ef765ad50dae5b4aac
5
5
  SHA512:
6
- metadata.gz: 5aee52aec3cf7db83e916aed9791e939bf1d96b7d7baedf6efcc49926d6401e27af4ccdad74ca4cd646f62d2408f2dbd42810e9fb6a711292d6ffd03fda3785d
7
- data.tar.gz: 9d29a5f19606d2d8fc18121a7348d5cc9b1ca215919de1ef4ce4177be543b1caae11cc3feeac99c6656d5a59a0ca85e80887204374b4ec4cb5f26410d3cde66d
6
+ metadata.gz: d1f328118997150f97cc1586794b40ba3b47b8493d35886fbc8a15ae1105f2501129056dffecd9a0ed3b7aab0b6089044e6708e2fd260cfba2041e762d7fe7b2
7
+ data.tar.gz: 87f157b31b56338d2e52345d45e9a5fc2ce427e43c469e9f2781c6d98040490f215d35f1f76da270219e4c35b5e741688a7757b977309638094fd9dd21c524bf
@@ -1,11 +1,13 @@
1
1
  script: "bundle exec rake spec"
2
2
  rvm:
3
- - 2.1.0
4
- - 2.0.0
3
+ - 2.4
4
+ - 2.3
5
+ - 2.2
5
6
 
6
7
  gemfile:
7
8
  - Gemfile
8
- - gemfiles/rails3_2.gemfile
9
+ - gemfiles/rails4_2.gemfile
10
+ - gemfiles/rails5_0.gemfile
9
11
 
10
12
  before_install:
11
- - gem install bundler
13
+ - gem install bundler
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rails", "~> 4.0"
3
+ gem "rails", "~> 5.1.1"
4
4
 
5
5
  # Specify your gem's dependencies in fume-nav.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -19,49 +19,63 @@ gem 'fume-nav'
19
19
 
20
20
  view.erb
21
21
 
22
- ~~~~ erb
22
+ ```rb
23
23
  <% @current = :edit %>
24
24
  <%= fume_nav @current do |n| %>
25
25
  <ul>
26
- <%= n.li_tag :show do %>
27
- <%= link_to 'show', link_path(@link) %>
28
- <% end %>
29
- <%= n.li_tag :edit do %>
30
- <%= link_to 'edit', edit_link_path(@link) %>
31
- <% end %>
26
+ <%= n.li_tag :show do %>
27
+ <%= link_to 'show', link_path(@link) %>
28
+ <% end %>
29
+ <%= n.li_tag :edit do %>
30
+ <%= link_to 'edit', edit_link_path(@link) %>
31
+ <% end %>
32
32
  </ul>
33
33
  <% end %>
34
- ~~~~
34
+
35
+ <%= fume_nav @current do |n| %>
36
+ <div class="dropdown">
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}" %>
40
+ <% end %>
41
+ </div>
42
+ <% end %>
43
+ ```
35
44
 
36
45
  output:
37
46
 
38
- ~~~~ html
47
+ ```html
39
48
  <ul>
40
- <li>
41
- <a href="/links/1">show</a>
42
- </li>
43
- <li class="active">
44
- <a href="/links/1/edit">edit</a>
45
- </li>
49
+ <li>
50
+ <a href="/links/1">show</a>
51
+ </li>
52
+ <li class="active">
53
+ <a href="/links/1/edit">edit</a>
54
+ </li>
46
55
  </ul>
47
- ~~~~
56
+
57
+ <div class="dropdown">
58
+ <a class="link active" href="/">link_1</a>
59
+ <a class="link " href="/">link_2</a>
60
+ </div>
61
+ ```
48
62
 
49
63
  ### Options
50
64
 
51
- ~~~ erb
65
+ ```erb
52
66
  <%= fume_nav(current_value, options) do |n| %>
53
- // OOXX
67
+ // OOXX
54
68
  <% end %>
55
- ~~~
69
+ ```
56
70
 
57
71
  OPTIONS:
58
72
  <table>
59
- <tr>
60
- <td>active_class</td><td>the current active item class, default: 'active'</td>
61
- </tr>
62
- <tr>
63
- <td>hide_if_empty</td><td>don't output content html if not exist any subitem, default: true</td>
64
- </tr>
73
+ <tr>
74
+ <td>active_class</td><td>the current active item class, default: 'active'</td>
75
+ </tr>
76
+ <tr>
77
+ <td>hide_if_empty</td><td>don't output content html if not exist any subitem, default: true</td>
78
+ </tr>
65
79
  </table>
66
80
 
67
81
 
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "rails"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
25
 
26
- spec.add_development_dependency "rspec", "~> 3.1.0"
26
+ spec.add_development_dependency "rspec", "~> 3.6.0"
27
27
  spec.add_development_dependency "pry-byebug"
28
28
  end
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rails", "~> 3.2.0"
3
+ gem "rails", "~> 4.2.8"
4
4
 
5
5
  # Specify your gem's dependencies in rspec-do_action.gemspec
6
6
  gemspec path: '..'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 5.0.3"
4
+
5
+ # Specify your gem's dependencies in rspec-do_action.gemspec
6
+ gemspec path: '..'
@@ -18,29 +18,40 @@ module Fume
18
18
  content_tag(value, :li, options, &block)
19
19
  end
20
20
 
21
+ def link_to(value, *args, &block)
22
+ options = args.extract_options!
23
+ apply_active_options(value, options)
24
+ helper.link_to(*args, options, &block)
25
+ end
26
+
21
27
  def content_tag(value, tag_name, options = {}, &block)
22
28
  apply_active_options(value, options)
23
29
  helper.content_tag(tag_name, options, &block)
24
30
  end
25
31
 
26
32
  def apply_active_options(value, options)
27
- match = case value
28
- when Regexp
29
- value.match(current)
30
- else
31
- value.to_s == current.to_s
32
- end
33
-
34
- if match
33
+ apply(value) do |cls|
35
34
  if options[:class]
36
- options[:class] += " #{active_class}"
35
+ options[:class] += " #{cls}"
37
36
  else
38
- options[:class] = "#{active_class}"
37
+ options[:class] = "#{cls}"
39
38
  end
40
39
  end
41
40
 
42
41
  @empty = false
43
42
  end
43
+
44
+ def apply(value, &block)
45
+ result = case value
46
+ when Regexp
47
+ value.match(current)
48
+ else
49
+ value.to_s == current.to_s
50
+ end
51
+
52
+ block.call(active_class) if result && block
53
+ result
54
+ end
44
55
  end
45
56
  end
46
57
  end
@@ -1,5 +1,5 @@
1
1
  module Fume
2
2
  module Nav
3
- VERSION = "0.0.3"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -24,4 +24,9 @@ RSpec.describe Fume::Nav::NavTag do
24
24
  it { subject.li_tag(:not_match) }
25
25
  end
26
26
  end
27
+
28
+ describe "#link_to" do
29
+ before { expect(context).to receive(:link_to).with("TEXT", [:root], hash_excluding(class: "active")) }
30
+ it { subject.link_to :foo, "TEXT", [:root] }
31
+ end
27
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fume-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sunteya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2017-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.1.0
61
+ version: 3.6.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.1.0
68
+ version: 3.6.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +95,8 @@ files:
95
95
  - README.md
96
96
  - Rakefile
97
97
  - fume-nav.gemspec
98
- - gemfiles/rails3_2.gemfile
98
+ - gemfiles/rails4_2.gemfile
99
+ - gemfiles/rails5_0.gemfile
99
100
  - lib/fume/nav.rb
100
101
  - lib/fume/nav/helper_ext.rb
101
102
  - lib/fume/nav/nav_tag.rb
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.5.2
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: help build navigation for rails.