lib/CLIntegracon/subject.rb in clintegracon-0.4.1 vs lib/CLIntegracon/subject.rb in clintegracon-0.5.0

- old
+ new

@@ -23,14 +23,15 @@ # should not been passed explicitly every time to the launch method. # Those are added behind the arguments given on +launch+. attr_accessor :default_args # @return [Hash<String,String>] - # The special paths, which are not relative to the project, when the statement - # will be executed. These are paths were side-effects occur, like manipulation + # The replace paths, whose keys are expected to occur in the output, + # which are not printed relative to the project, when the subject will + # be executed. These are e.g. paths were side-effects occur, like manipulation # of user configurations in dot files or caching-specific directories. - attr_accessor :special_paths + attr_accessor :replace_paths # @return [String] # The path where the output of the executable will be written to. attr_accessor :output_path @@ -50,42 +51,44 @@ def initialize(name='subject', executable=nil) self.name = name self.executable = executable || name self.environment_vars = {} self.default_args = [] - self.special_paths = {} + self.replace_paths = {} self.output_path = 'execution_output.txt' end #-----------------------------------------------------------------------------# # @!group DSL-like Setter - # Define a path in the user directory as special path + # Define a path, whose occurrences in the output should been replaced by + # either its basename or a given placeholder. # # @param [String] path # The path # # @param [String] name # The name of the path, or the basename of the given path # - def has_special_path(path, name=nil) + def replace_path(path, name=nil) name ||= File.basename path - self.special_paths[name] = path + self.replace_paths[name] = path end - # Define a path in the user directory as special path + # Define a path in the user directory, whose occurrences in the output + # should been replaced by either its basename or a given placeholder. # # @param [String] path # The path # # @param [String] name # The name of the path, or the basename of the given path # - def has_special_user_path(path, name=nil) - self.has_special_path %r[/Users/.*/#{path.to_s}], name + def replace_user_path(path, name=nil) + self.replace_path %r[/Users/.*/#{path.to_s}], name end #-----------------------------------------------------------------------------# # @!group Interaction @@ -112,10 +115,10 @@ File.open(output_path, 'w') do |file| file.write command.sub(executable, name) file.write "\n" - special_paths.each do |key, path| + replace_paths.each do |key, path| output.gsub!(path, key) end file.write output end