SitedogParser
A library for parsing and classifying web services from YAML files into structured Ruby objects.
Installation
gem 'sitedog_parser'
Usage
Basic Usage
require 'sitedog_parser'
parsed_data = SitedogParser::Parser.parse_file('data.yml')
domain_services = parsed_data['example.com']
if domain_services[:hosting]
puts "Hosting: #{domain_services[:hosting].first.service}"
puts "URL: #{domain_services[:hosting].first.url}"
end
Simple Fields
You can specify which fields should be treated as simple values:
simple_fields = [:project, :role, :environment, :registry]
parsed_data = SitedogParser::Parser.parse(yaml_data, simple_fields: simple_fields)
production_domains = SitedogParser::Parser.get_domains_by_field_value(parsed_data, :environment, 'production')
Export to JSON
json_data = SitedogParser::Parser.to_json('services.yml')
JSON Structure Example
{
"example.com": {
"hosting": [{"service":"Amazon Web Services","url":"https://aws.amazon.com"}],
"dns": [{"service":"Cloudflare","url":"https://cloudflare.com"}],
"registrar": [{"service":"Namecheap","url":"https://namecheap.com"}]
}
}
Service Object
service.service
service.url
service.children
Supported Data Formats
The library handles various data formats:
- URL strings:
"https://github.com/username/repo"
→ GitHub service
- Service names:
"GitHub"
→ GitHub service with URL
- Hashes with service and URL:
{service: "Github", url: "https://github.com/repo"}
- Nested hashes with service types
- Hashes with URLs as values
Dictionary Analysis
candidates = SitedogParser::DictionaryAnalyzer.find_dictionary_candidates(parsed_data)
report = SitedogParser::DictionaryAnalyzer.report(parsed_data)
Command Line Options
$ sitedog_cli --help
Usage: sitedog_cli [options] <path_to_yaml_file> [output_file]
-d, --debug Enable debug output
-c, --compact Compact JSON without formatting
-C, --compact-children Formatted JSON with compact inner objects
-q, --quiet Suppress non-error messages
-h, --help Show this help message
License
MIT