Class: Specinfra::Backend::PowerShell::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/specinfra/backend/powershell/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Command

Returns a new instance of Command.



6
7
8
9
10
# File 'lib/specinfra/backend/powershell/command.rb', line 6

def initialize &block
  @import_functions = []
  @script = ""
  instance_eval &block if block_given?
end

Instance Attribute Details

#import_functionsObject (readonly)

Returns the value of attribute import_functions.



5
6
7
# File 'lib/specinfra/backend/powershell/command.rb', line 5

def import_functions
  @import_functions
end

#scriptObject (readonly)

Returns the value of attribute script.



5
6
7
# File 'lib/specinfra/backend/powershell/command.rb', line 5

def script
  @script
end

Instance Method Details

#convert_regexp(target) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/specinfra/backend/powershell/command.rb', line 20

def convert_regexp(target)
  case target
  when Regexp
    target.source
  else
    target.to_s.gsub '(^\/|\/$)', ''
  end
end

#exec(code) ⇒ Object



16
17
18
# File 'lib/specinfra/backend/powershell/command.rb', line 16

def exec code
  @script = code
end

#get_identity(id) ⇒ Object



29
30
31
32
# File 'lib/specinfra/backend/powershell/command.rb', line 29

def get_identity id
  raise "You must provide a specific Windows user/group" if id =~ /(owner|group|others)/
  identity = id || 'Everyone'
end

#to_sObject



34
35
36
# File 'lib/specinfra/backend/powershell/command.rb', line 34

def to_s
  @script
end

#using(*functions) ⇒ Object



12
13
14
# File 'lib/specinfra/backend/powershell/command.rb', line 12

def using *functions
  functions.each { |f| import_functions << f }
end