kittyverse 0.5.0 → 1.0.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.
data/test/test_traits.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  ###
4
2
  # to run use
5
3
  # ruby -I ./lib -I ./test test/test_traits.rb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kittyverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-10 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base32-alphabets
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '3.18'
53
+ version: '3.22'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.18'
60
+ version: '3.22'
61
61
  description: kittyverse - helper classes for cattributes, trait types, traits, genes,
62
62
  genomes and more for cryptokitties and copycats
63
63
  email: wwwmake@googlegroups.com
@@ -65,22 +65,20 @@ executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files:
67
67
  - CHANGELOG.md
68
- - LICENSE.md
69
68
  - Manifest.txt
70
69
  - README.md
71
70
  files:
72
71
  - CHANGELOG.md
73
- - LICENSE.md
74
72
  - Manifest.txt
75
73
  - README.md
76
74
  - Rakefile
77
75
  - lib/kittyverse.rb
78
- - lib/kittyverse/api/client.rb
79
- - lib/kittyverse/api/versions.rb
80
76
  - lib/kittyverse/cattributes.rb
81
77
  - lib/kittyverse/config/colors.rb
78
+ - lib/kittyverse/config/exclusives.rb
82
79
  - lib/kittyverse/config/fancies.rb
83
80
  - lib/kittyverse/config/purrstiges.rb
81
+ - lib/kittyverse/config/special_editions.rb
84
82
  - lib/kittyverse/config/traits.rb
85
83
  - lib/kittyverse/config/traits_timeline.rb
86
84
  - lib/kittyverse/fancies.rb
@@ -101,7 +99,7 @@ homepage: https://github.com/cryptocopycats/kittyverse
101
99
  licenses:
102
100
  - Public Domain
103
101
  metadata: {}
104
- post_install_message:
102
+ post_install_message:
105
103
  rdoc_options:
106
104
  - "--main"
107
105
  - README.md
@@ -118,9 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
116
  - !ruby/object:Gem::Version
119
117
  version: '0'
120
118
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.5.2
123
- signing_key:
119
+ rubygems_version: 3.1.4
120
+ signing_key:
124
121
  specification_version: 4
125
122
  summary: kittyverse - helper classes for cattributes, trait types, traits, genes,
126
123
  genomes and more for cryptokitties and copycats
data/LICENSE.md DELETED
@@ -1,116 +0,0 @@
1
- CC0 1.0 Universal
2
-
3
- Statement of Purpose
4
-
5
- The laws of most jurisdictions throughout the world automatically confer
6
- exclusive Copyright and Related Rights (defined below) upon the creator and
7
- subsequent owner(s) (each and all, an "owner") of an original work of
8
- authorship and/or a database (each, a "Work").
9
-
10
- Certain owners wish to permanently relinquish those rights to a Work for the
11
- purpose of contributing to a commons of creative, cultural and scientific
12
- works ("Commons") that the public can reliably and without fear of later
13
- claims of infringement build upon, modify, incorporate in other works, reuse
14
- and redistribute as freely as possible in any form whatsoever and for any
15
- purposes, including without limitation commercial purposes. These owners may
16
- contribute to the Commons to promote the ideal of a free culture and the
17
- further production of creative, cultural and scientific works, or to gain
18
- reputation or greater distribution for their Work in part through the use and
19
- efforts of others.
20
-
21
- For these and/or other purposes and motivations, and without any expectation
22
- of additional consideration or compensation, the person associating CC0 with a
23
- Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
- and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
- and publicly distribute the Work under its terms, with knowledge of his or her
26
- Copyright and Related Rights in the Work and the meaning and intended legal
27
- effect of CC0 on those rights.
28
-
29
- 1. Copyright and Related Rights. A Work made available under CC0 may be
30
- protected by copyright and related or neighboring rights ("Copyright and
31
- Related Rights"). Copyright and Related Rights include, but are not limited
32
- to, the following:
33
-
34
- i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
- and translate a Work;
36
-
37
- ii. moral rights retained by the original author(s) and/or performer(s);
38
-
39
- iii. publicity and privacy rights pertaining to a person's image or likeness
40
- depicted in a Work;
41
-
42
- iv. rights protecting against unfair competition in regards to a Work,
43
- subject to the limitations in paragraph 4(a), below;
44
-
45
- v. rights protecting the extraction, dissemination, use and reuse of data in
46
- a Work;
47
-
48
- vi. database rights (such as those arising under Directive 96/9/EC of the
49
- European Parliament and of the Council of 11 March 1996 on the legal
50
- protection of databases, and under any national implementation thereof,
51
- including any amended or successor version of such directive); and
52
-
53
- vii. other similar, equivalent or corresponding rights throughout the world
54
- based on applicable law or treaty, and any national implementations thereof.
55
-
56
- 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
- applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
- unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
- and Related Rights and associated claims and causes of action, whether now
60
- known or unknown (including existing as well as future claims and causes of
61
- action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
- duration provided by applicable law or treaty (including future time
63
- extensions), (iii) in any current or future medium and for any number of
64
- copies, and (iv) for any purpose whatsoever, including without limitation
65
- commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
- the Waiver for the benefit of each member of the public at large and to the
67
- detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
- shall not be subject to revocation, rescission, cancellation, termination, or
69
- any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
- by the public as contemplated by Affirmer's express Statement of Purpose.
71
-
72
- 3. Public License Fallback. Should any part of the Waiver for any reason be
73
- judged legally invalid or ineffective under applicable law, then the Waiver
74
- shall be preserved to the maximum extent permitted taking into account
75
- Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
- is so judged Affirmer hereby grants to each affected person a royalty-free,
77
- non transferable, non sublicensable, non exclusive, irrevocable and
78
- unconditional license to exercise Affirmer's Copyright and Related Rights in
79
- the Work (i) in all territories worldwide, (ii) for the maximum duration
80
- provided by applicable law or treaty (including future time extensions), (iii)
81
- in any current or future medium and for any number of copies, and (iv) for any
82
- purpose whatsoever, including without limitation commercial, advertising or
83
- promotional purposes (the "License"). The License shall be deemed effective as
84
- of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
- License for any reason be judged legally invalid or ineffective under
86
- applicable law, such partial invalidity or ineffectiveness shall not
87
- invalidate the remainder of the License, and in such case Affirmer hereby
88
- affirms that he or she will not (i) exercise any of his or her remaining
89
- Copyright and Related Rights in the Work or (ii) assert any associated claims
90
- and causes of action with respect to the Work, in either case contrary to
91
- Affirmer's express Statement of Purpose.
92
-
93
- 4. Limitations and Disclaimers.
94
-
95
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
- surrendered, licensed or otherwise affected by this document.
97
-
98
- b. Affirmer offers the Work as-is and makes no representations or warranties
99
- of any kind concerning the Work, express, implied, statutory or otherwise,
100
- including without limitation warranties of title, merchantability, fitness
101
- for a particular purpose, non infringement, or the absence of latent or
102
- other defects, accuracy, or the present or absence of errors, whether or not
103
- discoverable, all to the greatest extent permissible under applicable law.
104
-
105
- c. Affirmer disclaims responsibility for clearing rights of other persons
106
- that may apply to the Work or any use thereof, including without limitation
107
- any person's Copyright and Related Rights in the Work. Further, Affirmer
108
- disclaims responsibility for obtaining any necessary consents, permissions
109
- or other rights required for any use of the Work.
110
-
111
- d. Affirmer understands and acknowledges that Creative Commons is not a
112
- party to this document and has no duty or obligation with respect to this
113
- CC0 or use of the Work.
114
-
115
- For more information, please see
116
- <http://creativecommons.org/publicdomain/zero/1.0/>
@@ -1,147 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Kitties
4
-
5
- class Error < StandardError
6
- end
7
-
8
- ####
9
- # todo/check:
10
- # rename to HttpRequestError or similar??
11
- # use "common" error class - why? why not?
12
- class HttpError < Error
13
- attr_reader :code, :message
14
-
15
- def initialize( code, message )
16
- @code, @message = code, message
17
- end
18
-
19
- def to_s
20
- "HTTP request failed (NOK) => #{@code} #{@message}"
21
- end
22
- end
23
-
24
-
25
- class Response ## track last response
26
- attr_accessor :code, :message,
27
- :headers, :body
28
-
29
- def initialize( code, message, headers, body )
30
- @code, @message, @headers, @body = code, message, headers, body
31
- end
32
-
33
- ## ratelimit convenience helpers (for headers)
34
- ## note: all values of headers are arrays e.g.:
35
- ## {"x-ratelimit-limit"=>["20"],
36
- ## "x-ratelimit-remaining"=>["19"],
37
- ## "x-ratelimit-reset"=>["1558206970"],
38
- ## "content-length"=>["776"], ... }
39
-
40
- def ratelimit_limit
41
- limit = @headers['x-ratelimit-limit']
42
- limit ? limit[0].to_i : nil
43
- end
44
-
45
- def ratelimit_remaining
46
- remaining = @headers['x-ratelimit-remaining']
47
- remaining ? remaining[0].to_i : nil
48
- end
49
-
50
- def ratelimit_reset?
51
- ## x-ratelimit-reset => 1558079593 ## - assume it's unix epoch time
52
- reset = @headers['x-ratelimit-reset']
53
- reset ? (reset[0].to_i < Time.now.to_i) : true ## always assume true (unlimited requests)
54
- end
55
-
56
- def ratelimit_reset
57
- ## x-ratelimit-reset => 1558079593 ## - assume it's unix epoch time
58
- reset = @headers['x-ratelimit-reset']
59
- reset ? Time.at(reset[0].to_i) : nil
60
- end
61
- end ## class Response (used for tracking last(_response))
62
-
63
-
64
-
65
- class Client
66
-
67
- ##
68
- ## todo: add (optional) close with @http.close - why? why not?
69
-
70
- def initialize( base_uri:, token: nil )
71
- uri = URI.parse( base_uri )
72
- @http = Net::HTTP.new( uri.host, uri.port )
73
- if uri.instance_of? URI::HTTPS
74
- @http.use_ssl = true
75
- @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
76
- end
77
-
78
- @base_request_uri = uri.request_uri ## e.g. save /v1 etc.
79
- ## puts "base_request_uri: >#{@base_request_uri}<"
80
-
81
- @request_headers = if token
82
- { "x-api-token" => token }
83
- else
84
- {}
85
- end
86
- end # method initialize
87
-
88
- def get( service, **params )
89
-
90
- ## add url-encoded query string from params hash e.g. ?limit=100&type=sale
91
- unless params.empty?
92
- query = URI.encode_www_form( params )
93
- service += "?#{query}"
94
- end
95
-
96
- puts "GET #{service}"
97
-
98
- request_uri = if @base_request_uri == "/"
99
- service
100
- else
101
- "#{@base_request_uri}#{service}" ## e.g. add /v1 etc.
102
- end
103
-
104
- pp @request_headers
105
-
106
- req = Net::HTTP::Get.new( request_uri, @request_headers )
107
-
108
- res = @http.request(req)
109
-
110
- headers = res.to_hash ## get all response headers
111
-
112
- if Kitties.debug?
113
- # Iterate all response headers.
114
- # res.each_header do |key, value|
115
- # p "#{key} => #{value}"
116
- # end
117
- pp headers
118
- # => "content-type => application/json; charset=utf-8"
119
- # => "x-ratelimit-limit => 20"
120
- # => "x-ratelimit-remaining => 19"
121
- # => "x-ratelimit-reset => 1558079593"
122
- # ...
123
- end
124
-
125
- body = res.read_body
126
- ## pp body
127
-
128
- ## track last response
129
- Kitties.last_response = Response.new( res.code,
130
- res.message,
131
- headers,
132
- body )
133
-
134
- if res.code != '200'
135
- raise HttpError.new( res.code, res.message )
136
- end
137
-
138
-
139
- json = JSON.parse( body ) ## use just body (any difference?) - why? why not?
140
- ## pp json
141
- json
142
- end # method get
143
-
144
- end ## class Client
145
-
146
-
147
- end # module Kitties
@@ -1,91 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Kitties
4
-
5
- class Configuration
6
- attr_accessor :token
7
- attr_accessor :debug
8
-
9
- def initialize
10
- # try default setup via ENV variables
11
- @token = ENV[ 'KITTIES_TOKEN' ]
12
- @debug = false
13
- end
14
- end
15
-
16
- ## lets you use
17
- ## Kitties.configure do |config|
18
- ## config.token = 'secret'
19
- ## end
20
- def self.configuration
21
- @configuration ||= Configuration.new
22
- end
23
-
24
- def self.configure
25
- yield( configuration )
26
- end
27
-
28
- ### debug convenience helpers
29
- def self.debug?() configuration.debug; end
30
- def self.debug=(value) configuration.debug = value; end
31
-
32
-
33
- ## track last response
34
- def self.last_response() @last_response; end
35
- def self.last_response=(value) @last_response = value; end
36
-
37
-
38
-
39
- module V0
40
- class Client < ::Kitties::Client
41
- def initialize
42
- super( base_uri: "https://api.cryptokitties.co" )
43
- end
44
-
45
- def get_cattributes() get('/cattributes'); end
46
- def get_kitty( id ) get("/kitties/#{id}"); end ## use get_kitty_by_id - why? why not?
47
- alias_method :get_kitten, :get_kitty
48
-
49
- def get_kitties( **params ) get( '/kitties', **params ); end
50
- def get_auctions( **params ) get( '/auctions', **params ); end
51
- def get_user( addr ) get( "/user/#{addr}" ); end
52
-
53
- def get_network_status() get( '/network-status' ); end
54
-
55
- end # class Client
56
- end # module V0
57
-
58
-
59
-
60
-
61
- module V1
62
- ###
63
- ## see https://docs.api.cryptokitties.co
64
-
65
- class Client < ::Kitties::Client
66
- def initialize
67
- super( base_uri: "https://public.api.cryptokitties.co/v1",
68
- token: Kitties.configuration.token )
69
- end
70
-
71
- def get_cattributes() get('/cattributes'); end
72
- def get_kitty( id ) get("/kitties/#{id}"); end ## use get_kitty_by_id - why? why not?
73
- alias_method :get_kitten, :get_kitty
74
-
75
- def get_colors_body() get('/colors/body'); end
76
- def get_colors_eyes() get('/colors/eyes'); end
77
- def get_colors_secondary() get('/colors/secondary'); end
78
- def get_colors_tertiary() get('/colors/tertiary'); end
79
-
80
- end # class Client
81
- end # module V1
82
-
83
-
84
-
85
- ## CLIENT_V0 = V0::Client.new
86
- ## CLIENT_V1 = V1::Client.new
87
- ##
88
- ## def self.v0() CLIENT_V0; end
89
- ## def self.v1() CLIENT_V1; end
90
-
91
- end # module Kitties