Module: Bixby::ScriptUtil
Defined Under Namespace
Modules: UseBundle
Instance Method Summary collapse
-
#get_json_input ⇒ Object
Reads JSON data from STDIN.
-
#read_stdin ⇒ String
Read all available data on STDIN without blocking (i.e., if no data is available, none will be returned).
-
#systemu(*args) ⇒ Mixlib::ShellOut
Simple wrapper around Mixlib::ShellOut.
Methods included from UseBundle
Instance Method Details
#get_json_input ⇒ Object
Reads JSON data from STDIN
32 33 34 35 36 |
# File 'lib/bixby-client/script_util.rb', line 32 def get_json_input input = read_stdin() input.strip! if input (input.nil? or input.empty?) ? {} : MultiJson.load(input) end |
#read_stdin ⇒ String
Read all available data on STDIN without blocking (i.e., if no data is available, none will be returned)
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bixby-client/script_util.rb', line 42 def read_stdin buff = [] while true do begin buff << STDIN.read_nonblock(64000) rescue break end end return buff.join('') end |
#systemu(*args) ⇒ Mixlib::ShellOut
Simple wrapper around Mixlib::ShellOut
59 60 61 62 63 |
# File 'lib/bixby-client/script_util.rb', line 59 def systemu(*args) cmd = Mixlib::ShellOut.new(*args) cmd.run_command cmd end |