Module: DoStuff::Standalone
Constant Summary collapse
- RUBY_BIN =
if File.executable? '/usr/bin/ruby' '/usr/bin/ruby' else require 'rbconfig' File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] end
- PREAMBLE =
<<-preamble #!#{RUBY_BIN} # # This file is generated code. # Please DO NOT EDIT or send patches for it. # # Please take a look at the source from # https://github.com/tsion/do_stuff # and submit patches against the individual files # that build do_stuff. # preamble
- POSTAMBLE =
"DoStuff::Runner.execute(*ARGV)\n"
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/do_stuff/standalone.rb', line 40 def build root = File.dirname(__FILE__) standalone = '' standalone << PREAMBLE files = Dir["#{root}/*.rb"].sort - [__FILE__] files.each do |file| File.readlines(file).each do |line| standalone << line end end standalone << POSTAMBLE standalone end |
#save(filename) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/do_stuff/standalone.rb', line 32 def save(filename) target = File.(filename) File.open(target, 'w') do |f| f.puts build f.chmod 0755 end end |