copycats 0.6.1 → 0.7.0
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/Manifest.txt +3 -2
- data/README.md +28 -53
- data/Rakefile +1 -0
- data/lib/copycats.rb +3 -1
- data/lib/copycats/data.rb +5 -1
- data/lib/copycats/fancies.rb +53 -0
- data/lib/copycats/gene.rb +44 -2
- data/lib/copycats/genome.rb +9 -3
- data/lib/copycats/reports/traits.rb +2 -2
- data/lib/copycats/schema.rb +6 -0
- data/lib/copycats/version.rb +2 -2
- data/test/test_genome.rb +0 -6
- data/test/test_models.rb +36 -0
- data/test/{test_base32.rb → test_traits.rb} +19 -29
- data/test/test_version.rb +0 -1
- metadata +19 -4
- data/lib/copycats/base32.rb +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4349c7259a07744027bdfe5c4a1264f1a2a618
|
4
|
+
data.tar.gz: be9e07b7f6537ac7b4e8bd204675ec0b4fcdefbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d3da0f26e104802d8bd35652fe5dc0e0ac6a04c77bedc1c9eb9e46d79c406de244c90e0327ab9ae227eee0c06ce5252287037128397b20d636027630c69801c
|
7
|
+
data.tar.gz: c90601d80f6a2c6e4ab19a6b5b0581a44fba9e906748286cc17cb26bdca80e1771168a40cc9b4c0ea2b74fcd610850d33e2f6ae7a2dfaacb8d48778daa737615
|
data/Manifest.txt
CHANGED
@@ -5,8 +5,8 @@ README.md
|
|
5
5
|
Rakefile
|
6
6
|
bin/kitty
|
7
7
|
lib/copycats.rb
|
8
|
-
lib/copycats/base32.rb
|
9
8
|
lib/copycats/data.rb
|
9
|
+
lib/copycats/fancies.rb
|
10
10
|
lib/copycats/gene.rb
|
11
11
|
lib/copycats/genome.rb
|
12
12
|
lib/copycats/models/kitty.rb
|
@@ -19,7 +19,8 @@ lib/copycats/tool.rb
|
|
19
19
|
lib/copycats/traits.rb
|
20
20
|
lib/copycats/version.rb
|
21
21
|
test/helper.rb
|
22
|
-
test/test_base32.rb
|
23
22
|
test/test_genome.rb
|
24
23
|
test/test_mixgenes.rb
|
24
|
+
test/test_models.rb
|
25
|
+
test/test_traits.rb
|
25
26
|
test/test_version.rb
|
data/README.md
CHANGED
@@ -12,76 +12,51 @@ copycats command line tool (and core library) - crypto cats / kitties collectibl
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
## Updates
|
15
|
+
## Timeline / Updates
|
16
16
|
|
17
|
-
New Traits / Catttributes
|
17
|
+
### New Traits / Catttributes
|
18
18
|
|
19
|
-
|
19
|
+
Mar 21, 2018
|
20
|
+
- **Springcrocus** - highlight color (2) trait is discovered. #Cattribute
|
20
21
|
|
21
|
-
|
22
|
+
Mar 16, 2018
|
23
|
+
- **Thunderstruck** - pattern (i) trait is discovered. #Cattribute
|
24
|
+
- **Rascal** - pattern (3) trait is discovered. #Cattribute
|
22
25
|
|
23
|
-
|
24
|
-
-
|
26
|
+
Mar 14, 2018
|
27
|
+
- **Dragonfruit** - base color (e) trait is discovered. #Cattribute
|
25
28
|
|
26
|
-
|
29
|
+
Mar 9, 2018
|
30
|
+
- **Belch** - mouth (7) trait is discovered. #Cattribute
|
27
31
|
|
28
|
-
|
32
|
+
Mar 8, 2018
|
33
|
+
- **Pixiebob** - fur (8) trait is discovered. #Cattribute
|
34
|
+
- **Poisonberry** - highlight color (4) trait is discovered. #Cattribute
|
35
|
+
- **Safetyvest** - highlight color (i) trait is discovered. #Cattribute
|
29
36
|
|
30
|
-
|
37
|
+
Mar 5, 2018
|
38
|
+
- **Cyan** - eye color (g) trait is discovered. #Cattribute
|
31
39
|
|
32
|
-
- Mar/9: **belch** - mouth (7)
|
33
40
|
|
34
|
-
|
41
|
+
See [Updates - Traits](updates/TRAITS.md) for more.
|
35
42
|
|
36
|
-
- Mar/8: **pixiebob** - fur (8)
|
37
|
-
- Mar/8: **poisonberry** - highlight color (4)
|
38
|
-
- Mar/8: **safetyvest** - highlight color (i)
|
39
43
|
|
40
|
-
|
44
|
+
### New Fancies / Exclusives
|
41
45
|
|
42
|
-
|
46
|
+
Mar 16, 2018
|
47
|
+
- **Berry** (?) Fancy Cat is discovered. #Fancy Cat
|
43
48
|
|
49
|
+
Mar 7, 2018
|
50
|
+
- **Lion Dance** (888) Fancy Cat is discovered. #Fancy Cat
|
44
51
|
|
52
|
+
Mar 2, 2018
|
53
|
+
- **Dogcat** (88) Fancy Cat is discovered. #Fancy Cat
|
45
54
|
|
46
|
-
|
55
|
+
Mar 1, 2018
|
56
|
+
- Exclusive **Knight Kitty** (?) is released. #Fancy Cat #Exclusive
|
47
57
|
|
48
|
-
- Feb/28: **missmuffet** - accent color (e)
|
49
|
-
- Feb/28: **wiley** - eye shape (f)
|
50
58
|
|
51
|
-
|
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))
|
59
|
+
See [Updates - Fancies / Exclusives](updates/FANCIES.md) for more.
|
85
60
|
|
86
61
|
|
87
62
|
|
data/Rakefile
CHANGED
data/lib/copycats.rb
CHANGED
@@ -15,11 +15,13 @@ require 'logger' # note: use for ActiveRecord::Base.logger -- remove/replace
|
|
15
15
|
## 3rd party gems
|
16
16
|
require 'active_record' ## todo: add sqlite3? etc.
|
17
17
|
|
18
|
+
require 'base32-kai' ## base32 / kai encoding / decoding for genes
|
19
|
+
|
18
20
|
|
19
21
|
## our own code
|
20
22
|
require 'copycats/version' # note: let version always go first
|
21
|
-
require 'copycats/base32'
|
22
23
|
require 'copycats/traits'
|
24
|
+
require 'copycats/fancies'
|
23
25
|
require 'copycats/gene'
|
24
26
|
require 'copycats/genome'
|
25
27
|
|
data/lib/copycats/data.rb
CHANGED
@@ -88,7 +88,7 @@ def setup_traits
|
|
88
88
|
name = trait_hash[:kai][kai]
|
89
89
|
name = '?' if name.nil? || name.empty?
|
90
90
|
|
91
|
-
tier =
|
91
|
+
tier = Gene::TIER[kai]
|
92
92
|
|
93
93
|
puts "Kai: #{kai} (#{n}) /#{tier}, Cattribute: #{name}"
|
94
94
|
trait = Copycats::Model::Trait.new
|
@@ -188,6 +188,10 @@ def read_datafiles( data_dir: './data' )
|
|
188
188
|
k.sire_id = row[headers['sire_id']].to_i unless row[headers['sire_id']].blank? || row[headers['sire_id']] == '0'
|
189
189
|
k.name = row[headers['name']] unless row[headers['name']].blank?
|
190
190
|
|
191
|
+
## founder cats - first one hundret (1 to 100 - note: includes genesis (1))
|
192
|
+
k.is_founder = true if k.id >= 1 && k.id <= 100
|
193
|
+
|
194
|
+
|
191
195
|
## todo: pretty print (format genes !!!!)
|
192
196
|
k.genes_kai = row[headers['genes']] ### .gsub( ' ', '' ) ## remove all spaces - why? why not?
|
193
197
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
#
|
5
|
+
# for latest updates on new fancies/exclusives see:
|
6
|
+
# https://updates.cryptokitties.co (official latest updates/timeline)
|
7
|
+
|
8
|
+
|
9
|
+
## todo: add formula: []
|
10
|
+
|
11
|
+
FANCIES =
|
12
|
+
{
|
13
|
+
bugcat: { name: 'Bug Cat', limit: 3, date: '2017-11-23', exclusive: true, ids: [101,102,103] },
|
14
|
+
shipcat: { name: 'Ship Cat', limit: 2_000, date: '2017-11-23' },
|
15
|
+
|
16
|
+
genesis: { name: 'Genesis', limit: 1, date: '2017-11-24', exclusive: true, ids: [1],
|
17
|
+
desc: '1st Kitty' },
|
18
|
+
|
19
|
+
ducat: { name: 'Du Cat', limit: 10_000, date: '2017-11-29' },
|
20
|
+
|
21
|
+
dracula: { name: 'Dracula', limit: 2_000, date: '2017-12-01' },
|
22
|
+
|
23
|
+
mistletoe: { name: 'Mistletoe', limit: 2_000, date: '2017-12-09',
|
24
|
+
desc: "XMas Kitty" },
|
25
|
+
|
26
|
+
santaclaws: { name: 'Santa Claws', limit: 1_000, date: '2017-12-12',
|
27
|
+
desc: 'Ho Ho Ho - Santa Claus Kitty' },
|
28
|
+
|
29
|
+
phuziqaat: { name: 'Phu Ziqaat', limit: 1_000, date: '2017-12-31',
|
30
|
+
desc: 'Alien Kitty' },
|
31
|
+
|
32
|
+
stiches: { name: 'Stiches', limit: 500, date: '2018-01-10',
|
33
|
+
desc: 'Zombie Kitty' },
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
berry: { name: 'Berry', limit: 200 },
|
38
|
+
cathena: { name: 'Cathena', limit: 1, desc: '500 000th Kitty' },
|
39
|
+
dogcat: { name: 'Dog Cat', name_cn: '汪星爷', limit: 88, desc: 'Year of the Dog (Greater China)' },
|
40
|
+
earnie: { name: 'Earnie', limit: 500, desc: 'Earn.com - Golden Kitty Award (Product Hunt)' },
|
41
|
+
fortunecat: { name: 'Fortune Cat', name_cn: '红包喵', limit: 888 },
|
42
|
+
goldendogcat: { name: 'Golden Dog Cat', name_cn: '旺财汪', limit: 11 },
|
43
|
+
goldendragoncat: { name: 'Golden Dragon Cat', name_cn: '帝龙喵', limit: 1, },
|
44
|
+
knightkitty: { name: 'Knight Kitty', limit: 11 },
|
45
|
+
liondance: { name: 'Lion Dance', name_cn: '咚咚锵', limit: 888 },
|
46
|
+
misterpurrfect: { name: 'Mister Purrfect', limit: 1_000, desc: "Valentine's Day" },
|
47
|
+
'momo-chan': { name: 'Momo-chan', limit: 500, desc: 'Ninja Kitty' },
|
48
|
+
negato: { name: 'Negato', limit: 500, desc: 'Ninja Kitty' },
|
49
|
+
pussforprogress: { name: 'Puss For Progress', limit: 1_920, desc: "Women's Day" },
|
50
|
+
tabby: { name: 'Tabby', limit: 250 },
|
51
|
+
yuricatsuki: { name: 'Yuri Catsuki', limit: 250, desc: 'Figure Scating Kitty - Winter Olympics (Korea)' }
|
52
|
+
|
53
|
+
}
|
data/lib/copycats/gene.rb
CHANGED
@@ -43,8 +43,8 @@ class Gene
|
|
43
43
|
def mutate( other )
|
44
44
|
puts "Gene#mutate"
|
45
45
|
|
46
|
-
gene1 =
|
47
|
-
gene2 =
|
46
|
+
gene1 = Kai::NUMBER[d] ## dominant gene1
|
47
|
+
gene2 = Kai::NUMBER[other.d] ## dominant gene2
|
48
48
|
if gene1 > gene2
|
49
49
|
gene1, gene2 = gene2, gene1 ## make sure gene2 is always bigger
|
50
50
|
end
|
@@ -89,4 +89,46 @@ class Gene
|
|
89
89
|
gene
|
90
90
|
end
|
91
91
|
|
92
|
+
|
93
|
+
|
94
|
+
#############################
|
95
|
+
# Tier 1 Tier 2 Tier 3 Tier 4 Tier 5
|
96
|
+
## (1-g) (h-p) (q-t) (u,v) (w)
|
97
|
+
|
98
|
+
### todo/check: move TIER mapping to Genome class or ... - why? why not?
|
99
|
+
TIER = { ## todo/fix: use an algo to calculate - why? why not?
|
100
|
+
'1' => 1,
|
101
|
+
'2' => 1,
|
102
|
+
'3' => 1,
|
103
|
+
'4' => 1,
|
104
|
+
'5' => 1,
|
105
|
+
'6' => 1,
|
106
|
+
'7' => 1,
|
107
|
+
'8' => 1,
|
108
|
+
'9' => 1,
|
109
|
+
'a' => 1,
|
110
|
+
'b' => 1,
|
111
|
+
'c' => 1,
|
112
|
+
'd' => 1,
|
113
|
+
'e' => 1,
|
114
|
+
'f' => 1,
|
115
|
+
'g' => 1,
|
116
|
+
'h' => 2,
|
117
|
+
'i' => 2,
|
118
|
+
'j' => 2,
|
119
|
+
'k' => 2,
|
120
|
+
'm' => 2,
|
121
|
+
'n' => 2,
|
122
|
+
'o' => 2,
|
123
|
+
'p' => 2,
|
124
|
+
'q' => 3,
|
125
|
+
'r' => 3,
|
126
|
+
's' => 3,
|
127
|
+
't' => 3,
|
128
|
+
'u' => 4,
|
129
|
+
'v' => 4,
|
130
|
+
'w' => 5,
|
131
|
+
'x' => nil
|
132
|
+
}
|
133
|
+
|
92
134
|
end # class Gene
|
data/lib/copycats/genome.rb
CHANGED
@@ -60,9 +60,15 @@ class Genome
|
|
60
60
|
sgenes = other.genes ## sire genes
|
61
61
|
new_genes = {}
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
[:body,
|
64
|
+
:pattern,
|
65
|
+
:coloreyes,
|
66
|
+
:eyes,
|
67
|
+
:color1,
|
68
|
+
:color2,
|
69
|
+
:color3,
|
70
|
+
:wild,
|
71
|
+
:mouth].each do |key|
|
66
72
|
mgene = mgenes[key]
|
67
73
|
sgene = sgenes[key]
|
68
74
|
|
@@ -29,7 +29,7 @@ def build
|
|
29
29
|
buf << "\n"
|
30
30
|
|
31
31
|
Kai::ALPHABET.each_char do |kai|
|
32
|
-
tier = ROMAN[
|
32
|
+
tier = ROMAN[ Gene::TIER[kai] ]
|
33
33
|
tier = '?' if tier.nil?
|
34
34
|
buf << "| #{tier} | #{kai} |"
|
35
35
|
TRAITS.values[0,6].each do |trait|
|
@@ -56,7 +56,7 @@ def build
|
|
56
56
|
buf << "\n"
|
57
57
|
|
58
58
|
Kai::ALPHABET.each_char do |kai|
|
59
|
-
tier = ROMAN[
|
59
|
+
tier = ROMAN[ Gene::TIER[kai] ]
|
60
60
|
tier = '?' if tier.nil?
|
61
61
|
buf << "| #{tier} | #{kai} |"
|
62
62
|
TRAITS.values[6,6].each do |trait|
|
data/lib/copycats/schema.rb
CHANGED
@@ -32,6 +32,12 @@ create_table :kitties do |t|
|
|
32
32
|
t.references :matron ## optional references kitty (with matron id)
|
33
33
|
t.references :sire ## optional references kitty (with sire id)
|
34
34
|
|
35
|
+
|
36
|
+
t.boolean :is_fancy, null: false, default: false
|
37
|
+
t.boolean :is_exclusive, null: false, default: false
|
38
|
+
t.boolean :is_founder, null: false, default: false # ids 1 to 100 (in cryptokitties)
|
39
|
+
|
40
|
+
|
35
41
|
## for easy queries add convenience gene-d for all traits
|
36
42
|
t.references :body, null: false ## gene 0 (d)
|
37
43
|
t.references :pattern, null: false ## gene 4 (d)
|
data/lib/copycats/version.rb
CHANGED
data/test/test_genome.rb
CHANGED
data/test/test_models.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_models.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestModels < MiniTest::Test
|
12
|
+
|
13
|
+
|
14
|
+
def test_create
|
15
|
+
## connect to local kitties.db database
|
16
|
+
connect( adapter: 'sqlite3',
|
17
|
+
database: ':memory:' )
|
18
|
+
|
19
|
+
setup_db
|
20
|
+
setup_traits # note: also builds TRAIT_IDS_CACHE for read_datafiles for now
|
21
|
+
|
22
|
+
## print some (record) stats
|
23
|
+
kitty_count = Copycats::Model::Kitty.count
|
24
|
+
gene_count = Copycats::Model::Gene.count
|
25
|
+
trait_count = Copycats::Model::Trait.count
|
26
|
+
|
27
|
+
puts "kitties: #{kitty_count}"
|
28
|
+
puts "genes: #{gene_count}"
|
29
|
+
puts "traits: #{trait_count}"
|
30
|
+
|
31
|
+
assert_equal 0, kitty_count
|
32
|
+
assert_equal 0, gene_count
|
33
|
+
assert_equal 384, trait_count
|
34
|
+
end
|
35
|
+
|
36
|
+
end # class TestModels
|
@@ -2,46 +2,35 @@
|
|
2
2
|
|
3
3
|
###
|
4
4
|
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/
|
5
|
+
# ruby -I ./lib -I ./test test/test_traits.rb
|
6
6
|
|
7
7
|
|
8
8
|
require 'helper'
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class TestTraits < MiniTest::Test
|
12
12
|
|
13
|
+
def test_traits
|
14
|
+
pp TRAITS
|
15
|
+
assert true ## (for now) everything ok if we get here
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
## Kitty #1001
|
17
|
-
## see https://cryptokittydex.com/kitties/1001
|
18
|
-
|
19
|
-
binary = 0b0000000000000000010010100101001010010011000111001110010000001000010111000001010010111101110011100000000101001010000000110001100010000100011010100000110010000000100011000110000000101001010010100110001100010100101000110100101000010010100101011011100111001110 # binary
|
20
|
-
hex = 0x00004a52931ce4085c14bdce014a0318846a0c808c60294a6314a34a_1295_b9ce # hex
|
21
|
-
|
22
|
-
kai = "aaaa 7885 22f2 agff 1661 7755 e979 2441 6667 7664 a9aa cfff".gsub( ' ', '' )
|
17
|
+
## todo: assert number of traits use traits.keys.size !!!
|
18
|
+
end
|
23
19
|
|
24
|
-
|
20
|
+
def test_fancies
|
21
|
+
pp FANCIES
|
22
|
+
assert true ## (for now) everything ok if we get here
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
puts "hex number:"
|
29
|
-
pp hex
|
24
|
+
## todo: assert number of fancies use fancies.keys.size !!!
|
25
|
+
end
|
30
26
|
|
31
|
-
kai2 = Base32.encode( hex )
|
32
|
-
pp kai
|
33
|
-
pp kai2
|
34
27
|
|
35
|
-
|
36
|
-
pp hex2
|
37
|
-
assert_equal hex, hex2
|
38
|
-
assert_equal kai, kai2
|
28
|
+
def test_kai
|
39
29
|
|
30
|
+
## Kitty #1001
|
31
|
+
## see https://cryptokittydex.com/kitties/1001
|
40
32
|
|
41
|
-
|
42
|
-
hex3 = Kai.decode( kai3 )
|
43
|
-
assert_equal hex, hex3
|
44
|
-
assert_equal kai, kai3
|
33
|
+
kai = "aaaa 7885 22f2 agff 1661 7755 e979 2441 6667 7664 a9aa cfff".gsub( ' ', '' )
|
45
34
|
|
46
35
|
puts "kai.length: #{kai.length}" ## 48
|
47
36
|
puts " first: #{kai[0]}"
|
@@ -71,7 +60,8 @@ def test_kai
|
|
71
60
|
puts TRAITS[:color1][color1[1]]
|
72
61
|
puts TRAITS[:color1][color1[2]]
|
73
62
|
puts TRAITS[:color1][color1[3]]
|
74
|
-
end
|
75
63
|
|
64
|
+
assert true
|
65
|
+
end
|
76
66
|
|
77
|
-
end # class
|
67
|
+
end # class TestTraits
|
data/test/test_version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copycats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base32-kai
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activerecord
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,8 +101,8 @@ files:
|
|
87
101
|
- Rakefile
|
88
102
|
- bin/kitty
|
89
103
|
- lib/copycats.rb
|
90
|
-
- lib/copycats/base32.rb
|
91
104
|
- lib/copycats/data.rb
|
105
|
+
- lib/copycats/fancies.rb
|
92
106
|
- lib/copycats/gene.rb
|
93
107
|
- lib/copycats/genome.rb
|
94
108
|
- lib/copycats/models/kitty.rb
|
@@ -101,9 +115,10 @@ files:
|
|
101
115
|
- lib/copycats/traits.rb
|
102
116
|
- lib/copycats/version.rb
|
103
117
|
- test/helper.rb
|
104
|
-
- test/test_base32.rb
|
105
118
|
- test/test_genome.rb
|
106
119
|
- test/test_mixgenes.rb
|
120
|
+
- test/test_models.rb
|
121
|
+
- test/test_traits.rb
|
107
122
|
- test/test_version.rb
|
108
123
|
homepage: https://github.com/openblockchains/copycats
|
109
124
|
licenses:
|
data/lib/copycats/base32.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
class Base32 ## Base32 (2^5 - 5bits)
|
5
|
-
|
6
|
-
# See https://en.wikipedia.org/wiki/Base58
|
7
|
-
ALPHABET = "123456789abcdefghijkmnopqrstuvwx"
|
8
|
-
BASE = ALPHABET.length ## 32 chars/letters/digits
|
9
|
-
|
10
|
-
# Converts a base10 integer to a base32 string.
|
11
|
-
def self.encode( num )
|
12
|
-
buf = String.new
|
13
|
-
while num >= BASE
|
14
|
-
puts "num=#{num}"
|
15
|
-
mod = num % BASE
|
16
|
-
puts " mod=#{mod} == #{ALPHABET[mod]}"
|
17
|
-
buf = ALPHABET[mod] + buf
|
18
|
-
puts "buf=#{buf}"
|
19
|
-
num = (num - mod)/BASE
|
20
|
-
end
|
21
|
-
ALPHABET[num] + buf
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
# Converts a base58 string to a base10 integer.
|
26
|
-
def self.decode( str )
|
27
|
-
num = 0
|
28
|
-
str.reverse.each_char.with_index do |char,index|
|
29
|
-
char_index = ALPHABET.index(char)
|
30
|
-
raise ArgumentError, 'Value passed not a valid Base32 String.' if char_index.nil?
|
31
|
-
num += (char_index)*(BASE**(index))
|
32
|
-
end
|
33
|
-
num
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
## simple hash map (helper) for conversion to binary string
|
38
|
-
BINARY = {
|
39
|
-
'1' => '00000', # 0
|
40
|
-
'2' => '00001', # 1
|
41
|
-
'3' => '00010', # 2
|
42
|
-
'4' => '00011', # 3
|
43
|
-
'5' => '00100', # 4
|
44
|
-
'6' => '00101', # 5
|
45
|
-
'7' => '00110', # 6
|
46
|
-
'8' => '00111', # 7
|
47
|
-
'9' => '01000', # 8
|
48
|
-
'a' => '01001', # 9
|
49
|
-
'b' => '01010', # 10
|
50
|
-
'c' => '01011', # 11
|
51
|
-
'd' => '01100', # 12
|
52
|
-
'e' => '01101', # 13
|
53
|
-
'f' => '01110', # 14
|
54
|
-
'g' => '01111', # 15
|
55
|
-
'h' => '10000', # 16
|
56
|
-
'i' => '10001', # 17
|
57
|
-
'j' => '10010', # 18
|
58
|
-
'k' => '10011', # 19
|
59
|
-
'm' => '10100', # 20
|
60
|
-
'n' => '10101', # 21
|
61
|
-
'o' => '10110', # 22
|
62
|
-
'p' => '10111', # 23
|
63
|
-
'q' => '11000', # 24
|
64
|
-
'r' => '11001', # 25
|
65
|
-
's' => '11010', # 26
|
66
|
-
't' => '11011', # 27
|
67
|
-
'u' => '11100', # 28
|
68
|
-
'v' => '11101', # 29
|
69
|
-
'w' => '11110', # 30
|
70
|
-
'x' => '11111' # 31
|
71
|
-
}
|
72
|
-
|
73
|
-
NUMBER = { ## rename INTEGER /INT - why? why not??
|
74
|
-
'1' => 0,
|
75
|
-
'2' => 1,
|
76
|
-
'3' => 2,
|
77
|
-
'4' => 3,
|
78
|
-
'5' => 4,
|
79
|
-
'6' => 5,
|
80
|
-
'7' => 6,
|
81
|
-
'8' => 7,
|
82
|
-
'9' => 8,
|
83
|
-
'a' => 9,
|
84
|
-
'b' => 10,
|
85
|
-
'c' => 11,
|
86
|
-
'd' => 12,
|
87
|
-
'e' => 13,
|
88
|
-
'f' => 14,
|
89
|
-
'g' => 15,
|
90
|
-
'h' => 16,
|
91
|
-
'i' => 17,
|
92
|
-
'j' => 18,
|
93
|
-
'k' => 19,
|
94
|
-
'm' => 20,
|
95
|
-
'n' => 21,
|
96
|
-
'o' => 22,
|
97
|
-
'p' => 23,
|
98
|
-
'q' => 24,
|
99
|
-
'r' => 25,
|
100
|
-
's' => 26,
|
101
|
-
't' => 27,
|
102
|
-
'u' => 28,
|
103
|
-
'v' => 29,
|
104
|
-
'w' => 30,
|
105
|
-
'x' => 31
|
106
|
-
}
|
107
|
-
|
108
|
-
## add shortcuts (convenience) aliases
|
109
|
-
BIN = BINARY
|
110
|
-
NUM = NUMBER
|
111
|
-
|
112
|
-
|
113
|
-
#############################
|
114
|
-
# Tier 1 Tier 2 Tier 3 Tier 4 Tier 5
|
115
|
-
## (1-g) (h-p) (q-t) (u,v) (w)
|
116
|
-
|
117
|
-
TIER = { ## todo/fix: use an algo to calculate - why? why not?
|
118
|
-
'1' => 1,
|
119
|
-
'2' => 1,
|
120
|
-
'3' => 1,
|
121
|
-
'4' => 1,
|
122
|
-
'5' => 1,
|
123
|
-
'6' => 1,
|
124
|
-
'7' => 1,
|
125
|
-
'8' => 1,
|
126
|
-
'9' => 1,
|
127
|
-
'a' => 1,
|
128
|
-
'b' => 1,
|
129
|
-
'c' => 1,
|
130
|
-
'd' => 1,
|
131
|
-
'e' => 1,
|
132
|
-
'f' => 1,
|
133
|
-
'g' => 1,
|
134
|
-
'h' => 2,
|
135
|
-
'i' => 2,
|
136
|
-
'j' => 2,
|
137
|
-
'k' => 2,
|
138
|
-
'm' => 2,
|
139
|
-
'n' => 2,
|
140
|
-
'o' => 2,
|
141
|
-
'p' => 2,
|
142
|
-
'q' => 3,
|
143
|
-
'r' => 3,
|
144
|
-
's' => 3,
|
145
|
-
't' => 3,
|
146
|
-
'u' => 4,
|
147
|
-
'v' => 4,
|
148
|
-
'w' => 5,
|
149
|
-
'x' => nil
|
150
|
-
}
|
151
|
-
|
152
|
-
end # class Base32
|
153
|
-
|
154
|
-
## add a shortcut (convenience) alias
|
155
|
-
Kai = Base32
|