artbase 0.1.0 → 0.2.2

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/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
- 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 = "./#{name}/config.rb"
63
- puts "==> reading collection config >#{path}<..."
64
-
65
- ## note: assume for now global const COLLECTION gets set/defined!!!
66
- ## use/change to a script/dsl loader/eval later!!!
67
- load( path )
68
-
69
- ## pp COLLECTION
70
-
71
- ## configure collection (note: requires self)
72
- self.collection = COLLECTION
73
-
74
-
75
- if ['d','dl','down', 'download'].include?( command )
76
- if subcommand
77
- if ['m', 'meta'].include?( subcommand )
78
- download_meta
79
- elsif ['i', 'img', 'image', 'images'].include?( subcommand )
80
- download_images
81
- end
82
- else
83
- download_meta
84
- download_images
85
- end
86
- elsif ['p', 'px', 'pix', 'pixel', 'pixelate'].include?( command )
87
- pixelate( offset: options[ :offset] )
88
- elsif ['m', 'meta'].include?( command )
89
- download_meta
90
- elsif ['i', 'img', 'image', 'images'].include?( command )
91
- download_images( offset: options[ :offset] )
92
- elsif ['a', 'attr', 'attributes'].include?( command )
93
- dump_attributes
94
- elsif ['x', 'exp', 'export'].include?( command )
95
- export_attributes
96
- elsif ['c', 'composite'].include?( command )
97
- make_composite
98
- elsif ['t', 'test'].include?( command )
99
- puts " testing, testing, testing"
100
- else
101
- puts "!! ERROR - unknown command >#{command}<, sorry"
102
- end
103
-
104
- puts "bye"
105
- end
106
-
107
- def self.make_composite
108
- puts "==> make composite"
109
- @collection.make_composite
110
- end
111
-
112
- def self.dump_attributes
113
- puts "==> dump attributes"
114
- @collection.dump_attributes
115
- end
116
-
117
- def self.export_attributes
118
- puts "==> export attributes"
119
- @collection.export_attributes
120
- end
121
-
122
-
123
- def self.download_meta
124
- puts "==> download meta"
125
- @collection.download_meta
126
- end
127
-
128
- def self.download_images( offset: )
129
- puts "==> download images"
130
-
131
- ## note: use three dots (...) to exclude e.g. count 100 => 0 to 99)
132
- range = if offset
133
- (offset...@collection.count)
134
- else
135
- (0...@collection.count)
136
- end
137
-
138
- @collection.download_images( range )
139
- end
140
-
141
- def self.pixelate( offset: )
142
- puts "==> pixelate"
143
-
144
- ## note: use three dots (...) to exclude e.g. count 100 => 0 to 99)
145
- range = if offset
146
- (offset...@collection.count)
147
- else
148
- (0...@collection.count)
149
- end
150
-
151
- @collection.pixelate( range )
152
- end
153
- end # class Tool
154
-
155
-
156
- end # module Artbase
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
+
@@ -1,22 +1,21 @@
1
-
2
-
3
- module Artbase
4
-
5
- MAJOR = 0
6
- MINOR = 1
7
- PATCH = 0
8
- VERSION = [MAJOR,MINOR,PATCH].join('.')
9
-
10
- def self.version
11
- VERSION
12
- end
13
-
14
- def self.banner
15
- "artbase/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
16
- end
17
-
18
- def self.root
19
- File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
20
- end
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 'pp'
2
- require 'time'
3
- require 'date'
4
-
5
- require 'uri'
6
- require 'net/http'
7
- require 'net/https'
8
- require 'cgi'
9
- require 'fileutils'
10
-
11
- require 'json'
12
-
13
- require 'optparse'
14
-
15
-
16
-
17
- ## our own gems
18
- require 'pixelart'
19
-
20
-
21
-
22
-
23
-
24
- ## our own code
25
- require 'artbase/version' # note: let version always go first
26
-
27
- require 'artbase/image'
28
-
29
-
30
- require 'artbase/helper'
31
- require 'artbase/opensea'
32
-
33
- require 'artbase/collection'
34
- require 'artbase/attributes'
35
-
36
-
37
- require 'artbase/tool'
38
-
39
-
40
-
41
- puts Artbase.banner
42
- puts Artbase.root
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.1.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-23 00:00:00.000000000 Z
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.22'
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.22'
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/24x24.rb
73
- - lib/artbase/image/32x32.rb
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.1.4
138
+ rubygems_version: 3.3.7
101
139
  signing_key:
102
140
  specification_version: 4
103
141
  summary: artbase