Class: NetLinx::Rake::Workspace::GenerateAPW

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/netlinx/rake/workspace/generate_apw.rb

Overview

Generate .apw workspace file from yaml config.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (GenerateAPW) initialize(name = :generate_apw) {|_self| ... }

Returns a new instance of GenerateAPW

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/netlinx/rake/workspace/generate_apw.rb', line 13

def initialize name = :generate_apw
  @name = name
  yield self if block_given?
  
  desc "Generate .apw workspace file from yaml config."
  
  task(name) do
    require 'netlinx/workspace'
    
    workspace_file = 'workspace.config.yaml'
    
    unless File.exists? workspace_file
      puts "File not found: #{workspace_file}"
      next
    end
    
    NetLinx::Workspace::YAML.parse_file(workspace_file).tap do |workspace|
      return unless workspace.name
      File.open("#{workspace.name.strip}.apw", 'w') do |f|
        f.write workspace.to_xml
      end
    end
  end
end

Instance Attribute Details

- (Object) name

Returns the value of attribute name



11
12
13
# File 'lib/netlinx/rake/workspace/generate_apw.rb', line 11

def name
  @name
end