Class: Specinfra::Backend::PowerShell::Command
- Inherits:
-
Object
- Object
- Specinfra::Backend::PowerShell::Command
- Defined in:
- lib/specinfra/backend/powershell/command.rb
Instance Attribute Summary collapse
-
#import_functions ⇒ Object
readonly
Returns the value of attribute import_functions.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
- #convert_regexp(target) ⇒ Object
- #exec(code) ⇒ Object
- #get_identity(id) ⇒ Object
-
#initialize(&block) ⇒ Command
constructor
A new instance of Command.
- #to_s ⇒ Object
- #using(*functions) ⇒ Object
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_functions ⇒ Object (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 |
#script ⇒ Object (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_s ⇒ Object
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 |