Module: Hub::Standalone
Constant Summary collapse
- PREAMBLE =
<<-preamble #!/usr/bin/env ruby # # This file, hub, is generated code. # Please DO NOT EDIT or send patches for it. # # Please take a look at the source from # http://github.com/defunkt/hub # and submit patches against the individual files # that build hub. # preamble
- POSTAMBLE =
"Hub::Runner.execute(*ARGV)\n"
- MANPAGE =
"__END__\n#{File.read(__DIR__ + '/../../man/hub.1')}"
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hub/standalone.rb', line 31 def build root = File.dirname(__FILE__) standalone = '' standalone << PREAMBLE Dir["#{root}/*.rb"].each do |file| # skip standalone.rb next if file == __FILE__ File.readlines(file).each do |line| next if line =~ /^\s*#/ standalone << line end end standalone << POSTAMBLE standalone << MANPAGE standalone end |
#save(filename, path = '.') ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hub/standalone.rb', line 23 def save(filename, path = '.') target = File.join(File.(path), filename) File.open(target, 'w') do |f| f.puts build f.chmod 0755 end end |