pax_global_header00006660000000000000000000000064143134436110014512gustar00rootroot0000000000000052 comment=08871cb9d3d226043cc0bc25bb1c86f0fb8f8a4e snaky_hash-v2.0.1/000077500000000000000000000000001431344361100140305ustar00rootroot00000000000000snaky_hash-v2.0.1/.gitignore000066400000000000000000000001611431344361100160160ustar00rootroot00000000000000/.bundle/ /.yardoc /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ # rspec failure tracking .rspec_status snaky_hash-v2.0.1/.gitlab-ci.yml000066400000000000000000000015111431344361100164620ustar00rootroot00000000000000# You can override the included template(s) by including variable overrides # SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings # Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings # Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings # Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings # Note that environment variables can be set in several places # See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence stages: - test sast: stage: test include: - template: Security/SAST.gitlab-ci.yml snaky_hash-v2.0.1/.rspec000066400000000000000000000000651431344361100151460ustar00rootroot00000000000000--format documentation --color --require spec_helper snaky_hash-v2.0.1/.rubocop.yml000066400000000000000000000006701431344361100163050ustar00rootroot00000000000000inherit_from: .rubocop_todo.yml inherit_gem: rubocop-lts: rubocop-lts.yml require: - 'rubocop-performance' - 'rubocop-rake' - 'rubocop-rspec' - 'rubocop-thread_safety' AllCops: DisplayCopNames: true # Display the name of the failing cops Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes Style/StringLiteralsInInterpolation: Enabled: true EnforcedStyle: double_quotes Metrics/LineLength: Max: 120 snaky_hash-v2.0.1/.rubocop_todo.yml000066400000000000000000000033351431344361100173330ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config` # on 2022-09-23 18:38:21 -0500 using RuboCop version 0.68.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 Metrics/AbcSize: Max: 31 # Offense count: 2 # Configuration parameters: CountComments, ExcludedMethods. # ExcludedMethods: refine Metrics/BlockLength: Max: 94 # Offense count: 1 Metrics/CyclomaticComplexity: Max: 9 # Offense count: 25 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: Max: 414 # Offense count: 2 # Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: Max: 33 # Offense count: 1 # Configuration parameters: Prefixes. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - 'spec/shared_contexts/base_hash.rb' # Offense count: 1 RSpec/DescribeClass: Exclude: - 'spec/snaky_hash/bad_snake_spec.rb' # Offense count: 5 # Configuration parameters: Max. RSpec/ExampleLength: Exclude: - 'spec/shared_examples/a_snaked_hash.rb' # Offense count: 1 RSpec/LeakyConstantDeclaration: Exclude: - 'spec/snaky_hash/snake_spec.rb' # Offense count: 12 RSpec/MultipleExpectations: Max: 15 # Offense count: 5 Style/Documentation: Exclude: - '**/*.md' - '**/*.markdown' - 'lib/snaky_hash/snake.rb' - 'lib/snaky_hash/string_keyed.rb' - 'lib/snaky_hash/symbol_keyed.rb' - 'spec/snaky_hash/snake_spec.rb' snaky_hash-v2.0.1/.simplecov000066400000000000000000000017371431344361100160420ustar00rootroot00000000000000# frozen_string_literal: true # To get coverage # On Local, default (HTML) output, it just works, coverage is turned on: # bundle exec rspec spec # On Local, all output formats: # COVER_ALL=true bundle exec rspec spec # # On CI, all output formats, the ENV variables CI is always set, # and COVER_ALL, and CI_CODECOV, are set in the coverage.yml workflow only, # so coverage only runs in that workflow, and outputs all formats. # if RUN_COVERAGE SimpleCov.start do enable_coverage :branch primary_coverage :branch add_filter "spec" add_filter "lib/snaky_hash/version.rb" track_files "**/*.rb" if ALL_FORMATTERS command_name "#{ENV.fetch("GITHUB_WORKFLOW", nil)} Job #{ENV.fetch("GITHUB_RUN_ID", nil)}:#{ENV.fetch("GITHUB_RUN_NUMBER", nil)}" else formatter SimpleCov::Formatter::HTMLFormatter end minimum_coverage(100) end else puts "Not running coverage on #{RUBY_ENGINE} #{RUBY_VERSION}" end snaky_hash-v2.0.1/CHANGELOG.md000066400000000000000000000036341431344361100156470ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format (since v2) is based on [Keep a Changelog v1](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Added ### Changed ### Fixed ### Removed ## [2.0.1] - 2022-09-23 ([tag][2.0.1t]) ### Added - Certificate for signing gem releases (@pboling) - Gemspec metadata (@pboling) - funding_uri - mailing_list_uri - Checksums for released gems (@pboling) ### Changed - Gem releases are now cryptographically signed (@pboling) ## [2.0.0] - 2022-08-29 ([tag][2.0.0t]) ### Changed - **BREAKING**: `SnakeHash::Snake` is now a mixin, now with support for symbol or string keys ```ruby class MySnakedHash < Hashie::Mash include SnakyHash::Snake.new(key_type: :string) # or :symbol end ``` ### Added - `SnakyHash::StringKeyed`: a Hashie::Mash class with snake-cased String keys - `SnakyHash::SymbolKeyed`: a Hashie::Mash class with snake-cased Symbol keys ## [1.0.1] - 2022-08-26 ([tag][1.0.1t]) ### Added - Missing LICENSE.txt file to release ### Removed - Accidentally added bundler dependency (vestige of transpec process) is now removed ## [1.0.0] - 2022-08-26 ([tag][1.0.0t]) ### Added - Initial release [Unreleased]: https://gitlab.com/oauth-xx/snaky_hash/-/compare/v2.0.1...main [2.0.1]: https://gitlab.com/oauth-xx/snaky_hash/-/compare/v2.0.0...v2.0.1 [2.0.1t]: https://gitlab.com/oauth-xx/snaky_hash/-/releases/tag/v2.0.1 [2.0.0]: https://gitlab.com/oauth-xx/snaky_hash/-/compare/v1.0.1...v2.0.0 [2.0.0t]: https://gitlab.com/oauth-xx/snaky_hash/-/releases/tag/v2.0.0 [1.0.1]: https://gitlab.com/oauth-xx/snaky_hash/-/compare/v1.0.0...v1.0.1 [1.0.1t]: https://gitlab.com/oauth-xx/snaky_hash/-/releases/tag/v1.0.1 [1.0.0]: https://gitlab.com/oauth-xx/snaky_hash/-/releases/tag/v1.0.0 [1.0.0t]: https://gitlab.com/oauth-xx/snaky_hash/-/releases/tag/v1.0.0 snaky_hash-v2.0.1/CODE_OF_CONDUCT.md000066400000000000000000000121441431344361100166310ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders 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, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. snaky_hash-v2.0.1/CONTRIBUTING.md000066400000000000000000000015641431344361100162670ustar00rootroot00000000000000## Contributing Bug reports and pull requests are welcome on GitLab at [https://gitlab.com/oauth-xx/snaky_hash/][source]. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct][conduct]. To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request and post a message to the [google group][mailinglist]. ## Contributors See: [https://gitlab.com/oauth-xx/oauth-tty/-/graphs/main][contributors] [comment]: <> (Following links are used by README, CONTRIBUTING, Homepage) [conduct]: https://gitlab.com/oauth-xx/snaky_hash/-/blob/main/CODE_OF_CONDUCT.md [contributors]: https://gitlab.com/oauth-xx/snaky_hash/-/graphs/main [mailinglist]: http://groups.google.com/group/oauth-ruby [source]: https://gitlab.com/oauth-xx/snaky_hash/-/tree/main snaky_hash-v2.0.1/Gemfile000066400000000000000000000031631431344361100153260ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } git_source(:gitlab) { |repo_name| "https://gitlab.com/#{repo_name}" } gem "rake", "~> 13.0" gem "rspec", "~> 3.0" ruby_version = Gem::Version.new(RUBY_VERSION) minimum_version = ->(version, engine = "ruby") { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == engine } linting = minimum_version.call("2.7") coverage = minimum_version.call("2.7") debug = minimum_version.call("2.5") gem "overcommit", "~> 0.58" if linting platforms :mri do if linting # Commented out rubocop-md because of the <--rubocop/md--> bug # gem "rubocop-md", require: false # Can be added once we reach rubocop-lts >= v10 (i.e. drop Ruby 2.2) # gem 'rubocop-packaging', require: false gem "rubocop-performance", require: false gem "rubocop-rake", require: false gem "rubocop-rspec", require: false gem "rubocop-thread_safety", require: false end if coverage gem "codecov", "~> 0.6" # For CodeCov gem "simplecov", "~> 0.21", require: false gem "simplecov-cobertura" # XML for Jenkins gem "simplecov-json" # For CodeClimate gem "simplecov-lcov", "~> 0.8", require: false end if debug # Add `byebug` to your code where you want to drop to REPL gem "byebug" end end platforms :jruby do # Add `binding.pry` to your code where you want to drop to REPL gem "pry-debugger-jruby" end ### deps for documentation and rdoc.info group :documentation do gem "github-markup", platform: :mri gem "redcarpet", platform: :mri gem "yard", require: false end snaky_hash-v2.0.1/Gemfile.lock000066400000000000000000000047671431344361100162700ustar00rootroot00000000000000PATH remote: . specs: snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) GEM remote: https://rubygems.org/ specs: ast (2.4.2) byebug (11.1.3) childprocess (4.1.0) codecov (0.6.0) simplecov (>= 0.15, < 0.22) diff-lcs (1.5.0) docile (1.4.0) github-markup (4.0.1) hashie (5.0.0) iniparse (1.5.0) jaro_winkler (1.5.4) json (2.6.2) overcommit (0.59.1) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) rexml (~> 3.2) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) rainbow (3.1.1) rake (13.0.6) redcarpet (3.5.1) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) rspec-expectations (~> 3.11.0) rspec-mocks (~> 3.11.0) rspec-block_is_expected (1.0.2) rspec-core rspec-core (3.11.0) rspec-support (~> 3.11.0) rspec-expectations (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.1) rubocop (0.68.1) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.6) rubocop-lts (8.0.2) rubocop-ruby2_2 (~> 1.0.4) rubocop-performance (1.3.0) rubocop (>= 0.68.0) rubocop-rake (0.5.1) rubocop rubocop-rspec (1.41.0) rubocop (>= 0.68.1) rubocop-ruby2_2 (1.0.4) rubocop (= 0.68.1) rubocop-thread_safety (0.4.4) rubocop (>= 0.53.0) ruby-progressbar (1.11.0) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) simplecov-html (0.12.3) simplecov-json (0.2.3) json simplecov simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) unicode-display_width (1.5.0) version_gem (1.1.1) webrick (1.7.0) yard (0.9.28) webrick (~> 1.7.0) PLATFORMS x86_64-darwin-21 DEPENDENCIES byebug codecov (~> 0.6) github-markup overcommit (~> 0.58) pry-debugger-jruby rake (~> 13.0) redcarpet rspec (~> 3.0) rspec-block_is_expected rubocop-lts (~> 8.0) rubocop-performance rubocop-rake rubocop-rspec rubocop-thread_safety simplecov (~> 0.21) simplecov-cobertura simplecov-json simplecov-lcov (~> 0.8) snaky_hash! yard BUNDLED WITH 2.3.21 snaky_hash-v2.0.1/LICENSE.txt000066400000000000000000000020671431344361100156600ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2022 Peter Boling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. snaky_hash-v2.0.1/README.md000066400000000000000000000067431431344361100153210ustar00rootroot00000000000000# SnakyHash This gem is used by the `oauth` and `oauth2` gems, and others, to normalize hash keys and lookups, and provide a nice psuedo-object interface. It has its roots in the `Rash` (specifically the [`rash_alt`](https://github.com/shishi/rash_alt) flavor), which is a special `Mash`, made popular by the `hashie` gem. Classes that include `SnakyHash::Snake` should inherit from `Hashie::Mash`. ## Installation Install the gem and add to the application's Gemfile by executing: $ bundle add snaky_hash If bundler is not being used to manage dependencies, install the gem by executing: $ gem install snaky_hash ## Usage ```ruby class MySnakedHash < Hashie::Mash include SnakyHash::Snake.new(key_type: :string) # or :symbol end snake = MySnakedHash.new(a: "a", "b" => "b", 2 => 2, "VeryFineHat" => "Feathers") snake.a # => 'a' snake.b # => 'b' snake[2] # 2 snake.very_fine_hat # => 'Feathers' snake[:very_fine_hat] # => 'Feathers' snake["very_fine_hat"] # => 'Feathers' ``` Note above that you can access the values via the string, or symbol. The `key_type` determines how the key is actually stored, but the hash acts as "indifferent". Note also that keys which do not respond to `to_sym`, because they don't have a natural conversion to a Symbol, are left as-is. ### Stranger Things I don't recommend using these features... but they exist (for now). You can still access the original un-snaked camel keys. And through them you can even use un-snaked camel methods. ```ruby snake.key?("VeryFineHat") # => true snake["VeryFineHat"] # => 'Feathers' snake.VeryFineHat # => 'Feathers', PLEASE don't do this!!! snake["VeryFineHat"] = "pop" # Please don't do this... you'll get a warning, and it works (for now), but no guarantees. # WARN -- : You are setting a key that conflicts with a built-in method MySnakedHash#VeryFineHat defined in MySnakedHash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. # => "pop" snake.very_fine_hat = "pop" # => 'pop', do this instead!!! snake.very_fine_hat # => 'pop' snake[:very_fine_hat] = "moose" # => 'moose', or do this instead!!! snake.very_fine_hat # => 'moose' snake["very_fine_hat"] = "cheese" # => 'cheese', or do this instead!!! snake.very_fine_hat # => 'cheese' ``` ## Development 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. 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://gitlab.com/oauth-xx/snaky_hash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/oauth-xx/snaky_hash/-/blob/main/CODE_OF_CONDUCT.md). ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the SnakyHash project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/oauth-xx/snaky_hash/-/blob/main/CODE_OF_CONDUCT.md). snaky_hash-v2.0.1/Rakefile000066400000000000000000000011021431344361100154670ustar00rootroot00000000000000# frozen_string_literal: true # !/usr/bin/env rake require "bundler/gem_tasks" begin require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) rescue LoadError desc "spec task stub" task :spec do warn "rspec is disabled" end end desc "alias test task to spec" task test: :spec begin require "rubocop/rake_task" RuboCop::RakeTask.new do |task| task.options = ["-D"] # Display the name of the failing cops end rescue LoadError desc "rubocop task stub" task :rubocop do warn "RuboCop is disabled" end end task default: %i[test rubocop] snaky_hash-v2.0.1/SECURITY.md000066400000000000000000000022171431344361100156230ustar00rootroot00000000000000# Security Policy ## Supported Versions | Version | Supported | EOL | Post-EOL / Enterprise | |---------|-----------|---------|---------------------------------------| | 1.0.x | ✅ | 04/2023 | [Tidelift Subscription][tidelift-ref] | ### EOL Policy Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April. ## Reporting a Vulnerability To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. ## Snaky Hash for Enterprise Available as part of the Tidelift Subscription. The maintainers of snaky_hash and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.][tidelift-ref] [tidelift-ref]: https://tidelift.com/subscription/pkg/rubygems-snaky_hash?utm_source=rubygems-oauth&utm_medium=referral&utm_campaign=enterprise&utm_term=repo snaky_hash-v2.0.1/bin/000077500000000000000000000000001431344361100146005ustar00rootroot00000000000000snaky_hash-v2.0.1/bin/checksum000077500000000000000000000012171431344361100163310ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require "digest/sha2" gems = Dir["*.gem"] puts "Found: #{gems.inspect}" raise "No Gems" if gems.length.zero? raise "Too Many Gems" if gems.length > 1 built_gem_path = gems.first checksum512 = Digest::SHA512.new.hexdigest(File.read(built_gem_path)) checksum512_path = "checksums/#{built_gem_path}.sha512" File.write(checksum512_path, checksum512) checksum256 = Digest::SHA256.new.hexdigest(File.read(built_gem_path)) checksum256_path = "checksums/#{built_gem_path}.sha256" File.write(checksum256_path, checksum256) puts "You must now git add and commit '#{checksum256_path}' and '#{checksum512_path}'" snaky_hash-v2.0.1/bin/console000077500000000000000000000005671431344361100162000ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "snaky_hash" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. # (If you use this, don't forget to add pry to your Gemfile!) # require "pry" # Pry.start require "irb" IRB.start(__FILE__) snaky_hash-v2.0.1/bin/setup000077500000000000000000000002031431344361100156610ustar00rootroot00000000000000#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' set -vx bundle install # Do any other automated setup that you need to do here snaky_hash-v2.0.1/certs/000077500000000000000000000000001431344361100151505ustar00rootroot00000000000000snaky_hash-v2.0.1/certs/pboling.pem000066400000000000000000000031271431344361100173100ustar00rootroot00000000000000-----BEGIN CERTIFICATE----- MIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl ci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW A2NvbTAeFw0yMjA5MTgyMzEyMzBaFw0yMzA5MTgyMzEyMzBaMEMxFTATBgNVBAMM DHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy LGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA2Dn1GM3W 8K2/rvN1zz+06bQMcxD16ZKTihVwi7Pb1v3T98rM4Omnxohm3s+CwpDWGeiB9pj6 0I/CTce0e4e3s8GKJSOrg93veImPSoH2PfsMsRsuB8wtqyiOCjLbF5o6S29x87r0 LA5EawH+Lh4xqrkkPjdffsmLk7TaCig/vlmNvnzxXKBdey/X/aEJZXzzBiWRfVdh O1fmMbVKyieGv9HK7+pLotIoT08bjDv8NP6V7zZslwQRqW27bQc6cqC2LGIbTYO3 3jt1kQxfMWmhOictS6SzG9VtKSrXf0L4Neq0Gh7CLBZBvJFWJYZPfb92YNITDbd8 emPOAQlXXNMN4mMXsEqtEhCPZRMnmwO+fOk/cC4AyglKi9lnQugCQoFV1XDMZST/ CYbzdQyadOdPDInTntG6V+Uw51d2QGXZ6PDDfrx9+toc/3sl5h68rCUGgE6Q3jPz srinqmBsxv2vTpmd4FjmiAtEnwH5/ooLpQYL8UdAjEoeysxS3AwIh+5dAgMBAAGj fzB9MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQWU6D156a2cle+ lb5RBfvVXlxTwjAhBgNVHREEGjAYgRZwZXRlci5ib2xpbmdAZ21haWwuY29tMCEG A1UdEgQaMBiBFnBldGVyLmJvbGluZ0BnbWFpbC5jb20wDQYJKoZIhvcNAQELBQAD ggGBAJ4SqhPlgUiLYIrphGXIaxXScHyvx4kixuvdrwhI4VoQV2qXvO7R6ZjOXVwX f/z84BWPiTZ8lzThPbt1UV/BGwkvLw9I4RjOdzvUz3J42j9Ly6q63isall07bo3F QWe/OBvIMBF1IbjC3q5vKPg4rq8+TkNRJNoE86U2gfR+PkW3jYYs9uiy0GloHDCP k5xgaj0vSL0Uy5mTOPdk3K6a/sUGZyYniWK05zdhIi956ynhfGaFO988FFdVw5Jq LHtXfIpAU8F7ES04syZSslxOluw7VlcSKyRdVIr737J92ZTduppB4PRGSKRgBsWV hXTahRE72Kyw53Q7FAuzF3v102WxAAQ7BuMjW+MyCUT75fwPm3W4ELPL8HYkNGE7 2oA5CPghFitRnvYS3GNrDG+9bNiRMEskeaBYwZ9UgReBQIwGYVj7LZk3UhiAsn44 gwGrEXGQGDZ0NIgBcmvMOqlXjkGQwQvugKycJ024z89+fz2332vdZIKTrSxJrXGk 4/bR9A== -----END CERTIFICATE----- snaky_hash-v2.0.1/checksums/000077500000000000000000000000001431344361100160155ustar00rootroot00000000000000snaky_hash-v2.0.1/checksums/snaky_hash-2.0.1.gem.sha256000066400000000000000000000001001431344361100222710ustar00rootroot000000000000007baa71c0932f418506a4198d8862d43a4a42e1ca1f9f0678cd54e47fcf0c7fe7snaky_hash-v2.0.1/checksums/snaky_hash-2.0.1.gem.sha512000066400000000000000000000002001431344361100222650ustar00rootroot000000000000002cbda10f977709742e0af6cd1ffb06d7269d3b48058d6f8c1048adf1277d984327f354778e63e4530214766e338fe28a80ebb7b5796e8d4c3fc4d666e03842c4snaky_hash-v2.0.1/lib/000077500000000000000000000000001431344361100145765ustar00rootroot00000000000000snaky_hash-v2.0.1/lib/snaky_hash.rb000066400000000000000000000005661431344361100172620ustar00rootroot00000000000000# frozen_string_literal: true # third party gems require "hashie" require "version_gem" require_relative "snaky_hash/version" require_relative "snaky_hash/snake" require_relative "snaky_hash/string_keyed" require_relative "snaky_hash/symbol_keyed" # This is the namespace for this gem module SnakyHash end SnakyHash::Version.class_eval do extend VersionGem::Basic end snaky_hash-v2.0.1/lib/snaky_hash/000077500000000000000000000000001431344361100167265ustar00rootroot00000000000000snaky_hash-v2.0.1/lib/snaky_hash/snake.rb000066400000000000000000000046611431344361100203630ustar00rootroot00000000000000# This is a module-class hybrid. # # Hashie's standard SymbolizeKeys is similar to the functionality we want. # ... but not quite. We need to support both String (for oauth2) and Symbol keys (for oauth). # include Hashie::Extensions::Mash::SymbolizeKeys module SnakyHash class Snake < Module def initialize(key_type: :string) super() @key_type = key_type end def included(base) conversions_module = SnakyModulizer.to_mod(@key_type) base.include(conversions_module) end module SnakyModulizer def self.to_mod(key_type) Module.new do # Converts a key to a symbol, or a string, depending on key_type, # but only if it is able to be converted to a symbol, # and after underscoring it. # # @api private # @param [] key the key to attempt convert to a symbol # @return [Symbol, K] case key_type when :string then define_method(:convert_key) { |key| key.respond_to?(:to_sym) ? underscore_string(key.to_s) : key } when :symbol then define_method(:convert_key) { |key| key.respond_to?(:to_sym) ? underscore_string(key.to_s).to_sym : key } else raise ArgumentError, "SnakyHash: Unhandled key_type: #{key_type}" end # Unlike its parent Mash, a SnakyHash::Snake will convert other # Hashie::Hash values to a SnakyHash::Snake when assigning # instead of respecting the existing subclass define_method :convert_value do |val, duping = false| #:nodoc: case val when self.class val.dup when ::Hash val = val.dup if duping self.class.new(val) when ::Array val.collect { |e| convert_value(e) } else val end end # converts a camel_cased string to a underscore string # subs spaces with underscores, strips whitespace # Same way ActiveSupport does string.underscore define_method :underscore_string do |str| str.to_s.strip .tr(" ", "_") .gsub(/::/, "/") .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr("-", "_") .squeeze("_") .downcase end end end end end end snaky_hash-v2.0.1/lib/snaky_hash/string_keyed.rb000066400000000000000000000001621431344361100217410ustar00rootroot00000000000000module SnakyHash class StringKeyed < Hashie::Mash include SnakyHash::Snake.new(key_type: :string) end end snaky_hash-v2.0.1/lib/snaky_hash/symbol_keyed.rb000066400000000000000000000001621431344361100217400ustar00rootroot00000000000000module SnakyHash class SymbolKeyed < Hashie::Mash include SnakyHash::Snake.new(key_type: :symbol) end end snaky_hash-v2.0.1/lib/snaky_hash/version.rb000066400000000000000000000001501431344361100207340ustar00rootroot00000000000000# frozen_string_literal: true module SnakyHash module Version VERSION = "2.0.1".freeze end end snaky_hash-v2.0.1/sig/000077500000000000000000000000001431344361100146125ustar00rootroot00000000000000snaky_hash-v2.0.1/sig/snaky_hash.rbs000066400000000000000000000001541431344361100174520ustar00rootroot00000000000000module SnakyHash VERSION: String # See the writing guide of rbs: https://github.com/ruby/rbs#guides end snaky_hash-v2.0.1/snaky_hash.gemspec000066400000000000000000000035571431344361100175370ustar00rootroot00000000000000# frozen_string_literal: true require_relative "lib/snaky_hash/version" Gem::Specification.new do |spec| spec.cert_chain = ["certs/pboling.pem"] spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $PROGRAM_NAME.end_with?("gem") spec.add_dependency "hashie" spec.add_dependency "version_gem", ["~> 1.1", ">= 1.1.1"] spec.name = "snaky_hash" spec.version = SnakyHash::Version::VERSION spec.authors = ["Peter Boling"] spec.email = ["peter.boling@gmail.com", "oauth-ruby@googlegroups.com"] spec.summary = "A very snaky hash" spec.description = "A Hashie::Mash joint to make #snakelife better" spec.license = "MIT" spec.required_ruby_version = ">= 2.2" spec.homepage = "https://gitlab.com/oauth-xx/snaky_hash" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "#{spec.homepage}/-/tree/v#{spec.version}" spec.metadata["changelog_uri"] = "#{spec.homepage}/-/blob/v#{spec.version}/CHANGELOG.md" spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/-/issues" spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/#{spec.name}/#{spec.version}" spec.metadata["wiki_uri"] = "#{spec.homepage}/-/wiki" spec.metadata["mailing_list_uri"] = "https://groups.google.com/g/oauth-ruby" spec.metadata["funding_uri"] = "https://liberapay.com/pboling" spec.metadata["rubygems_mfa_required"] = "true" spec.files = Dir[ "lib/**/*", "CHANGELOG.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE.txt", "README.md", "SECURITY.md", ] spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_development_dependency "rake", ">= 12" spec.add_development_dependency "rspec", ">= 3" spec.add_development_dependency "rspec-block_is_expected" spec.add_development_dependency "rubocop-lts", "~> 8.0" end snaky_hash-v2.0.1/spec/000077500000000000000000000000001431344361100147625ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/config/000077500000000000000000000000001431344361100162275ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/config/rspec/000077500000000000000000000000001431344361100173435ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/config/rspec/rspec_core.rb000066400000000000000000000005371431344361100220210ustar00rootroot00000000000000# frozen_string_literal: true RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with :rspec do |c| c.syntax = :expect end end snaky_hash-v2.0.1/spec/shared_contexts/000077500000000000000000000000001431344361100201575ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/shared_contexts/base_hash.rb000066400000000000000000000012741431344361100224250ustar00rootroot00000000000000# frozen_string_literal: true RSpec.shared_context "base hash" do let(:base_hash) do { "varOne" => 1, "two" => 2, :three => 3, :varFour => 4, "fiveHumpHumps" => 5, :nested => { "NestedOne" => "One", :two => "two", "nested_three" => "three" }, "nestedTwo" => { "nested_two" => 22, :nestedThree => 23 }, :nestedThree => [ { nestedFour: 4 }, { "nestedFour" => 4 } ], "spaced Key" => "When would this happen?", "trailing spaces " => "better safe than sorry", "extra spaces" => "hopefully this never happens", 4 => "not symbolizable" } end end snaky_hash-v2.0.1/spec/shared_examples/000077500000000000000000000000001431344361100201265ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/shared_examples/a_snaked_hash.rb000066400000000000000000000102051431344361100232210ustar00rootroot00000000000000# frozen_string_literal: true RSpec.shared_examples_for "a snaked hash" do include_context "base hash" it { is_expected.to be_a(Hashie::Mash) } it "creates a new rash where all the keys are underscored instead of camelcased" do expect(subject.var_one).to eq(1) expect(subject.two).to eq(2) expect(subject.three).to eq(3) expect(subject.var_four).to eq(4) expect(subject.five_hump_humps).to eq(5) expect(subject.nested).to be_a(subject.class) expect(subject.nested.nested_one).to eq("One") expect(subject.nested.two).to eq("two") expect(subject.nested.nested_three).to eq("three") expect(subject.nested_two).to be_a(subject.class) expect(subject.nested_two.nested_two).to eq(22) expect(subject.nested_two.nested_three).to eq(23) expect(subject.spaced_key).to eq("When would this happen?") expect(subject.trailing_spaces).to eq("better safe than sorry") expect(subject.extra_spaces).to eq("hopefully this never happens") end it "allows camelCased accessors" do # avoiding hashie v5- warnings subject.class.disable_warnings(:varOne) if Gem::Version.new(Hashie::VERSION) >= Gem::Version.new("5.0.0") expect(subject.varOne).to eq(1) subject.varOne = "once" expect(subject.varOne).to eq("once") expect(subject.var_one).to eq("once") end it "allows camelCased accessors on nested hashes" do # avoiding hashie v5- warnings subject.class.disable_warnings(:nestedOne) if Gem::Version.new(Hashie::VERSION) >= Gem::Version.new("5.0.0") expect(subject.nested.nestedOne).to eq("One") subject.nested.nestedOne = "once" expect(subject.nested.nested_one).to eq("once") end it "merges well with a Mash" do merged = subject.merge Hashie::Mash.new( nested: { fourTimes: "a charm" }, nested3: { helloWorld: "hi" } ) expect(merged.nested.four_times).to eq("a charm") expect(merged.nested.fourTimes).to eq("a charm") expect(merged.nested3).to be_a(subject.class) expect(merged.nested3.hello_world).to eq("hi") expect(merged.nested3.helloWorld).to eq("hi") expect(merged[:nested3][:helloWorld]).to eq("hi") end it "updates well with a Mash" do subject.update Hashie::Mash.new( nested: { fourTimes: "a charm" }, nested3: { helloWorld: "hi" } ) expect(subject.nested.four_times).to eq("a charm") expect(subject.nested.fourTimes).to eq("a charm") expect(subject.nested3).to be_a(subject.class) expect(subject.nested3.hello_world).to eq("hi") expect(subject.nested3.helloWorld).to eq("hi") expect(subject[:nested3][:helloWorld]).to eq("hi") end it "merges well with a Hash" do merged = subject.merge( nested: { fourTimes: "work like a charm" }, nested3: { helloWorld: "hi" } ) expect(merged.nested.four_times).to eq("work like a charm") expect(merged.nested.fourTimes).to eq("work like a charm") expect(merged.nested3).to be_a(subject.class) expect(merged.nested3.hello_world).to eq("hi") expect(merged.nested3.helloWorld).to eq("hi") expect(merged[:nested3][:helloWorld]).to eq("hi") end it "handles assigning a new Hash and convert it to a rash" do subject.nested3 = { helloWorld: "hi" } expect(subject.nested3).to be_a(subject.class) expect(subject.nested3.hello_world).to eq("hi") expect(subject.nested3.helloWorld).to eq("hi") expect(subject[:nested3][:helloWorld]).to eq("hi") end it "converts an array of Hashes" do expect(subject.nested_three).to be_a(Array) expect(subject.nested_three[0]).to be_a(subject.class) expect(subject.nested_three[0].nested_four).to eq(4) expect(subject.nested_three[1]).to be_a(subject.class) expect(subject.nested_three[1].nested_four).to eq(4) end it "allows initializing reader" do subject.nested3!.helloWorld = "hi" expect(subject.nested3.hello_world).to eq("hi") end it "does not transform non-Symbolizable keys" do expect(subject[4]).to eq("not symbolizable") expect(subject[:"4"]).to be_nil expect(subject["4"]).to be_nil expect(subject.key?("4")).to be false expect(subject.key?(:"4")).to be false expect(subject.key?(4)).to be true end end snaky_hash-v2.0.1/spec/snaky_hash/000077500000000000000000000000001431344361100171125ustar00rootroot00000000000000snaky_hash-v2.0.1/spec/snaky_hash/bad_snake_spec.rb000066400000000000000000000004331431344361100223600ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe "a bad one" do subject(:bad_snake) do Class.new(Hashie::Mash) do include SnakyHash::Snake.new(key_type: :slartibartfarst) end end it "raises an error" do block_is_expected.to raise_error(ArgumentError) end end snaky_hash-v2.0.1/spec/snaky_hash/snake_spec.rb000066400000000000000000000015341431344361100215550ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe SnakyHash::Snake do class TheSnakedHash < Hashie::Mash include SnakyHash::Snake.new(key_type: :string) end subject do TheSnakedHash.new(base_hash) end it_behaves_like "a snaked hash" it "returns a SnakyHash::Snake from a snake + snake merge" do a = TheSnakedHash.new("asd" => "asd") b = TheSnakedHash.new(zxc: "zxc") expect(a.merge(b)).to be_a(TheSnakedHash) end it "returns a SnakyHash::Snake from a snake + hash merge" do a = TheSnakedHash.new("asd" => "asd") b = Hash.new(zxc: "zxc") expect(a.merge(b)).to be_a(TheSnakedHash) end it "returns a Hash from a hash + snake merge" do a = TheSnakedHash.new("asd" => "asd") b = Hash.new(zxc: "zxc") res = b.merge(a) expect(res).not_to be_a(TheSnakedHash) expect(res).to be_a(Hash) end end snaky_hash-v2.0.1/spec/snaky_hash/string_keyed_spec.rb000066400000000000000000000005531431344361100231430ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe SnakyHash::StringKeyed do subject(:instance) do described_class.new(base_hash) end it_behaves_like "a snaked hash" it "can transform keys to string" do a = described_class.new(asd: "asd") b = a.transform_keys(&:to_s) expect(b.keys).to eq(["asd"]) expect(b["asd"]).to eq("asd") end end snaky_hash-v2.0.1/spec/snaky_hash/symbol_keyed_spec.rb000066400000000000000000000005571431344361100231460ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe SnakyHash::SymbolKeyed do subject(:instance) do described_class.new(base_hash) end it_behaves_like "a snaked hash" it "can transform keys to symbol" do a = described_class.new("asd" => "asd") b = a.transform_keys(&:to_sym) expect(b.keys).to eq([:asd]) expect(b[:asd]).to eq("asd") end end snaky_hash-v2.0.1/spec/snaky_hash/version_spec.rb000066400000000000000000000002401431344361100221320ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe SnakyHash::Version do it "has a version number" do expect(described_class::VERSION).not_to be nil end end snaky_hash-v2.0.1/spec/spec_helper.rb000066400000000000000000000034571431344361100176110ustar00rootroot00000000000000# frozen_string_literal: true # ensure test env ENV["RACK_ENV"] = "test" # Third Party Libraries require "rspec" require "rspec/block_is_expected" DEBUG = ENV["DEBUG"] == "true" ruby_version = Gem::Version.new(RUBY_VERSION) minimum_version = ->(version, engine = "ruby") { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == engine } actual_version = lambda do |major, minor| actual = Gem::Version.new(ruby_version) major == actual.segments[0] && minor == actual.segments[1] && RUBY_ENGINE == "ruby" end debugging = minimum_version.call("2.7") && DEBUG RUN_COVERAGE = minimum_version.call("2.6") && (ENV["COVER_ALL"] || ENV["CI_CODECOV"] || ENV["CI"].nil?) ALL_FORMATTERS = actual_version.call(2, 7) && (ENV["COVER_ALL"] || ENV["CI_CODECOV"] || ENV["CI"]) if DEBUG if debugging require "byebug" elsif minimum_version.call("2.7", "jruby") require "pry-debugger-jruby" end end if RUN_COVERAGE require "simplecov" # Config file `.simplecov` is run immediately when simplecov loads require "codecov" require "simplecov-json" require "simplecov-lcov" require "simplecov-cobertura" # This will override the formatter set in .simplecov if ALL_FORMATTERS SimpleCov::Formatter::LcovFormatter.config do |c| c.report_with_single_file = true c.single_report_path = "coverage/lcov.info" end SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::CoberturaFormatter, # XML for Jenkins SimpleCov::Formatter::LcovFormatter, SimpleCov::Formatter::JSONFormatter, # For CodeClimate SimpleCov::Formatter::Codecov # For CodeCov ] end end # This gem require "snaky_hash" # Library Configs # N/A # RSpec Configs require "config/rspec/rspec_core" require "shared_contexts/base_hash" require "shared_examples/a_snaked_hash"