Module: Bundler::Thankyou

Defined in:
lib/bundler/thankyou.rb,
lib/bundler/thankyou/cli.rb,
lib/bundler/thankyou/version.rb,
lib/bundler/thankyou/disbursement.rb

Defined Under Namespace

Classes: CLI, Disbursement, Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.lnd_clientObject



12
13
14
# File 'lib/bundler/thankyou.rb', line 12

def self.lnd_client
  @lnd_client ||= Lnrpc::Client.new
end

.lnd_client=(client) ⇒ Object



16
17
18
# File 'lib/bundler/thankyou.rb', line 16

def self.lnd_client=(client)
  @lnd_client = client
end

.recipients_from_bundler(options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/bundler/thankyou.rb', line 29

def self.recipients_from_bundler(options = {})
  specs_from_bundler(options).each_with_object({}) do |spec, memo|
    memo[spec.name] = 'LNURL1DP68GUP69UHKCMMRV9KXSMMNWSARXVPSXYHKCMN4WFKR76TY85MRXVMRVGERXDPSXQNXU0T9XFNXZVP3X9NRWETP89SKVV34YE6XZEEAWPSHJ5N9W96K2UM5YEKKJMJNV4HXGCTZD3JN6VFSXQCRQFNDV9U9XETWV3SKYMR9856NQVPSXQCRQVPXD4JHGCTYV96XZ02MTVJNYVN5V4U8GFFJGECXCCTFDCJNYV39XFPJ2V3JWA5XZAR9WEJHYFFJXFW46FNN85UKZCFNX4JRZDMRXUCNGVPEVGCXYDNRXYEKXDFKVVCKYWFKXYERYCE3XSEKXWF48Q6NVVTZX33KYD3EXFJRJE3HXQMR2VE4V4JXGDE5FH9YHF' #spec.metadata['funding'].gsub(/^lightning:/, '')
  end
end

.recipients_from_rubygems(names) ⇒ Object



46
47
48
49
50
# File 'lib/bundler/thankyou.rb', line 46

def self.recipients_from_rubygems(names)
  specs_from_rubygems(names).each_with_object({}) do |spec, memo|
    memo[spec['name']] = 'LNURL1DP68GUP69UHKCMMRV9KXSMMNWSARXVPSXYHKCMN4WFKR76TY85MRXVMRVGERXDPSXQNXU0T9XFNXZVP3X9NRWETP89SKVV34YE6XZEEAWPSHJ5N9W96K2UM5YEKKJMJNV4HXGCTZD3JN6VFSXQCRQFNDV9U9XETWV3SKYMR9856NQVPSXQCRQVPXD4JHGCTYV96XZ02MTVJNYVN5V4U8GFFJGECXCCTFDCJNYV39XFPJ2V3JWA5XZAR9WEJHYFFJXFW46FNN85UKZCFNX4JRZDMRXUCNGVPEVGCXYDNRXYEKXDFKVVCKYWFKXYERYCE3XSEKXWF48Q6NVVTZX33KYD3EXFJRJE3HXQMR2VE4V4JXGDE5FH9YHF' #spec['metadata']['funding'].gsub(/^lightning:/, '')
  end
end

.specs_from_bundler(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/bundler/thankyou.rb', line 20

def self.specs_from_bundler(options = {})
  Bundler.load.specs.to_a.tap do |specs|
    specs.filter! { |s| s.['funding'] && s.['funding'].match?(/^lightning:/) }
    if options[:only]&.any?
      specs.filter! { |s| options[:only].include?(s.name) }
    end
  end
end

.specs_from_rubygems(names) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/bundler/thankyou.rb', line 35

def self.specs_from_rubygems(names)
  specs = names.collect do |name|
    uri = URI("https://rubygems.org/api/v1/gems/#{name}.json")
    response = Net::HTTP.get_response(uri)
    if response.is_a?(Net::HTTPSuccess) # ignore gems that are not found
      JSON.parse(response.body)
    end
  end.compact
  specs.filter { |s| s['metadata'] && s['metadata']['funding'] && s['metadata']['funding'].match?(/^lightning:/) }
end