diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2022-03-07 14:43:44 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2022-03-07 14:43:44 +0100 |
commit | cbcab8684e06379c9f5c51cfc9cac68d8684fe0c (patch) | |
tree | d03b04e9a7f8e3aae70e590953408f90deed077c /skeletons.rb | |
parent | 721a7ea65d23e7b149ba73968a1d75727a55b390 (diff) | |
download | vim-cbcab8684e06379c9f5c51cfc9cac68d8684fe0c.zip vim-cbcab8684e06379c9f5c51cfc9cac68d8684fe0c.tar.gz |
move to old
Diffstat (limited to 'skeletons.rb')
-rwxr-xr-x | skeletons.rb | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/skeletons.rb b/skeletons.rb deleted file mode 100755 index 55c31aa..0000000 --- a/skeletons.rb +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env ruby -# -# vmirc => au BufNewFile * :exe("0r! ~/.vim/skeletons.rb %:p " . &filetype) -# -require 'erb' -require 'date' - -SKELETON_DIR = File.expand_path("~/.vim/skeletons"); -EXTENSION = "erb" - -filepath, filetype = ARGV -filename = File.basename( filepath ) -extension = File.extname( filename ).split( '.' )[1] - -if filename =~ /\.h$/ then filetype='c_header'; end # otherwise filetype is cpp -if filetype.nil? then filetype = extension; end - -skeleton = [ filename, extension, filetype ].map { |s| File.join( SKELETON_DIR, "#{s}.#{EXTENSION}" ) }.find { |s| File.exist?(s) && File.readable?(s) } - -exit if skeleton.nil? - -@username = ENV['USERNAME'] || 'John Doe' -@email = ENV['EMAIL'] || 'john.doe@nope.com' -@website = ENV['WEBSITE'] || 'http://john.doe.org' -@now = Date.today.strftime("%d/%m/%y") -@year = Date.today.strftime("%Y") -@license_file = ENV['LICENSE'] || nil -@filename = filename -@filename_base = filename.split('.')[0] -@class_name = filename.split('.')[0].capitalize -@project = File.split( File.dirname( filepath ) ).last - -def license comment=nil - return unless @license_file and File.exist? @license_file - return File.new( @license_file ).read if comment.nil? - license = '' - File.new( @license_file ).each_line { |l| license+=comment+l } - license -end - -def header fn - fp = File.join( SKELETON_DIR, fn ) - return unless File.exists? fp - File.open( fp ) { |f| puts ERB.new( f.read, nil, '<>' ).result( binding ) } -end - -File.open( skeleton ) do |f| puts ERB.new( f.read, nil, '<>' ).result( binding ) end |