-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_api.rb
54 lines (40 loc) · 1.6 KB
/
generate_api.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'cocos'
specs = read_csv( "./punks24px.csv" )
=begin
{"name":"#0",
"image":"https://live---metadata-5covpqijaa-uc.a.run.app/images/0",
"external_url":"https://www.proof.xyz/moonbirds/0",
"attributes":[
{"trait_type":"Eyes","value":"Angry"},
{"trait_type":"Outerwear","value":"Hoodie Down"},
{"trait_type":"Body","value":"Tabby"},
{"trait_type":"Feathers","value":"Gray"},
{"trait_type":"Background","value":"Green"},
{"trait_type":"Beak","value":"Small"}]
}
=end
specs.each_with_index do |rec, i|
# break if i > 10
print "."
print i if i % 100 == 0
base = rec['type']
attributes = (rec['attributes'] || '' ).split( '/').map { |attr| attr.strip }
item_attributes = []
item_attributes << { 'trait_type' => 'type',
'value' => base }
attributes.each do |attr| ## change name to attribute (from accessory)
item_attributes << { 'trait_type' => 'attribute',
'value' => attr }
end
item_attributes << { 'trait_type' => 'attribute count',
'value' => attributes.size.to_s } ## number (type) possible?
num = "%04d" % i
# puts "==> punk #{num}"
item = {
'name' => "Punk 24px \##{i}",
'image' => "https://github.com/0xCompute/punks24px/raw/master/i/punk#{num}.png",
'attributes' => item_attributes
}
write_json( "./metadata/#{i}", item )
end
puts "bye"