Skip to content

Commit

Permalink
Allow parsing local html, add basic eclipse sponsorship map
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneCurcuru committed Mar 11, 2024
1 parent 5814f7d commit 53febc7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
45 changes: 45 additions & 0 deletions _sponsorships/eclipse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
identifier: eclipse
commonName: Eclipse
nonprofit: c6
sponsorurl: https://www.eclipse.org/membership/exploreMembership.php
levelurl: https://www.eclipse.org/membership/documents/membership-prospectus.pdf
levels:
first:
name: Strategic
amount: '300000'
amountCurrency: EUR
amountVaries: sliding scale by corporate revenues
selector: "div.eclipsefdn-members-list > div.row:nth-of-type(1) a.link-unstyled"
attr: href
benefits:
governance: board seat
advisory: can lead working groups; seat on Foundation councils
events: additional event discounts
services: IP analysis and reporting
marketing: access to marketing programs
logo: yes, premium spot in conferences
second:
name: Contributing
amount: '25000'
amountCurrency: EUR
amountVaries: sliding scale by corporate revenues
selector: "div.eclipsefdn-members-list > div.row:nth-of-type(2) a.link-unstyled"
attr: href
benefits:
governance: can vote in board elections
advisory: can join working groups as voting member
events: ticket and sponsorship discounts
marketing: access to marketing programs
logo: yes
third:
name: Associate
amount: '25000'
amountCurrency: EUR
amountVaries: sliding scale by corporate revenues; 0 for nonprofits
selector: "div.eclipsefdn-members-list > div.row:nth-of-type(3) a.link-unstyled"
attr: href
benefits:
advisory: can join working groups as guest
logo: yes
---
18 changes: 15 additions & 3 deletions assets/ruby/sponsor_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def get_current_sponsorship(sponsorship)
# Parse either live url, or override with a path reference (for cached/historical data)
# @param org id of org being parsed
# @param sponsorship parsed _sponsorship hash defining what to do
# @param cachefile optional filepath to local html to parse
# @return processed hash of sponsors
def parse_sponsorship(org, sponsorship, cachefile = nil)
io = nil
Expand Down Expand Up @@ -233,16 +234,17 @@ def mapped_sponsorship(org, sponsorship)
# Process one sponsorship mapping
# @param org id of org being processed
# @param sponsorship parsed _sponsorship hash
# @param cachefile optional filepath to local html to parse
# @return processed hash of sponsors
def process_sponsorship(org, sponsorship)
def process_sponsorship(org, sponsorship, cachefile = nil)
sponsors = {}
staticmap = sponsorship.fetch('staticmap', nil)
verbose("process_sponsorship(#{org}...) #{staticmap ? 'static map' : 'parsing url'}")
if staticmap
sponsors = mapped_sponsorship(org, sponsorship)
sponsors[PARSE_DATE] = staticmap
else
sponsors = parse_sponsorship(org, sponsorship)
sponsors = parse_sponsorship(org, sponsorship, cachefile)
sponsors[PARSE_DATE] = DateTime.now.strftime('%Y%m%d')
end
return sponsors
Expand Down Expand Up @@ -295,6 +297,9 @@ def parse_commandline
opts.on('-oORGID', '--one ORGID', 'Input org id (asf, python, etc.) to parse one.') do |orgid|
options[:orgid] = orgid
end
opts.on('-iINFILE', '--in INFILE', 'Input local filename to parse for one org.') do |infile|
options[:infile] = infile
end
opts.on('-mMAPID', '--map MAPID', 'Lint one existing sponsorship with its map.') do |mapid|
options[:mapid] = mapid
end
Expand All @@ -319,6 +324,7 @@ def parse_commandline
options = parse_commandline
orgid = options.fetch(:orgid, nil)
mapid = options.fetch(:mapid, nil)
infile = options.fetch(:infile, nil)
parsed = {}
if mapid
sponsor_file = File.join('_data/sponsorships', "#{mapid}.json")
Expand All @@ -331,7 +337,13 @@ def parse_commandline
exit 0
elsif orgid
options[:outfile] ||= File.join(DEFAULT_OUTDIR, "#{orgid}.json")
parsed = process_sponsorship(orgid, get_current_sponsorship(get_sponsorship_file(orgid)))
sponsorship = get_current_sponsorship(get_sponsorship_file(orgid))
if infile
# Parse a local file instead of the normal URL
parsed = process_sponsorship(orgid, sponsorship, cachefile = infile)
else
parsed = process_sponsorship(orgid, sponsorship)
end
File.open(options[:outfile], "w") do |f|
f.write(JSON.pretty_generate(parsed))
end
Expand Down

0 comments on commit 53febc7

Please sign in to comment.