Variable Name Converter API - Ruby Gem
Variable Name Converter transforms variable names between different naming conventions including camelCase, snake_case, PascalCase, and kebab-case.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_variablenameconverter'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_variablenameconverter
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_variablenameconverter'
# Initialize the client
client = APIVerve::Variablenameconverter::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
variables: myVariableName,another_var_name,SomeClassName,kebab-case-name,CONSTANT_VALUE,
to: "snake_case"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ variables: myVariableName,another_var_name,SomeClassName,kebab-case-name,CONSTANT_VALUE, to: "snake_case" })
puts response["data"]
rescue APIVerve::Variablenameconverter::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Variablenameconverter::APIError => e
puts "API error: #{e.message}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Variablenameconverter::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"results": [
{
"original": "myVariableName",
"converted": "my_variable_name"
},
{
"original": "another_var_name",
"converted": "another_var_name"
},
{
"original": "SomeClassName",
"converted": "some_class_name"
},
{
"original": "kebab-case-name",
"converted": "kebab_case_name"
},
{
"original": "CONSTANT_VALUE",
"converted": "c_o_n_s_t_a_n_t__v_a_l_u_e"
}
],
"count": 5,
"targetFormat": "snake_case"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/variablenameconverter?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.