artbase 0.0.1 → 0.2.1
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 +12 -0
- data/README.md +272 -26
- data/Rakefile +40 -29
- data/bin/artbase +17 -0
- data/lib/artbase/attributes.rb +83 -0
- data/lib/artbase/collection/base.rb +306 -0
- data/lib/artbase/collection/image.rb +39 -0
- data/lib/artbase/collection/opensea.rb +297 -0
- data/lib/artbase/collection/token.rb +372 -0
- data/lib/artbase/collection.rb +12 -0
- data/lib/artbase/helper.rb +169 -0
- data/lib/artbase/image/sample.rb +31 -0
- data/lib/artbase/image.rb +31 -0
- data/lib/artbase/retry.rb +41 -0
- data/lib/artbase/tool.rb +185 -0
- data/lib/artbase/version.rb +21 -22
- data/lib/artbase.rb +78 -9
- metadata +62 -7
data/lib/artbase/tool.rb
ADDED
@@ -0,0 +1,185 @@
|
|
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
|
+
options = { }
|
20
|
+
parser = OptionParser.new do |opts|
|
21
|
+
|
22
|
+
opts.on("--offset NUM", Integer,
|
23
|
+
"Start counting at offset (default: 0)") do |num|
|
24
|
+
options[ :offset] = num
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("--limit NUM", Integer,
|
28
|
+
"Limit collection (default: ∞)") do |num|
|
29
|
+
options[ :limit] = num
|
30
|
+
end
|
31
|
+
|
32
|
+
## todo/fix: unsupported argument type: Range
|
33
|
+
## opts.on("--range RANGE", Range,
|
34
|
+
## "Range of collection (default: 0..∞") do |range|
|
35
|
+
## options[ :range] = range
|
36
|
+
## end
|
37
|
+
|
38
|
+
opts.on("-h", "--help", "Prints this help") do
|
39
|
+
puts opts
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
parser.parse!( args )
|
45
|
+
puts "options:"
|
46
|
+
pp options
|
47
|
+
|
48
|
+
puts "args:"
|
49
|
+
pp args
|
50
|
+
|
51
|
+
if args.size < 2
|
52
|
+
puts "!! ERROR - no command found - use <collection> <command>..."
|
53
|
+
puts ""
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
|
57
|
+
name = args[0] ## todo/check - use collection_name/slug or such?
|
58
|
+
command = args[1]
|
59
|
+
subcommand = args[2]
|
60
|
+
|
61
|
+
|
62
|
+
path = if File.exist?( "./#{name}/config.rb" )
|
63
|
+
"./#{name}/config.rb"
|
64
|
+
else
|
65
|
+
"./#{name}/collection.rb"
|
66
|
+
end
|
67
|
+
puts "==> reading collection config >#{path}<..."
|
68
|
+
|
69
|
+
## note: assume for now global const COLLECTION gets set/defined!!!
|
70
|
+
## use/change to a script/dsl loader/eval later!!!
|
71
|
+
load( path )
|
72
|
+
|
73
|
+
## pp COLLECTION
|
74
|
+
|
75
|
+
## configure collection (note: requires self)
|
76
|
+
self.collection = COLLECTION
|
77
|
+
|
78
|
+
|
79
|
+
if ['d','dl','down', 'download'].include?( command )
|
80
|
+
if subcommand
|
81
|
+
if ['m', 'meta'].include?( subcommand )
|
82
|
+
download_meta
|
83
|
+
elsif ['i', 'img', 'image', 'images'].include?( subcommand )
|
84
|
+
download_images
|
85
|
+
end
|
86
|
+
else
|
87
|
+
download_meta
|
88
|
+
download_images
|
89
|
+
end
|
90
|
+
elsif ['p', 'px', 'pix', 'pixel', 'pixelate'].include?( command )
|
91
|
+
pixelate( offset: options[ :offset] )
|
92
|
+
elsif ['m', 'meta'].include?( command )
|
93
|
+
download_meta( offset: options[ :offset] )
|
94
|
+
elsif ['i', 'img', 'image', 'images'].include?( command )
|
95
|
+
download_images( offset: options[ :offset] )
|
96
|
+
elsif ['conv', 'convert'].include?( command )
|
97
|
+
convert_images
|
98
|
+
elsif ['a', 'attr', 'attributes'].include?( command )
|
99
|
+
dump_attributes
|
100
|
+
elsif ['x', 'exp', 'export'].include?( command )
|
101
|
+
export_attributes
|
102
|
+
elsif ['c', 'composite'].include?( command )
|
103
|
+
make_composite
|
104
|
+
elsif ['strip'].include?( command )
|
105
|
+
make_strip
|
106
|
+
elsif ['t', 'test'].include?( command )
|
107
|
+
puts " testing, testing, testing"
|
108
|
+
else
|
109
|
+
puts "!! ERROR - unknown command >#{command}<, sorry"
|
110
|
+
end
|
111
|
+
|
112
|
+
puts "bye"
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.make_composite
|
116
|
+
puts "==> make composite"
|
117
|
+
@collection.make_composite
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.convert_images
|
121
|
+
puts "==> convert images"
|
122
|
+
@collection.convert_images( overwrite: false )
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def self.make_strip
|
127
|
+
puts "==> make strip"
|
128
|
+
@collection.make_strip
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
def self.dump_attributes
|
133
|
+
puts "==> dump attributes"
|
134
|
+
@collection.dump_attributes
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.export_attributes
|
138
|
+
puts "==> export attributes"
|
139
|
+
@collection.export_attributes
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def self.download_meta( offset: )
|
144
|
+
puts "==> download meta"
|
145
|
+
|
146
|
+
range = if offset
|
147
|
+
@collection._range( offset: offset )
|
148
|
+
else
|
149
|
+
@collection._range
|
150
|
+
end
|
151
|
+
|
152
|
+
@collection.download_meta( range )
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
def self.download_images( offset: )
|
157
|
+
puts "==> download images"
|
158
|
+
|
159
|
+
range = if offset
|
160
|
+
@collection._range( offset: offset )
|
161
|
+
else
|
162
|
+
@collection._range
|
163
|
+
end
|
164
|
+
|
165
|
+
@collection.download_images( range )
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.pixelate( offset: )
|
169
|
+
puts "==> pixelate"
|
170
|
+
|
171
|
+
range = if offset
|
172
|
+
@collection._range( offset: offset )
|
173
|
+
else
|
174
|
+
@collection._range
|
175
|
+
end
|
176
|
+
|
177
|
+
@collection.pixelate( range )
|
178
|
+
end
|
179
|
+
end # class Tool
|
180
|
+
|
181
|
+
|
182
|
+
end # module Artbase
|
183
|
+
|
184
|
+
|
185
|
+
|
data/lib/artbase/version.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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 = 1
|
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,9 +1,78 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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.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: 2022-
|
11
|
+
date: 2022-08-22 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,17 +78,18 @@ 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
|
-
executables:
|
91
|
+
executables:
|
92
|
+
- artbase
|
50
93
|
extensions: []
|
51
94
|
extra_rdoc_files:
|
52
95
|
- CHANGELOG.md
|
@@ -57,9 +100,21 @@ files:
|
|
57
100
|
- Manifest.txt
|
58
101
|
- README.md
|
59
102
|
- Rakefile
|
103
|
+
- bin/artbase
|
60
104
|
- lib/artbase.rb
|
105
|
+
- lib/artbase/attributes.rb
|
106
|
+
- lib/artbase/collection.rb
|
107
|
+
- lib/artbase/collection/base.rb
|
108
|
+
- lib/artbase/collection/image.rb
|
109
|
+
- lib/artbase/collection/opensea.rb
|
110
|
+
- lib/artbase/collection/token.rb
|
111
|
+
- lib/artbase/helper.rb
|
112
|
+
- lib/artbase/image.rb
|
113
|
+
- lib/artbase/image/sample.rb
|
114
|
+
- lib/artbase/retry.rb
|
115
|
+
- lib/artbase/tool.rb
|
61
116
|
- lib/artbase/version.rb
|
62
|
-
homepage: https://github.com/pixelartexchange/
|
117
|
+
homepage: https://github.com/pixelartexchange/artbase
|
63
118
|
licenses:
|
64
119
|
- Public Domain
|
65
120
|
metadata: {}
|
@@ -80,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
135
|
- !ruby/object:Gem::Version
|
81
136
|
version: '0'
|
82
137
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.3.7
|
84
139
|
signing_key:
|
85
140
|
specification_version: 4
|
86
141
|
summary: artbase
|