Module: GitTracker::Standalone

Extended by:
Standalone
Included in:
Standalone
Defined in:
lib/git_tracker/standalone.rb

Constant Summary collapse

GIT_TRACKER_ROOT =
File.expand_path('../../..', __FILE__)
PREAMBLE =
<<-preamble
#
# This file is generated code. DO NOT send patches for it.
#
# Original source files with comments are at:
# https://github.com/stevenharman/git_tracker
#

preamble

Instance Method Summary collapse

Instance Method Details

#build(io) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/git_tracker/standalone.rb', line 24

def build(io)
  io.puts "#!#{ruby_executable}"
  io << PREAMBLE

  each_source_file do |filename|
    File.open(filename, 'r') do |source|
      inline_source(source, io)
    end
  end

  io.puts 'GitTracker::Runner.execute(*ARGV)'
  io
end

#ruby_executableObject



38
39
40
41
42
43
44
# File 'lib/git_tracker/standalone.rb', line 38

def ruby_executable
  if File.executable? '/usr/bin/ruby' then '/usr/bin/ruby'
  else
    require 'rbconfig'
    File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
  end
end

#save(filename, path = '.') ⇒ Object



16
17
18
19
20
21
22
# File 'lib/git_tracker/standalone.rb', line 16

def save(filename, path = '.')
  dest = File.join(File.expand_path(path), filename)
  File.open(dest, 'w') do |f|
    build(f)
    f.chmod(0755)
  end
end