Module: I3::Standalone
Constant Summary collapse
- PREAMBLE =
<<-preamble #!/usr/bin/env ruby # # This file, i3-ipc, is generated code. # Please DO NOT EDIT or send patches for it. # # Please take a look at the source from # http://github.com/badboy/i3-ipc # and submit patches against the individual files # that build i3-ipc. # preamble
- POSTAMBLE =
"I3::Runner.execute(*ARGV)\n"
- MANPAGE =
"__END__\n#{File.read(__DIR__ + '/../../man/i3-ipc.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 51 52 53 54 55 56 57 |
# File 'lib/i3-ipc/standalone.rb', line 31 def build root = File.dirname(__FILE__) standalone = '' standalone << PREAMBLE file_dir = File.(File.dirname(__FILE__)) exclude_files = %w() exclude_file_list = exclude_files.map { |file| File.join(file_dir, file) } + [File.(__FILE__)] Dir["#{root}/../**/*.rb"].each do |file| # skip standalone.rb next if exclude_file_list.include?(File.(file)) File.readlines(file).each do |line| next if line =~ /^\s*#/ next if line =~ /^require(_relative)? 'i3-ipc/ standalone << line end end standalone << POSTAMBLE standalone << MANPAGE standalone end |
#save(filename, path = '.') ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/i3-ipc/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 |