Module: Unisat

Defined in:
lib/unisat.rb,
lib/unisat/cache.rb,
lib/unisat/version.rb

Defined Under Namespace

Modules: Puppeteer Classes: Cache

Constant Summary collapse

MAJOR =

sync version w/ sport.db n friends - why? why not?

0
MINOR =

todo: namespace inside version or something - why? why not??

0
PATCH =
1
VERSION =
[MAJOR,MINOR,PATCH].join('.')

Class Method Summary collapse

Class Method Details



14
15
16
# File 'lib/unisat/version.rb', line 14

def self.banner
  "unisat/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in >#{root}<"
end

.cacheObject



5
# File 'lib/unisat/cache.rb', line 5

def self.cache()  @cache ||= Cache.new( './unisat' ); end

.cache_dir=(dir) ⇒ Object

todo: use a config block in the future - why? why not?



4
# File 'lib/unisat/cache.rb', line 4

def self.cache_dir=( dir ) @cache = Cache.new( dir ); end

.parse_page(html) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/unisat/cache.rb', line 8

def self.parse_page( html )
    doc = Nokogiri::HTML( html )
  
    items = [] 
  
    sats = doc.css( '.item-container' )
    sats.each_with_index do |el,i|
      puts "==> sat ##{i+1}/#{sats.size}..."
  
      h = {}
  #    <a href="https://ordinals.com/inscription/
  #    9613d44f53a1245bf34f43820163bb3064a5715c19f0d6c767a14d1b49f46614i0" 
  #    target="_blank" rel="noreferrer" class="sats-item  ">
      a = el.at( 'a.sats-item' )
      h['href'] = a['href']
  
      name = el.at( '.name' )
      h['name'] = name.text
  
      num = el.at( '.num' )
      h['num'] = num.text
  
      address = el.at( '.address' )
      h['address'] = address.text
  
      date = el.at( '.date' )
      h['date'] = date.text
      ##pp h
      
      items << h
    end  
    items
end

.rootObject



18
19
20
# File 'lib/unisat/version.rb', line 18

def self.root
  File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
end

.versionObject



10
11
12
# File 'lib/unisat/version.rb', line 10

def self.version
  VERSION
end