Class: PGit::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/pgit/installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(glob_opts, opts, args) ⇒ Installer

Returns a new instance of Installer.



3
4
5
6
7
8
9
10
11
12
# File 'lib/pgit/installer.rb', line 3

def initialize(glob_opts, opts, args)
  file_path = "~/.pgit.rc.yml"
  @expanded_path = File.expand_path(file_path)

  if File.exists? @expanded_path
    raise "Error: #{file_path} already exists"
  else
    ask_continue
  end
end

Instance Method Details

#ask_continueObject



14
15
16
17
18
19
20
21
22
# File 'lib/pgit/installer.rb', line 14

def ask_continue
  puts  "*** Installing example pgit configuration file under ~/.pgit.rc.yml. Continue? [Y/n]"
  if STDIN.gets.chomp.match(/y/i)
    puts "Saving example pgit config in ~/.pgit.rc.yml..."
    write_example_pgit_rc_file
  else
    puts "Aborting installation..."
  end
end

#write_example_pgit_rc_fileObject



24
25
26
27
28
29
30
# File 'lib/pgit/installer.rb', line 24

def write_example_pgit_rc_file
  File.open(@expanded_path, 'w') do |f|
    YAML.dump(PGit::Configuration.default_options, f)
  end

  puts "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
end