Skip to content

Commit

Permalink
spec_ruby_to_javascript: added proper lowerCamelCase conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyCat committed Aug 18, 2016
1 parent 35b7263 commit de8abf9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec_ruby_to_javascript
Expand Up @@ -18,6 +18,16 @@ s.gsub!(/^\s*r = (.*?)\.from_file\('(.*?)'\)$/) {

s = s[2..-1] if s[0..1] == "\n\n"

# under_score_case => lowerCamelCase
s.gsub!(/\.([a-zA-Z0-9_]+)/) {
arg = $1
w = arg.split(/_/)
first = w.shift
w.map! { |x| x.capitalize }
w.unshift(first)
".#{w.join}"
}

s.gsub!(/expect\((.*?)\)\.to eq\(? *(.*?)\)?$/, 'assert.equal(\1, \2);')
s.gsub!(/^ /, '')
s.gsub!(/^\s*end\n/, '')
Expand Down

0 comments on commit de8abf9

Please sign in to comment.