Sha256: 1659369df30143071fdcf585edc6a41f61f349e4fd6231beb6d6e36935ed2472

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

class Gitignore

	def self.create_gitignore (file_names,overwrite)

		mode = overwrite ? 'w' : 'a'

		#file_name=File.join(File.dirname(__FILE__), ".gitignore") 
		file_name=File.join(".", ".gitignore") 
		#puts file_name
	 
		File::open(file_name,mode) do |f|
		
			file_names.each do |name|

				f<<"\n#########{name}#########\n\n"

				begin

				#puts "Inserting #{name} settings" 

					template_file_name=File.join(File.dirname(__FILE__),"gitignore","templates","#{name}.gitignore") 

					#puts template_file_name

					file_content=File::read(template_file_name)
					f<<file_content unless file_content.nil?
					rescue =>err

						return "Exception: #{err}"
						#err
				end

				f<<"\n#####################\n\n"
			end

		end

		return "Successfull created"

	end

end

#if __FILE__ == $0
  # Do something.. run tests, call a method, etc. We're direct.
#  ignore =Gitignore.new
  #puts ignore.create_gitignore(['Linux','Eclipse','emacs``'],true)
#  puts ignore.create_gitignore(ARGV,false)
#end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitignore-0.0.0 lib/gitignore.rb