Sha256: 9505a89831dff52223bfd49fdc395937409c17ac437485e59ed07b136547c0d3
Contents?: true
Size: 614 Bytes
Versions: 7
Compression:
Stored size: 614 Bytes
Contents
require 'json' types = JSON.load File.read 'types.json' ans = types.map { |type, fields| max_length = fields.keys.map(&:length).max # haskell (ry # <<~EOF # data #{type} = { # #{fields.map { |field, attr| # "#{"%-#{max_length}s" % field} :: #{attr['type'].inspect.delete('"')}" # }.join("\n ")} # } # EOF <<~EOF #{type} #{fields.map { |field, attr| "#{attr['optional'] ? ' ' : '*'} #{"%-#{max_length}s" % field} #{attr['type'].inspect.delete('"')}" }.join("\n ")} EOF }.join("\n") open 'types.txt', 'w' do |f| f.write ans end
Version data entries
7 entries across 7 versions & 1 rubygems