Sha256: 0543f660f4a8cfbb8d828a3b67ec185d03a5173f404ac9e52ba562cc04604e94

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'gli'
require 'clenver'
require 'clenver/project'
require 'clenver/logging'
require 'clenver/package_manager'

module Clenver
  class Runner
    include Logging

    def initialize(path, dst)
      @path = path
      @dst = dst
    end

    def start
      if File.exist?(@path)
        begin
          yaml = Psych.load_file("#{@path}")
          logger.debug("yaml: #{yaml}")
          #TODO: create test and fix this place with check for empty file
          p = Project.new(File.basename("#{@path}", ".yml"), yaml, @dst)
          pkgs = ""
          unless yaml['apt'].nil?
            for pkg in yaml['apt'] do
              pkgs = pkgs + " " + pkg + " "
            end
            puts pkgs
            p_mgr = PackageManger.new('apt', pkgs)
            p_mgr.install()
          end
          pkgs = ""
          unless yaml['gem'].nil?
            for pkg in yaml['gem'] do
              pkgs = pkgs + " " + pkg + " "
            end
            puts pkgs
            p_mgr = PackageManger.new('gem', pkgs)
            p_mgr.install()
          end
          p.create_repos
          p.init_project
        rescue Psych::SyntaxError => ex
          exit_now!("#{@path}: syntax error : #{ex.message}", 1)
        end
      else
        exit_now!("#{@path} no such file or directory", 2)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clenver-0.1.13 lib/clenver/runner.rb
clenver-0.1.12 lib/clenver/runner.rb