Skip to content

Commit

Permalink
Fix another bug seemingly introduced between ruby 3.0 and 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
buermann committed Jan 31, 2024
1 parent fa472b5 commit 0da49bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
1.0.0 01/31/2024
================

Don't let integer hash keys raise your enemies up. Test against Ruby 3.3.0.
Test against Ruby 3.3.0.

Don't let integer hash keys unleashed the bees.

Fix an introduced bug that produces leading underscores when snaking PascalCase.

0.1.0 10/14/2022
================
Expand Down
3 changes: 2 additions & 1 deletion lib/camel_snake_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def camelcase(obj)
end

def snakecase(obj)
string = +obj.to_s
string = +obj.to_s
string[0] = string[0].downcase if string[0]
string.gsub!(/([A-Z])/) { "_#{$1}" }
string.downcase!
string
Expand Down
2 changes: 1 addition & 1 deletion lib/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Store the version of the gem here rather than the gemspec
module CamelSnakeKeys
VERSION = '1.0.0'
VERSION = '1.1.0'

def self.version
VERSION
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/camel_snake_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
CamelSnakeKeys.camelcase(nil).should eq ""
CamelSnakeKeys.snakecase(nil).should eq ""
end

it "handles pascal case (destructively)" do
CamelSnakeKeys.camelcase("pascal_case").should eq "pascalCase"
CamelSnakeKeys.snakecase("PascalCase").should eq "pascal_case"
end
end

context 'arrays' do
Expand Down

0 comments on commit 0da49bc

Please sign in to comment.