fume-nav 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d682e1939e12111f75a2e9b2dc8b1095efcb9c1f
4
+ data.tar.gz: 14bbeb60222dd15f059fb441e167c478bf427240
5
+ SHA512:
6
+ metadata.gz: ce1b72c25593b1ff323a223e643d16ce8e376cb7db1602cec1eb11df82ac89cb4761479b37afea1f98dbc23d970b00b820b3d920e721c8e90a95539787f32408
7
+ data.tar.gz: e0d8619f9bd4cffa282506c1a595398d09f18615fed705ce278350b7d838e265d5eacf906454e54359f3bbef9612c8e74480ff7cd05c189c62686336139b5af1
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ coverage
3
+ pkg/*
4
+ tmp/*
5
+ gem_graph.png
6
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fume.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 sunteya
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Fume::Nav
2
+
3
+ help build navigation for rails.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fume-nav'
10
+
11
+ ## Usage
12
+
13
+ ### example
14
+
15
+ view.erb
16
+
17
+ ~~~~ erb
18
+ <% @current = :edit %>
19
+ <%= fume_nav @current do |n| %>
20
+ <ul>
21
+ <%= n.li_tag :show do %>
22
+ <%= link_to 'show', link_path(@link) %>
23
+ <% end %>
24
+ <%= n.li_tag :edit do %>
25
+ <%= link_to 'edit', edit_link_path(@link) %>
26
+ <% end %>
27
+ </ul>
28
+ <% end %>
29
+ ~~~~
30
+
31
+ output:
32
+
33
+ ~~~~ html
34
+ <ul>
35
+ <li>
36
+ <a href="/links/1">show</a>
37
+ </li>
38
+ <li class="active">
39
+ <a href="/links/1/edit">edit</a>
40
+ </li>
41
+ </ul>
42
+ ~~~~
43
+
44
+ ### Options
45
+
46
+ ~~~ erb
47
+ <%= fume_nav(current_value, options) do |n| %>
48
+ // OOXX
49
+ <% end %>
50
+ ~~~
51
+
52
+ OPTIONS:
53
+ <table>
54
+ <tr>
55
+ <td>active_class</td><td>the current active item class, default: 'active'</td>
56
+ </tr>
57
+ <tr>
58
+ <td>hide_if_empty</td><td>don't output content html if not exist any subitem, default: true</td>
59
+ </tr>
60
+ </table>
61
+
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/version_task'
4
+ Rake::VersionTask.new
5
+
6
+
7
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/fume-nav.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fume-nav"
7
+ spec.version = File.read(File.expand_path("../VERSION", __FILE__)).chomp
8
+ spec.authors = ["sunteya"]
9
+ spec.email = ["sunteya@gmail.com"]
10
+ spec.description = %q{help build navigation for rails.}
11
+ spec.summary = %q{help build navigation for rails.}
12
+ spec.homepage = "https://github.com/sunteya/fume-nav"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "railties"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "version"
25
+ end
@@ -0,0 +1,53 @@
1
+ require "hashie"
2
+
3
+ module Fume
4
+ module Nav
5
+ module HelperExtensions
6
+ def fume_nav(*args, &block)
7
+ attributes = {
8
+ active_class: "active",
9
+ hide_if_empty: true
10
+ }.merge(args.extract_options!)
11
+
12
+ attributes[:current] = args.shift
13
+ attributes[:helper] = self
14
+ tag = NavTag.new(attributes)
15
+ content = capture(tag, &block)
16
+
17
+ return content if !tag.hide?
18
+ end
19
+
20
+ class NavTag
21
+ attr_accessor :helper, :current, :active_class, :hide_if_empty
22
+
23
+ def initialize(attributes = {})
24
+ attributes.each_pair do |name, value|
25
+ send("#{name}=", value)
26
+ end
27
+ @empty = true
28
+ end
29
+
30
+ def hide?
31
+ hide_if_empty && @empty
32
+ end
33
+
34
+ def li_tag(value, options = {}, &block)
35
+ self.content_tag(value, :li, options, &block)
36
+ end
37
+
38
+ def content_tag(value, tag_name, options = {}, &block)
39
+ if value == current
40
+ if options[:class]
41
+ options[:class] += " #{active_class}"
42
+ else
43
+ options[:class] = "#{active_class}"
44
+ end
45
+ end
46
+
47
+ @empty = false
48
+ helper.content_tag(tag_name, options, &block)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ require "rails/railtie"
2
+
3
+ module Fume
4
+ module Nav
5
+ class Railtie < ::Rails::Railtie
6
+ initializer 'fume.initialize', :after => :after_initialize do |app|
7
+ ::ActionView::Base.send :include, HelperExtensions
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/fume/nav.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.expand_path("../nav/helper_ext", __FILE__)
2
+ require File.expand_path("../nav/railtie", __FILE__)
data/lib/fume-nav.rb ADDED
@@ -0,0 +1 @@
1
+ require File.expand_path("../fume/nav", __FILE__)
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fume-nav
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - sunteya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: version
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: help build navigation for rails.
70
+ email:
71
+ - sunteya@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - VERSION
82
+ - fume-nav.gemspec
83
+ - lib/fume-nav.rb
84
+ - lib/fume/nav.rb
85
+ - lib/fume/nav/helper_ext.rb
86
+ - lib/fume/nav/railtie.rb
87
+ homepage: https://github.com/sunteya/fume-nav
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: help build navigation for rails.
111
+ test_files: []