kappamaki 0.0.3 → 1.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 +5 -5
- data/.github/workflows/ruby.yml +28 -0
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +23 -0
- data/DEVELOPMENT.md +13 -0
- data/Gemfile +7 -1
- data/LICENSE.txt +1 -1
- data/README.md +26 -42
- data/Rakefile +21 -0
- data/dprint.json +11 -0
- data/kappamaki.gemspec +17 -21
- data/lib/kappamaki.rb +43 -20
- data/spec/kappamaki_spec.rb +81 -40
- data/spec/spec_helper.rb +9 -4
- metadata +17 -43
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f70299e68a03ca40f132bb49a60f2fa3795118ca12a39e79d018957e434febcc
|
|
4
|
+
data.tar.gz: b462b40eec165b8a2cc909c9c7a4b8dc75a3e4abfde52204e1ccbc0479de4b5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 273a3d2b356ec902cd30238d2b53da839d982124c9157056507cfbf5ed4a0efdfa2807e65d760bcf9c55eaccd5dccd3e6d2bf79a9b62f957ab9f635b2c6b3190
|
|
7
|
+
data.tar.gz: 46cdaf4f025c4ea8e00d73b3df5c359865ab2fe9aef960a01869c75f26f3e5613460d802bd56e1ebf3fb5167436d42db98b01ded1d098991a6cc033b4777054f
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
ruby-version: ["3.4"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: dprint/check@v2.2
|
|
21
|
+
- uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
25
|
+
- run: bundle exec rake
|
|
26
|
+
- run: bundle exec rake fix
|
|
27
|
+
- run: git diff HEAD --exit-code --color
|
|
28
|
+
- uses: coverallsapp/github-action@v2
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
DisplayCopNames: true
|
|
4
|
+
DisplayStyleGuide: true
|
|
5
|
+
Include:
|
|
6
|
+
- "**/Rakefile"
|
|
7
|
+
SuggestExtensions: false
|
|
8
|
+
|
|
9
|
+
Layout/LineLength:
|
|
10
|
+
Max: 100
|
|
11
|
+
|
|
12
|
+
Style/StringLiterals:
|
|
13
|
+
EnforcedStyle: double_quotes
|
|
14
|
+
|
|
15
|
+
Style/SymbolArray:
|
|
16
|
+
EnforcedStyle: brackets
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0 (2025-11-04)
|
|
4
|
+
|
|
5
|
+
- Update minimum Ruby version to 3.2
|
|
6
|
+
- The `symbolize_keys` function is now more generic
|
|
7
|
+
- Verifies argument types (#25)
|
|
8
|
+
|
|
9
|
+
## 1.0.0 (2015-12-22)
|
|
10
|
+
|
|
11
|
+
- Stable release
|
|
12
|
+
|
|
13
|
+
## 0.0.3 (2014-09-26)
|
|
14
|
+
|
|
15
|
+
- added the `symbolize_keys_deep!` method
|
|
16
|
+
|
|
17
|
+
## 0.0.2 (2014-09-23)
|
|
18
|
+
|
|
19
|
+
- Require at least Ruby 1.9.3
|
|
20
|
+
|
|
21
|
+
## 0.0.1 (2014-09-23)
|
|
22
|
+
|
|
23
|
+
- Basic functionality for deep symbolizing hash keys
|
data/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Development handbook
|
|
2
|
+
|
|
3
|
+
- run all tests: `bundle exec rake`
|
|
4
|
+
- auto-fix all fixable issues: `bundle exec fix`
|
|
5
|
+
- update dependencies: `bundle update`
|
|
6
|
+
|
|
7
|
+
## Release a new version to RubyGems
|
|
8
|
+
|
|
9
|
+
- in a branch:
|
|
10
|
+
- update CHANGELOG.md
|
|
11
|
+
- search and replace all occurrences of `1.1.0`
|
|
12
|
+
- ship this branch
|
|
13
|
+
- push a new version to Rubygems: `rake release`
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://github.com/kevgo/kappamaki/actions/workflows/ruby.yml)
|
|
2
|
+
[](https://coveralls.io/github/kevgo/kappamaki?branch=main)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Inspired by the simplicity of a cucumber-filled sushi roll, Kappamaki provides
|
|
5
|
+
helper methods to implement Cucumber steps that define data using natural
|
|
6
|
+
language.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
which adds naturalness and freshness to a meal.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
Kappamaki provides a number of helper methods that can be used directly
|
|
12
|
-
in your Cucumber step definitions.
|
|
13
|
-
|
|
14
|
-
### from_sentence
|
|
8
|
+
## from_sentence
|
|
15
9
|
|
|
16
10
|
Parses a list of values from a sentence.
|
|
17
11
|
|
|
@@ -19,26 +13,25 @@ Parses a list of values from a sentence.
|
|
|
19
13
|
Given the restaurant offers cucumber rolls, philadelphia rolls, and avocado rolls
|
|
20
14
|
```
|
|
21
15
|
|
|
22
|
-
Your step
|
|
16
|
+
Your implementation of this Cucumber step would look like this:
|
|
23
17
|
|
|
24
18
|
```ruby
|
|
25
19
|
Given /^the restaurant offers (.+)$/ do |menu_list|
|
|
26
20
|
|
|
27
21
|
# menu_list is this string:
|
|
28
|
-
|
|
22
|
+
# "cucumber rolls, philadelphia rolls, and avocado rolls"
|
|
29
23
|
|
|
30
|
-
#
|
|
24
|
+
# let's parse this string into an array
|
|
31
25
|
menu = Kappamaki.from_sentence menu_list
|
|
32
26
|
|
|
33
|
-
#
|
|
34
|
-
[
|
|
27
|
+
# the result (the variable menu) is this array:
|
|
28
|
+
# ["cucumber rolls", "philadelphia rolls", "avocado rolls"]
|
|
35
29
|
|
|
36
30
|
# Now we can set up our menu here...
|
|
37
31
|
end
|
|
38
32
|
```
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
### attributes_from_sentence
|
|
34
|
+
## attributes_from_sentence
|
|
42
35
|
|
|
43
36
|
Parses key-value pairs from natural sentences.
|
|
44
37
|
|
|
@@ -52,22 +45,23 @@ Your step definition would look like this:
|
|
|
52
45
|
When /^I order a dinner with (.+)$/ do |order_items|
|
|
53
46
|
|
|
54
47
|
# order_items is this string:
|
|
55
|
-
'starter: "miso soup" and entree: "cucumber rolls"'
|
|
48
|
+
# 'starter: "miso soup" and entree: "cucumber rolls"'
|
|
56
49
|
|
|
57
|
-
# Let's parse
|
|
58
|
-
order_data = Kappamaki.attributes_from_sentence
|
|
50
|
+
# Let's parse this string using Kappamaki
|
|
51
|
+
order_data = Kappamaki.attributes_from_sentence order_items
|
|
59
52
|
|
|
60
53
|
# The result, order_data, is this hash:
|
|
61
|
-
{
|
|
62
|
-
|
|
54
|
+
# {
|
|
55
|
+
# starter: "miso soup",
|
|
56
|
+
# entree: "cucumber rolls"
|
|
57
|
+
# }
|
|
63
58
|
|
|
64
59
|
# now we can set up our order...
|
|
65
60
|
create :order, order_data
|
|
66
61
|
end
|
|
67
62
|
```
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
### symbolize_keys_deep
|
|
64
|
+
## symbolize_keys_deep
|
|
71
65
|
|
|
72
66
|
Converts the keys of a hash into symbols.
|
|
73
67
|
|
|
@@ -81,17 +75,17 @@ Then I am served these items
|
|
|
81
75
|
Your step definition would look like this:
|
|
82
76
|
|
|
83
77
|
```ruby
|
|
84
|
-
Then
|
|
78
|
+
Then /^I am served these items$/ do |entrees|
|
|
85
79
|
entrees.hashes.each do |entree|
|
|
86
80
|
|
|
87
81
|
# entree is this hash:
|
|
88
|
-
{
|
|
82
|
+
# { "name" => "miso soup", "count" => "1" }
|
|
89
83
|
|
|
90
84
|
# Let's convert the keys to symbols.
|
|
91
85
|
Kappamaki.symbolize_keys_deep! entree
|
|
92
86
|
|
|
93
87
|
# Now entree is this hash:
|
|
94
|
-
{ name:
|
|
88
|
+
# { name: "miso soup", count: "1" }
|
|
95
89
|
|
|
96
90
|
# Now we can use this hash in places that expect hashes with symbols
|
|
97
91
|
expect(order).to include entree
|
|
@@ -99,18 +93,8 @@ Then ^I am served these items do |entrees|
|
|
|
99
93
|
end
|
|
100
94
|
```
|
|
101
95
|
|
|
102
|
-
|
|
103
96
|
## Installation
|
|
104
97
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Contributing
|
|
111
|
-
|
|
112
|
-
1. Fork it ( https://github.com/Originate/kappamaki/fork )
|
|
113
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
114
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
115
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
116
|
-
5. Create a new Pull Request
|
|
98
|
+
- add `gem "kappamaki"` to your application's Gemfile
|
|
99
|
+
- run `bundle install`
|
|
100
|
+
- add `require 'kappamaki'` to your `/features/support/env.rb` file
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler"
|
|
4
|
+
require "bundler/gem_tasks"
|
|
5
|
+
require "rspec/core/rake_task"
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new :spec
|
|
8
|
+
|
|
9
|
+
task default: [:lint, :spec]
|
|
10
|
+
|
|
11
|
+
desc "Fix all auto-fixable issues"
|
|
12
|
+
task "fix" do
|
|
13
|
+
sh "bundle exec rubocop -A"
|
|
14
|
+
sh "dprint fmt"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run linter"
|
|
18
|
+
task "lint" do
|
|
19
|
+
sh "bundle exec rubocop"
|
|
20
|
+
sh "dprint check"
|
|
21
|
+
end
|
data/dprint.json
ADDED
data/kappamaki.gemspec
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
|
|
5
|
-
Gem::Specification.new do |
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.name = "kappamaki"
|
|
6
|
+
gem.version = "1.1.0"
|
|
7
|
+
gem.authors = ["Kevin Goslar"]
|
|
8
|
+
gem.email = ["kevin.goslar@gmail.com"]
|
|
9
|
+
gem.summary = "Tools for defining data using natural language in Cucumber steps"
|
|
10
|
+
gem.homepage = "https://github.com/kevgo/kappamaki"
|
|
11
|
+
gem.license = "MIT"
|
|
12
|
+
gem.description = <<-DESC
|
|
14
13
|
Kappamaki is a collection of string manipulation methods
|
|
15
|
-
that make parsing high-
|
|
16
|
-
|
|
14
|
+
that make parsing high-level cucumber steps easier.
|
|
15
|
+
DESC
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
spec.require_paths = ['lib']
|
|
17
|
+
gem.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
gem.executables = []
|
|
19
|
+
gem.require_paths = ["lib"]
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
spec.required_ruby_version = '>= 1.9.3'
|
|
21
|
+
gem.required_ruby_version = ">= 3.2"
|
|
22
|
+
gem.metadata["rubygems_mfa_required"] = "true"
|
|
27
23
|
end
|
data/lib/kappamaki.rb
CHANGED
|
@@ -1,34 +1,57 @@
|
|
|
1
|
+
# Kappamaki provides helper methods to implement Cucumber steps
|
|
2
|
+
# that define data using natural language.
|
|
1
3
|
module Kappamaki
|
|
2
|
-
|
|
3
4
|
# Parses a given string containing key-value pairs into a Hash
|
|
4
5
|
#
|
|
5
6
|
# Values must be delimited by double-quotes, like this:
|
|
6
7
|
# key: "value"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
#
|
|
9
|
+
# @param sentence [String] the sentence to parse
|
|
10
|
+
# @return [Hash] the parsed key-value pairs
|
|
11
|
+
# @raise [ArgumentError] if sentence is not a String
|
|
12
|
+
def self.attributes_from_sentence(sentence)
|
|
13
|
+
raise ArgumentError, "sentence must be a String" unless sentence.is_a?(String)
|
|
14
|
+
|
|
15
|
+
Kappamaki.from_sentence(sentence)
|
|
16
|
+
.map { |piece| piece.split(": ") }
|
|
17
|
+
.to_h { |key, value| [key.to_sym, value] }
|
|
13
18
|
end
|
|
14
19
|
|
|
20
|
+
# Reverse of ActiveSupport's "to_sentence" method
|
|
21
|
+
#
|
|
22
|
+
# @param sentence [String] the sentence to parse
|
|
23
|
+
# @return [Array<String>] the parsed array of items
|
|
24
|
+
# @raise [ArgumentError] if sentence is not a String
|
|
25
|
+
def self.from_sentence(sentence)
|
|
26
|
+
raise ArgumentError, "sentence must be a String" unless sentence.is_a?(String)
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.split(', ')
|
|
21
|
-
.map{|s| s.gsub '"', ''}
|
|
28
|
+
sentence.gsub(", and ", ", ")
|
|
29
|
+
.gsub(" and ", ", ")
|
|
30
|
+
.split(", ")
|
|
31
|
+
.map { |s| s.delete('"') }
|
|
22
32
|
end
|
|
23
33
|
|
|
24
|
-
|
|
25
34
|
# Converts all keys in the given hash to symbols
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
#
|
|
36
|
+
# @param hash [Hash] the hash to modify
|
|
37
|
+
# @return [Hash] the modified hash with symbolized keys
|
|
38
|
+
# @raise [ArgumentError] if hash is not a Hash
|
|
39
|
+
def self.symbolize_keys_deep!(hash)
|
|
40
|
+
raise ArgumentError, "hash must be a Hash" unless hash.is_a?(Hash)
|
|
41
|
+
|
|
42
|
+
hash.keys.each do |key|
|
|
43
|
+
key_sym = key.to_sym
|
|
44
|
+
value = hash.delete(key)
|
|
45
|
+
hash[key_sym] = case value
|
|
46
|
+
when Hash
|
|
47
|
+
symbolize_keys_deep!(value)
|
|
48
|
+
when Array
|
|
49
|
+
value.map { |item| item.is_a?(Hash) ? symbolize_keys_deep!(item) : item }
|
|
50
|
+
else
|
|
51
|
+
value
|
|
52
|
+
end
|
|
31
53
|
end
|
|
32
|
-
end
|
|
33
54
|
|
|
55
|
+
hash
|
|
56
|
+
end
|
|
34
57
|
end
|
data/spec/kappamaki_spec.rb
CHANGED
|
@@ -1,55 +1,96 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "kappamaki"
|
|
4
3
|
|
|
5
4
|
describe Kappamaki do
|
|
5
|
+
describe ".attributes_from_sentence" do
|
|
6
|
+
test_data = {
|
|
7
|
+
'name: "Foo"' => { name: "Foo" },
|
|
8
|
+
'name: "Foo" and body: "Bar"' => { name: "Foo", body: "Bar" },
|
|
9
|
+
'name: "Foo", body: "Bar" and title: "Baz"' => { name: "Foo", body: "Bar", title: "Baz" },
|
|
10
|
+
'name: "Foo", body: "Bar", and title: "Baz"' => { name: "Foo", body: "Bar", title: "Baz" }
|
|
11
|
+
}
|
|
12
|
+
test_data.each do |sentence, expected_result|
|
|
13
|
+
it "parses '#{sentence}' into '#{expected_result}'" do
|
|
14
|
+
expect(Kappamaki.attributes_from_sentence(sentence)).to eql expected_result
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "raises ArgumentError when given non-string input" do
|
|
19
|
+
expect { Kappamaki.attributes_from_sentence(nil) }.to raise_error(ArgumentError, "sentence must be a String")
|
|
20
|
+
expect { Kappamaki.attributes_from_sentence(123) }.to raise_error(ArgumentError, "sentence must be a String")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
6
23
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'one'
|
|
18
|
-
'"one"' => ['one'],
|
|
19
|
-
'one and two' => ['one', 'two'],
|
|
20
|
-
'"one" and "two"' => ['one', 'two'],
|
|
21
|
-
'one, two and three' => ['one', 'two', 'three'],
|
|
22
|
-
'"one", "two" and "three"' => ['one', 'two', 'three'],
|
|
23
|
-
'one, two, and three' => ['one', 'two', 'three'],
|
|
24
|
-
'one, two, three and four' => ['one', 'two', 'three', 'four'],
|
|
25
|
-
'"one", "two", "three" and "four"' => ['one', 'two', 'three', 'four']
|
|
24
|
+
describe ".from_sentence" do
|
|
25
|
+
test_data = {
|
|
26
|
+
"one" => ["one"],
|
|
27
|
+
'"one"' => ["one"],
|
|
28
|
+
"one and two" => %w[one two],
|
|
29
|
+
'"one" and "two"' => %w[one two],
|
|
30
|
+
"one, two and three" => %w[one two three],
|
|
31
|
+
'"one", "two" and "three"' => %w[one two three],
|
|
32
|
+
"one, two, and three" => %w[one two three],
|
|
33
|
+
"one, two, three and four" => %w[one two three four],
|
|
34
|
+
'"one", "two", "three" and "four"' => %w[one two three four]
|
|
26
35
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
describe method_name do
|
|
31
|
-
expected.each do |sentence, expected_result|
|
|
32
|
-
it "parses '#{sentence}' into '#{expected_result}'" do
|
|
33
|
-
expect(Kappamaki.send method_name, sentence).to eql expected_result
|
|
34
|
-
end
|
|
36
|
+
test_data.each do |sentence, expected_result|
|
|
37
|
+
it "parses '#{sentence}' into '#{expected_result}'" do
|
|
38
|
+
expect(Kappamaki.from_sentence(sentence)).to eql expected_result
|
|
35
39
|
end
|
|
36
40
|
end
|
|
41
|
+
|
|
42
|
+
it "handles empty string" do
|
|
43
|
+
expect(Kappamaki.from_sentence("")).to eq []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "raises ArgumentError when given non-string input" do
|
|
47
|
+
expect { Kappamaki.from_sentence(nil) }.to raise_error(ArgumentError, "sentence must be a String")
|
|
48
|
+
expect { Kappamaki.from_sentence([]) }.to raise_error(ArgumentError, "sentence must be a String")
|
|
49
|
+
end
|
|
37
50
|
end
|
|
38
51
|
|
|
52
|
+
describe ".symbolize_keys_deep!" do
|
|
53
|
+
it "converts string keys to symbols" do
|
|
54
|
+
actual = { "one" => "two", "alpha" => "beta" }
|
|
55
|
+
Kappamaki.symbolize_keys_deep!(actual)
|
|
56
|
+
expect(actual).to eq one: "two", alpha: "beta"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "converts nested keys" do
|
|
60
|
+
actual = { "one" => { "alpha" => "beta" } }
|
|
61
|
+
Kappamaki.symbolize_keys_deep!(actual)
|
|
62
|
+
expect(actual).to eq one: { alpha: "beta" }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "handles arrays containing hashes" do
|
|
66
|
+
actual = { "items" => [{ "name" => "foo" }, { "name" => "bar" }] }
|
|
67
|
+
Kappamaki.symbolize_keys_deep!(actual)
|
|
68
|
+
expect(actual).to eq items: [{ name: "foo" }, { name: "bar" }]
|
|
69
|
+
end
|
|
39
70
|
|
|
40
|
-
|
|
71
|
+
it "handles arrays containing non-hash values" do
|
|
72
|
+
actual = { "items" => ["foo", "bar", 123] }
|
|
73
|
+
Kappamaki.symbolize_keys_deep!(actual)
|
|
74
|
+
expect(actual).to eq items: ["foo", "bar", 123]
|
|
75
|
+
end
|
|
41
76
|
|
|
42
|
-
it
|
|
43
|
-
actual = {
|
|
44
|
-
Kappamaki.symbolize_keys_deep!
|
|
45
|
-
expect(
|
|
77
|
+
it "handles empty hash" do
|
|
78
|
+
actual = {}
|
|
79
|
+
result = Kappamaki.symbolize_keys_deep!(actual)
|
|
80
|
+
expect(result).to eq({})
|
|
81
|
+
expect(actual).to eq({})
|
|
46
82
|
end
|
|
47
83
|
|
|
48
|
-
it
|
|
49
|
-
actual = {
|
|
50
|
-
Kappamaki.symbolize_keys_deep!
|
|
51
|
-
expect(
|
|
84
|
+
it "returns the modified hash" do
|
|
85
|
+
actual = { "one" => "two" }
|
|
86
|
+
result = Kappamaki.symbolize_keys_deep!(actual)
|
|
87
|
+
expect(result).to eq one: "two"
|
|
88
|
+
expect(result).to be(actual)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "raises ArgumentError when given non-hash input" do
|
|
92
|
+
expect { Kappamaki.symbolize_keys_deep!(nil) }.to raise_error(ArgumentError, "hash must be a Hash")
|
|
93
|
+
expect { Kappamaki.symbolize_keys_deep!("string") }.to raise_error(ArgumentError, "hash must be a Hash")
|
|
52
94
|
end
|
|
53
95
|
end
|
|
54
96
|
end
|
|
55
|
-
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
if ENV["CI"]
|
|
2
|
+
require "simplecov"
|
|
3
|
+
SimpleCov.start
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require "bundler/setup"
|
|
2
7
|
Bundler.setup
|
|
3
|
-
require
|
|
8
|
+
require "kappamaki"
|
|
4
9
|
|
|
5
10
|
RSpec.configure do |config|
|
|
6
11
|
config.color = true
|
|
7
|
-
config.order =
|
|
8
|
-
config.formatter =
|
|
12
|
+
config.order = "random"
|
|
13
|
+
config.formatter = "documentation"
|
|
9
14
|
end
|
metadata
CHANGED
|
@@ -1,66 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kappamaki
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Goslar
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
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: '0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rspec
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
10
|
+
date: 2025-11-04 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
41
12
|
description: |2
|
|
42
13
|
Kappamaki is a collection of string manipulation methods
|
|
43
|
-
that make parsing high-
|
|
14
|
+
that make parsing high-level cucumber steps easier.
|
|
44
15
|
email:
|
|
45
|
-
- kevin.goslar@
|
|
16
|
+
- kevin.goslar@gmail.com
|
|
46
17
|
executables: []
|
|
47
18
|
extensions: []
|
|
48
19
|
extra_rdoc_files: []
|
|
49
20
|
files:
|
|
21
|
+
- ".github/workflows/ruby.yml"
|
|
50
22
|
- ".gitignore"
|
|
51
|
-
- ".
|
|
23
|
+
- ".rubocop.yml"
|
|
24
|
+
- CHANGELOG.md
|
|
25
|
+
- DEVELOPMENT.md
|
|
52
26
|
- Gemfile
|
|
53
27
|
- LICENSE.txt
|
|
54
28
|
- README.md
|
|
29
|
+
- Rakefile
|
|
30
|
+
- dprint.json
|
|
55
31
|
- kappamaki.gemspec
|
|
56
32
|
- lib/kappamaki.rb
|
|
57
33
|
- spec/kappamaki_spec.rb
|
|
58
34
|
- spec/spec_helper.rb
|
|
59
|
-
homepage: https://github.com/
|
|
35
|
+
homepage: https://github.com/kevgo/kappamaki
|
|
60
36
|
licenses:
|
|
61
37
|
- MIT
|
|
62
|
-
metadata:
|
|
63
|
-
|
|
38
|
+
metadata:
|
|
39
|
+
rubygems_mfa_required: 'true'
|
|
64
40
|
rdoc_options: []
|
|
65
41
|
require_paths:
|
|
66
42
|
- lib
|
|
@@ -68,16 +44,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
68
44
|
requirements:
|
|
69
45
|
- - ">="
|
|
70
46
|
- !ruby/object:Gem::Version
|
|
71
|
-
version:
|
|
47
|
+
version: '3.2'
|
|
72
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
49
|
requirements:
|
|
74
50
|
- - ">="
|
|
75
51
|
- !ruby/object:Gem::Version
|
|
76
52
|
version: '0'
|
|
77
53
|
requirements: []
|
|
78
|
-
|
|
79
|
-
rubygems_version: 2.2.2
|
|
80
|
-
signing_key:
|
|
54
|
+
rubygems_version: 3.6.2
|
|
81
55
|
specification_version: 4
|
|
82
|
-
summary: Tools for natural
|
|
56
|
+
summary: Tools for defining data using natural language in Cucumber steps
|
|
83
57
|
test_files: []
|
data/.travis.yml
DELETED