Class: Inspec::Resources::MssqlSession
- Inherits:
-
Object
- Object
- Inspec::Resources::MssqlSession
- Defined in:
- lib/resources/mssql_session.rb
Instance Method Summary collapse
-
#initialize(user = nil, pass = nil) ⇒ MssqlSession
constructor
A new instance of MssqlSession.
- #query(q) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(user = nil, pass = nil) ⇒ MssqlSession
Returns a new instance of MssqlSession.
16 17 18 19 20 |
# File 'lib/resources/mssql_session.rb', line 16 def initialize(user = nil, pass = nil) @user = user @pass = pass skip_resource('user and pass are required for MSSQL tests') if @user.nil? or @pass.nil? end |
Instance Method Details
#query(q) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/resources/mssql_session.rb', line 22 def query(q) escaped_query = q.gsub(/\\/, '\\\\').gsub(/"/, '\\"').gsub(/\$/, '\\$').gsub(/\@/, '`@') cmd = inspec.command("sqlcmd -U #{@user} -P #{@pass} -Q \"#{escaped_query}\"") cmd end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/resources/mssql_session.rb', line 29 def to_s 'MSSQL' end |