browser.rb 0.18.0 → 0.19.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56f139b18dfff55d6bc1cb220969ae862e8fd8f0faba7f4c9c1d328fcdb87e0f
4
- data.tar.gz: 741fbfa0b248ffe280a7677aa83a49d835317471c7267a8cc90a0f9bb4bc68bb
3
+ metadata.gz: a736546223df5f12913619dac1b903777955ea041b4ee806bfa1bd3b09ab3a4b
4
+ data.tar.gz: a0d4448f4e869e97dfb4f73af4faadeb3c60ac6e48a18c6c0e57806fe815376e
5
5
  SHA512:
6
- metadata.gz: 770fc41a0c5a3092bbe120a72e8c38ccf8d75b42fe85237bd0e09dc452a0e7e3bc0dc57648ce5a9cfbca06983298c1e45cf31a1cd74c39b1bb6ad707c9c47ac2
7
- data.tar.gz: b7c30b4d4575a9a707dd75b0f2c3b057b53f37f4a17e07ddfc1628aa53b810f9cc0eb487d82dc1cd7ef7fb3dafaa9a650f5079cfcc87d5d1ff6f180a20b5dd31
6
+ metadata.gz: 9439088a3a40be8275d04a5f415300c7cfbbcaa6db69eb7c3c4e3a658d40c0e81a3401aa310894a10471715d2659585c7bd3da4ff4777227240f2598de439fd3
7
+ data.tar.gz: bd4ae380165c93fd78ab013e4e6f5ed244097b09fb68347bee13874f30573ee6027317c8cccf57cb66c9995654d0250826e3eab1fb542ebd6eaf44f9645ebe0e
data/CHANGELOG CHANGED
@@ -28,6 +28,8 @@
28
28
  | `profile_path`, the directory a profile sits in | 0.17.0 | 2026-10-03 |
29
29
  | `Browser::Visit`, history as one record whatever the browser, the three epochs converted to a `Time` | 0.18.0 | 2026-10-05 |
30
30
  | `Browser::History#visits`, the records, each carrying the browser's own columns besides | 0.18.0 | 2026-10-05 |
31
+ | Every meaningful history column carried, each browser's own bookkeeping left out | 0.19.0 | 2026-10-06 |
32
+ | Safari's history titles, which its query had never asked for | 0.19.0 | 2026-10-06 |
31
33
 
32
34
 
33
35
  ## Capabilities, per browser, and when each arrived
@@ -43,6 +45,31 @@ The README's table, with each cell holding the version at which it became true.
43
45
  | Safari | 0.6.1 | 0.4.0 | 0.10.0 | none | none |
44
46
  | Tor Browser | 0.7.0 | 0.7.0 | 0.14.0 | 0.7.0 | 0.13.0 |
45
47
 
48
+ ## 20261006
49
+
50
+ 0.19.0: ~ the history queries: carry everything meaningful, the bookkeeping left out; + Safari's titles.
51
+
52
+ 1. ~ Browser::Safari.history_sql: + history_visits.title, which Safari has held all along and the query had never asked for.
53
+ 2. So Browser::Visit#title is no longer nil for Safari, and to_objects, to_csv, to_json and to_plist carry it.
54
+ 3. 0.18.0 shipped the claim that Safari stores no title, in Browser::Visit's header and in README.md, and it was never so.
55
+ 4. ~ the same: + load_successful, http_non_get, synthesized, redirect_source, redirect_destination, origin, visit_count and status_code.
56
+ 5. ~ the same: history_visits.id in place of history_items.id, a row being a visit rather than an item.
57
+ 6. ~ the same: the join driven from history_visits, ON rather than a WHERE, so that a visit whose item is gone arrives with no url in place of vanishing.
58
+ 7. ~ Browser::FirefoxBased.history_sql: + from_visit, visit_type, session, source, visit_count, hidden, typed, last_visit_date, guid, description, preview_image_url and site_name, four columns of twenty-seven becoming sixteen.
59
+ 8. - from both: the internal keys, the index helpers, the opaque blobs, the ranking scores and their recalculation flags, which are each browser's own bookkeeping and tell a consumer nothing.
60
+ 9. Browser::ChromiumBased.history_sql is unchanged, SELECT * over urls carrying all seven of its columns, every one of them meaningful.
61
+ 10. to_objects is untouched throughout, so the renderers carry the same three fields and the detail rides on attributes.
62
+ 11. ~ Browser::Visit: the header, which had said Chromium's visit_count, typed_count and hidden have no counterpart in the others; moz_places holds visit_count, hidden and typed, and the query had not asked.
63
+ 12. ~ Rakefile: + status_code to the Safari fixture's history_items, which the real table has and the fixture lacked.
64
+ 13. ~ the same: the Firefox fixture's place carrying a visit_count, typed, last_visit_date, guid, description and site_name, and its visit a session and a source.
65
+ 14. ~ test/fixtures/Safari_history.sqlite, FirefoxBased_places.sqlite rebuilt.
66
+ 15. ~ test/Browser/Safari_test.rb: the history expected with its titles; + the carried detail and the bookkeeping left out.
67
+ 16. ~ test/Browser/Firefox_test.rb, TorBrowser_test.rb: the widened sql; + the same.
68
+ 17. ~ test/Browser/Visit_test.rb: a nil title is a browser which gave none, not Safari.
69
+ 18. ~ README.md: what attributes carries, in place of the claim about Safari's titles.
70
+ 19. ~ Browser::VERSION: /0.18.0/0.19.0/
71
+
72
+
46
73
  ## 20261005
47
74
 
48
75
  0.18.0: + Browser::Visit, history as one representation whatever the browser.
data/README.md CHANGED
@@ -79,8 +79,10 @@ where a folder, or `Bookmark#name`, is to be had.
79
79
  `visited_at`, which is a `Time` in UTC, with the browser's own row kept on
80
80
  `attributes`. The three browsers count from three epochs — Chromium in microseconds
81
81
  from 1601, Firefox in microseconds from 1970, Safari in seconds from 2001 — and all
82
- three arrive converted. Safari stores no title with its history, so that field is nil
83
- there.
82
+ three arrive converted. `attributes` carries everything else the browser holds which
83
+ a consumer could want, leaving out its internal keys, index helpers and ranking
84
+ scores: Firefox's `guid`, `description` and `visit_type`, Safari's `load_successful`
85
+ and `status_code`, the Chromium family's `typed_count`.
84
86
 
85
87
  `profile_path` is the directory the profile sits in, which a Selenium front end wants
86
88
  in place of a throwaway one. Safari, having no profiles, answers `nil`.
data/Rakefile CHANGED
@@ -118,7 +118,18 @@ namespace :fixtures do
118
118
  )
119
119
  end
120
120
 
121
- db.execute('INSERT INTO moz_historyvisits (id, place_id, visit_date, visit_type) VALUES (?, ?, ?, ?)', [1, 5, added + 152741667, 1])
121
+ # Place 5 is the one with history, so it carries what a visit holds besides the
122
+ # url and the title, which Browser::Visit keeps as attributes.
123
+ db.execute(
124
+ 'UPDATE moz_places SET visit_count = ?, typed = ?, last_visit_date = ?, guid = ?, description = ?, site_name = ? WHERE id = ?',
125
+ [1, 1, added + 152741667, 'Ab1cD2eF3gH4', 'Recommended extensions for Firefox', 'addons.mozilla.org', 5]
126
+ )
127
+
128
+ # source 0 is a local visit, 1 a synced one; visit_type 1 is a followed link.
129
+ db.execute(
130
+ 'INSERT INTO moz_historyvisits (id, place_id, visit_date, visit_type, session, source) VALUES (?, ?, ?, ?, ?, ?)',
131
+ [1, 5, added + 152741667, 1, 1, 0]
132
+ )
122
133
  db.close
123
134
  puts "Wrote #{path} (#{File.size(path)} bytes)."
124
135
  end
@@ -141,7 +152,8 @@ namespace :fixtures do
141
152
  weekly_visit_counts BLOB NULL,
142
153
  autocomplete_triggers BLOB NULL,
143
154
  should_recompute_derived_visit_counts INTEGER NOT NULL,
144
- visit_count_score INTEGER NOT NULL
155
+ visit_count_score INTEGER NOT NULL,
156
+ status_code INTEGER NOT NULL DEFAULT 0
145
157
  );
146
158
  CREATE TABLE history_visits (
147
159
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -161,12 +173,12 @@ namespace :fixtures do
161
173
  CREATE INDEX history_visits_history_item_index ON history_visits (history_item);
162
174
  SQL
163
175
  [
164
- [1, 'https://www.apple.com/', 'apple', 3, 1],
165
- [2, 'https://support.apple.com/', 'support.apple', 1, 0],
166
- ].each do |id, url, domain, visit_count, score|
176
+ [1, 'https://www.apple.com/', 'apple', 3, 1, 200],
177
+ [2, 'https://support.apple.com/', 'support.apple', 1, 0, 200],
178
+ ].each do |id, url, domain, visit_count, score, status_code|
167
179
  db.execute(
168
- 'INSERT INTO history_items (id, url, domain_expansion, visit_count, daily_visit_counts, should_recompute_derived_visit_counts, visit_count_score) VALUES (?, ?, ?, ?, ?, 0, ?)',
169
- [id, url, domain, visit_count, SQLite3::Blob.new(''), score]
180
+ 'INSERT INTO history_items (id, url, domain_expansion, visit_count, daily_visit_counts, should_recompute_derived_visit_counts, visit_count_score, status_code) VALUES (?, ?, ?, ?, ?, 0, ?, ?)',
181
+ [id, url, domain, visit_count, SQLite3::Blob.new(''), score, status_code]
170
182
  )
171
183
  end
172
184
  # visit_time is seconds since 2001-01-01, which is Core Data's epoch.
@@ -80,8 +80,11 @@ class Browser
80
80
  'SELECT moz_bookmarks.id, moz_bookmarks.parent, moz_bookmarks.position, moz_bookmarks.type, moz_bookmarks.title, moz_bookmarks.guid, moz_places.url FROM moz_bookmarks LEFT JOIN moz_places ON moz_bookmarks.fk = moz_places.id ORDER BY moz_bookmarks.parent, moz_bookmarks.position;'
81
81
  end
82
82
 
83
+ # Everything either table holds which a consumer could want, which is all of
84
+ # them but the internal keys, rev_host and url_hash, and the frecency scores
85
+ # and their recalculation flags, all of which are Firefox's own bookkeeping.
83
86
  def history_sql
84
- 'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'
87
+ 'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date, moz_historyvisits.from_visit, moz_historyvisits.visit_type, moz_historyvisits.session, moz_historyvisits.source, moz_places.visit_count, moz_places.hidden, moz_places.typed, moz_places.last_visit_date, moz_places.guid, moz_places.description, moz_places.preview_image_url, moz_places.site_name FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'
85
88
  end
86
89
 
87
90
  def visited_at(row)
@@ -41,8 +41,12 @@ class Browser
41
41
  nil
42
42
  end
43
43
 
44
+ # Everything either table holds which a consumer could want, which leaves out
45
+ # the internal keys, domain_expansion, the visit count blobs and their
46
+ # recomputation flag, the two ranking scores, and generation and attributes,
47
+ # all of which are Safari's own bookkeeping.
44
48
  def history_sql
45
- 'SELECT history_items.id, history_items.url, history_visits.visit_time FROM history_items LEFT JOIN history_visits WHERE history_items.id = history_visits.history_item ORDER BY visit_time DESC;'
49
+ 'SELECT history_visits.id, history_items.url, history_visits.title, history_visits.visit_time, history_visits.load_successful, history_visits.http_non_get, history_visits.synthesized, history_visits.redirect_source, history_visits.redirect_destination, history_visits.origin, history_items.visit_count, history_items.status_code FROM history_visits LEFT JOIN history_items ON history_visits.history_item = history_items.id ORDER BY history_visits.visit_time DESC;'
46
50
  end
47
51
 
48
52
  def visited_at(row)
@@ -2,5 +2,5 @@
2
2
  # Browser::VERSION
3
3
 
4
4
  class Browser
5
- VERSION = '0.18.0'
5
+ VERSION = '0.19.0'
6
6
  end
data/lib/Browser/Visit.rb CHANGED
@@ -5,8 +5,9 @@
5
5
  # read: a url, a title and a time. For Firefox and Safari a row is one visit; for
6
6
  # the Chromium family it is a url and the last visit to it, so a page visited three
7
7
  # times is one Visit there and three elsewhere. The browser's own row stays as
8
- # attributes, since Chromium's visit_count, typed_count and hidden have no
9
- # counterpart in the others, and Safari stores no title at all.
8
+ # attributes, under the names that browser gave it: all three keep a visit count,
9
+ # Firefox alone a guid and a description, and Safari alone whether the page loaded
10
+ # and with what status.
10
11
 
11
12
  class Browser
12
13
  class Visit
@@ -18,7 +18,7 @@ require 'browser'
18
18
  describe Browser::Firefox do
19
19
  let(:places_fixtures_location){File.expand_path("#{__FILE__}/../../fixtures/FirefoxBased_places.sqlite")}
20
20
  let(:expected_bookmarks_sql){'SELECT moz_bookmarks.id, moz_bookmarks.parent, moz_bookmarks.position, moz_bookmarks.type, moz_bookmarks.title, moz_bookmarks.guid, moz_places.url FROM moz_bookmarks LEFT JOIN moz_places ON moz_bookmarks.fk = moz_places.id ORDER BY moz_bookmarks.parent, moz_bookmarks.position;'}
21
- let(:expected_history_sql){'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'}
21
+ let(:expected_history_sql){'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date, moz_historyvisits.from_visit, moz_historyvisits.visit_type, moz_historyvisits.session, moz_historyvisits.source, moz_places.visit_count, moz_places.hidden, moz_places.typed, moz_places.last_visit_date, moz_places.guid, moz_places.description, moz_places.preview_image_url, moz_places.site_name FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'}
22
22
 
23
23
  describe '.default_profile_name' do
24
24
  let(:profiles_ini) do
@@ -194,6 +194,17 @@ describe Browser::Firefox do
194
194
  expect(visit.visited_at).to eq(Time.utc(2026, 8, 23, 1, 39, 12) + Rational(741_667, 1_000_000))
195
195
  expect(visit.attributes['visit_date']).to eq(1787449152741667)
196
196
  end
197
+
198
+ it "carries everything meaningful either table holds, and none of the bookkeeping" do
199
+ attributes = subject.history.visits.first.attributes
200
+ expect(attributes['guid']).to eq('Ab1cD2eF3gH4')
201
+ expect(attributes['description']).to eq('Recommended extensions for Firefox')
202
+ expect(attributes['site_name']).to eq('addons.mozilla.org')
203
+ expect(attributes['visit_type']).to eq(1)
204
+ expect(attributes['source']).to eq(0)
205
+ expect(attributes['visit_count']).to eq(1)
206
+ expect(attributes.keys).to_not include('place_id', 'rev_host', 'url_hash', 'frecency')
207
+ end
197
208
  end
198
209
 
199
210
  describe "#readable?" do
@@ -15,7 +15,7 @@ require 'browser'
15
15
  describe Browser::Safari do
16
16
  let(:bookmarks_fixtures_location){File.expand_path("#{__FILE__}/../../fixtures/Safari_bookmarks.plist")}
17
17
  let(:history_fixtures_location){File.expand_path("#{__FILE__}/../../fixtures/Safari_history.sqlite")}
18
- let(:expected_history_sql){'SELECT history_items.id, history_items.url, history_visits.visit_time FROM history_items LEFT JOIN history_visits WHERE history_items.id = history_visits.history_item ORDER BY visit_time DESC;'}
18
+ let(:expected_history_sql){'SELECT history_visits.id, history_items.url, history_visits.title, history_visits.visit_time, history_visits.load_successful, history_visits.http_non_get, history_visits.synthesized, history_visits.redirect_source, history_visits.redirect_destination, history_visits.origin, history_items.visit_count, history_items.status_code FROM history_visits LEFT JOIN history_items ON history_visits.history_item = history_items.id ORDER BY history_visits.visit_time DESC;'}
19
19
 
20
20
  describe 'DEFAULT_PROFILE_NAME' do
21
21
  it "has no default profile name" do
@@ -67,8 +67,8 @@ describe Browser::Safari do
67
67
  let(:browser_name){'Safari'}
68
68
  let(:expected_history) do
69
69
  [
70
- {url: 'https://www.apple.com/', title: nil, visited_at: Time.utc(2025, 9, 25)},
71
- {url: 'https://support.apple.com/', title: nil, visited_at: Time.utc(2025, 9, 24, 23, 40)},
70
+ {url: 'https://www.apple.com/', title: 'Apple', visited_at: Time.utc(2025, 9, 25)},
71
+ {url: 'https://support.apple.com/', title: 'Apple Support', visited_at: Time.utc(2025, 9, 24, 23, 40)},
72
72
  ]
73
73
  end
74
74
 
@@ -144,13 +144,22 @@ describe Browser::Safari do
144
144
  expect(subject.history.to_objects).to eq(expected_history)
145
145
  end
146
146
 
147
- it "returns the visits, with no title, Safari storing none" do
147
+ it "returns the visits, with the title history_visits holds" do
148
148
  visit = subject.history.visits.first
149
149
  expect(visit).to be_a(Browser::Visit)
150
- expect(visit.title).to be_nil
150
+ expect(visit.title).to eq('Apple')
151
151
  expect(visit.visited_at).to eq(Time.utc(2025, 9, 25))
152
152
  expect(visit.attributes['visit_time']).to eq(780451200.0)
153
153
  end
154
+
155
+ it "carries everything meaningful either table holds, and none of the bookkeeping" do
156
+ attributes = subject.history.visits.first.attributes
157
+ expect(attributes['load_successful']).to eq(1)
158
+ expect(attributes['status_code']).to eq(200)
159
+ expect(attributes['visit_count']).to eq(3)
160
+ expect(attributes['origin']).to eq(0)
161
+ expect(attributes.keys).to_not include('history_item', 'domain_expansion', 'daily_visit_counts', 'visit_count_score', 'score', 'generation', 'attributes')
162
+ end
154
163
  end
155
164
 
156
165
  describe "#readable?" do
@@ -15,7 +15,7 @@ require 'browser'
15
15
  describe Browser::TorBrowser do
16
16
  let(:places_fixtures_location){File.expand_path("#{__FILE__}/../../fixtures/FirefoxBased_places.sqlite")}
17
17
  let(:expected_bookmarks_sql){'SELECT moz_bookmarks.id, moz_bookmarks.parent, moz_bookmarks.position, moz_bookmarks.type, moz_bookmarks.title, moz_bookmarks.guid, moz_places.url FROM moz_bookmarks LEFT JOIN moz_places ON moz_bookmarks.fk = moz_places.id ORDER BY moz_bookmarks.parent, moz_bookmarks.position;'}
18
- let(:expected_history_sql){'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'}
18
+ let(:expected_history_sql){'SELECT moz_historyvisits.id, moz_places.url, moz_places.title, moz_historyvisits.visit_date, moz_historyvisits.from_visit, moz_historyvisits.visit_type, moz_historyvisits.session, moz_historyvisits.source, moz_places.visit_count, moz_places.hidden, moz_places.typed, moz_places.last_visit_date, moz_places.guid, moz_places.description, moz_places.preview_image_url, moz_places.site_name FROM moz_historyvisits LEFT JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'}
19
19
 
20
20
  describe '.default_profile_name' do
21
21
  let(:profiles_ini){"[Profile0]\nName=default\nIsRelative=1\nPath=abcd1234.default\nDefault=1\n\n[General]\nStartWithLastProfile=1\nVersion=2\n"}
@@ -26,7 +26,7 @@ describe Browser::Visit do
26
26
  expect(visit.to_h).to eq({url: 'https://example.com/', title: 'Home', visited_at: visited_at})
27
27
  end
28
28
 
29
- it "carries a nil title, which Safari stores none of" do
29
+ it "carries a nil title where the browser gave none" do
30
30
  expect(Browser::Visit.new(url: 'https://example.com/', visited_at: visited_at).to_h[:title]).to be_nil
31
31
  end
32
32
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran