breadcrumb_key 0.1.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
+ SHA256:
3
+ metadata.gz: bef4969b9ceecd94de53667c3285c2e28430bbdbddc9f0a50dbe59d0f56d2d70
4
+ data.tar.gz: af07fd9e84b317661f7e31c8102f8da920c6e9e3503622c3c1505b44f03cac75
5
+ SHA512:
6
+ metadata.gz: 81457994b44bc28bf7d044c346324ee6c8362da952717b7d8cfb1fc74e5f795315d3c642b8403af148772a7e0c29384074266d372a231b64e73dd546b672ce94
7
+ data.tar.gz: 422f0c1e96a6e7fb0ee40010e0c90aa0a2a7620ffca35d16b7df2745df278a0e575f86f29ac8799cf30baaeb22dc85b501e5299b42f50715b46b7809fb831d1d
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-09-27
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in breadcrumb_key.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ breadcrumb_key (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ base64 (0.1.1)
11
+ diff-lcs (1.5.0)
12
+ json (2.6.3)
13
+ language_server-protocol (3.17.0.3)
14
+ parallel (1.23.0)
15
+ parser (3.2.2.3)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ racc (1.7.1)
19
+ rainbow (3.1.1)
20
+ rake (13.0.6)
21
+ regexp_parser (2.8.1)
22
+ rexml (3.2.6)
23
+ rspec (3.12.0)
24
+ rspec-core (~> 3.12.0)
25
+ rspec-expectations (~> 3.12.0)
26
+ rspec-mocks (~> 3.12.0)
27
+ rspec-core (3.12.2)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-expectations (3.12.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-mocks (3.12.6)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.12.0)
35
+ rspec-support (3.12.1)
36
+ rubocop (1.56.3)
37
+ base64 (~> 0.1.1)
38
+ json (~> 2.3)
39
+ language_server-protocol (>= 3.17.0)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.2.2.3)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.28.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.29.0)
49
+ parser (>= 3.2.1.0)
50
+ ruby-progressbar (1.13.0)
51
+ unicode-display_width (2.4.2)
52
+
53
+ PLATFORMS
54
+ x86_64-darwin-21
55
+ x86_64-linux
56
+
57
+ DEPENDENCIES
58
+ breadcrumb_key!
59
+ rake (~> 13.0)
60
+ rspec (~> 3.0)
61
+ rubocop (~> 1.21)
62
+
63
+ BUNDLED WITH
64
+ 2.3.25
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 yamitake
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,35 @@
1
+ # BreadcrumbKey
2
+
3
+ BreadcrumbKey is a gem that provides a straightforward way to generate consistent and standardized breadcrumb keys for Rails applications. It's optimized for seamless integration with breadcrumb generation libraries, especially Gretel.
4
+
5
+
6
+ ## Installation
7
+
8
+ Install the gem and add to the application's Gemfile by executing:
9
+
10
+ $ bundle add breadcrumb_key
11
+
12
+ If bundler is not being used to manage dependencies, install the gem by executing:
13
+
14
+ $ gem install breadcrumb_key
15
+
16
+ ## Usage
17
+
18
+ BreadcrumbKey works hand-in-hand with breadcrumb generation libraries, and while it's not exclusive to any particular library, it's optimized for a seamless experience with [Gretel](https://github.com/kzkn/gretel).
19
+
20
+ ```erb
21
+ <%# app/views/items/show.html.erb %>
22
+ <% breadcrumb breadcrumb_key, @item.name, item_path(@item) %>
23
+ ```
24
+
25
+ By using breadcrumb_key, you can automatically generate the appropriate breadcrumb key based on the controller and action name, reducing the potential for typos and inconsistency.
26
+
27
+ For a controller named items and an action named show, the breadcrumb_key would return items_show, which can be directly utilized with Gretel's breadcrumb definitions.
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yapr/breadcrumb_key.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/breadcrumb_key/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "breadcrumb_key"
7
+ spec.version = BreadcrumbKey::VERSION
8
+ spec.authors = ["yamitake"]
9
+ spec.email = ["take.yapr@gmail.com"]
10
+
11
+ spec.summary = "A gem for generating consistent breadcrumb keys in Rails applications."
12
+ spec.description = <<~DESC
13
+ BreadcrumbKey provides a straightforward way to generate consistent and
14
+ standardized breadcrumb keys for Rails applications. It's optimized for
15
+ smooth integration with breadcrumb generation libraries, especially Gretel.
16
+ By offering flexible configurations, it ensures breadcrumb management
17
+ is seamless and efficient.
18
+ DESC
19
+ spec.homepage = "https://github.com/yapr/breadcrumb_key"
20
+ spec.license = "MIT"
21
+ spec.required_ruby_version = ">= 2.6.0"
22
+
23
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
24
+
25
+ spec.metadata["homepage_uri"] = spec.homepage
26
+ spec.metadata["source_code_uri"] = spec.homepage
27
+ spec.metadata["changelog_uri"] = "https://github.com/yapr/breadcrumb_key/commits/main"
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(__dir__) do
32
+ `git ls-files -z`.split("\x0").reject do |f|
33
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
34
+ end
35
+ end
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ["lib"]
39
+
40
+ # Uncomment to register a new dependency of your gem
41
+ # spec.add_dependency "example-gem", "~> 1.0"
42
+
43
+ # For more information and examples about making a new gem, check out our
44
+ # guide at: https://bundler.io/guides/creating_gem.html
45
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # BreadcrumbKey module serves as a namespace for all related functionality.
4
+ module BreadcrumbKey
5
+ # The Helper module provides utility methods for generating breadcrumb keys
6
+ # based on the current controller and action.
7
+ module Helper
8
+ # Generates a key for breadcrumbs based on the normalized controller path
9
+ # and action name.
10
+ #
11
+ # @return [Symbol] the generated breadcrumb key
12
+ def breadcrumb_key
13
+ "#{normalized_controller_path}_#{normalized_action_name}".to_sym
14
+ end
15
+
16
+ private
17
+
18
+ # Converts the controller path to a format suitable for breadcrumb key generation.
19
+ # This primarily involves replacing slashes with underscores.
20
+ #
21
+ # @return [String] the normalized controller path
22
+ def normalized_controller_path
23
+ controller_path.tr("/", "_")
24
+ end
25
+
26
+ # Retrieves the action name in a format suitable for breadcrumb key generation.
27
+ # Specific actions like 'create' and 'update' are mapped to more general ones
28
+ # like 'new' and 'show' respectively.
29
+ #
30
+ # @return [String] the normalized action name
31
+ def normalized_action_name
32
+ case action_name
33
+ when "create"
34
+ "new"
35
+ when "update"
36
+ "show"
37
+ else
38
+ action_name
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "breadcrumb_key/helper"
4
+ require "rails"
5
+
6
+ module BreadcrumbKey
7
+ # Railtie integrates BreadcrumbKey::Helper with Rails' ActionView,
8
+ # based on the `BreadcrumbKey.auto_include_helpers` configuration.
9
+ class Railtie < Rails::Railtie
10
+ initializer "breadcrumb_key.view_helpers" do
11
+ ActiveSupport.on_load :action_view do
12
+ include BreadcrumbKey::Helper if BreadcrumbKey.auto_include_helpers?
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BreadcrumbKey
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "breadcrumb_key/version"
4
+ require "breadcrumb_key/railtie" if defined?(Rails)
5
+
6
+ # This module provides methods related to breadcrumb key generation.
7
+ module BreadcrumbKey
8
+ class << self
9
+ attr_accessor :auto_include_helpers
10
+
11
+ def auto_include_helpers?
12
+ auto_include_helpers
13
+ end
14
+ end
15
+
16
+ self.auto_include_helpers = true
17
+ end
@@ -0,0 +1,4 @@
1
+ module BreadcrumbKey
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: breadcrumb_key
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yamitake
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ BreadcrumbKey provides a straightforward way to generate consistent and
15
+ standardized breadcrumb keys for Rails applications. It's optimized for
16
+ smooth integration with breadcrumb generation libraries, especially Gretel.
17
+ By offering flexible configurations, it ensures breadcrumb management
18
+ is seamless and efficient.
19
+ email:
20
+ - take.yapr@gmail.com
21
+ executables: []
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - ".rspec"
26
+ - ".rubocop.yml"
27
+ - CHANGELOG.md
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - LICENSE.txt
31
+ - README.md
32
+ - Rakefile
33
+ - breadcrumb_key.gemspec
34
+ - lib/breadcrumb_key.rb
35
+ - lib/breadcrumb_key/helper.rb
36
+ - lib/breadcrumb_key/railtie.rb
37
+ - lib/breadcrumb_key/version.rb
38
+ - sig/breadcrumb_key.rbs
39
+ homepage: https://github.com/yapr/breadcrumb_key
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/yapr/breadcrumb_key
44
+ source_code_uri: https://github.com/yapr/breadcrumb_key
45
+ changelog_uri: https://github.com/yapr/breadcrumb_key/commits/main
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.3.7
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: A gem for generating consistent breadcrumb keys in Rails applications.
65
+ test_files: []