rakelib/smalltalk-utils.rb
author Jan Vrany <jan.vrany@labware.com>
Wed, 04 Nov 2020 11:10:18 +0000
changeset 310 2cf08578aa5f
parent 137 e665031cade7
permissions -rw-r--r--
Do not ship VDB as part of default build / toy archive The reason is that few people used it and those who did (or will) are those who may want to hack on it. To make this easier when using toy archive, we won't ship VDB in toy archive anymore and instead we'll document on how to install it in VDB's `README.md`

module Rake::StX

  # Simple utility to add records to smalltalk ChangeSet
  class ChangeSet
    def initialize(filename) 
      @filename = filename
    end

    # Evaluates a block for each standard changeset found in
    # given directory (BUILD_DIR usually)
    def self.standardChangesetsDo(root)
      yield(ChangeSet.new(f)) if block_given? if File.exist?(f = root / 'stx' / 'st.chg')
      yield(ChangeSet.new(f)) if block_given? if File.exist?(f = root / 'project' / 'smalltalk' / 'st.chg')
    end

    def addInfoChange(info)
      if unix?
        hostname = `hostname`.chop
        username = ENV['USER']
      else
        hostname = '???'
        username = ENV['USERNAME']
      end
      timestamp = Time.now.strftime("%d-%m-%Y %H:%M:%S")
      file = File.open(@filename, 'a')
      begin
        file.print("'---- #{info} #{username}@#{hostname} #{timestamp} ----'!\n")
      ensure
        file.close
      end
    end

    def addTimestampInfo  # ? why it does not follow ruby's camel case?
      addInfoChange('timestamp')
    end

    def addRakeUpdateInfo
      addInfoChange('rake update')
    end

    def addRakeCompileInfo
      addInfoChange('rake compile')
    end
  end
end