ordinals 1.1.1 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 586a022b2167110472eaea7be6d88e4f21fe72ea1f05ed6465ce29913a10cc15
4
- data.tar.gz: fe6f05e73dfdfd42560607c0721b0bdf642718debc83f48e0c36ba2a0ac82db2
3
+ metadata.gz: 19ed27e28ef41fc1d249f8275cc9a5dc829dee789693c3b32ee4af3ebfd40408
4
+ data.tar.gz: 28b5186c473c0b21fcf493d446edb718c3715667cf1ba89eebff2609a7d0f28b
5
5
  SHA512:
6
- metadata.gz: 0b7550126e529e67d821042f6fa5d2092f8e93460d4b6e892fe9d21e7bd4e7e5f83673beb39557dafbb1617eb7527569c2b4347e57cf6ce61090e1c00979d335
7
- data.tar.gz: 452fc65024f99d80bddf2254e2177a4397b816525d43cf8e42c7e914b95706c4f1a5b4086e5a2e2135792cfe895edcd9dca9e39190c95c74c63cee1550a0da41
6
+ metadata.gz: 61a44488afd23242742de448620670b9b610ec68b5df9fe00c94f7e282449c41785476e35f4a78a29429a3d1ace452382eb62b42f4a013d69d84f88cd546b1da
7
+ data.tar.gz: 9faa0175c1a53637db9f2119f9b20dd6c632c72f8f631b2daef505c67f85056820d1259bfe6f8d7c618dd8f26908f241f8dd467e7a7140db553137f53a63fb40
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 1.1.1
1
+ ### 1.1.2
2
2
 
3
3
  ### 0.0.1 / 2023-03-23
4
4
 
data/Manifest.txt CHANGED
@@ -7,4 +7,5 @@ lib/ordinals/api.rb
7
7
  lib/ordinals/recursive/composite.rb
8
8
  lib/ordinals/recursive/generator.rb
9
9
  lib/ordinals/recursive/image.rb
10
+ lib/ordinals/sandbox.rb
10
11
  lib/ordinals/stats.rb
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ require 'hoe'
10
10
 
11
11
  Hoe.spec 'ordinals' do
12
12
 
13
- self.version = '1.1.1'
13
+ self.version = '1.1.2'
14
14
 
15
15
  self.summary = 'ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litecoin, Dogecoin & co.'
16
16
  self.description = summary
@@ -0,0 +1,127 @@
1
+
2
+
3
+ module Ordinals
4
+ class Sandbox
5
+ def initialize( dir='./content' )
6
+ @dir = dir
7
+ @force = false
8
+ @delay_in_s = 0.5 ## wait 0.5s before next (possible) request
9
+ @requests = 0
10
+ end
11
+
12
+
13
+ def exist?( id ) ### add alias for different name(s) - why? why not?
14
+ path = "#{@dir}/#{id}"
15
+ File.exist?( path )
16
+ end
17
+
18
+ def read( id )
19
+ path = "#{@dir}/#{id}"
20
+ read_blob( path )
21
+ end
22
+
23
+ def add( id )
24
+ path = "#{@dir}/#{id}"
25
+ if !@force && File.exist?( path )
26
+ ## puts " in sandbox"
27
+ else
28
+ sleep( @delay_in_s ) if @delay_in_s && @requests > 0
29
+
30
+ ## note: save text as blob - byte-by-byte as is (might be corrupt text)
31
+ content = Ordinals.content( id )
32
+ ## pp content
33
+ #=> #<Ordinals::Api::Content:0x000001a1352df938
34
+ # @data="RIFF\xF8\v\x00\x00WEBPVP8 \xEC\v\x00\x00...",
35
+ # @length=3072,
36
+ # @type="image/png"
37
+
38
+ ## puts "data:"
39
+ ## puts content.data
40
+ write_blob( path, content.data )
41
+ @requests += 1
42
+ end
43
+ end
44
+
45
+
46
+ def add_csv( path )
47
+ recs = read_csv( path )
48
+ puts " #{recs.size} record(s)"
49
+
50
+ recs.each_with_index do |rec,i|
51
+ id = rec['id']
52
+ puts "==> #{i+1}/#{recs.size} - #{id}..."
53
+ add( id )
54
+ end
55
+ end
56
+
57
+ def add_collection( path )
58
+ data = read_json( path )
59
+ puts " #{data['items'].size} record(s)"
60
+
61
+ data['items'].each_with_index do |rec,i|
62
+ name = rec['name']
63
+ id = rec['inscription_id']
64
+ puts "==> #{i+1}/#{data['items'].size} - #{name} @ #{id}..."
65
+ add( id )
66
+ end
67
+ end
68
+
69
+
70
+
71
+ ID_RX = /[a-f0-9]{64}i[0-9]/x
72
+
73
+ def _find_ids( values )
74
+ values.select { |val| val.is_a?(String) && ID_RX.match(val) }
75
+ end
76
+
77
+ def add_data( obj )
78
+ if obj.is_a?( Array )
79
+ recs = obj
80
+ puts " #{recs.size} record(s)"
81
+ recs.each_with_index do |rec,i|
82
+ if rec.is_a?( String )
83
+ id = rec
84
+ puts "==> #{i+1}/#{recs.size} #{id}..."
85
+ add( id )
86
+ else ## assume array of strings for now
87
+ values = rec
88
+ print "==> #{i+1}/#{recs.size} "
89
+ ids = _find_ids( values )
90
+ if ids.size == 1
91
+ id = ids[0]
92
+ puts " #{id}..."
93
+ add( id )
94
+ else
95
+ puts
96
+ if ids.empty?
97
+ puts "!! ERROR - no inscribe id found in data row:"
98
+ else
99
+ puts "!! ERROR - more than one (that is, #{ids.size}) inscribe id found in data row:"
100
+ end
101
+ pp values
102
+ exit 1
103
+ end
104
+ end
105
+ end
106
+ else
107
+ ## todo/fix: raise ArgumentError - why? why not?
108
+ puts "!! ERROR - sorry"
109
+ exit 1
110
+ end
111
+ end
112
+
113
+ # todo/add
114
+ # def add_html( path )
115
+ # end
116
+
117
+
118
+ def add_dir( rootdir )
119
+ ## glob for **.csv and **.html
120
+ datasets = Dir.glob( "#{rootdir}/**/*.csv" )
121
+ datasets.each do |path|
122
+ add_csv( path )
123
+ end
124
+ end
125
+ end ## class Sandbox
126
+ end ## module Ordinals
127
+
data/lib/ordinals.rb CHANGED
@@ -85,6 +85,8 @@ end # module Ordinals
85
85
 
86
86
  ## our own code
87
87
  require_relative 'ordinals/api'
88
+
89
+ require_relative 'ordinals/sandbox' ## (blob) "flat" content cache by inscribe id (./content)
88
90
  require_relative 'ordinals/stats'
89
91
 
90
92
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinals
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -91,6 +91,7 @@ files:
91
91
  - lib/ordinals/recursive/composite.rb
92
92
  - lib/ordinals/recursive/generator.rb
93
93
  - lib/ordinals/recursive/image.rb
94
+ - lib/ordinals/sandbox.rb
94
95
  - lib/ordinals/stats.rb
95
96
  homepage: https://github.com/ordbase/ordbase
96
97
  licenses: