Sha256: 9d504c94f8896cd7946f8975a7cec9f0cbe43713f2a254671e10879c459d9698

Contents?: true

Size: 920 Bytes

Versions: 2

Compression:

Stored size: 920 Bytes

Contents

module PGit
  class Installer
    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

    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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pgit-0.0.3 lib/pgit/installer.rb
pgit-0.0.2 lib/pgit/installer.rb