Module: Gluez
- Defined in:
- lib/gluez.rb,
lib/gluez/context.rb,
lib/gluez/resource.rb
Defined Under Namespace
Modules: Resources Classes: Context, Resource
Class Method Summary collapse
- .args ⇒ Object
-
.format(lines) ⇒ Object
Takes an array of bash code lines and returns it as a nicely formatted string.
- .options ⇒ Object
Class Method Details
.args ⇒ Object
24 25 26 |
# File 'lib/gluez.rb', line 24 def self.args() ARGV.select{|a| !(a =~ /^-/)} end |
.format(lines) ⇒ Object
Takes an array of bash code lines and returns it as a nicely formatted string.
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 58 59 |
# File 'lib/gluez.rb', line 33 def self.format(lines) indent = 0 num_line = 0 prev_line = nil lines.split("\n").collect do |line| num_line += 1 begin line = line.strip indent -= 2 if ['}', 'fi', 'else'].include?(line) l = (' ' * indent) + line indent += 2 if [/^function /, /^if /, /^else/].any?{|e| line =~ e} indent -= 2 if line.index('cat >~/.gluez_transfer <<\DATA') indent += 2 if line == 'DATA"' prev_line = line l rescue Exception => e puts "error on line: #{num_line}" raise e end end.join("\n") end |
.options ⇒ Object
28 29 30 |
# File 'lib/gluez.rb', line 28 def self.() ARGV.select{|a| a =~ /^-/} end |