artbase 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/artbase/tool.rb CHANGED
@@ -1,159 +1,169 @@
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
+ 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 ['a', 'attr', 'attributes'].include?( command )
97
+ dump_attributes
98
+ elsif ['x', 'exp', 'export'].include?( command )
99
+ export_attributes
100
+ elsif ['c', 'composite'].include?( command )
101
+ make_composite
102
+ elsif ['t', 'test'].include?( command )
103
+ puts " testing, testing, testing"
104
+ else
105
+ puts "!! ERROR - unknown command >#{command}<, sorry"
106
+ end
107
+
108
+ puts "bye"
109
+ end
110
+
111
+ def self.make_composite
112
+ puts "==> make composite"
113
+ @collection.make_composite
114
+ end
115
+
116
+ def self.dump_attributes
117
+ puts "==> dump attributes"
118
+ @collection.dump_attributes
119
+ end
120
+
121
+ def self.export_attributes
122
+ puts "==> export attributes"
123
+ @collection.export_attributes
124
+ end
125
+
126
+
127
+ def self.download_meta( offset: )
128
+ puts "==> download meta"
129
+
130
+ range = if offset
131
+ @collection._range( offset: offset )
132
+ else
133
+ @collection._range
134
+ end
135
+
136
+ @collection.download_meta( range )
137
+ end
138
+
139
+
140
+ def self.download_images( offset: )
141
+ puts "==> download images"
142
+
143
+ range = if offset
144
+ @collection._range( offset: offset )
145
+ else
146
+ @collection._range
147
+ end
148
+
149
+ @collection.download_images( range )
150
+ end
151
+
152
+ def self.pixelate( offset: )
153
+ puts "==> pixelate"
154
+
155
+ range = if offset
156
+ @collection._range( offset: offset )
157
+ else
158
+ @collection._range
159
+ end
160
+
161
+ @collection.pixelate( range )
162
+ end
163
+ end # class Tool
164
+
165
+
166
+ end # module Artbase
167
+
168
+
169
+
@@ -1,22 +1,22 @@
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
+
5
+ MAJOR = 0
6
+ MINOR = 2
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
data/lib/artbase.rb CHANGED
@@ -1,42 +1,103 @@
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 '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
+
18
+ ##################
19
+ #### commons convenience helpers
20
+ ### - move read_json( path ) to shared commons/prolog/... or such - why? why not?
21
+
22
+ def read_json( path )
23
+ txt = File.open( path, 'r:utf-8' ) { |f| f.read }
24
+ data = JSON.parse( txt )
25
+ data
26
+ end
27
+
28
+
29
+
30
+
31
+ ## our own gems
32
+ require 'pixelart'
33
+
34
+
35
+
36
+
37
+
38
+ ## our own code
39
+ require 'artbase/version' # note: let version always go first
40
+
41
+ ### add (shared) "global" config
42
+ module Artbase
43
+ class Configuration
44
+
45
+ #######################
46
+ ## accessors
47
+
48
+ ## todo/check: keep trailing / in ipfs_gateway - why? why not?
49
+ def ipfs_gateway() @ipfs_gateway || 'https://ipfs.io/ipfs/'; end
50
+ def ipfs_gateway=(value) @ipfs_gateway = value; end
51
+ end # class Configuration
52
+
53
+
54
+ ## lets you use
55
+ ## Artbase.configure do |config|
56
+ ## config.ipfs_gateway = 'https://cloudflare-ipfs.com/ipfs/'
57
+ ## end
58
+ def self.configure() yield( config ); end
59
+ def self.config() @config ||= Configuration.new; end
60
+ end # module Artbase
61
+
62
+
63
+ require 'artbase/image'
64
+
65
+
66
+ require 'artbase/helper'
67
+ require 'artbase/retry' ## (global) retry_on_error helper
68
+
69
+ require 'artbase/collection'
70
+ require 'artbase/attributes'
71
+
72
+
73
+ require 'artbase/tool'
74
+
75
+
76
+ ######
77
+ ## move to helper - why? why not?
78
+
79
+
80
+
81
+ ## quick ipfs (interplanetary file system) hack
82
+ ## - make more reuseable
83
+ ## - different name e.g. ipfs_to_http or such - why? why not?
84
+ ## change/rename parameter str to url or suc - why? why not?
85
+ def handle_ipfs( str, normalize: true,
86
+ ipfs_gateway: Artbase.config.ipfs_gateway )
87
+
88
+ if normalize && str.start_with?( 'https://ipfs.io/ipfs/' )
89
+ str = str.sub( 'https://ipfs.io/ipfs/', 'ipfs://' )
90
+ end
91
+
92
+ if str.start_with?( 'ipfs://' )
93
+ str = str.sub( 'ipfs://', ipfs_gateway ) # use/replace with public gateway
94
+ end
95
+ str
96
+ end
97
+
98
+
99
+
100
+
101
+
102
+ puts Artbase.banner
103
+ puts Artbase.root
metadata CHANGED
@@ -1,15 +1,29 @@
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.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-01-23 00:00:00.000000000 Z
11
+ date: 2022-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: webclient
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.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.2.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rdoc
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -36,14 +50,14 @@ dependencies:
36
50
  requirements:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: '3.22'
53
+ version: '3.23'
40
54
  type: :development
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: '3.22'
60
+ version: '3.23'
47
61
  description: artbase
48
62
  email: wwwmake@googlegroups.com
49
63
  executables:
@@ -51,12 +65,10 @@ executables:
51
65
  extensions: []
52
66
  extra_rdoc_files:
53
67
  - CHANGELOG.md
54
- - LICENSE.md
55
68
  - Manifest.txt
56
69
  - README.md
57
70
  files:
58
71
  - CHANGELOG.md
59
- - LICENSE.md
60
72
  - Manifest.txt
61
73
  - README.md
62
74
  - Rakefile
@@ -64,16 +76,14 @@ files:
64
76
  - lib/artbase.rb
65
77
  - lib/artbase/attributes.rb
66
78
  - lib/artbase/collection.rb
79
+ - lib/artbase/collection/base.rb
67
80
  - lib/artbase/collection/image.rb
68
81
  - lib/artbase/collection/opensea.rb
69
82
  - lib/artbase/collection/token.rb
70
83
  - lib/artbase/helper.rb
71
84
  - 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
85
+ - lib/artbase/image/sample.rb
86
+ - lib/artbase/retry.rb
77
87
  - lib/artbase/tool.rb
78
88
  - lib/artbase/version.rb
79
89
  homepage: https://github.com/pixelartexchange/artbase
@@ -97,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
107
  - !ruby/object:Gem::Version
98
108
  version: '0'
99
109
  requirements: []
100
- rubygems_version: 3.1.4
110
+ rubygems_version: 3.3.7
101
111
  signing_key:
102
112
  specification_version: 4
103
113
  summary: artbase