Sha256: 4304f30f172b4665696bf3868e87728896a99a0792c2b135b76adb3995ec1aa8

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'rake'
require 'rake/tasklib'

module NetLinx
  module Rake
    module Workspace
      
      # Generate .apw workspace file from yaml config.
      class GenerateAPW < ::Rake::TaskLib
        
        attr_accessor :name
        
        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
        
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
netlinx-workspace-1.2.1 lib/netlinx/rake/workspace/generate_apw.rb
netlinx-workspace-1.2.0 lib/netlinx/rake/workspace/generate_apw.rb
netlinx-workspace-1.1.0 lib/netlinx/rake/workspace/generate_apw.rb
netlinx-workspace-1.0.0 lib/netlinx/rake/workspace/generate_apw.rb