Class: Utils

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

Overview

Getting authentication creds from users

Instance Method Summary collapse

Instance Method Details

#AuthUserObject

Getting creds from user to authenticate upon dyn



55
56
57
58
59
60
61
62
# File 'lib/dyntool.rb', line 55

def AuthUser()
	@creds = []
	@username = ask("Enter your username:  ") { |q| q.echo = true }
	@password = ask("Enter your password:  ") { |q| q.echo = "*" }
	@creds << @username
	@creds << @password
	return(@creds)
end

#SvnChk(uid) ⇒ Object

check if dyn.yaml configuration is same as commited in svn



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/dyntool.rb', line 64

def SvnChk(uid)
	@rep_uid = `svn info | grep "Repository UUID" | awk '{ print $3 }' 2>/dev/null`
	if @rep_uid.chomp != "#{uid}"
		abort("You are not in a directory that checkout to authorized SVN")
	end
	@svn_chk=`svn stat dyn.yml`
	if @svn_chk != ""
		puts "Your dyn.yaml is not identical to the dyn.yml in the svn, or does not exist."
		@q1 = ask("Do you want to see the diffrences? (yes|no)? ") { |q| q.echo = true }
		case @q1 
			when "yes" then
				@diff_output = `svn diff dyn.yml`
				puts @diff_output
				@q2 = ask("Do you want to use the local or svn version? (local|svn)? ") { |q| q.echo = true }
				if @q2 == "local"
					@commit_output = `svn ci dyn.yml -m"Updating dyn.yml file to svn"`
					puts "Checking in and moving forward"
					puts @commit_output
				elsif @q2 == "svn"
					@revert_output = `svn revert dyn.yml; svn up`
					puts "Reverting to svn version and moving forward"
					puts @revert_output
				end
			when "no"
				puts "Please make sure that you local and svn copies are identical"
				exit 2
		end
	end
end