Class: GemMonitor::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/gem_monitor/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_files_to_gitignoreObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/gem_monitor/install_generator.rb', line 17

def add_files_to_gitignore
  gitignore_content = "./gem_monitor"
  gitignore_file_path = File.join(".gitignore")
  if File.exist? gitignore_file_path
    gitignore_file_content = GemMonitor::Reader.new(file_path: gitignore_file_path).read
    if gitignore_file_content.include? gitignore_content
      puts "Report files are already added to the gitignore file"
    else
      puts "Adding report files to the gitignore file"
      open(gitignore_file_path, "a") do |f|
        f.puts gitignore_content
      end
    end
  end
end

#create_taks_fileObject



7
8
9
10
11
12
13
14
15
# File 'lib/generators/gem_monitor/install_generator.rb', line 7

def create_taks_file
  app_task_path = File.join("lib", "tasks", "gem_monitor.rake")
  if File.exist? app_task_path
    puts "Task file already exists"
  else
    puts "Creating task file"
    FileUtils.cp "#{GemMonitor.root}/lib/gem_monitor/tasks/gem_monitor.rake", app_task_path
  end
end