trap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6dfb4d5ec281807111853d256b36096b66f6a808
4
+ data.tar.gz: ea9c65def6b9ca4ad393c4c6a46bfab2f9c6c908
5
+ SHA512:
6
+ metadata.gz: 794d4945079544069965bbf87969375bdd7c1e436d490afe36c32c4ad61cbd16268d636c900273d9b037e41165d1f64872d20227735d407cd1cb76513a6bd784
7
+ data.tar.gz: c05cdc376a26cb0e63654fc227b6c557d761c3cf695afb59298754852789aec20532295bbbe6debd9982c1ab443320d580adcdddca42b26bfbb5488bafdc54dd
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trap.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Pavel Kalashnikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Trap
2
+
3
+ Bootstrap helpers
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'trap'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install trap
20
+
21
+ ## Usage
22
+
23
+ After installing you should add line to *application_helper.rb*
24
+
25
+ ```ruby
26
+ module ApplicationHelper
27
+ include Trap
28
+ end
29
+ ```
30
+
31
+ List of methods you can use with Trap:
32
+
33
+ * menu_item
34
+ Bootstrap navbar item
35
+
36
+ ```erb
37
+ <%= menu_item 'ButtonText', 'ButtonLink', class: 'some-classes', another_option: :value %>
38
+ ```
39
+
40
+ Using `menu_item` instead of
41
+
42
+ ```
43
+ <li>
44
+ <a href="ButtonLink">
45
+ ButtonText
46
+ </a>
47
+ </li>
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/[my-github-username]/trap/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trap"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/trap.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'trap/version'
2
+ require 'trap/helpers/bootstrap_helper'
3
+
4
+ module Trap
5
+ include BootstrapHelper
6
+ end
@@ -0,0 +1,37 @@
1
+ module BootstrapHelper
2
+ def menu_item(name = nil, path = '#', *args, &block)
3
+ path = name || path if block_given?
4
+ options = args.extract_options!
5
+ content_tag :li, class: is_active?(path, options) do
6
+ name, path = path, options if block_given?
7
+ link_to name, path, options, &block
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def is_active?(path, options = {})
14
+ :active if uri_state(path, options).in? [:active, :chosen]
15
+ end
16
+
17
+ def uri_state(uri, options = {})
18
+ root_url = request.host_with_port + '/'
19
+ root = uri == '/' || uri == root_url
20
+ request_uri = if uri.start_with? root_url
21
+ request.url
22
+ else
23
+ request.path
24
+ end
25
+ if !options[:method].nil? || !options["data-method"].nil?
26
+ :inactive
27
+ elsif uri == request_uri || (options[:root] && (request_uri == '/') || (request_uri == root_url))
28
+ :active
29
+ else
30
+ if request_uri.start_with?(uri) and not(root)
31
+ :chosen
32
+ else
33
+ :inactive
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Trap
2
+ VERSION = "0.0.1"
3
+ end
data/trap.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trap/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'trap'
8
+ spec.version = Trap::VERSION
9
+ spec.authors = ['Pavel Kalashnikov']
10
+ spec.email = ['kalashnikovisme@gmail.com']
11
+
12
+ spec.summary = %q{Bootstrap helpers}
13
+ spec.description = %q{Bootstrap helpers}
14
+ spec.homepage = 'https://github.com/kalashnikovisme/trap'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib', 'app']
21
+
22
+ spec.add_development_dependency 'bundler', '>= 1.8'
23
+ spec.add_development_dependency 'rake', '>= 10.0'
24
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Kalashnikov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-12 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.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
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: Bootstrap helpers
42
+ email:
43
+ - kalashnikovisme@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/trap.rb
58
+ - lib/trap/helpers/bootstrap_helper.rb
59
+ - lib/trap/version.rb
60
+ - trap.gemspec
61
+ homepage: https://github.com/kalashnikovisme/trap
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ - app
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Bootstrap helpers
86
+ test_files: []