copycats 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +180 -0
- data/lib/copycats/data.rb +54 -10
- data/lib/copycats/traits.rb +8 -5
- data/lib/copycats/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a95619e02e3d6db1a9fe343844871ee523ba0a
|
4
|
+
data.tar.gz: 6dacf27f0f458222fc4c149dd070096de742a5d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ba1e1ccfc4df5e04d4e53a6fbf67fdcb2351b19d1c0e7097b19bdca20c9a09993b84f793c5f630d36d3d6f31de6f82cfc863756627a91ffb97c30aba1d378b
|
7
|
+
data.tar.gz: cce891ba518978154083f84c9323e4214b95fb241e3d330dc35c470f02491bc1a998e9e00c8afd2c6099c7f85c821f23f5408b2235398ca82a1f7bb57abfe8dc
|
data/README.md
CHANGED
@@ -12,6 +12,80 @@ copycats command line tool (and core library) - crypto cats / kitties collectibl
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
## Updates
|
16
|
+
|
17
|
+
New Traits / Catttributes:
|
18
|
+
|
19
|
+
### 2018
|
20
|
+
|
21
|
+
March
|
22
|
+
|
23
|
+
- Mar/16: **thunderstruck** - pattern (i)
|
24
|
+
- Mar/16: **rascal** - pattern (3)
|
25
|
+
|
26
|
+
<!-- break -->
|
27
|
+
|
28
|
+
- Mar/14: **dragonfruit** - base color (e)
|
29
|
+
|
30
|
+
<!-- break -->
|
31
|
+
|
32
|
+
- Mar/9: **belch** - mouth (7)
|
33
|
+
|
34
|
+
<!-- break -->
|
35
|
+
|
36
|
+
- Mar/8: **pixiebob** - fur (8)
|
37
|
+
- Mar/8: **poisonberry** - highlight color (4)
|
38
|
+
- Mar/8: **safetyvest** - highlight color (i)
|
39
|
+
|
40
|
+
<!-- break -->
|
41
|
+
|
42
|
+
- Mar/5: **cyan** - eye color (g)
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
February
|
47
|
+
|
48
|
+
- Feb/28: **missmuffet** - accent color (e)
|
49
|
+
- Feb/28: **wiley** - eye shape (f)
|
50
|
+
|
51
|
+
<!-- break -->
|
52
|
+
|
53
|
+
- Feb/23: **dippedcone** - pattern (j)
|
54
|
+
- Feb/23: **leopard** - pattern (5)
|
55
|
+
|
56
|
+
<!-- break -->
|
57
|
+
|
58
|
+
- Feb/20: **harbourfog** - base color (9)
|
59
|
+
|
60
|
+
<!-- break -->
|
61
|
+
|
62
|
+
- Feb/13: **baddate** - eye shape (b)
|
63
|
+
|
64
|
+
<!-- break -->
|
65
|
+
|
66
|
+
- Feb/12: **wuvme** - mouth (3)
|
67
|
+
- Feb/12: **yokel** - mouth (q)
|
68
|
+
- Feb/12: **starstruck** - mouth (i)
|
69
|
+
|
70
|
+
<!-- break -->
|
71
|
+
|
72
|
+
- Feb/9: **egyptiankohl** - highlight color (3)
|
73
|
+
- Feb/9: **bobtail** - fur (6)
|
74
|
+
|
75
|
+
<!-- break -->
|
76
|
+
|
77
|
+
- Feb/6: **tiger** - pattern (2)
|
78
|
+
|
79
|
+
<!-- break -->
|
80
|
+
|
81
|
+
- Feb/2: **birman** - fur (4)
|
82
|
+
- Feb/2: **coralsunrise** - eye color (c)
|
83
|
+
|
84
|
+
(Source: [CryptoKitties Updates](https://updates.cryptokitties.co))
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
15
89
|
## kitty Command Line Tool
|
16
90
|
|
17
91
|
Use the `kitty` command line tool to (auto-)read kitty data records
|
@@ -245,6 +319,107 @@ Table Diagram
|
|
245
319
|

|
246
320
|
|
247
321
|
|
322
|
+
SQL Tables (in SQLite Dialect)
|
323
|
+
|
324
|
+
``` sql
|
325
|
+
CREATE TABLE kitties (
|
326
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT
|
327
|
+
NOT NULL,
|
328
|
+
name VARCHAR,
|
329
|
+
genes_kai VARCHAR NOT NULL,
|
330
|
+
gen INTEGER NOT NULL,
|
331
|
+
birthdate DATETIME NOT NULL,
|
332
|
+
day_count INTEGER NOT NULL,
|
333
|
+
matron_id INTEGER,
|
334
|
+
sire_id INTEGER,
|
335
|
+
body_id INTEGER NOT NULL,
|
336
|
+
pattern_id INTEGER NOT NULL,
|
337
|
+
coloreyes_id INTEGER NOT NULL,
|
338
|
+
eyes_id INTEGER NOT NULL,
|
339
|
+
color1_id INTEGER NOT NULL,
|
340
|
+
color2_id INTEGER NOT NULL,
|
341
|
+
color3_id INTEGER NOT NULL,
|
342
|
+
wild_id INTEGER NOT NULL,
|
343
|
+
mouth_id INTEGER NOT NULL
|
344
|
+
);
|
345
|
+
|
346
|
+
|
347
|
+
CREATE TABLE genes (
|
348
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT
|
349
|
+
NOT NULL,
|
350
|
+
kitty_id INTEGER NOT NULL,
|
351
|
+
n INTEGER NOT NULL,
|
352
|
+
gene VARCHAR NOT NULL,
|
353
|
+
gene_n INTEGER NOT NULL,
|
354
|
+
trait_id INTEGER NOT NULL
|
355
|
+
);
|
356
|
+
|
357
|
+
|
358
|
+
CREATE TABLE traits (
|
359
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT
|
360
|
+
NOT NULL,
|
361
|
+
trait_type_id INTEGER NOT NULL,
|
362
|
+
name VARCHAR NOT NULL,
|
363
|
+
n INTEGER NOT NULL,
|
364
|
+
kai VARCHAR NOT NULL,
|
365
|
+
tier INTEGER
|
366
|
+
);
|
367
|
+
|
368
|
+
CREATE TABLE trait_types (
|
369
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT
|
370
|
+
NOT NULL,
|
371
|
+
name VARCHAR NOT NULL,
|
372
|
+
[key] VARCHAR NOT NULL
|
373
|
+
);
|
374
|
+
|
375
|
+
```
|
376
|
+
|
377
|
+
## Database Setup
|
378
|
+
|
379
|
+
Use the kitty setup command to setup an SQLite database and (auto-)read
|
380
|
+
all datafiles. Example:
|
381
|
+
|
382
|
+
```
|
383
|
+
$ kitty setup
|
384
|
+
```
|
385
|
+
|
386
|
+
This will create:
|
387
|
+
|
388
|
+
- a single-file SQLite database `kitties.db`
|
389
|
+
- setup all tables
|
390
|
+
- add all known traits and trait types (body, pattern, eyes, ...) and
|
391
|
+
- (auto-)read all datafiles (`**/*.csv`) in the `.` and all subdirectories
|
392
|
+
|
393
|
+
|
394
|
+
Note: Use the `-i/--include` option to change the default data directory (that is, `.`)
|
395
|
+
and use the `-n/--dbname` option to change the default SQLite database name (that is, `kitties.db`)
|
396
|
+
and use the `-d/--dbpath` option to change the default SQLite database path (that is, `.`).
|
397
|
+
|
398
|
+
|
399
|
+
Showtime! Use the sqlite3 command line tool
|
400
|
+
and try some queries. Example:
|
401
|
+
|
402
|
+
```
|
403
|
+
$ sqlite3 kitties.db
|
404
|
+
|
405
|
+
sqlite> SELECT * FROM kitties WHERE id = 1;
|
406
|
+
|
407
|
+
1||ccac 7787 fa7f afaa 1646 7755 f9ee 4444 6766 7366 cccc eede|0|2017-11-23 06:19:59|...
|
408
|
+
|
409
|
+
sqlite> SELECT * FROM genes WHERE trait_id = 14; -- sphynx (14)
|
410
|
+
|
411
|
+
1|1|0|d|0|14
|
412
|
+
3|1|2|r2|2|14
|
413
|
+
4|1|3|r3|3|14
|
414
|
+
38|2|1|r1|1|14
|
415
|
+
146|5|1|r1|1|14
|
416
|
+
181|6|0|d|0|14
|
417
|
+
183|6|2|r2|2|14
|
418
|
+
...
|
419
|
+
```
|
420
|
+
|
421
|
+
|
422
|
+
|
248
423
|
## Database Queries
|
249
424
|
|
250
425
|
### SQL
|
@@ -404,6 +579,11 @@ $ gem install copycats
|
|
404
579
|
```
|
405
580
|
|
406
581
|
|
582
|
+
## Questions? Comments?
|
583
|
+
|
584
|
+
Post them on the [cryptokitties reddit](https://www.reddit.com/r/cryptokitties). Thanks.
|
585
|
+
|
586
|
+
|
407
587
|
|
408
588
|
## License
|
409
589
|
|
data/lib/copycats/data.rb
CHANGED
@@ -129,26 +129,70 @@ def read_datafiles( data_dir: './data' )
|
|
129
129
|
kitties = CSV.read( file, headers:true )
|
130
130
|
pp kitties.headers
|
131
131
|
|
132
|
-
##
|
133
|
-
|
132
|
+
## check format
|
133
|
+
if kitties.headers.include?( 'id' ) &&
|
134
|
+
kitties.headers.include?( 'gen' ) &&
|
135
|
+
kitties.headers.include?( 'matron_id' ) &&
|
136
|
+
kitties.headers.include?( 'sire_id' ) &&
|
137
|
+
kitties.headers.include?( 'birthdate' ) &&
|
138
|
+
kitties.headers.include?( 'genes' ) &&
|
139
|
+
kitties.headers.include?( 'name' )
|
140
|
+
## "standard" format
|
141
|
+
## required headers include: id, gen, matron_id, sire_id, birthdate, genes, name
|
142
|
+
headers = {
|
143
|
+
'id' => 'id',
|
144
|
+
'gen' => 'gen',
|
145
|
+
'matron_id' => 'matron_id',
|
146
|
+
'sire_id' => 'sire_id',
|
147
|
+
'birthdate' => 'birthdate',
|
148
|
+
'genes' => 'genes',
|
149
|
+
'name' => 'name'
|
150
|
+
}
|
151
|
+
elsif kitties.headers.include?( 'id' ) &&
|
152
|
+
kitties.headers.include?( 'matron_id' ) &&
|
153
|
+
kitties.headers.include?( 'sire_id' ) &&
|
154
|
+
kitties.headers.include?( 'gen' ) &&
|
155
|
+
kitties.headers.include?( 'birth_date' ) &&
|
156
|
+
kitties.headers.include?( 'genes_kai' )
|
157
|
+
## "kittydex" format
|
158
|
+
## see https://cryptokittydex.com/resources
|
159
|
+
## required headers include: id, matron_id, sire_id, gen, birth_date, genes_kai
|
160
|
+
headers = {
|
161
|
+
'id' => 'id',
|
162
|
+
'matron_id' => 'matron_id',
|
163
|
+
'sire_id' => 'sire_id',
|
164
|
+
'gen' => 'gen',
|
165
|
+
'birthdate' => 'birth_date',
|
166
|
+
'genes' => 'genes_kai',
|
167
|
+
'name' => 'name' ## note: will always be nil (is missing in kittydex)
|
168
|
+
}
|
169
|
+
else
|
170
|
+
## unknown format
|
171
|
+
puts "!!! unknown datafile format; matching headers NOT found / missing"
|
172
|
+
exit 1
|
173
|
+
end
|
174
|
+
|
134
175
|
|
135
176
|
## start of kitties blockchain / genesis
|
136
177
|
genesisdate = Date.new( 2017, 11, 23) ## 2017-11-23
|
137
178
|
|
179
|
+
## note: for now use first 5 rows for testing
|
180
|
+
## kitties[0..4].each do |row|
|
181
|
+
|
138
182
|
kitties.each do |row|
|
139
183
|
## puts row['id'] + '|' + row['gen'] + '|' + row['genes_kai']
|
140
184
|
k = Copycats::Model::Kitty.new
|
141
|
-
k.id = row['id'].to_i
|
142
|
-
k.gen = row['gen'].to_i
|
143
|
-
k.matron_id = row['matron_id'] unless row['matron_id'].blank?
|
144
|
-
k.sire_id = row['sire_id']
|
145
|
-
k.name = row['name']
|
185
|
+
k.id = row[headers['id']].to_i
|
186
|
+
k.gen = row[headers['gen']].to_i
|
187
|
+
k.matron_id = row[headers['matron_id']].to_i unless row[headers['matron_id']].blank? || row[headers['matron_id']] == '0'
|
188
|
+
k.sire_id = row[headers['sire_id']].to_i unless row[headers['sire_id']].blank? || row[headers['sire_id']] == '0'
|
189
|
+
k.name = row[headers['name']] unless row[headers['name']].blank?
|
146
190
|
|
147
|
-
## todo: pretty print (format
|
148
|
-
k.genes_kai = row['genes']
|
191
|
+
## todo: pretty print (format genes !!!!)
|
192
|
+
k.genes_kai = row[headers['genes']] ### .gsub( ' ', '' ) ## remove all spaces - why? why not?
|
149
193
|
|
150
194
|
## pp row['birthdate']
|
151
|
-
birthdate = DateTime.strptime( row['birthdate'], '%Y-%m-%d %H:%M:%S' )
|
195
|
+
birthdate = DateTime.strptime( row[headers['birthdate']], '%Y-%m-%d %H:%M:%S' )
|
152
196
|
k.birthdate = birthdate
|
153
197
|
k.day_count = (birthdate.to_date.jd - genesisdate.jd)+1
|
154
198
|
|
data/lib/copycats/traits.rb
CHANGED
@@ -26,7 +26,7 @@ TRAITS =
|
|
26
26
|
'5' => '',
|
27
27
|
'6' => 'bobtail',
|
28
28
|
'7' => '',
|
29
|
-
'8' => '',
|
29
|
+
'8' => 'pixiebob',
|
30
30
|
'9' => '',
|
31
31
|
'a' => 'cymric',
|
32
32
|
'b' => 'chartreux',
|
@@ -59,7 +59,7 @@ TRAITS =
|
|
59
59
|
kai: {
|
60
60
|
'1' => '',
|
61
61
|
'2' => 'tiger',
|
62
|
-
'3' => '',
|
62
|
+
'3' => 'rascal',
|
63
63
|
'4' => 'ganado',
|
64
64
|
'5' => 'leopard',
|
65
65
|
'6' => 'camo ',
|
@@ -74,7 +74,7 @@ TRAITS =
|
|
74
74
|
'f' => 'totesbasic', ## use totesbasic_f - why? why not?
|
75
75
|
'g' => 'totesbasic', ## use totesbasic_g
|
76
76
|
'h' => '',
|
77
|
-
'i' => '',
|
77
|
+
'i' => 'thunderstruck',
|
78
78
|
'j' => 'dippedcone',
|
79
79
|
'k' => '',
|
80
80
|
'm' => 'tigerpunk',
|
@@ -110,7 +110,7 @@ TRAITS =
|
|
110
110
|
'd' => '',
|
111
111
|
'e' => '',
|
112
112
|
'f' => '',
|
113
|
-
'g' => '',
|
113
|
+
'g' => 'cyan',
|
114
114
|
'h' => 'pumpkin',
|
115
115
|
'i' => 'limegreen',
|
116
116
|
'j' => '',
|
@@ -167,6 +167,7 @@ TRAITS =
|
|
167
167
|
'8' => 'nachocheez',
|
168
168
|
'9' => 'harbourfog',
|
169
169
|
'b' => 'greymatter',
|
170
|
+
'd' => 'dragonfruit',
|
170
171
|
'f' => 'hintomint',
|
171
172
|
'g' => 'bananacream',
|
172
173
|
'h' => 'cloudwhite',
|
@@ -181,6 +182,7 @@ TRAITS =
|
|
181
182
|
name: 'Highlight Color', ## colorsecondary / sec color / pattern color
|
182
183
|
kai: {
|
183
184
|
'3' => 'egyptiankohl',
|
185
|
+
'4' => 'poisonberry',
|
184
186
|
'5' => 'lilac',
|
185
187
|
'6' => 'apricot',
|
186
188
|
'7' => 'royalpurple',
|
@@ -191,6 +193,7 @@ TRAITS =
|
|
191
193
|
'd' => 'coffee',
|
192
194
|
'e' => 'lemonade',
|
193
195
|
'f' => 'chocolate',
|
196
|
+
'i' => 'safetyvest',
|
194
197
|
'j' => 'turtleback',
|
195
198
|
'm' => 'wolfgrey',
|
196
199
|
'n' => 'cerulian',
|
@@ -254,7 +257,7 @@ TRAITS =
|
|
254
257
|
'4' => 'gerbil',
|
255
258
|
'5' => '',
|
256
259
|
'6' => '',
|
257
|
-
'7' => '',
|
260
|
+
'7' => 'belch',
|
258
261
|
'8' => '',
|
259
262
|
'9' => 'beard',
|
260
263
|
'a' => 'pouty',
|
data/lib/copycats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copycats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|