This vim function turns Ruby arrays of symbols into new-style Ruby hashes where the symbol is the key and the value is the symbol converted to a MixedCase string.
This vim function switches Ruby hashes from the old hash-rocket style to the newer JSONesque style and back. It'll try and guess what the current style is and switch to the other one.
- (surround.vim)[https://github.com/tpope/vim-surround]
- (abolish.vim)[https://github.com/tpope/vim-abolish]
NODE_ORDER = [:employee_details, :employment]
becomes
NODE_ORDER = { employee_details: "EmployeeDetails",
employment: "Employment" }
NODE_ORDER = [
:tax_code,
:taxable_pay,
:benefits_taxed_via_payroll,
:employee_pension_contributions_paid,
:employee_pension_contributions_not_paid,
:student_loan_recovered,
:tax,
:statutory_sick_pay,
:statutory_maternity_pay,
:ordinary_statutory_paternity_pay,
:statutory_adoption_pay,
:additional_statutory_paternity_pay,
:trivial_commutation_payment,
]
becomes
NODE_ORDER = { tax_code: "TaxCode",
taxable_pay: "TaxablePay",
benefits_taxed_via_payroll: "BenefitsTaxedViaPayroll",
employee_pension_contributions_paid: "EmployeePensionContributionsPaid",
employee_pension_contributions_not_paid: "EmployeePensionContributionsNotPaid",
student_loan_recovered: "StudentLoanRecovered",
tax: "Tax",
statutory_sick_pay: "StatutorySickPay",
statutory_maternity_pay: "StatutoryMaternityPay",
ordinary_statutory_paternity_pay: "OrdinaryStatutoryPaternityPay",
statutory_adoption_pay: "StatutoryAdoptionPay",
additional_statutory_paternity_pay: "AdditionalStatutoryPaternityPay",
trivial_commutation_payment: "TrivialCommutationPayment",
}
Should I write a switching version that gives the old hashrocket syntax? 😁