Skip to content

Instantly share code, notes, and snippets.

/sample.rb Secret

Created June 8, 2016 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0782eff1fb232480adbff584230b0a17 to your computer and use it in GitHub Desktop.
Save anonymous/0782eff1fb232480adbff584230b0a17 to your computer and use it in GitHub Desktop.
yaml help
Sample.yml:
accounts:
- domain: CONTOSO
username: Administrator
description: Some user
- domain: CONTSO
usernane: Joe
description: Some admin
Sample.rb:
#!/usr/bin/env ruby
require 'yaml'
config = YAML.load_file("Sample.yaml")
accounts = config["accounts"]
test = {"domain"=>"CONTOSO", "username"=>"Administrator", "description"=>"Some user"}
puts(accounts.include? test)
<<exports true>
Is there a less sloppy way of testing for this without having to type the keyvalues in such an ugly way?
I need some crafty way of checking if a specific user exists in this sample list without overly complicating a search?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment