rakelib/smalltalk-utils.rb
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 22 Sep 2018 00:00:27 +0100
changeset 257 c6a3ceed613c
parent 137 e665031cade7
permissions -rw-r--r--
`stmkmf`: fix incorrect `TOP` test when using `-C / `--cd` When testing for `TOP` existence when `-C` / `--cd` is specified, must test it relative to `-C` / `--cd` value, not relative to current directory!

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