Skip to content

Commit

Permalink
Switch to yardspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kspurgin committed Aug 12, 2024
1 parent 9b10ca1 commit 89ba413
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 105 deletions.
30 changes: 8 additions & 22 deletions lib/kiba/extend/transforms/append/nil_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,15 @@ module Append
# Adds the given field(s) to the row with nil value if they do not
# already exist in row
#
# # Examples
# @example
# # Used in pipeline as:
# # transform Append::NilFields, fields: %i[a b z]
#
# Input table:
#
# ~~~
# | z |
# |----|
# | zz |
# ~~~
#
# Used in pipeline as:
#
# ~~~
# transform Append::NilFields, fields: %i[a b c z]
# ~~~
#
# Results in:
#
# ~~~
# | z | a | b | c |
# |----+-----+-----+-----|
# | zz | nil | nil | nil |
# ~~~
# xform = Append::NilFields.new(fields: %i[a b z])
# input = [{z: "zz"}]
# result = input.map{ |row| xform.process(row) }
# expected = [{z: "zz", a: nil, b: nil}]
# expect(result).to eq(expected)
class NilFields
# @param fields [Array<Symbol>, Symbol] field name or list of field
# names to add
Expand Down
45 changes: 20 additions & 25 deletions lib/kiba/extend/transforms/append/to_field_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,28 @@ module Kiba
module Extend
module Transforms
module Append
# # Examples
# Adds the given value to the end of value of the given field. Does not
# affect nil/empty field values
#
# Input table:
# @example Treated as single value (default)
# # Used in pipeline as:
# # transform Append::ToFieldValue, field: :name, value: " (name)"
#
# ~~~
# | name |
# |-------|
# | Weddy |
# | nil |
# | |
# ~~~
#
# Used in pipeline as:
#
# ~~~
# transform Append::ToFieldValue, field: :name, value: ' (name)'
# ~~~
#
# Results in:
#
# ~~~
# | name |
# |--------------|
# | Weddy (name) |
# | nil |
# | |
# ~~~
# xform = Append::ToFieldValue.new(field: :name, value: " (name)")
# input = [
# {name: "Weddy"},
# {name: "Kernel|Zipper"},
# {name: nil},
# {name: ""}
# ]
# result = input.map{ |row| xform.process(row) }
# expected = [
# {name: "Weddy (name)"},
# {name: "Kernel|Zipper (name)"},
# {name: nil},
# {name: ""}
# ]
# expect(result).to eq(expected)
class ToFieldValue
# @param field [Symbol] name of field to append to
# @param value [String] value to append to existing field values
Expand Down
58 changes: 0 additions & 58 deletions spec/kiba/extend/transforms/append_spec.rb

This file was deleted.

0 comments on commit 89ba413

Please sign in to comment.