artbase 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 549b31d6f628fcb714c22fd03f179b75fd9b99e9c2bbe8532b1e79660e4f1ade
4
- data.tar.gz: aadb6b67430375da20a83e94362562405dfca370dac2b8cfe514086a926ff2df
3
+ metadata.gz: a1060552f98ae102ea9d98593be2cb3dafd13d07e7d5ef20eb77cc4176c7fd94
4
+ data.tar.gz: 239322b6fcab84714305f14c2bfc91a488dba35b653b906f484f7690a99abec4
5
5
  SHA512:
6
- metadata.gz: c7d1a745322df0250841c03975135d35f0f4ab4a9b8258e36482258e14b1847cece236b09755fd8962b6e942b21ed1ee5b28449c0d0b4d32f9f3c7c08e508533
7
- data.tar.gz: 735c9079a101dd5aea55d5cb8458256082864e07bcaef81dff178cdeabb583df381ff9880d6aca7871c094a7f529342a9a206f4a4d877efe9c9b6b6b2600c27f
6
+ metadata.gz: 5c99a8d16e494bf0572db121c2b19843d2db20b8084df874ce123c10a99cfc39a3508733f9b7eb8da450cf95bea019fe8de66cbbb7771f8e007fbaf828bcb65b
7
+ data.tar.gz: aadfdb81650d27d1f8830755b41c5ab314b2b3de9efe54c76a2b2afa121809123f686438d415d0fb55df02b5fdf498ba6bd9333a8b9e8db4fd4d6dc60e7fad44
data/Manifest.txt CHANGED
@@ -4,15 +4,5 @@ README.md
4
4
  Rakefile
5
5
  bin/artbase
6
6
  lib/artbase.rb
7
- lib/artbase/attributes.rb
8
- lib/artbase/collection.rb
9
- lib/artbase/collection/base.rb
10
- lib/artbase/collection/image.rb
11
- lib/artbase/collection/opensea.rb
12
- lib/artbase/collection/token.rb
13
- lib/artbase/helper.rb
14
- lib/artbase/image.rb
15
- lib/artbase/image/sample.rb
16
- lib/artbase/retry.rb
17
7
  lib/artbase/tool.rb
18
8
  lib/artbase/version.rb
data/Rakefile CHANGED
@@ -26,9 +26,10 @@ Hoe.spec 'artbase' do
26
26
  self.history_file = 'CHANGELOG.md'
27
27
 
28
28
  self.extra_deps = [
29
- ['cocos', '>= 0.1.2'],
30
- ['webclient', '>= 0.2.2'],
31
- ['pixelart', '>= 1.3.6'],
29
+ ['artbase-cocos', '>= 0.0.1'],
30
+ # ['artbase-importers', '>= 0.0.1'], ## note: make "heavy" sql/sqlite db support "soft" dependency
31
+ ['artserve'],
32
+ ['artq'],
32
33
  ]
33
34
 
34
35
  self.licenses = ['Public Domain']
data/lib/artbase/tool.rb CHANGED
@@ -16,7 +16,11 @@ class Tool
16
16
  puts "==> welcome to collection tool with args:"
17
17
  pp args
18
18
 
19
- options = { }
19
+
20
+ options = { faster: false,
21
+ mirror: false,
22
+ }
23
+
20
24
  parser = OptionParser.new do |opts|
21
25
 
22
26
  opts.on("--offset NUM", Integer,
@@ -35,6 +39,15 @@ class Tool
35
39
  ## options[ :range] = range
36
40
  ## end
37
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
+
38
51
  opts.on("-h", "--help", "Prints this help") do
39
52
  puts opts
40
53
  exit
@@ -58,23 +71,29 @@ class Tool
58
71
  command = args[1]
59
72
  subcommand = args[2]
60
73
 
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
-
74
+ if File.exist?( "./#{name}/collection.yml" )
75
+ path = "./#{name}/collection.yml"
76
+ puts "==> reading collection config >#{path}<..."
77
+ self.collection = TokenCollection.read( path )
78
+ else
79
+ ## todo/check: keep config.rb alternate name - why? why not?
80
+ ## or use collection.rb only ???
81
+ path = if File.exist?( "./#{name}/config.rb" )
82
+ "./#{name}/config.rb"
83
+ else
84
+ "./#{name}/collection.rb"
85
+ end
86
+ puts "==> reading collection config >#{path}<..."
87
+
88
+ ## note: assume for now global const COLLECTION gets set/defined!!!
89
+ ## use/change to a script/dsl loader/eval later!!!
90
+ load( path )
91
+
92
+ ## pp COLLECTION
93
+
94
+ ## configure collection (note: requires self)
95
+ self.collection = COLLECTION
96
+ end
78
97
 
79
98
  if ['d','dl','down', 'download'].include?( command )
80
99
  if subcommand
@@ -88,7 +107,8 @@ class Tool
88
107
  download_images
89
108
  end
90
109
  elsif ['p', 'px', 'pix', 'pixel', 'pixelate'].include?( command )
91
- pixelate( offset: options[ :offset] )
110
+ pixelate( offset: options[ :offset],
111
+ faster: options[ :faster] )
92
112
  elsif ['m', 'meta'].include?( command )
93
113
  download_meta( offset: options[ :offset] )
94
114
  elsif ['i', 'img', 'image', 'images'].include?( command )
@@ -99,8 +119,11 @@ class Tool
99
119
  dump_attributes
100
120
  elsif ['x', 'exp', 'export'].include?( command )
101
121
  export_attributes
122
+ elsif ['b', 'build'].include?( command )
123
+ build_database
102
124
  elsif ['c', 'composite'].include?( command )
103
- make_composite
125
+ make_composite( limit: options[ :limit],
126
+ mirror: options[ :mirror ])
104
127
  elsif ['strip'].include?( command )
105
128
  make_strip
106
129
  elsif ['t', 'test'].include?( command )
@@ -112,9 +135,34 @@ class Tool
112
135
  puts "bye"
113
136
  end
114
137
 
115
- def self.make_composite
138
+
139
+
140
+ def self.build_database
141
+ puts "===> build database"
142
+
143
+ ### note. load database "heavy" machinery only on-demand
144
+ ## make it a "soft" dependency for now - why? why not?
145
+ require 'artbase-importers'
146
+
147
+
148
+ slug = @collection.slug
149
+
150
+ importer = Importer.read( "./#{slug}/build.rb" )
151
+
152
+ columns = importer.metadata_columns
153
+ pp columns
154
+
155
+ Database.connect( "./#{slug}/artbase.db" )
156
+ Database.auto_migrate!( columns )
157
+
158
+ @collection.import( importer )
159
+ end
160
+
161
+
162
+
163
+ def self.make_composite( limit: nil, mirror: false )
116
164
  puts "==> make composite"
117
- @collection.make_composite
165
+ @collection.make_composite( limit: limit, mirror: mirror )
118
166
  end
119
167
 
120
168
  def self.convert_images
@@ -165,7 +213,9 @@ class Tool
165
213
  @collection.download_images( range )
166
214
  end
167
215
 
168
- def self.pixelate( offset: )
216
+
217
+ def self.pixelate( offset:,
218
+ faster: )
169
219
  puts "==> pixelate"
170
220
 
171
221
  range = if offset
@@ -174,7 +224,7 @@ class Tool
174
224
  @collection._range
175
225
  end
176
226
 
177
- @collection.pixelate( range )
227
+ @collection.pixelate( range, faster: faster )
178
228
  end
179
229
  end # class Tool
180
230
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Artbase
4
4
  MAJOR = 0
5
- MINOR = 2
6
- PATCH = 1
5
+ MINOR = 3
6
+ PATCH = 0
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
data/lib/artbase.rb CHANGED
@@ -1,78 +1,12 @@
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
1
+
2
+ require 'artbase-cocos'
3
+
4
+
5
+
6
+ ## our own code
7
+ require_relative 'artbase/version'
8
+ require_relative 'artbase/tool'
9
+
10
+
11
+
12
+ puts Artbase.banner # say hello
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.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: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: cocos
14
+ name: artbase-cocos
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: 0.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: 0.0.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: webclient
28
+ name: artserve
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.2
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.2
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pixelart
42
+ name: artq
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.6
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.6
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,16 +102,6 @@ files:
102
102
  - Rakefile
103
103
  - bin/artbase
104
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
105
  - lib/artbase/tool.rb
116
106
  - lib/artbase/version.rb
117
107
  homepage: https://github.com/pixelartexchange/artbase
@@ -1,83 +0,0 @@
1
-
2
-
3
- def counter_to_text( counter )
4
-
5
- counter = counter.to_a
6
-
7
- attribute_counter = counter[0]
8
- more_counter = counter[1..-1]
9
-
10
-
11
- puts "Attribute Counts\n"
12
- trait_type, h = attribute_counter
13
-
14
- total = h[:by_type].values.reduce(0) { |sum,count| sum+count }
15
-
16
-
17
- types = h[:by_type]
18
- types = types.sort { |l,r| l[0]<=>r[0] } ## sort by name
19
-
20
- puts "\n"
21
- puts "|Name|Total (%)|"
22
- puts "|--------|----------:|"
23
-
24
- types.each do |rec|
25
- name = rec[0]
26
- count = rec[1]
27
- percent = Float(count*100)/Float(total)
28
-
29
- puts "| **#{name} Attributes** | #{count} (#{'%.2f' % percent}) |"
30
- end
31
- puts "\n"
32
-
33
- more_counter.each_with_index do |(trait_type, h),i|
34
- print " · " if i > 0 ## add separator
35
- print "#{trait_type } (#{h[:by_type].size})"
36
- end
37
- puts "\n\n"
38
-
39
-
40
-
41
- more_counter.each do |trait_type, h|
42
- print "### #{trait_type } (#{h[:by_type].size}) - "
43
- print "∑Total #{h[:count]}/#{total}\n"
44
-
45
- puts "\n"
46
- puts "|Name|Total (%)|"
47
- puts "|--------|----------:|"
48
-
49
- types = h[:by_type]
50
- types = types.sort do |l,r|
51
- # sort by 1) by count
52
- # 2) by name a-z
53
- res = r[1] <=> l[1]
54
- res = l[0] <=> r[0] if res == 0
55
- res
56
- end ## sort by count
57
- types.each do |rec|
58
- name = rec[0]
59
- count = rec[1]
60
- percent = Float(count*100)/Float(total)
61
-
62
- puts "| **#{name}** | #{count} (#{'%.2f' % percent}) |"
63
- end
64
- puts "\n\n"
65
- end
66
- end
67
-
68
-
69
-
70
-
71
- def counter_to_csv( counter )
72
-
73
- puts "type, name, count"
74
- counter.each do |trait_type, h|
75
- puts "#{trait_type}, ∑ Total, #{h[:count]}"
76
- h[:by_type].each do |trait_value, count|
77
- puts "#{trait_type}, #{trait_value}, #{count}"
78
- end
79
- end
80
- end
81
-
82
-
83
-