<commit_before>#
# omnibus software dsl reader
#

require 'digest/md5'
require 'mixlib/shellout'
require 'net/ftp'
require 'net/http'
require 'net/https'
require 'uri'

require 'omnibus/fetcher'
require 'omnibus/builder'
require 'omnibus/config'

module Omnibus
  class Software
    include Rake::DSL

    NULL_ARG = Object.new

    attr_reader :description
    attr_reader :dependencies

    def initialize(io)
      @version        = nil
      @name           = nil
      @description    = nil
      @source         = nil
      @relative_path  = nil
      @source_uri     = nil

      @builder = NullBuilder.new(self)

      @dependencies = ["preparation"]
      instance_eval(io)
      render_tasks
    end

    def name(val=NULL_ARG)
      @name = val unless val.equal?(NULL_ARG)
      @name
    end

    def description(val)
      @description = val
    end

    def dependencies(deps)
      deps.each do |dep|
        @dependencies << dep
      end
    end

    def source(val=NULL_ARG)
      @source = val unless val.equal?(NULL_ARG)
      @source
    end

    def version(val=NULL_ARG)
      @version = val unless val.equal?(NULL_ARG)
      @version
    end

    def relative_path(val)
      @relative_path = val
    end

    def source_uri
      @source_uri ||= URI(@source[:url])
    end

    def checksum
      @source[:md5]
    end

    def config
      Omnibus.config
    end

    def source_dir
      config.source_dir
    end

    def cache_dir
      config.cache_dir
    end

    def build_dir
      config.build_dir
    end

    def install_dir
      config.install_dir
    end

    def project_file
      filename = source_uri.path.split('/').last
      "#{cache_dir}/#{filename}"
    end

    def project_dir
      @relative_path ? "#{source_dir}/#{@relative_path}" : "#{source_dir}/#{@name}"
    end

    def manifest_file
      self.class.manifest_file_from_name(@name)
    end

    def self.manifest_file_from_name(software_name)
      "#{Omnibus.config.build_dir}/#{software_name}.manifest"
    end

    def build(&block)
      @builder = Builder.new(self, &block)
    end

    def platform
      OHAI.platform
    end

    private

    def command(*args)
      raise "Method Moved."
    end

    def render_tasks
      namespace :software do

        #
        # set up inter-project dependencies
        #
        (@dependencies - [@name]).uniq.each do |dep|
          task @name => dep
          file manifest_file => self.class.manifest_file_from_name(dep)
        end

        namespace @name do
<commit_msg>make install-dir-specific build manifests<commit_after>#
# omnibus software dsl reader
#

require 'digest/md5'
require 'mixlib/shellout'
require 'net/ftp'
require 'net/http'
require 'net/https'
require 'uri'

require 'omnibus/fetcher'
require 'omnibus/builder'
require 'omnibus/config'

module Omnibus
  class Software
    include Rake::DSL

    NULL_ARG = Object.new

    attr_reader :description
    attr_reader :dependencies

    def initialize(io)
      @version        = nil
      @name           = nil
      @description    = nil
      @source         = nil
      @relative_path  = nil
      @source_uri     = nil

      @builder = NullBuilder.new(self)

      @dependencies = ["preparation"]
      instance_eval(io)
      render_tasks
    end

    def name(val=NULL_ARG)
      @name = val unless val.equal?(NULL_ARG)
      @name
    end

    def description(val)
      @description = val
    end

    def dependencies(deps)
      deps.each do |dep|
        @dependencies << dep
      end
    end

    def source(val=NULL_ARG)
      @source = val unless val.equal?(NULL_ARG)
      @source
    end

    def version(val=NULL_ARG)
      @version = val unless val.equal?(NULL_ARG)
      @version
    end

    def relative_path(val)
      @relative_path = val
    end

    def source_uri
      @source_uri ||= URI(@source[:url])
    end

    def checksum
      @source[:md5]
    end

    def config
      Omnibus.config
    end

    def source_dir
      config.source_dir
    end

    def cache_dir
      config.cache_dir
    end

    def build_dir
      "#{config.build_dir}/#{camel_case_path(install_dir)}"
    end

    def install_dir
      config.install_dir
    end

    def project_file
      filename = source_uri.path.split('/').last
      "#{cache_dir}/#{filename}"
    end

    def project_dir
      @relative_path ? "#{source_dir}/#{@relative_path}" : "#{source_dir}/#{@name}"
    end

    def manifest_file
      manifest_file_from_name(@name)
    end

    def manifest_file_from_name(software_name)
      "#{build_dir}/#{software_name}.manifest"
    end

    def camel_case_path(path)
      # split the path and remove and empty strings
      parts = path.split("/") - [""]
      parts.join("_")
    end

    def build(&block)
      @builder = Builder.new(self, &block)
    end

    def platform
      OHAI.platform
    end

    private

    def command(*args)
      raise "Method Moved."
    end

    def render_tasks
      namespace :software do

        #
        # set up inter-project dependencies
        #
        (@dependencies - [@name]).uniq.each do |dep|
          task @name => dep
          file manifest_file => manifest_file_from_name(dep)
        end

        namespace @name do

{'fraction_non_alphanumeric': 0.09418493803622498, 'fraction_numerical': 0.0007626310772163965, 'mean_word_length': 2.146970605878824, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5250919', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1638, 'n_words': 393}