artbase-cocos 0.0.1

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.
@@ -0,0 +1,41 @@
1
+
2
+ ## for more ideas on retry
3
+ ## see https://github.com/ooyala/retries
4
+
5
+
6
+ ## todo/check: use a different name than retry - why? why not?
7
+ def retry_on_error( max_tries: 3, &block )
8
+ errors = []
9
+ delay = 3 ## 3 secs
10
+
11
+ begin
12
+ block.call
13
+
14
+ ## note: add more exception here (separated by comma) like
15
+ ## rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED => e
16
+ rescue Net::ReadTimeout => e
17
+ ## (re)raise (use raise with arguments or such - why? why not?)
18
+ raise if errors.size >= max_tries
19
+
20
+ ## ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the response cannot be read within the read_timeout.
21
+ ## subclass of RuntimeError
22
+ ## subclass of StandardError
23
+ ## subclass of Exception
24
+ puts "!! ERROR - #{e}:"
25
+ pp e
26
+
27
+ errors << e
28
+
29
+ puts
30
+ puts "==> retrying (count=#{errors.size}, max_tries=#{max_tries}) in #{delay} sec(s)..."
31
+ sleep( delay )
32
+ retry
33
+ end
34
+
35
+ if errors.size > 0
36
+ puts " #{errors.size} retry attempt(s) on error(s):"
37
+ pp errors
38
+ end
39
+
40
+ errors
41
+ end
@@ -0,0 +1,25 @@
1
+
2
+
3
+ module Artbase
4
+ module Module
5
+ module Cocos ## use Commons - why? why not?
6
+ MAJOR = 0
7
+ MINOR = 0
8
+ PATCH = 1
9
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
10
+
11
+ def self.version
12
+ VERSION
13
+ end
14
+
15
+ def self.banner
16
+ "artbase-cocos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
17
+ end
18
+
19
+ def self.root
20
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
21
+ end
22
+
23
+ end # module Cocos
24
+ end # module Module
25
+ end # module Artbase
@@ -0,0 +1,82 @@
1
+ require 'cocos'
2
+
3
+
4
+ ## 3rd party gems
5
+ require 'pixelart'
6
+
7
+
8
+
9
+ ## our own code
10
+ require_relative 'artbase-cocos/version' # note: let version always go first
11
+
12
+
13
+ ### add (shared) "global" config
14
+ module Artbase
15
+ class Configuration
16
+
17
+ #######################
18
+ ## accessors
19
+
20
+ ## todo/check: keep trailing / in ipfs_gateway - why? why not?
21
+ def ipfs_gateway() @ipfs_gateway || 'https://ipfs.io/ipfs/'; end
22
+ def ipfs_gateway=(value) @ipfs_gateway = value; end
23
+ end # class Configuration
24
+
25
+
26
+ ## lets you use
27
+ ## Artbase.configure do |config|
28
+ ## config.ipfs_gateway = 'https://cloudflare-ipfs.com/ipfs/'
29
+ ## end
30
+ def self.configure() yield( config ); end
31
+ def self.config() @config ||= Configuration.new; end
32
+ end # module Artbase
33
+
34
+
35
+ require_relative 'artbase-cocos/image'
36
+ require_relative 'artbase-cocos/image/sample' ## check - change to downsample/pixelate - why? why not?
37
+
38
+
39
+
40
+ require_relative 'artbase-cocos/helper'
41
+ require_relative 'artbase-cocos/retry' ## (global) retry_on_error helper
42
+
43
+ require_relative 'artbase-cocos/collection/base'
44
+ require_relative 'artbase-cocos/collection/token'
45
+ require_relative 'artbase-cocos/collection/token_meta'
46
+ require_relative 'artbase-cocos/collection/image'
47
+
48
+ require_relative 'artbase-cocos/attributes'
49
+
50
+
51
+
52
+
53
+
54
+ ######
55
+ ## move to helper - why? why not?
56
+
57
+
58
+
59
+ ## quick ipfs (interplanetary file system) hack
60
+ ## - make more reuseable
61
+ ## - different name e.g. ipfs_to_http or such - why? why not?
62
+ ## change/rename parameter str to url or suc - why? why not?
63
+ def handle_ipfs( str, normalize: true,
64
+ ipfs_gateway: Artbase.config.ipfs_gateway )
65
+
66
+ if normalize && str.start_with?( 'https://ipfs.io/ipfs/' )
67
+ str = str.sub( 'https://ipfs.io/ipfs/', 'ipfs://' )
68
+ end
69
+
70
+ if str.start_with?( 'ipfs://' )
71
+ str = str.sub( 'ipfs://', ipfs_gateway ) # use/replace with public gateway
72
+ end
73
+ str
74
+ end
75
+
76
+
77
+
78
+ puts Artbase::Module::Cocos.banner # say hello
79
+
80
+
81
+
82
+
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artbase-cocos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-26 00:00:00.000000000 Z
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: pixelart
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: webclient
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '7'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '4.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '7'
75
+ - !ruby/object:Gem::Dependency
76
+ name: hoe
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.23'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.23'
89
+ description: artbase-cocos - artbase (shared) code commons (cocos); read artbase collection
90
+ configs & metadata; download collection token metadata, images, and more
91
+ email: wwwmake@googlegroups.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files:
95
+ - CHANGELOG.md
96
+ - Manifest.txt
97
+ - README.md
98
+ files:
99
+ - CHANGELOG.md
100
+ - Manifest.txt
101
+ - README.md
102
+ - Rakefile
103
+ - lib/artbase-cocos.rb
104
+ - lib/artbase-cocos/attributes.rb
105
+ - lib/artbase-cocos/collection/base.rb
106
+ - lib/artbase-cocos/collection/image.rb
107
+ - lib/artbase-cocos/collection/token.rb
108
+ - lib/artbase-cocos/collection/token_meta.rb
109
+ - lib/artbase-cocos/helper.rb
110
+ - lib/artbase-cocos/image.rb
111
+ - lib/artbase-cocos/image/sample.rb
112
+ - lib/artbase-cocos/retry.rb
113
+ - lib/artbase-cocos/version.rb
114
+ homepage: https://github.com/pixelartexchange/artbase
115
+ licenses:
116
+ - Public Domain
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options:
120
+ - "--main"
121
+ - README.md
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 2.2.2
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubygems_version: 3.3.7
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: artbase-cocos - artbase (shared) code commons (cocos); read artbase collection
139
+ configs & metadata; download collection token metadata, images, and more
140
+ test_files: []