Last active
January 16, 2020 03:13
-
-
Save matthewtrask/cf98d35e000002b0140493ba7fb4ce55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Apimatic Transformer | |
category: converters | |
language: SaaS | |
description: Transform API Descriptions to and from RAML, API Blueprint, OAI v2/v3, WSDL, etc. | |
link: https://apimatic.io/transformer | |
v2: true | |
v3: true | |
- name: Google Gnostic | |
category: converters | |
github: https://github.com/googleapis/gnostic | |
language: Go | |
description: Compile OpenAPI descriptions into equivalent Protocol Buffer representations | |
v2: true | |
v3: true | |
{"name"=>"Apimatic Transformer", "category"=>"converters", "language"=>"SaaS", "description"=>"Transform API Descriptions to and from RAML, API Blueprint, OAI v2/v3, WSDL, etc.", "link"=>"https://apimatic.io/transformer", "v2"=>true, "v3"=>true} | |
{"name"=>"Google Gnostic", "category"=>"converters", "github"=>"https://github.com/googleapis/gnostic", "language"=>"Go", "description"=>"Compile OpenAPI descriptions into equivalent Protocol Buffer representations", "v2"=>true, "v3"=>true} | |
Trying to add a new key "key" and a value. | |
I know about the YAML lib and looping, but I dont know how ot manipulate an array of hashes. | |
What I currently have: | |
```ruby | |
#!/usr/bin/env ruby | |
require 'yaml' | |
yaml_string = File.read "./_data/tools.yml" | |
tools = YAML.load yaml_string | |
tools.map do |tool| | |
tool.store("key", tool["name"].downcase) | |
end | |
File.open("./_data/tools.yml", "w") {|file| file.write(tools) } | |
``` |
@itszaga.. I updated the gist and what I have works in that it adds the key and value. Like I mentioned in the tweet, its writing to the file with the hash, instead of yaml, so im trying to figure that one out.
Change your last line to File.open("./_data/tools.yml", "w") { |file| file.write(tools.to_yaml) }
@itszaga yooo that worked! Thank you so much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll need to do something like this:
See: https://repl.it/repls/WirelessJubilantDecimal