activenavbar 1.0.0

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: e4b4b1e577faf5b816cb7dba047e718b5181ee1b
4
+ data.tar.gz: 52c0e1219b172d00669e3cbe9125c7e84aa0f630
5
+ SHA512:
6
+ metadata.gz: 8bb585ec127613c384a1557a772555101e662cff0f97142c7a9dbce4c71e0a682f7aaa038b39b56273eda9b939ee6c9675b20a4c20e46f711f6645f86ca3e688
7
+ data.tar.gz: 0aaadac717ddc386f891bae11b2b31ff5bcced6e27bca9859a5fc9db39304541f104b8ed8fa8d73361cf3f67e29057ef810ce809fdaf539ee584e31a48efa858
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rvmrc ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 2.1.2@activenavbar" > .rvmrc
9
+ environment_id="ruby-2.1.2@activenavbar"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.25.14 (latest)" # 1.10.1 seems like a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
27
+ do
28
+ if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
29
+ then \. "${__hook}" || true
30
+ fi
31
+ done
32
+ unset __hook
33
+ if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
34
+ then
35
+ if [[ $- == *i* ]] # check for interactive shells
36
+ then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
37
+ " # show the user the ruby and gemset they are using in green
38
+ else printf "%b" "Using: $GEM_HOME
39
+ " # don't use colors in non-interactive shells
40
+ fi
41
+ fi
42
+ else
43
+ # If the environment file has not yet been created, use the RVM CLI to select.
44
+ rvm --create "$environment_id" || {
45
+ echo "Failed to create RVM environment '${environment_id}'."
46
+ return 1
47
+ }
48
+ fi
49
+
50
+ # If you use bundler, this might be useful to you:
51
+ # if [[ -s Gemfile ]] && {
52
+ # ! builtin command -v bundle >/dev/null ||
53
+ # builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
54
+ # }
55
+ # then
56
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
57
+ # gem install bundler
58
+ # fi
59
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
60
+ # then
61
+ # bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
62
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activenavbar.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bunlong
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,83 @@
1
+ # Activenavbar
2
+
3
+ active navbar is used to set the active navbar link, a navbar link becomes active when you click on it.
4
+
5
+
6
+ ## Installation
7
+
8
+ The simplest way to install is to use Bundler.
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'activenavbar'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install activenavbar
23
+
24
+ ## Method
25
+
26
+ navbar_link(label, path, active_class)
27
+
28
+ - label: the link label.
29
+ - path: the link path or controller path.
30
+ - active_class: the style sheet active class.
31
+
32
+ ## Usage
33
+
34
+ Assume we have home, post and category page, and have navbar for each page below:
35
+
36
+ %ul
37
+ %li
38
+ = link_to "Home", homes_path
39
+ %li
40
+ = link_to "Food", posts_path
41
+ %li
42
+ = link_to "Beverage", categories_path
43
+
44
+ Assume we have style sheet for navbar below:
45
+
46
+ ul {
47
+ list-style-type: none;
48
+ overflow: hidden;
49
+ }
50
+
51
+ li {
52
+ float: left;
53
+ }
54
+
55
+ .nav > li > a {
56
+ border-right: 1px solid #A80000;
57
+ padding: 5px;
58
+ color: #000;
59
+ }
60
+
61
+ .nav .active > a,
62
+ .nav .active > a:focus {
63
+ color: red;
64
+ }
65
+
66
+ Now we want a navbar link becomes active when we click on it:
67
+
68
+ %ul
69
+ = navbar_link "Home", homes_path, "active"
70
+ = navbar_link "Food", posts_path, "active"
71
+ = navbar_link "Beverage", categories_path, "active"
72
+
73
+ Well, Home link becomes active when we click on Home link.
74
+
75
+ HTML output:
76
+
77
+ <ul>
78
+ <li class="active"><a href="/homes">Home</a></li>
79
+ <li class=""><a href="/posts">Post</a></li>
80
+ <li class=""><a href="/categories">Category</a></li>
81
+ </ul>
82
+
83
+ Say hi to me @bunlongvan
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
Binary file
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'activenavbar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activenavbar"
8
+ spec.version = Activenavbar::VERSION
9
+ spec.authors = ["Bunlong"]
10
+ spec.email = ["bunlong.van@gmail.com"]
11
+ spec.summary = %q{active navbar is used to set the active menu link, a link becomes active when you click on it.}
12
+ spec.description = %q{active navbar is used to set the active menu link, a link becomes active when you click on it.}
13
+ spec.homepage = "https://github.com/Bunlong/activenavbar"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ module Activenavbar
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "activenavbar/version"
2
+
3
+ module Activenavbar
4
+ def navbar_link(label, path, active_class)
5
+ class_name = current_page?(path) ? active_class : ''
6
+ content_tag(:li, :class => class_name) { link_to label, path }
7
+ end
8
+ end
9
+
10
+ ActionView::Base.send :include, Activenavbar
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activenavbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bunlong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: active navbar is used to set the active menu link, a link becomes active
42
+ when you click on it.
43
+ email:
44
+ - bunlong.van@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rvmrc"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - activenavbar-0.0.1.gem
56
+ - activenavbar.gemspec
57
+ - gem-private_key.pem
58
+ - lib/activenavbar.rb
59
+ - lib/activenavbar/version.rb
60
+ homepage: https://github.com/Bunlong/activenavbar
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: active navbar is used to set the active menu link, a link becomes active
84
+ when you click on it.
85
+ test_files: []