public
Description: NatsuLiphone - The twitter client for iPhone / iPod touch
Homepage: http://iphone.natsulion.org
Clone URL: git://github.com/takuma104/ntlniph.git
ntlniph / version.rb
100644 39 lines (32 sloc) 0.837 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby -wKU
 
def version(fn)
  str = open(fn){|f| f.read}
  str.scan(/<key>CFBundleVersion<\/key>\s+<string>([\d\.]+)<\/string>/)[0][0]
end
 
def gitcommit
# `git show | head -n 1 | cut -d' ' -f2`.chop
  id = '(unknown)'
  head = open('.git/HEAD'){|f| f.read}
  if head
    fn = head.scan(/^ref:\s(.+)/)[0][0]
    id = open('.git/'+fn){|f| f.read}.chop
  end
  id
end
 
if $0 == __FILE__
  template = './readme.html'
  output = './resources/readme.html'
 
  v = version('./Info.plist')
  begin gc = gitcommit; rescue; gc = ""; end
  url = 'http://github.com/takuma104/ntlniph/commit/' + gc
 
  open(template) do |r|
    open(output,'w') do |w|
      r.each_line do |l|
        l.sub!('<!--VERSION-->', v)
        l.sub!('<!--GITID-->', gc)
        l.sub!('<!--GITHUB_URL-->', url)
        w.puts l
      end
    end
  end
 
end