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
31 32 33 34 35 |
# File 'lib/bixby-client/script_util.rb', line 31 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)
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bixby-client/script_util.rb', line 41 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
58 59 60 61 62 |
# File 'lib/bixby-client/script_util.rb', line 58 def systemu(*args) cmd = Mixlib::ShellOut.new(*args) cmd.run_command cmd end |