Class: Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/is/build.rb

Instance Method Summary collapse

Instance Method Details

#mkbuild(prefix = '') ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/is/build.rb', line 27

def mkbuild prefix = ''
  @spec = caller[0].split(':')[0]
  file = "./.#{name}.vers"
  if File.exists? file
    data = File.read(file)
    vers = sandbox { eval(data) }
  else
    vers = {}
  end
  hash = mkhash
  vx = version.to_s + '.' + prefix
  if vers[vx]
    current = vers[vx]
    if current[:hash] != hash
      current[:build] += 1
      current[:hash] = hash
    end
  else
    current = { :hash => hash, :build => 0 }
  end
  vers[vx] = current
  File.open file, 'w' do |f|
    f.puts vers.inspect
  end
  if current[:build] && (current[:build] != 0 || prefix != '')
    self.version = vx + current[:build].to_s
  end
end

#mkhashObject



19
20
21
22
23
24
25
# File 'lib/is/build.rb', line 19

def mkhash
  s = File.read @spec
  files.each do |f|
    s += File.read f
  end
  Digest::SHA1.hexdigest s
end