ordinals 1.0.2 → 1.1.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: a7a362c24bda8951706799ad74ddd75b148b94353166d4bf807b2b929ec1c1a1
4
- data.tar.gz: ee12466f380d678b7f652a33a4035fb66e593ece071d5489777abf121c1fbef7
3
+ metadata.gz: fec9f519a6abfabeae1243ccd48ab0abdd0b03db8cf1f58256fbea7346673a8b
4
+ data.tar.gz: 7633ca1833fbbe8a41fc31608c9c084c983342a3abe33a2dda08422ae65eb3a1
5
5
  SHA512:
6
- metadata.gz: 73cf537fef77274ef1a6acb568fe2a516bec3c4cf3eeceef32e51e8e43df27cbf8236d304897b957a462f1946466db2b38d79969d5ad9228e917a99d32189c4b
7
- data.tar.gz: f45716b1e22dcdc42542e5972c1df9635272af900187ce61796d9cf5916a785c65d9c8bca74943733d069b80d7f3acaed78e231820a9a58ad806d31387cb7470
6
+ metadata.gz: e89f0c5897973530ccabc577f4e055645ae428abbe35430252131992a95a4058e31c4e31a40717c24dbf1237067b153669a7e2a25b0e688f1c2495c58c73b476
7
+ data.tar.gz: f225b18511b8eea28e0f8068198ad5076a6632cdab4850cf1f70a7f712b1476b66c8990b88f809f93fb2588d3fb6ac7960785e7db744ef23800467b0b2ce252f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ### 1.1.0
2
+
1
3
  ### 0.0.1 / 2023-03-23
2
4
 
3
5
  * Everything is new. First release
data/Manifest.txt CHANGED
@@ -4,3 +4,6 @@ README.md
4
4
  Rakefile
5
5
  lib/ordinals.rb
6
6
  lib/ordinals/api.rb
7
+ lib/ordinals/recursive/composite.rb
8
+ lib/ordinals/recursive/image.rb
9
+ lib/ordinals/stats.rb
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litcoin, Dogecoin & co.
4
4
 
5
5
 
6
- * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
7
- * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
6
+ * home :: [github.com/ordbase/ordbase](https://github.com/ordbase/ordbase)
7
+ * bugs :: [github.com/ordbase/ordbase/issues](https://github.com/ordbase/ordbase/issues)
8
8
  * gem :: [rubygems.org/gems/ordinals](https://rubygems.org/gems/ordinals)
9
9
  * rdoc :: [rubydoc.info/gems/ordinals](http://rubydoc.info/gems/ordinals)
10
10
 
@@ -14,7 +14,7 @@ ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litcoin
14
14
 
15
15
  For now ordinal inscription api queries are supported on
16
16
  - Bitcoin (via <https://ordinals.com>)
17
- - Litecoin (via <https://litecoin.earlyordies.com>) and
17
+ - Litecoin (via <https://ordinalslite.com>) and
18
18
  - Dogecoin (via <https://doginals.com>)
19
19
 
20
20
 
@@ -65,7 +65,7 @@ Ordinals.chain = :ltc
65
65
 
66
66
 
67
67
  # get the inscription binary blob / data by id
68
- # e.g. GET https://litecoin.earlyordies.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
68
+ # e.g. GET https://ordinalslite.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
69
69
 
70
70
  id = 'f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0'
71
71
  content = Ordinals.content( id )
@@ -77,7 +77,7 @@ pp content
77
77
 
78
78
 
79
79
  # get the inscription meta data by id
80
- # e.g GET https://litecoin.earlyordies.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
80
+ # e.g GET https://ordinalslite.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
81
81
  data = Ordinals.inscription( id )
82
82
  pp data
83
83
  #=> {"title"=>"Inscription 642",
@@ -104,7 +104,7 @@ That's it for now.
104
104
  ## Bonus: Ordinal Pixel Art Collections
105
105
 
106
106
 
107
- See the [**Ordinals (Pixel Art) Sandbox (& Cache)**](https://github.com/pixelartexchange/ordinals.sandbox)
107
+ See the [**Ordinals (Pixel Art) Sandbox (& Cache)**](https://github.com/ordbase/ordinals.sandbox)
108
108
  for collections incl. Ordinal Punks & Phunks (24×24), Bitcoin Punks (24×24), Ordinal Mini Doges (24×24), Ordinal Doggies (32×32),
109
109
  Extra Ordinal Women (32×32), Ordinal Penguins (35×35),
110
110
  Ordinal Birds (42×42), Bitcoin Bears (48×48) and much more.
data/Rakefile CHANGED
@@ -3,22 +3,22 @@ require 'hoe'
3
3
 
4
4
  ###
5
5
  # hack/ quick fix for broken intuit_values - overwrite with dummy
6
- class Hoe
7
- def intuit_values( input ); end
8
- end
6
+ # class Hoe
7
+ # def intuit_values( input ); end
8
+ # end
9
9
 
10
10
 
11
11
  Hoe.spec 'ordinals' do
12
12
 
13
- self.version = '1.0.2'
13
+ self.version = '1.1.0'
14
14
 
15
15
  self.summary = 'ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litecoin, Dogecoin & co.'
16
16
  self.description = summary
17
17
 
18
- self.urls = { home: 'https://github.com/pixelartexchange/artbase' }
18
+ self.urls = { home: 'https://github.com/ordbase/ordbase' }
19
19
 
20
20
  self.author = 'Gerald Bauer'
21
- self.email = 'wwwmake@googlegroups.com'
21
+ self.email = 'gerald.bauer@gmail.com'
22
22
 
23
23
  # switch extension to .markdown for gihub formatting
24
24
  self.readme_file = 'README.md'
data/lib/ordinals/api.rb CHANGED
@@ -5,7 +5,8 @@ module Ordinals
5
5
 
6
6
  class Api ## change/rename Api to Client - why? why not?
7
7
  def self.litecoin
8
- @litecoin ||= new( 'https://litecoin.earlyordies.com' )
8
+ ## @litecoin ||= new( 'https://litecoin.earlyordies.com' )
9
+ @litecoin ||= new( 'https://ordinalslite.com' )
9
10
  @litecoin
10
11
  end
11
12
 
@@ -0,0 +1,78 @@
1
+ ###
2
+ # helpers for recursive images (in .SVG)
3
+
4
+
5
+ class RecursiveImageComposite
6
+ def initialize( cols, rows,
7
+ width: 100, height: 100 )
8
+ @tile_cols = cols
9
+ @tile_rows = rows
10
+
11
+ @tile_width = width
12
+ @tile_height = height
13
+
14
+ @recursions = []
15
+ end
16
+
17
+
18
+ def count() @recursions.size; end
19
+ alias_method :size, :count ## add size alias (confusing if starting with 0?) - why? why not?
20
+
21
+ def tile_width() @tile_width; end
22
+ def tile_height() @tile_height; end
23
+ def width() @tile_width*@tile_cols; end
24
+ def height() @tile_height*@tile_rows; end
25
+
26
+ def add( obj ) @recursions << obj; end
27
+ alias_method :<<, :add
28
+
29
+ def to_svg
30
+ buf =<<TXT
31
+ <svg
32
+ xmlns="http://www.w3.org/2000/svg"
33
+ width="100%" height="100%"
34
+ viewBox="0 0 #{width} #{height}">
35
+ TXT
36
+
37
+ @recursions.each_with_index do |recursion,i|
38
+ y,x = i.divmod( @tile_cols )
39
+
40
+ if recursion.is_a?( RecursiveImage )
41
+ comment = "№#{i} @ (#{x}/#{y})"
42
+ buf += <<TXT
43
+ <g transform="translate(#{x*@tile_width},#{y*@tile_height})">
44
+ <!-- #{comment} -->
45
+ #{recursion.to_svg( :inline )}
46
+ </g>
47
+ TXT
48
+ else
49
+ id, opts = recursion.is_a?( Array )? recursion : [recursion, {}]
50
+
51
+ pixelate = opts.has_key?(:pixelate) ? opts[:pixelate]
52
+ : false
53
+ comment = opts.has_key?(:comment) ? opts[:comment]
54
+ : "№#{i} @ (#{x}/#{y})"
55
+
56
+
57
+ style = pixelate ? %Q[style="image-rendering: pixelated;"] : ''
58
+
59
+ buf += <<TXT
60
+ <g transform="translate(#{x*@tile_width},#{y*@tile_height})">
61
+ <!-- #{comment} -->
62
+ <image
63
+ width="#{@tile_width}" height="#{@tile_height}"
64
+ href="/content/#{id}"
65
+ #{style} />
66
+ </g>
67
+ TXT
68
+ end
69
+ end
70
+
71
+
72
+ buf += <<TXT
73
+ </svg>
74
+ TXT
75
+
76
+ buf
77
+ end
78
+ end # class RecursiveImageComposite
@@ -0,0 +1,77 @@
1
+ ###
2
+ # helpers for recursive images (in .SVG)
3
+
4
+
5
+ class RecursiveImage
6
+ def initialize( width, height )
7
+ @width = width
8
+ @height = height
9
+
10
+ @recursions = []
11
+ end
12
+
13
+ def add( obj ) @recursions << obj; end
14
+ alias_method :<<, :add
15
+
16
+ def count() @recursions.size; end
17
+ alias_method :size, :count ## add size alias (confusing if starting with 0?) - why? why not?
18
+
19
+ def width() @width; end
20
+ def height() @height; end
21
+
22
+
23
+ def to_svg( format=:standalone )
24
+ buf = ''
25
+
26
+ if [:standalone].include?( format.downcase.to_sym )
27
+ buf +=<<TXT
28
+ <svg
29
+ xmlns="http://www.w3.org/2000/svg"
30
+ width="100%" height="100%"
31
+ viewBox="0 0 #{width} #{height}">
32
+ TXT
33
+ else ## assume :inline/:embed or such
34
+ ## todo/check: add px e.g. 100 => 100px - why? why not?
35
+ buf +=<<TXT
36
+ <svg width="#{width}" height="#{height}">
37
+ TXT
38
+ end
39
+
40
+ @recursions.each_with_index do |recursion,i|
41
+ id, opts = recursion.is_a?( Array )? recursion : [recursion, {}]
42
+
43
+ pixelate = opts.has_key?(:pixelate) ? opts[:pixelate]
44
+ : false
45
+
46
+ style = pixelate ? %Q[style="image-rendering: pixelated;"] : ''
47
+
48
+ ## note: assumes spritesheet has tile of same size as image itself!!!!
49
+ spritesheet = opts[:spritesheet]
50
+ if spritesheet
51
+ num = opts[:num] || opts[:tile]
52
+ spritesheet_width = spritesheet[0]
53
+ tile_cols = spritesheet_width/width
54
+ y,x = num.divmod( tile_cols )
55
+
56
+ buf += <<TXT
57
+ <svg viewBox="#{x*width} #{y*height} #{width} #{height}">
58
+ <image href="/content/#{id}"
59
+ #{style} />
60
+ </svg>
61
+ TXT
62
+ else
63
+ buf += <<TXT
64
+ <image href="/content/#{id}"
65
+ #{style} />
66
+ TXT
67
+ end
68
+ end
69
+
70
+ buf += <<TXT
71
+ </svg>
72
+ TXT
73
+ buf
74
+ end # method to_svg
75
+ end # class RecursiveImage
76
+
77
+
@@ -0,0 +1,145 @@
1
+
2
+
3
+ class InscriptionStats
4
+
5
+ TITLE_RX = /^(Inscription|Shibescription)[ ]+(?<ord>[0-9]+)$/
6
+ BYTES_RX = /^(?<bytes>[0-9]+)[ ]+bytes$/
7
+
8
+ def initialize
9
+ @stats = {
10
+ count: 0,
11
+ ord: { '<100' => 0,
12
+ '<1000' => 0,
13
+ '<10000' => 0,
14
+ '<100000' => 0,
15
+ '<1000000' => 0,
16
+ 'min' => nil,
17
+ 'max' => nil, },
18
+ type: Hash.new(0),
19
+ bytes: { '<100' => 0,
20
+ '<1000' => 0,
21
+ '<10000' => 0,
22
+ '<100000' => 0,
23
+ '<1000000' => 0,
24
+ 'min' => nil,
25
+ 'max' => nil, },
26
+ }
27
+
28
+ @days = Hash.new(0)
29
+ end
30
+
31
+ def size() @stats[:count]; end
32
+
33
+
34
+
35
+ def update( data )
36
+ data = JSON.parse( data) if data.is_a?( String )
37
+
38
+ @stats[ :count ] += 1
39
+
40
+
41
+ ord = nil
42
+ if m=TITLE_RX.match( data['title'] )
43
+ ord = m[:ord].to_i(10)
44
+ else
45
+ puts "!! ERROR - cannot find ord in inscription title; sorry"
46
+ pp data
47
+ exit 1
48
+ end
49
+
50
+ if ord < 100 then @stats[:ord]['<100'] += 1
51
+ elsif ord < 1000 then @stats[:ord]['<1000'] += 1
52
+ elsif ord < 10000 then @stats[:ord]['<10000'] += 1
53
+ elsif ord < 100000 then @stats[:ord]['<100000'] += 1
54
+ elsif ord < 1000000 then @stats[:ord]['<1000000'] += 1
55
+ else
56
+ puts "!! ERROR ord out-of-bounds"
57
+ exit 1
58
+ end
59
+
60
+ ## update min/max
61
+ @stats[:ord]['min'] = ord if ord < (@stats[:ord]['min'] || 9999999)
62
+ @stats[:ord]['max'] = ord if ord > (@stats[:ord]['max'] || -1)
63
+
64
+
65
+ bytes = nil
66
+ if m=BYTES_RX.match( data['content length'] )
67
+ bytes = m[:bytes].to_i(10)
68
+ else
69
+ puts "!! ERROR - cannot find bytes in inscription content length; sorry"
70
+ pp data
71
+ exit 1
72
+ end
73
+
74
+ if bytes < 100 then @stats[:bytes]['<100'] += 1
75
+ elsif bytes < 1000 then @stats[:bytes]['<1000'] += 1
76
+ elsif bytes < 10000 then @stats[:bytes]['<10000'] += 1
77
+ elsif bytes < 100000 then @stats[:bytes]['<100000'] += 1
78
+ elsif bytes < 1000000 then @stats[:bytes]['<1000000'] += 1
79
+ else
80
+ puts "!! ERROR bytes (content-length) out-of-bounds"
81
+ exit 1
82
+ end
83
+
84
+ ## update min/max
85
+ @stats[:bytes]['min'] = bytes if bytes < (@stats[:bytes]['min'] || 9999999)
86
+ @stats[:bytes]['max'] = bytes if bytes > (@stats[:bytes]['max'] || -1)
87
+
88
+
89
+ type = data['content type']
90
+
91
+ @stats[:type][ type ] += 1
92
+
93
+ ## "timestamp"=>"2023-02-05 01:45:22 UTC",
94
+ ts = Time.strptime( data['timestamp'], '%Y-%m-%d %H:%M:%S' )
95
+
96
+ @days[ ts.strftime('%Y-%m-%d') ] +=1
97
+ end # method update
98
+
99
+
100
+ def data ## rename to model or such - why? why not?
101
+ ## sort days
102
+ days = @days.sort {|l,r| l[0] <=> r[0] }
103
+ ## add to stats
104
+ @stats[:days] = {}
105
+ days.each {|k,v| @stats[:days][k] = v }
106
+ @stats
107
+ end
108
+
109
+ =begin
110
+ {:count=>101,
111
+ :ord=>{"<1000"=>0, "<10000"=>0, "<100000"=>101, "<1000000"=>0, "min"=>14343, "max"=>42901},
112
+ :type=>{"image/png"=>101},
113
+ :bytes=>{"<100"=>0, "<1000"=>101, "<10000"=>0, "<100000"=>0, "<1000000"=>0, "min"=>274, "max"=>512},
114
+ :days=>{"2023-02-22"=>10, "2023-02-25"=>17, "2023-02-26"=>74}}
115
+ =end
116
+
117
+ def format ## rename to pretty_print or such - why? why not?
118
+ stat = data
119
+
120
+ buf = String.new('')
121
+ buf << "#{stat[:count]} inscription(s)\n"
122
+
123
+ buf << "- from ##{stat[:ord]['min']} to ##{stat[:ord]['max']} (min. to max.)\n"
124
+ buf << " - <100 => #{stat[:ord]['<100']}\n" if stat[:ord]["<100"] > 0
125
+ buf << " - <1000 => #{stat[:ord]['<1000']}\n" if stat[:ord]["<1000"] > 0
126
+ buf << " - <10000 => #{stat[:ord]['<10000']}\n" if stat[:ord]["<10000"] > 0
127
+ buf << " - <100000 => #{stat[:ord]['<100000']}\n" if stat[:ord]["<100000"] > 0
128
+ buf << " - <1000000 => #{stat[:ord]['<1000000']}\n" if stat[:ord]["<1000000"] > 0
129
+
130
+ buf << "- format(s)\n"
131
+ stat[:type].each do |k,v|
132
+ buf << " - #{k} => #{v}\n"
133
+ end
134
+
135
+ buf << "- day(s)\n"
136
+ stat[:days].each do |k,v|
137
+ buf << " - #{k} => #{v}\n"
138
+ end
139
+
140
+ buf
141
+ end
142
+
143
+ end ## class InscriptionStats
144
+
145
+
data/lib/ordinals.rb CHANGED
@@ -85,5 +85,14 @@ end # module Ordinals
85
85
 
86
86
  ## our own code
87
87
  require_relative 'ordinals/api'
88
+ require_relative 'ordinals/stats'
88
89
 
89
90
 
91
+ ### add recursive image helpers
92
+ require_relative 'ordinals/recursive/image'
93
+ require_relative 'ordinals/recursive/composite'
94
+
95
+ ## add conveniecen shortcuts/alias - why? why not?
96
+ RcsvImage = RecursiveImage
97
+ RcsvImageComposite = RecursiveImageComposite
98
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinals
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.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: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -64,17 +64,17 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.23'
67
+ version: '4.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.23'
74
+ version: '4.0'
75
75
  description: ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin,
76
76
  Litecoin, Dogecoin & co.
77
- email: wwwmake@googlegroups.com
77
+ email: gerald.bauer@gmail.com
78
78
  executables: []
79
79
  extensions: []
80
80
  extra_rdoc_files:
@@ -88,7 +88,10 @@ files:
88
88
  - Rakefile
89
89
  - lib/ordinals.rb
90
90
  - lib/ordinals/api.rb
91
- homepage: https://github.com/pixelartexchange/artbase
91
+ - lib/ordinals/recursive/composite.rb
92
+ - lib/ordinals/recursive/image.rb
93
+ - lib/ordinals/stats.rb
94
+ homepage: https://github.com/ordbase/ordbase
92
95
  licenses:
93
96
  - Public Domain
94
97
  metadata: {}
@@ -109,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
112
  - !ruby/object:Gem::Version
110
113
  version: '0'
111
114
  requirements: []
112
- rubygems_version: 3.3.7
115
+ rubygems_version: 3.4.10
113
116
  signing_key:
114
117
  specification_version: 4
115
118
  summary: ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin,