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



101
102
103
104
105
106
107
108
# File 'lib/dyntool.rb', line 101

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



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dyntool.rb', line 110

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