Sha256: ada050a7470ca1ca2d1461247226295d2b5e1bf21553608d203424d3b57b9104

Contents?: true

Size: 542 Bytes

Versions: 5

Compression:

Stored size: 542 Bytes

Contents

#!/usr/bin/env ruby

require 'linodeapi'
require 'yaml'

SPEC_FILE = $ARGV.first || 'dev/spec.yml'

def parse_node(node)
  return clean_node(node) if node[:type] == :call
  Hash[node[:subs].sort.map { |k, v| [k.to_s, parse_node(v)] }]
end

def clean_node(node)
  node.delete(:type)
  hash_to_array(node)
end

def hash_to_array(hash)
  return hash unless hash.is_a? Hash
  hash.to_a.sort.map { |x| Hash[x.first.to_s, hash_to_array(x.last)] }
end

result = parse_node(LinodeAPI.spec)

File.open(SPEC_FILE, 'w') { |fh| fh << YAML.dump(result) }

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
linodeapi-1.0.0 dev/cache_spec.rb
linodeapi-0.2.2 dev/cache_spec.rb
linodeapi-0.2.1 dev/cache_spec.rb
linodeapi-0.2.0 dev/cache_spec.rb
linodeapi-0.1.1 dev/cache_spec.rb