Sha256: 85bcab9d6c110ccae97af1f10989a420bed54a6c6ccf2158b7d138813901df06
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
class GitignoreManager def initialize(gitignore_path = '.gitignore') @gitignore_path = gitignore_path.end_with?('.gitignore') ? gitignore_path : File.join(gitignore_path, '.gitignore') create_gitignore_if_not_exists end def self.ignore_redundant_files GitignoreManager.new(FilePath.project_root) .add_items([ "# Generated by Solara. Ignore redundant brand specific changes.", "**/artifacts/", "**/Artifacts/", "solara/brands/current_app.json", "solara/.solara/aliases/", "solara/.solara/solara_settings.json", ]) end def add_items(items) items.each do |item| add_item(item) end end def add_item(item) existing_items = read_gitignore if existing_items.include?(item) Solara.logger.debug("'#{item}' already exists in .gitignore") else File.open(@gitignore_path, 'a') do |file| file.puts(item) end Solara.logger.debug("Added '#{item}' to .gitignore") end end private def create_gitignore_if_not_exists unless File.exist?(@gitignore_path) File.open(@gitignore_path, 'w') do |file| file.puts("# Generated by Solara") file.puts("# Git ignore file") file.puts("# Add items to ignore below") end Solara.logger.debug("Created new .gitignore file at #{@gitignore_path}") end end def read_gitignore File.readlines(@gitignore_path).map(&:chomp) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solara-0.2.0 | solara/lib/core/scripts/gitignore_manager.rb |
solara-0.1.0 | solara/lib/core/scripts/gitignore_manager.rb |