class Object
Public Instance Methods
array_aware_each(&b)
click to toggle source
# File lib/lsl/command/execution.rb, line 17 def array_aware_each(&b) [self].flatten.each(&b) end
blank?()
click to toggle source
# File lib/lsl/ext/ext.rb, line 2 def blank? to_s.strip == '' end
dsl_method(meth,ops={})
click to toggle source
# File lib/lsl/ext/ext.rb, line 42 def dsl_method(meth,ops={}) define_method(meth) do |*args| if args.size > 0 send("#{meth}=",*args) elsif false && b send("#{meth}=",b) else instance_variable_get("@#{meth}") end end attr_writer meth define_method("#{meth}!") do send("#{meth}=",true) end end
dsl_method_arr(meth,ops={},&obj_blk)
click to toggle source
# File lib/lsl/ext/ext.rb, line 57 def dsl_method_arr(meth,ops={},&obj_blk) define_method(meth) do |*args| #puts 'start' send("#{meth}=",[]) unless instance_variable_get("@#{meth}") #puts 'start set' if args.size == 1 instance_variable_get("@#{meth}") << args.first elsif args.size == 2 arg = args[1] arg[:name] = args.first instance_variable_get("@#{meth}") << arg elsif false && b instance_variable_get("@#{meth}") << b else res = instance_variable_get("@#{meth}") res = res.map { |x| obj_blk[x,self] } if obj_blk res end end attr_writer meth end
ec_array(cmd)
click to toggle source
# File lib/lsl/shell.rb, line 9 def ec_array(cmd) `#{cmd}`.output_to_array end
find_child_node2x(node)
click to toggle source
# File lib/lsl/junk.rb, line 22 def find_child_node2x(node) find_child_node(node) end
find_child_nodesxx(node)
click to toggle source
# File lib/lsl/junk.rb, line 8 def find_child_nodesxx(node) return [] unless elements res = [] elements.each do |e| #puts e.inspect if $debug and node.to_s == 'single_command' if e.respond_to?(node) res << e.send(node) else res += e.find_child_nodes(node) end end #return send(node) if respond_to?(node) res end
find_child_nodexx(node)
click to toggle source
# File lib/lsl/junk.rb, line 5 def find_child_nodexx(node) find_child_nodes(node).first end
get_spaced_node(meth)
click to toggle source
# File lib/lsl/ext/ext.rb, line 23 def get_spaced_node(meth) parent = send("spaced_#{meth}") parent.send_if_respond(meth) end
list_values()
click to toggle source
# File lib/lsl/ext/ext.rb, line 30 def list_values elements.map { |x| x.text_value.strip }.map { |x| x.split(" ") }.flatten.map { |x| x.strip }.select { |x| x.present? }.map { |x| x.unquoted } end
load_config!()
click to toggle source
# File lib/lsl.rb, line 31 def load_config! f = ENV['HOME'] + "/.lsl" if FileTest.exist?(f) eval(File.read(f)) end end
present?()
click to toggle source
# File lib/lsl/ext/ext.rb, line 5 def present? !blank? end
quoted()
click to toggle source
# File lib/lsl/ext/ext.rb, line 14 def quoted quoted? ? self : "\"#{self}\"" end
quoted?()
click to toggle source
# File lib/lsl/ext/ext.rb, line 8 def quoted? ((self[0..0]+self[-1..-1]) == '""') end
run_shell!(obj=nil)
click to toggle source
# File lib/lsl/shell.rb, line 139 def run_shell!(obj=nil) s = LSL::Shell.instance s.env = obj if obj s.run_loop end
send_if_respond(meth)
click to toggle source
# File lib/lsl/ext/ext.rb, line 20 def send_if_respond(meth) respond_to?(meth) ? send(meth) : nil end
send_with_expansion(sym,*args,&b)
click to toggle source
# File lib/lsl/command/execution.rb, line 20 def send_with_expansion(sym,*args,&b) return send(sym,&b) if args.empty? res = [] args.each_with_expansion do |a| res << send(sym,*a,&b) end res = res.select { |x| x.present? } if res.size == 1 res = res.first elsif res.empty? res = nil end res end
unquoted()
click to toggle source
# File lib/lsl/ext/ext.rb, line 11 def unquoted quoted? ? self[1..-2] : self end
with_debug() { || ... }
click to toggle source
# File lib/lsl.rb, line 63 def with_debug $debug = true yield ensure $debug = false end