Class: Gitignore
- Inherits:
-
Object
- Object
- Gitignore
- Defined in:
- lib/gitignore.rb
Class Method Summary collapse
Class Method Details
.create_gitignore(file_names, overwrite) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gitignore.rb', line 17 def self.create_gitignore (file_names,overwrite) mode = overwrite ? 'w' : 'a' file_name=File.join(".", ".gitignore") File::open(file_name,mode) do |f| file_names.each do |name| f<<"\n##{'*' * 10 } #{name} template#{'*' * 10 } \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" end end return "Successful created" end |
.list_gitignore_files ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gitignore.rb', line 3 def self.list_gitignore_files template_dir=File.join(File.dirname(__FILE__),"gitignore","templates") list_files = Dir.entries(template_dir) list_files.delete('.') list_files.delete('..') list_files.collect{|file| file.gsub(".gitignore","") } end |