rocket_navigation 0.1.0

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
+ SHA256:
3
+ metadata.gz: 4f7de06e21e62674df4c423c329342c9d1c63f92dee911fcb469d9fd3f7a2b25
4
+ data.tar.gz: aa5aceafad0baa1547a194fa03095c8f18c9919be527213de90aeb24ed34f4a5
5
+ SHA512:
6
+ metadata.gz: bbedadd16b9dac68463ff0066e5d84e05bc826d99762ff10c4e5808567a17ac7035282179c076ae97624687789b0ed0ccafe0cff1b04e726c7722d65ba5da75f
7
+ data.tar.gz: 0f5a529474cc0de5faad7bc64523e1243962a9218d8fad6ef61cc08e1e77e60ca246eed93373421f2f50807b979ed97624687ac9ca046bf936f34de28904ba18
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.5.0
5
+
6
+ notifications:
7
+ email: false
8
+
9
+ env:
10
+ global:
11
+ - CC_TEST_REPORTER_ID=f23ba257d0a12c588551991b4377e3eb218c1ff80050bc48c6b18c49ca16cb62
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
16
+ after_script:
17
+ - ./cc-test-reporter after-build --debug --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ Initial version based on simple-navigation
6
+
7
+
8
+ - Thread safety
9
+ - Supports only Rails, support for sinatra/paradino is removed.
10
+ - Defining navigation via magic eval-loaded config file is not available, use real code.
11
+ - Much simpler and more configurable at the same time.
12
+ - Add highlight by controller \ action
13
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at glebtv@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rocket_navigation.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,205 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rocket_navigation (0.1.0)
5
+ actionpack (>= 5.0)
6
+ actionview (>= 5.0)
7
+ activesupport (>= 5.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.1.5)
13
+ actionpack (= 5.1.5)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (~> 0.6.1)
16
+ actionmailer (5.1.5)
17
+ actionpack (= 5.1.5)
18
+ actionview (= 5.1.5)
19
+ activejob (= 5.1.5)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.1.5)
23
+ actionview (= 5.1.5)
24
+ activesupport (= 5.1.5)
25
+ rack (~> 2.0)
26
+ rack-test (>= 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.1.5)
30
+ activesupport (= 5.1.5)
31
+ builder (~> 3.1)
32
+ erubi (~> 1.4)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ activejob (5.1.5)
36
+ activesupport (= 5.1.5)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.1.5)
39
+ activesupport (= 5.1.5)
40
+ activerecord (5.1.5)
41
+ activemodel (= 5.1.5)
42
+ activesupport (= 5.1.5)
43
+ arel (~> 8.0)
44
+ activesupport (5.1.5)
45
+ concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ i18n (~> 0.7)
47
+ minitest (~> 5.1)
48
+ tzinfo (~> 1.1)
49
+ addressable (2.5.2)
50
+ public_suffix (>= 2.0.2, < 4.0)
51
+ arel (8.0.0)
52
+ builder (3.2.3)
53
+ capybara (2.18.0)
54
+ addressable
55
+ mini_mime (>= 0.1.3)
56
+ nokogiri (>= 1.3.3)
57
+ rack (>= 1.0.0)
58
+ rack-test (>= 0.5.4)
59
+ xpath (>= 2.0, < 4.0)
60
+ coderay (1.1.2)
61
+ concurrent-ruby (1.0.5)
62
+ crass (1.0.3)
63
+ diff-lcs (1.3)
64
+ docile (1.1.5)
65
+ erubi (1.7.1)
66
+ ffi (1.9.23)
67
+ formatador (0.2.5)
68
+ globalid (0.4.1)
69
+ activesupport (>= 4.2.0)
70
+ guard (2.14.2)
71
+ formatador (>= 0.2.4)
72
+ listen (>= 2.7, < 4.0)
73
+ lumberjack (>= 1.0.12, < 2.0)
74
+ nenv (~> 0.1)
75
+ notiffany (~> 0.0)
76
+ pry (>= 0.9.12)
77
+ shellany (~> 0.0)
78
+ thor (>= 0.18.1)
79
+ guard-compat (1.2.1)
80
+ guard-rspec (4.7.3)
81
+ guard (~> 2.1)
82
+ guard-compat (~> 1.1)
83
+ rspec (>= 2.99.0, < 4.0)
84
+ i18n (0.9.5)
85
+ concurrent-ruby (~> 1.0)
86
+ json (2.1.0)
87
+ listen (3.1.5)
88
+ rb-fsevent (~> 0.9, >= 0.9.4)
89
+ rb-inotify (~> 0.9, >= 0.9.7)
90
+ ruby_dep (~> 1.2)
91
+ loofah (2.2.0)
92
+ crass (~> 1.0.2)
93
+ nokogiri (>= 1.5.9)
94
+ lumberjack (1.0.12)
95
+ mail (2.7.0)
96
+ mini_mime (>= 0.1.1)
97
+ method_source (0.9.0)
98
+ mini_mime (1.0.0)
99
+ mini_portile2 (2.3.0)
100
+ minitest (5.11.3)
101
+ nenv (0.3.0)
102
+ nio4r (2.2.0)
103
+ nokogiri (1.8.2)
104
+ mini_portile2 (~> 2.3.0)
105
+ notiffany (0.1.1)
106
+ nenv (~> 0.1)
107
+ shellany (~> 0.0)
108
+ pry (0.11.3)
109
+ coderay (~> 1.1.0)
110
+ method_source (~> 0.9.0)
111
+ public_suffix (3.0.2)
112
+ rack (2.0.4)
113
+ rack-test (0.8.3)
114
+ rack (>= 1.0, < 3)
115
+ rails (5.1.5)
116
+ actioncable (= 5.1.5)
117
+ actionmailer (= 5.1.5)
118
+ actionpack (= 5.1.5)
119
+ actionview (= 5.1.5)
120
+ activejob (= 5.1.5)
121
+ activemodel (= 5.1.5)
122
+ activerecord (= 5.1.5)
123
+ activesupport (= 5.1.5)
124
+ bundler (>= 1.3.0)
125
+ railties (= 5.1.5)
126
+ sprockets-rails (>= 2.0.0)
127
+ rails-dom-testing (2.0.3)
128
+ activesupport (>= 4.2.0)
129
+ nokogiri (>= 1.6)
130
+ rails-html-sanitizer (1.0.3)
131
+ loofah (~> 2.0)
132
+ railties (5.1.5)
133
+ actionpack (= 5.1.5)
134
+ activesupport (= 5.1.5)
135
+ method_source
136
+ rake (>= 0.8.7)
137
+ thor (>= 0.18.1, < 2.0)
138
+ rake (12.3.0)
139
+ rb-fsevent (0.10.3)
140
+ rb-inotify (0.9.10)
141
+ ffi (>= 0.5.0, < 2)
142
+ rdoc (6.0.1)
143
+ rspec (3.7.0)
144
+ rspec-core (~> 3.7.0)
145
+ rspec-expectations (~> 3.7.0)
146
+ rspec-mocks (~> 3.7.0)
147
+ rspec-core (3.7.1)
148
+ rspec-support (~> 3.7.0)
149
+ rspec-expectations (3.7.0)
150
+ diff-lcs (>= 1.2.0, < 2.0)
151
+ rspec-support (~> 3.7.0)
152
+ rspec-mocks (3.7.0)
153
+ diff-lcs (>= 1.2.0, < 2.0)
154
+ rspec-support (~> 3.7.0)
155
+ rspec-rails (3.7.2)
156
+ actionpack (>= 3.0)
157
+ activesupport (>= 3.0)
158
+ railties (>= 3.0)
159
+ rspec-core (~> 3.7.0)
160
+ rspec-expectations (~> 3.7.0)
161
+ rspec-mocks (~> 3.7.0)
162
+ rspec-support (~> 3.7.0)
163
+ rspec-support (3.7.1)
164
+ ruby_dep (1.5.0)
165
+ shellany (0.0.1)
166
+ simplecov (0.15.1)
167
+ docile (~> 1.1.0)
168
+ json (>= 1.8, < 3)
169
+ simplecov-html (~> 0.10.0)
170
+ simplecov-html (0.10.2)
171
+ sprockets (3.7.1)
172
+ concurrent-ruby (~> 1.0)
173
+ rack (> 1, < 3)
174
+ sprockets-rails (3.2.1)
175
+ actionpack (>= 4.0)
176
+ activesupport (>= 4.0)
177
+ sprockets (>= 3.0.0)
178
+ thor (0.20.0)
179
+ thread_safe (0.3.6)
180
+ tzinfo (1.2.5)
181
+ thread_safe (~> 0.1)
182
+ websocket-driver (0.6.5)
183
+ websocket-extensions (>= 0.1.0)
184
+ websocket-extensions (0.1.3)
185
+ xpath (3.0.0)
186
+ nokogiri (~> 1.8)
187
+
188
+ PLATFORMS
189
+ ruby
190
+
191
+ DEPENDENCIES
192
+ bundler (~> 1.16)
193
+ capybara
194
+ guard-rspec (~> 4.2)
195
+ rails
196
+ rake (~> 12.0)
197
+ rdoc
198
+ rocket_navigation!
199
+ rspec (~> 3.0)
200
+ rspec-rails
201
+ simplecov
202
+ tzinfo
203
+
204
+ BUNDLED WITH
205
+ 1.16.1
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ guard :rspec, all_after_pass: true, failed_mode: :none do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch(%r{^spec/fake_app/.+\.rb$}) { 'spec/integration' }
5
+
6
+ watch('spec/spec_helper.rb') { 'spec' }
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Gleb Tv
4
+ Copyright (c) 2017 codeplant GmbH
5
+ Copyright (c) 2009-17 Oleg Khabarov
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # RocketNavigation
2
+
3
+ [![Build Status](https://travis-ci.org/rs-pro/rocket_navigation.svg?branch=master)](https://travis-ci.org/rs-pro/rocket_navigation)
4
+
5
+ # WORK IN PROGRESS
6
+ # Currently alpha qualiy, use at your own risk.
7
+
8
+ This gem is heavily inspired by (and uses some code from) [simple-navigation](https://github.com/codeplant/simple-navigation) but it is NOT a drop-in replacement.
9
+
10
+ Changes include:
11
+
12
+ 1. Simple with no dark magic involved
13
+ 2. Thread safe with no mutexes. (simple_navigation's render_navigation can render incomplete navs and not render any items at all under multithread load due to app-global config, which is used internally even if proc or items passed)
14
+ 3. Supports only Rails, support for sinatra/paradino is removed.
15
+ 4. Defining navigation via magic eval-loaded config file is not available, use real code.
16
+ 5. Much simpler and more configurable at the same time.
17
+ 6. Add many additional highlight options from [active_link_to](https://github.com/comfy/active_link_to) gem
18
+ 7. Add ability to set CSS classes and container DOM attributes on render
19
+ 8. ID autogeneration is removed
20
+ 9. Rewritten to use and allow helpers in renderers and to use ActiveSupport::SafeBuffer everywhere in renderers
21
+ 10. All css classes are managed in renderers and can be easily overriden from them
22
+ 11. Added [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails) integration
23
+ 12. expand_all defaults to true, as pretty much all menus are js-based now.
24
+
25
+ ## Installation
26
+
27
+ Add this line to your application's Gemfile:
28
+
29
+ ```ruby
30
+ gem 'rocket_navigation'
31
+ ```
32
+
33
+ And then execute:
34
+
35
+ $ bundle
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install rocket_navigation
40
+
41
+ ## Usage
42
+
43
+ Basic usage is the same and complatible with simple_navigation - but only if you pass menu data as a proc or as items hash (config file not supported).
44
+
45
+ helper:
46
+ ```ruby
47
+ def navigation(kind = :main)
48
+ proc do |primary|
49
+ primary.item :home, 'Home', root_path do |sub_nav|
50
+ sub_nav.item(:people, 'People', people_path, highlights_on: [:people, :show]) do |person|
51
+ person.item :person, @person.try(:name), url_for(@person), highlights_on: /people\/[0-9]+/
52
+ person.item :new_person, 'New Person', new_person_path, highlights_on: /people\/new$/
53
+ end
54
+ end
55
+ end
56
+ end
57
+ ```
58
+
59
+ view:
60
+ ```slim
61
+ = render_navigation level: 1..2, &navigation(:main)
62
+ ```
63
+
64
+ ## More docs
65
+
66
+ Basic menu usage is the same as simple-navigation
67
+
68
+ See https://github.com/codeplant/simple-navigation/wiki/Dynamic-Navigation-Items
69
+
70
+ This gem aims to be a drop-in replacement for this mode, including custom renderer code and api.
71
+ Any incomatibility can be reported as a bug.
72
+
73
+ Most renderers should be compatible out of the box, or require minimal changes due to ActiveSupport::SafeBuffer usage instead of .html_safe.
74
+
75
+ ## Setting HTML attributes
76
+
77
+ on render:
78
+
79
+ ```ruby
80
+ # helper
81
+ def menu_options
82
+ {
83
+ container_html: {class: "nav"},
84
+ item_html: {
85
+ class: 'nav nav-item'
86
+ },
87
+ link_html: {
88
+ class: %w(link nav-link),
89
+ rel: "nofollow",
90
+ },
91
+ selected_class: {
92
+ leaf: "selected-leaf",
93
+ item: "selected-li",
94
+ link: "selected-a"
95
+ }
96
+ }
97
+ end
98
+ ```
99
+
100
+ view:
101
+ ```
102
+ = render_navigation menu_options, &navigation(:main)
103
+ = render_navigation no_default_classes: true, &navigation(:main)
104
+
105
+ ```
106
+
107
+ Same options could be defined on a container when defining menu:
108
+ ```ruby
109
+ def navigation(kind = :main)
110
+ proc do |primary|
111
+ primary.container_html = {class: "nav"}
112
+ primary.item_html = {class: 'nav-item'}
113
+ primary.link_html = {class: 'nav-link'}
114
+ primary.selected_class = {branch: "active-branch", item: "active", link: "active"}
115
+ primary.item :home, 'Home', root_path, item_html: {class: "other"}, link_html: {class: "other"}
116
+ primary.item :two, 'Two', root_path, item_html: {class: "more two"}, link_html: {class: "two", method: :post}
117
+ end
118
+ end
119
+ ```
120
+
121
+
122
+ HTML options priority - item, renderer, default
123
+
124
+ ## BreadcrumbsOnRails integration
125
+
126
+ Just render with a breadcrumbs_on_rails renderer.
127
+ Returns nothing, calls add_breadcrumb instead.
128
+ Should be called before ```= render_breadcrumbs```, i.e. in controller
129
+
130
+ ```
131
+ render_navigation renderer: :breadcrumbs_on_rails, &navigation(:main)
132
+ ```
133
+
134
+ ## Development
135
+
136
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
137
+
138
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
139
+
140
+ ## Contributing
141
+
142
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rs-pro/rocket_navigation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
143
+
144
+ ## License
145
+
146
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
147
+
148
+ Parts of code Copyright (c) 2017 codeplant GmbH - [MIT License](https://github.com/codeplant/simple-navigation/blob/master/LICENSE)
149
+
150
+ Uses code from [active_link_to](https://github.com/comfy/active_link_to) - Copyright (c) 2009-17 Oleg Khabarov - [MIT License](https://github.com/comfy/active_link_to/blob/master/LICENSE)
151
+
152
+ ## Code of Conduct
153
+
154
+ Everyone interacting in the RocketNavigation project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rs-pro/rocket_navigation/blob/master/CODE_OF_CONDUCT.md).