Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make raw results accessible #12

Open
stepnivlk opened this issue Oct 29, 2015 · 1 comment
Open

Make raw results accessible #12

stepnivlk opened this issue Oct 29, 2015 · 1 comment

Comments

@stepnivlk
Copy link

hi,
I'm working on project using Rsync as server and ruby-rsync is accessing this server.
On server there could be many modules and I need to list and parse them.

So I can do something like this:

test = Rsync.run("rsync://domain.domain", "")
=> #<Rsync::Result:0x000000014c3f28
 @exitcode=0,
 @raw="zabbix         \tzabbix config directory)\netc            \tmain config directory\n">

But in Result class, there is no attr_reader fo raw ouput. Also it would be nice to have some parser, which will ouput hash with separated name and comment.
When running this list command, in arguments there should be only source, no destination. I'm suggesting to make destination optional, but I know, it will brake something.

@stepnivlk stepnivlk changed the title make raw results accessible Make raw results accessible Oct 29, 2015
@stepnivlk
Copy link
Author

I quickly wrote this method to Result class:

# Try to parse @raw, when retururned exitcode 0 and @raw isn't "Success".
def list_modules
  if success? && @raw != "Success"
    modules = @raw.split(/[\n,\t]/).each { |m| m.strip! }
    modules = Hash[modules.each_slice(2).to_a]
  else
    return nil
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant