funding-round-timeline 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: de07c863280d0c79c65482eba17b599a7835a54bb5a084c6acd37180885a2065
4
+ data.tar.gz: 135b4a8c0c266e06e390c4db4bc0631882a4acd7fd8cbdf34761a9fb93cb97bb
5
+ SHA512:
6
+ metadata.gz: 5c65d41da4081e2ea63c610a40fa7e0be038d3b74547302b0562328f3ece3b5c949b9fcdf18e960c24bbeb34702db02b6f57122ee6d8eeb1df6c3b31fba1107d
7
+ data.tar.gz: ed1b6ee2bde65e2e86ff4e532c860c81de22906b025bb63bf9d5d333ded061ca9f60fcd8ff3299c4a4cf70f91acda06e020a453ccce10e9da7a469198d5a829f
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OneGTMLab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # funding-round-timeline
2
+
3
+ Ruby command line tool and library. Give it a CSV of funding rounds you have listed per company, with a date and an amount, and a date to count from. It shows, per company, the rounds in date order, the gaps in whole days between rounds, the median and longest gap, the total of the amounts you gave, the days since the last round and a quiet flag, and totals across all companies.
4
+
5
+ Part of the [OneGTMLab](https://www.onegtmlab.dev) free GTM tools. Background on the idea: [Crunchbase](https://www.onegtmlab.dev/tool-directory/data-platforms/crunchbase).
6
+
7
+ ## Install
8
+
9
+ ```
10
+ gem install funding-round-timeline
11
+ ```
12
+
13
+ ## Use
14
+
15
+ CSV columns: company, round, announced_on, amount. The company and round are labels you type; the dates are yyyy-mm-dd; the amount is your own figure in any currency (a number of 0 or more, or empty when unknown). Nothing is read from any database and nothing is predicted. Company names are compared trimmed and ignoring upper and lower case, and the first spelling seen is shown. Rounds are sorted by date, then by round label; two rounds of one company on one date are both kept and the gap between them is 0. Gaps are whole calendar days. The median gap is the middle gap, or the mean of the two middle gaps when the count is even, and shows n/a when a company has one round. The total raised is the sum of the known amounts with 2 decimals (n/a when none is known; the number of unknown amounts is shown). --today yyyy-mm-dd is required: the tool never reads the clock, so the same file and the same date always give the same output. A company is flagged quiet when the days since its last round are above --quiet-days (a whole number of 1 or more, default 540, set by you). Medians show 1 decimal and money 2 decimals, rounded half away from zero. A bad date or amount (the row is named), a --today before a company's last round (the company is named), a missing --today, a bad --quiet-days, a missing column, a missing file or a CSV with no rows stops the run with an error and a non-zero exit code. A UTF-8 BOM and CRLF line endings are accepted.
16
+
17
+ ```
18
+ $ ruby bin/funding-round-timeline sample.csv --today 2026-06-30
19
+ today: 2026-06-30
20
+ quiet when the days since the last round are above: 540
21
+
22
+ company rounds first last total raised unknown median gap longest gap days since flag
23
+ Beta Ltd 2 2022-03-01 2023-09-01 250000.00 1 549.0 549 1033 quiet
24
+ Epsilon Org 1 2024-06-01 2024-06-01 n/a 1 n/a n/a 759 quiet
25
+ Alpha Co 3 2024-01-15 2025-02-10 6250000.75 0 196.0 218 505
26
+ Delta Group 2 2025-05-05 2025-05-05 150000.00 0 0.0 0 421
27
+ Gamma Inc 1 2026-03-15 2026-03-15 100000.00 0 n/a n/a 107
28
+
29
+ timeline
30
+ Beta Ltd
31
+ 2022-03-01 Seed 250000.00
32
+ 2023-09-01 Series A unknown gap 549 days
33
+ Epsilon Org
34
+ 2024-06-01 Seed unknown
35
+ Alpha Co
36
+ 2024-01-15 Seed 1000000.00
37
+ 2024-08-20 Bridge 250000.25 gap 218 days
38
+ 2025-02-10 Series A 5000000.50 gap 174 days
39
+ Delta Group
40
+ 2025-05-05 Seed 100000.00
41
+ 2025-05-05 Seed Extension 50000.00 gap 0 days
42
+ Gamma Inc
43
+ 2026-03-15 Seed 100000.00
44
+
45
+ companies: 5
46
+ rounds: 9
47
+ quiet companies: 2
48
+ total of known amounts: 6750000.75
49
+ rounds with an unknown amount: 2
50
+ ```
51
+
52
+ ## Test
53
+
54
+ ```
55
+ ruby test/run.rb
56
+ ```
57
+
58
+ Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/funding_round_timeline'
5
+
6
+ if ARGV.empty? || ARGV.include?('-h') || ARGV.include?('--help')
7
+ warn "usage: funding-round-timeline rounds.csv --today yyyy-mm-dd [--quiet-days N]\n" \
8
+ "CSV columns: company, round, announced_on, amount. More: https://www.onegtmlab.dev/tool-directory/data-platforms/crunchbase"
9
+ exit 2
10
+ end
11
+
12
+ begin
13
+ o = FundingRoundTimeline.parse_args(ARGV)
14
+ rounds = FundingRoundTimeline.from_csv(File.read(o[:path], encoding: 'bom|utf-8'))
15
+ print FundingRoundTimeline.render(FundingRoundTimeline.analyze(rounds, today: o[:today], quiet_days: o[:quiet_days]))
16
+ rescue ArgumentError, SystemCallError, CSV::MalformedCSVError => e
17
+ abort "error: #{e.message}"
18
+ end
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+ require 'date'
5
+
6
+ # Lay out the funding rounds you list per company: dates, the gaps between rounds, the amounts you give and the days since the
7
+ # last round at a date you pass in. It measures dates and adds amounts; it reads no database and predicts nothing.
8
+ # It never reads the clock: "today" is always a required option.
9
+ module FundingRoundTimeline
10
+ Round = Struct.new(:company, :label, :date, :amount, keyword_init: true)
11
+
12
+ DEFAULT_QUIET_DAYS = 540
13
+
14
+ # yyyy-mm-dd only, and a real calendar date. Returns a Date or nil.
15
+ def self.parse_date(text)
16
+ s = text.to_s.strip
17
+ return nil unless s.match?(/\A\d{4}-\d{2}-\d{2}\z/)
18
+
19
+ y, m, d = s.split('-').map(&:to_i)
20
+ Date.valid_date?(y, m, d) ? Date.new(y, m, d) : nil
21
+ end
22
+
23
+ # Non-negative decimal, exact (Rational). Empty means unknown (nil). Raises ArgumentError otherwise.
24
+ def self.parse_amount(raw, line)
25
+ s = raw.to_s.strip
26
+ return nil if s.empty?
27
+ raise ArgumentError, "row #{line}: bad amount #{s.inspect}, expected a number of 0 or more or an empty cell" unless s.match?(/\A\d+(\.\d+)?\z/)
28
+
29
+ Rational(s)
30
+ end
31
+
32
+ # Whole number of digits after the point, rounded half away from zero (the values here are never negative).
33
+ def self.fmt(value, decimals)
34
+ scaled = (value * (10**decimals)).round
35
+ digits = scaled.to_s.rjust(decimals + 1, '0')
36
+ decimals.zero? ? digits : "#{digits[0...-decimals]}.#{digits[-decimals..]}"
37
+ end
38
+
39
+ def self.from_csv(text)
40
+ table = CSV.parse(text.sub(/\A/, ''), headers: true, skip_blanks: true,
41
+ header_converters: ->(h) { h.to_s.strip.downcase })
42
+ missing = %w[company round announced_on amount] - table.headers.compact
43
+ raise ArgumentError, "missing column(s): #{missing.join(', ')}" unless missing.empty?
44
+ raise ArgumentError, 'no rows in the CSV' if table.empty?
45
+
46
+ table.each_with_index.map do |r, i|
47
+ line = i + 2
48
+ company = r['company'].to_s.strip
49
+ label = r['round'].to_s.strip
50
+ raise ArgumentError, "row #{line}: empty company" if company.empty?
51
+ raise ArgumentError, "row #{line}: empty round for #{company.inspect}" if label.empty?
52
+
53
+ date = parse_date(r['announced_on'])
54
+ raise ArgumentError, "row #{line}: bad date #{r['announced_on'].to_s.strip.inspect} in announced_on, expected yyyy-mm-dd" unless date
55
+
56
+ Round.new(company: company, label: label, date: date, amount: parse_amount(r['amount'], line))
57
+ end
58
+ end
59
+
60
+ def self.median(values)
61
+ return nil if values.empty?
62
+
63
+ s = values.sort
64
+ mid = s.size / 2
65
+ s.size.odd? ? Rational(s[mid]) : Rational(s[mid - 1] + s[mid], 2)
66
+ end
67
+
68
+ # today: a Date. quiet_days: integer >= 1. Raises ArgumentError when today is before a company's last round.
69
+ def self.analyze(rounds, today:, quiet_days: DEFAULT_QUIET_DAYS)
70
+ raise ArgumentError, '--quiet-days must be a whole number of 1 or more' unless quiet_days.is_a?(Integer) && quiet_days >= 1
71
+
72
+ groups = {}
73
+ rounds.each { |r| (groups[r.company.downcase] ||= { name: r.company, rounds: [] })[:rounds] << r }
74
+ companies = groups.values.map do |g|
75
+ rs = g[:rounds].sort_by { |r| [r.date, r.label.downcase, r.label] }
76
+ gaps = rs.each_cons(2).map { |a, b| (b.date - a.date).to_i }
77
+ known = rs.map(&:amount).compact
78
+ last = rs.last.date
79
+ raise ArgumentError, "#{g[:name]}: --today #{today} is before the last round date #{last}" if today < last
80
+
81
+ since = (today - last).to_i
82
+ { name: g[:name], rounds: rs, count: rs.size, first: rs.first.date, last: last,
83
+ total: known.empty? ? nil : known.sum, unknown: rs.size - known.size, gaps: gaps,
84
+ median_gap: median(gaps), longest_gap: gaps.max, days_since: since, quiet: since > quiet_days }
85
+ end
86
+ companies.sort_by! { |c| [-c[:days_since], c[:name].downcase, c[:name]] }
87
+ all_known = rounds.map(&:amount).compact
88
+ { today: today, quiet_days: quiet_days, companies: companies, rounds: rounds.size,
89
+ quiet: companies.count { |c| c[:quiet] }, total_known: all_known.sum(Rational(0)),
90
+ unknown: rounds.size - all_known.size }
91
+ end
92
+
93
+ def self.render(res)
94
+ cs = res[:companies]
95
+ w = [cs.map { |c| c[:name].size }.max, 7].max
96
+ out = +"today: #{res[:today]}\nquiet when the days since the last round are above: #{res[:quiet_days]}\n\n"
97
+ out << "#{'company'.ljust(w)} rounds first last total raised unknown median gap longest gap days since flag\n"
98
+ cs.each do |c|
99
+ total = c[:total] ? fmt(c[:total], 2) : 'n/a'
100
+ median = c[:median_gap] ? fmt(c[:median_gap], 1) : 'n/a'
101
+ longest = c[:longest_gap] ? c[:longest_gap].to_s : 'n/a'
102
+ out << "#{c[:name].ljust(w)} #{c[:count].to_s.rjust(6)} #{c[:first]} #{c[:last]} #{total.rjust(12)} " \
103
+ "#{c[:unknown].to_s.rjust(7)} #{median.rjust(10)} #{longest.rjust(11)} #{c[:days_since].to_s.rjust(10)} " \
104
+ "#{c[:quiet] ? 'quiet' : ''}".rstrip << "\n"
105
+ end
106
+ out << "\ntimeline\n"
107
+ cs.each do |c|
108
+ out << "#{c[:name]}\n"
109
+ c[:rounds].each_with_index do |r, i|
110
+ amount = r.amount ? fmt(r.amount, 2) : 'unknown'
111
+ gap = i.zero? ? '' : " gap #{c[:gaps][i - 1]} days"
112
+ out << " #{r.date} #{r.label} #{amount}#{gap}\n"
113
+ end
114
+ end
115
+ out << "\ncompanies: #{cs.size}\nrounds: #{res[:rounds]}\nquiet companies: #{res[:quiet]}\n"
116
+ out << "total of known amounts: #{fmt(res[:total_known], 2)}\nrounds with an unknown amount: #{res[:unknown]}\n"
117
+ out
118
+ end
119
+
120
+ # Returns { path:, today:, quiet_days: }; raises ArgumentError on bad input.
121
+ def self.parse_args(argv)
122
+ args = argv.dup
123
+ path = nil
124
+ today = nil
125
+ quiet = DEFAULT_QUIET_DAYS
126
+ until args.empty?
127
+ arg = args.shift
128
+ name, inline = arg.start_with?('--') && arg.include?('=') ? arg.split('=', 2) : [arg, nil]
129
+ case name
130
+ when '--today', '--quiet-days'
131
+ value = inline
132
+ if value.nil?
133
+ raise ArgumentError, "#{name} needs a value" if args.empty?
134
+
135
+ value = args.shift
136
+ end
137
+ if name == '--today'
138
+ today = parse_date(value)
139
+ raise ArgumentError, "--today #{value.inspect} is not a date, expected yyyy-mm-dd" unless today
140
+ else
141
+ raise ArgumentError, "--quiet-days #{value.inspect} is not a whole number of 1 or more" unless value.strip.match?(/\A\d+\z/) && value.to_i >= 1
142
+
143
+ quiet = value.strip.to_i
144
+ end
145
+ when /\A-/ then raise ArgumentError, "unknown option #{name}"
146
+ else
147
+ raise ArgumentError, "unexpected extra argument #{arg.inspect}" if path
148
+
149
+ path = arg
150
+ end
151
+ end
152
+ raise ArgumentError, 'no CSV file given' unless path
153
+ raise ArgumentError, '--today is required (yyyy-mm-dd); the tool never reads the clock' unless today
154
+
155
+ { path: path, today: today, quiet_days: quiet }
156
+ end
157
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: funding-round-timeline
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - OneGTMLab
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: csv
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ -
17
+ - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: "0"
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ -
25
+ - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: "0"
28
+ description: "Ruby CLI and library: from a CSV of company, round, date and amount, show per company the rounds in date order, the gaps in days, the median and longest gap, the total of the amounts you gave, and the days since the last round at a date you pass in, with a quiet flag. It reads no database and predicts nothing. Offline."
29
+ executables:
30
+ - funding-round-timeline
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - bin/funding-round-timeline
37
+ - lib/funding_round_timeline.rb
38
+ homepage: "https://www.onegtmlab.dev/tool-directory/data-platforms/crunchbase"
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ source_code_uri: "https://github.com/jaizendra-netizen/funding-round-timeline"
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ -
49
+ - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "2.7"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ -
55
+ - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ requirements: []
59
+ rubygems_version: 4.1.0
60
+ specification_version: 4
61
+ summary: "Lay out the funding rounds you list per company: gaps between rounds, totals and days since the last round"
62
+ test_files: []