artbase 0.1.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -3
- data/Manifest.txt +3 -6
- data/README.md +272 -39
- data/Rakefile +40 -29
- data/bin/artbase +17 -17
- data/lib/artbase/attributes.rb +83 -83
- data/lib/artbase/collection/base.rb +329 -0
- data/lib/artbase/collection/image.rb +39 -39
- data/lib/artbase/collection/opensea.rb +297 -484
- data/lib/artbase/collection/token.rb +400 -72
- data/lib/artbase/collection.rb +12 -12
- data/lib/artbase/helper.rb +169 -149
- data/lib/artbase/image/sample.rb +31 -0
- data/lib/artbase/image.rb +31 -75
- data/lib/artbase/retry.rb +41 -0
- data/lib/artbase/tool.rb +220 -159
- data/lib/artbase/version.rb +21 -22
- data/lib/artbase.rb +78 -42
- metadata +50 -12
- data/LICENSE.md +0 -116
- data/lib/artbase/image/24x24.rb +0 -68
- data/lib/artbase/image/32x32.rb +0 -43
- data/lib/artbase/image/60x60.rb +0 -70
- data/lib/artbase/image/80x80.rb +0 -90
- data/lib/artbase/opensea.rb +0 -144
data/lib/artbase/tool.rb
CHANGED
@@ -1,159 +1,220 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module Artbase
|
5
|
-
class Tool
|
6
|
-
|
7
|
-
def self.collection=(value)
|
8
|
-
puts " setting collection to:"
|
9
|
-
pp value
|
10
|
-
|
11
|
-
@collection = value
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
def self.main( args=ARGV )
|
16
|
-
puts "==> welcome to collection tool with args:"
|
17
|
-
pp args
|
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
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Artbase
|
5
|
+
class Tool
|
6
|
+
|
7
|
+
def self.collection=(value)
|
8
|
+
puts " setting collection to:"
|
9
|
+
pp value
|
10
|
+
|
11
|
+
@collection = value
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def self.main( args=ARGV )
|
16
|
+
puts "==> welcome to collection tool with args:"
|
17
|
+
pp args
|
18
|
+
|
19
|
+
|
20
|
+
options = { faster: false,
|
21
|
+
mirror: false,
|
22
|
+
}
|
23
|
+
|
24
|
+
parser = OptionParser.new do |opts|
|
25
|
+
|
26
|
+
opts.on("--offset NUM", Integer,
|
27
|
+
"Start counting at offset (default: 0)") do |num|
|
28
|
+
options[ :offset] = num
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("--limit NUM", Integer,
|
32
|
+
"Limit collection (default: ∞)") do |num|
|
33
|
+
options[ :limit] = num
|
34
|
+
end
|
35
|
+
|
36
|
+
## todo/fix: unsupported argument type: Range
|
37
|
+
## opts.on("--range RANGE", Range,
|
38
|
+
## "Range of collection (default: 0..∞") do |range|
|
39
|
+
## options[ :range] = range
|
40
|
+
## end
|
41
|
+
|
42
|
+
opts.on( "--faster", "Use faster (optional) pixelate binary (default: false)") do
|
43
|
+
options[ :faster ] = true
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on( "--mirror", "Mirror (or flip) images (default: false)" ) do
|
47
|
+
options[ :mirror ] = true
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
opts.on("-h", "--help", "Prints this help") do
|
52
|
+
puts opts
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
parser.parse!( args )
|
58
|
+
puts "options:"
|
59
|
+
pp options
|
60
|
+
|
61
|
+
puts "args:"
|
62
|
+
pp args
|
63
|
+
|
64
|
+
if args.size < 2
|
65
|
+
puts "!! ERROR - no command found - use <collection> <command>..."
|
66
|
+
puts ""
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
name = args[0] ## todo/check - use collection_name/slug or such?
|
71
|
+
command = args[1]
|
72
|
+
subcommand = args[2]
|
73
|
+
|
74
|
+
if File.exist?( "./#{name}/collection.yml" )
|
75
|
+
path = "./#{name}/collection.yml"
|
76
|
+
puts "==> reading collection config >#{path}<..."
|
77
|
+
config = read_yaml( path )
|
78
|
+
|
79
|
+
## todo - use TokenCollection.read( ) or such -- why? why not?
|
80
|
+
## or TokenCollection.build( hash ) ?? - why? why not?
|
81
|
+
self.collection = TokenCollection.new(
|
82
|
+
config['slug'],
|
83
|
+
config['count'],
|
84
|
+
token_base: config['token_base'],
|
85
|
+
image_base: config['image_base'],
|
86
|
+
format: config['format'],
|
87
|
+
source: config['source'],
|
88
|
+
offset: config['offset'] || 0
|
89
|
+
)
|
90
|
+
else
|
91
|
+
## todo/check: keep config.rb alternate name - why? why not?
|
92
|
+
## or use collection.rb only ???
|
93
|
+
path = if File.exist?( "./#{name}/config.rb" )
|
94
|
+
"./#{name}/config.rb"
|
95
|
+
else
|
96
|
+
"./#{name}/collection.rb"
|
97
|
+
end
|
98
|
+
puts "==> reading collection config >#{path}<..."
|
99
|
+
|
100
|
+
## note: assume for now global const COLLECTION gets set/defined!!!
|
101
|
+
## use/change to a script/dsl loader/eval later!!!
|
102
|
+
load( path )
|
103
|
+
|
104
|
+
## pp COLLECTION
|
105
|
+
|
106
|
+
## configure collection (note: requires self)
|
107
|
+
self.collection = COLLECTION
|
108
|
+
end
|
109
|
+
|
110
|
+
if ['d','dl','down', 'download'].include?( command )
|
111
|
+
if subcommand
|
112
|
+
if ['m', 'meta'].include?( subcommand )
|
113
|
+
download_meta
|
114
|
+
elsif ['i', 'img', 'image', 'images'].include?( subcommand )
|
115
|
+
download_images
|
116
|
+
end
|
117
|
+
else
|
118
|
+
download_meta
|
119
|
+
download_images
|
120
|
+
end
|
121
|
+
elsif ['p', 'px', 'pix', 'pixel', 'pixelate'].include?( command )
|
122
|
+
pixelate( offset: options[ :offset],
|
123
|
+
faster: options[ :faster] )
|
124
|
+
elsif ['m', 'meta'].include?( command )
|
125
|
+
download_meta( offset: options[ :offset] )
|
126
|
+
elsif ['i', 'img', 'image', 'images'].include?( command )
|
127
|
+
download_images( offset: options[ :offset] )
|
128
|
+
elsif ['conv', 'convert'].include?( command )
|
129
|
+
convert_images
|
130
|
+
elsif ['a', 'attr', 'attributes'].include?( command )
|
131
|
+
dump_attributes
|
132
|
+
elsif ['x', 'exp', 'export'].include?( command )
|
133
|
+
export_attributes
|
134
|
+
elsif ['c', 'composite'].include?( command )
|
135
|
+
make_composite( limit: options[ :limit],
|
136
|
+
mirror: options[ :mirror ])
|
137
|
+
elsif ['strip'].include?( command )
|
138
|
+
make_strip
|
139
|
+
elsif ['t', 'test'].include?( command )
|
140
|
+
puts " testing, testing, testing"
|
141
|
+
else
|
142
|
+
puts "!! ERROR - unknown command >#{command}<, sorry"
|
143
|
+
end
|
144
|
+
|
145
|
+
puts "bye"
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.make_composite( limit: nil, mirror: false )
|
149
|
+
puts "==> make composite"
|
150
|
+
@collection.make_composite( limit: limit, mirror: mirror )
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.convert_images
|
154
|
+
puts "==> convert images"
|
155
|
+
@collection.convert_images( overwrite: false )
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def self.make_strip
|
160
|
+
puts "==> make strip"
|
161
|
+
@collection.make_strip
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
def self.dump_attributes
|
166
|
+
puts "==> dump attributes"
|
167
|
+
@collection.dump_attributes
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.export_attributes
|
171
|
+
puts "==> export attributes"
|
172
|
+
@collection.export_attributes
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def self.download_meta( offset: )
|
177
|
+
puts "==> download meta"
|
178
|
+
|
179
|
+
range = if offset
|
180
|
+
@collection._range( offset: offset )
|
181
|
+
else
|
182
|
+
@collection._range
|
183
|
+
end
|
184
|
+
|
185
|
+
@collection.download_meta( range )
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
def self.download_images( offset: )
|
190
|
+
puts "==> download images"
|
191
|
+
|
192
|
+
range = if offset
|
193
|
+
@collection._range( offset: offset )
|
194
|
+
else
|
195
|
+
@collection._range
|
196
|
+
end
|
197
|
+
|
198
|
+
@collection.download_images( range )
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
def self.pixelate( offset:,
|
203
|
+
faster: )
|
204
|
+
puts "==> pixelate"
|
205
|
+
|
206
|
+
range = if offset
|
207
|
+
@collection._range( offset: offset )
|
208
|
+
else
|
209
|
+
@collection._range
|
210
|
+
end
|
211
|
+
|
212
|
+
@collection.pixelate( range, faster: faster )
|
213
|
+
end
|
214
|
+
end # class Tool
|
215
|
+
|
216
|
+
|
217
|
+
end # module Artbase
|
218
|
+
|
219
|
+
|
220
|
+
|
data/lib/artbase/version.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Artbase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end # module Artbase
|
1
|
+
|
2
|
+
|
3
|
+
module Artbase
|
4
|
+
MAJOR = 0
|
5
|
+
MINOR = 2
|
6
|
+
PATCH = 2
|
7
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
8
|
+
|
9
|
+
def self.version
|
10
|
+
VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"artbase/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module Artbase
|
data/lib/artbase.rb
CHANGED
@@ -1,42 +1,78 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
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
|
-
|
1
|
+
require 'cocos'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## 3rd party gems
|
6
|
+
require 'pixelart'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
## our own code
|
12
|
+
require_relative 'artbase/version' # note: let version always go first
|
13
|
+
|
14
|
+
|
15
|
+
### add (shared) "global" config
|
16
|
+
module Artbase
|
17
|
+
class Configuration
|
18
|
+
|
19
|
+
#######################
|
20
|
+
## accessors
|
21
|
+
|
22
|
+
## todo/check: keep trailing / in ipfs_gateway - why? why not?
|
23
|
+
def ipfs_gateway() @ipfs_gateway || 'https://ipfs.io/ipfs/'; end
|
24
|
+
def ipfs_gateway=(value) @ipfs_gateway = value; end
|
25
|
+
end # class Configuration
|
26
|
+
|
27
|
+
|
28
|
+
## lets you use
|
29
|
+
## Artbase.configure do |config|
|
30
|
+
## config.ipfs_gateway = 'https://cloudflare-ipfs.com/ipfs/'
|
31
|
+
## end
|
32
|
+
def self.configure() yield( config ); end
|
33
|
+
def self.config() @config ||= Configuration.new; end
|
34
|
+
end # module Artbase
|
35
|
+
|
36
|
+
|
37
|
+
require_relative 'artbase/image'
|
38
|
+
|
39
|
+
|
40
|
+
require_relative 'artbase/helper'
|
41
|
+
require_relative 'artbase/retry' ## (global) retry_on_error helper
|
42
|
+
|
43
|
+
require_relative 'artbase/collection'
|
44
|
+
require_relative 'artbase/attributes'
|
45
|
+
|
46
|
+
|
47
|
+
require_relative 'artbase/tool'
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
######
|
52
|
+
## move to helper - why? why not?
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
## quick ipfs (interplanetary file system) hack
|
57
|
+
## - make more reuseable
|
58
|
+
## - different name e.g. ipfs_to_http or such - why? why not?
|
59
|
+
## change/rename parameter str to url or suc - why? why not?
|
60
|
+
def handle_ipfs( str, normalize: true,
|
61
|
+
ipfs_gateway: Artbase.config.ipfs_gateway )
|
62
|
+
|
63
|
+
if normalize && str.start_with?( 'https://ipfs.io/ipfs/' )
|
64
|
+
str = str.sub( 'https://ipfs.io/ipfs/', 'ipfs://' )
|
65
|
+
end
|
66
|
+
|
67
|
+
if str.start_with?( 'ipfs://' )
|
68
|
+
str = str.sub( 'ipfs://', ipfs_gateway ) # use/replace with public gateway
|
69
|
+
end
|
70
|
+
str
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
puts Artbase.banner
|
78
|
+
puts Artbase.root
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01
|
11
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocos
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webclient
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pixelart
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: rdoc
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -36,14 +78,14 @@ dependencies:
|
|
36
78
|
requirements:
|
37
79
|
- - "~>"
|
38
80
|
- !ruby/object:Gem::Version
|
39
|
-
version: '3.
|
81
|
+
version: '3.23'
|
40
82
|
type: :development
|
41
83
|
prerelease: false
|
42
84
|
version_requirements: !ruby/object:Gem::Requirement
|
43
85
|
requirements:
|
44
86
|
- - "~>"
|
45
87
|
- !ruby/object:Gem::Version
|
46
|
-
version: '3.
|
88
|
+
version: '3.23'
|
47
89
|
description: artbase
|
48
90
|
email: wwwmake@googlegroups.com
|
49
91
|
executables:
|
@@ -51,12 +93,10 @@ executables:
|
|
51
93
|
extensions: []
|
52
94
|
extra_rdoc_files:
|
53
95
|
- CHANGELOG.md
|
54
|
-
- LICENSE.md
|
55
96
|
- Manifest.txt
|
56
97
|
- README.md
|
57
98
|
files:
|
58
99
|
- CHANGELOG.md
|
59
|
-
- LICENSE.md
|
60
100
|
- Manifest.txt
|
61
101
|
- README.md
|
62
102
|
- Rakefile
|
@@ -64,16 +104,14 @@ files:
|
|
64
104
|
- lib/artbase.rb
|
65
105
|
- lib/artbase/attributes.rb
|
66
106
|
- lib/artbase/collection.rb
|
107
|
+
- lib/artbase/collection/base.rb
|
67
108
|
- lib/artbase/collection/image.rb
|
68
109
|
- lib/artbase/collection/opensea.rb
|
69
110
|
- lib/artbase/collection/token.rb
|
70
111
|
- lib/artbase/helper.rb
|
71
112
|
- lib/artbase/image.rb
|
72
|
-
- lib/artbase/image/
|
73
|
-
- lib/artbase/
|
74
|
-
- lib/artbase/image/60x60.rb
|
75
|
-
- lib/artbase/image/80x80.rb
|
76
|
-
- lib/artbase/opensea.rb
|
113
|
+
- lib/artbase/image/sample.rb
|
114
|
+
- lib/artbase/retry.rb
|
77
115
|
- lib/artbase/tool.rb
|
78
116
|
- lib/artbase/version.rb
|
79
117
|
homepage: https://github.com/pixelartexchange/artbase
|
@@ -97,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
135
|
- !ruby/object:Gem::Version
|
98
136
|
version: '0'
|
99
137
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.3.7
|
101
139
|
signing_key:
|
102
140
|
specification_version: 4
|
103
141
|
summary: artbase
|