Created
February 18, 2011 17:03
-
-
Save timruffles/833995 to your computer and use it in GitHub Desktop.
a little Textmate command to take a lot of typing out of require.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pathname' | |
proj_dir = Pathname.new(ENV['TM_PROJECT_DIRECTORY']) | |
file_path = Pathname.new(ENV['TM_FILEPATH']) | |
path = file_path.relative_path_from(proj_dir).to_s | |
module_name = path.gsub(/\.js$/,'') | |
class_name = (module_name.split('/').last.capitalize.gsub(/_(\w)/) {|str| $1.upcase}) | |
puts "define('#{module_name}',[],function() { | |
var #{class_name} = function() { | |
$1 | |
} | |
#{class_name}.prototype = { | |
} | |
return #{class_name} | |
})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment