Skip to content

docs: add demos for issue 80 utility methods#323

Open
landeqiming666 wants to merge 1 commit into
rubyworks:mainfrom
landeqiming666:codex/issuehunt-80-demo-docs
Open

docs: add demos for issue 80 utility methods#323
landeqiming666 wants to merge 1 commit into
rubyworks:mainfrom
landeqiming666:codex/issuehunt-80-demo-docs

Conversation

@landeqiming666

Copy link
Copy Markdown

Summary

This adds QED-style demos for several utility methods discussed in #80 that already exist in the codebase:

  • Enumerable#squeeze
  • Enumerator::Lazy#squeeze
  • Hash#fetch_nested
  • String#rotate / String#rotate!

The issue discussion asked for methods to be submitted with documentation, Lemon tests, and QED demos. These methods already have implementations and related test coverage, so this PR fills in the missing demo/docs side for the existing APIs.

Refs #80

Validation

  • git diff --check
  • ruby -Ilib/core -e "require 'facets/enumerable/squeeze'; raise unless [1,2,2,3,3,2,1].squeeze == [1,2,3,2,1]; raise unless [1,2,2,3,3,2,1].squeeze(3) == [1,2,2,3,2,1]"
  • ruby -Ilib/core -e "require 'facets/enumerator/lazy/squeeze'; raise unless [1,2,2,3,3,2,1].lazy.squeeze.to_a == [1,2,3,2,1]; raise unless [1,2,2,3,3,2,1].lazy.squeeze(3).to_a == [1,2,2,3,2,1]"
  • ruby -Ilib/core -e "require 'facets/string/rotate'; raise unless 'abcdefgh'.rotate(2) == 'cdefghab'; raise unless 'abcdefgh'.rotate(-2) == 'ghabcdef'; s='abcdefgh'; s.rotate!(2); raise unless s == 'cdefghab'"
  • ruby -Ilib/core -e "require 'facets/hash/fetch_nested'; data={'hello'=>{'world'=>42}}; raise unless data.fetch_nested('hello','world') == 42; raise unless data.fetch_nested('hello','missing').nil?; raise unless data.fetch_nested('hello','missing'){|*keys| keys.join('.')} == 'hello.missing'"

Note: I attempted to install the QED test dependency via Bundler, but dependency resolution did not complete in a reasonable time on this local Ruby 2.6.10 environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant