zillace 0.0.1
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 +7 -0
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -0
- data/README.md +23 -0
- data/Rakefile +14 -0
- data/lib/zillace/version.rb +3 -0
- data/lib/zillace.rb +80 -0
- data/manifest.scm +1 -0
- data/script/sample.rb +13 -0
- data/sig/zillace.rbs +4 -0
- metadata +70 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 19b7f2fd9f94f910b62184f4bd8bc1c940e887e772b729089c729fa386d5f418
|
|
4
|
+
data.tar.gz: d2bdb6c7e6c172a7f3fad783268a7dda28845b1dc48899713ac6b7a140f8e635
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 00275e10e87ba43b5c725e722ff7b905e477ca9acefe8494c9e442e720c57673d77415f4dd0772446a07511cb0f42ca8ad92452df2b9e105d1d1a27c0ea93ce4
|
|
7
|
+
data.tar.gz: 4f2231c47d58d523d001248396a9528c56721b304251f3ab39c7671f085306694c8072ba1da6cb65df12fbf781638c485ba4775774c707b3823b4a57d8bffafe
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.1
|
|
3
|
+
NewCops: enable
|
|
4
|
+
DisabledByDefault: true
|
|
5
|
+
|
|
6
|
+
Style/StringLiterals:
|
|
7
|
+
Enabled: true
|
|
8
|
+
EnforcedStyle: single_quotes
|
|
9
|
+
|
|
10
|
+
Style/StringLiteralsInInterpolation:
|
|
11
|
+
Enabled: true
|
|
12
|
+
EnforcedStyle: single_quotes
|
|
13
|
+
|
|
14
|
+
Style/FrozenStringLiteralComment:
|
|
15
|
+
Enabled: true
|
|
16
|
+
EnforcedStyle: never
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Zillace
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Install the gem and add to the application's `Gemfile` by executing: `bundle add zillace`.
|
|
6
|
+
If Bundler is not being used to manage dependencies, install the gem by executing: `gem install zillace`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Please see `script/sample.rb` as a simple example at the moment.
|
|
11
|
+
|
|
12
|
+
## Development
|
|
13
|
+
|
|
14
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
|
15
|
+
Then, run `rake test` to run the tests.
|
|
16
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
17
|
+
|
|
18
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
19
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
23
|
+
Bug reports and pull requests are welcome.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << 'test'
|
|
6
|
+
t.libs << 'lib'
|
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require 'rubocop/rake_task'
|
|
11
|
+
|
|
12
|
+
RuboCop::RakeTask.new
|
|
13
|
+
|
|
14
|
+
task default: %i[test rubocop]
|
data/lib/zillace.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require_relative 'zillace/version'
|
|
2
|
+
require 'sqlite3'
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
module Zillace
|
|
6
|
+
def self.prtime(micro_seconds)
|
|
7
|
+
Time.new(Rational(micro_seconds, 1_000_000))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Error < StandardError; end
|
|
11
|
+
|
|
12
|
+
class Database
|
|
13
|
+
def initialize(profile_prefix: File.join(Dir.home, '.var/app/org.mozilla.firefox'))
|
|
14
|
+
@profile_prefix = profile_prefix
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def connect
|
|
18
|
+
pattern = File.join(@profile_prefix, '.mozilla/firefox/*.default-release/places.sqlite')
|
|
19
|
+
path = Dir[pattern].first
|
|
20
|
+
@database = SQLite3::Database.new(path)
|
|
21
|
+
self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
extend Forwardable
|
|
25
|
+
def_delegators :@database, :execute
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Place
|
|
29
|
+
attr_reader :url, :title
|
|
30
|
+
|
|
31
|
+
def initialize(id:, url:, title:)
|
|
32
|
+
@id = id
|
|
33
|
+
@url = url
|
|
34
|
+
@title = title
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.each(database: Database.new.connect, &block)
|
|
38
|
+
enumerator = Enumerator.new do |enumerator|
|
|
39
|
+
database.execute('select id, url, title from moz_places') do |row|
|
|
40
|
+
id, url, title = row
|
|
41
|
+
enumerator << new(id:, url:, title:)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
block_given? ? enumerator.each(&block) : enumerator
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.find(id, database: Database.new.connect)
|
|
49
|
+
url, title = database.execute('select url, title from moz_places where id = ?', id).first
|
|
50
|
+
return new(id:, url:, title:)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Bookmark
|
|
55
|
+
attr_reader :title, :date_added, :last_modified
|
|
56
|
+
|
|
57
|
+
def initialize(fk:, title:, date_added:, last_modified:, database: Database.new.connect)
|
|
58
|
+
@fk = fk
|
|
59
|
+
@title = title
|
|
60
|
+
@date_added = date_added
|
|
61
|
+
@last_modified = last_modified
|
|
62
|
+
@database = database
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.each(database: Database.new.connect, &block)
|
|
66
|
+
enumerator = Enumerator.new do |enumerator|
|
|
67
|
+
database.execute('select fk, title, dateAdded, lastModified from moz_bookmarks') do |row|
|
|
68
|
+
fk, title, date_added, last_modified = row
|
|
69
|
+
enumerator << new(fk:, title:, date_added: ::Zillace.prtime(date_added), last_modified: ::Zillace.prtime(last_modified), database:)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
block_given? ? enumerator.each(&block) : enumerator
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def url
|
|
77
|
+
Place.find(@fk, database: @database).url
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/manifest.scm
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(specifications->manifest (list "ruby@3.1" "ruby-sqlite3" "ruby-rubocop"))
|
data/script/sample.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This sample script generates bookmark contents for qutebrowser's quickmarks file content
|
|
2
|
+
#
|
|
3
|
+
# Usage:
|
|
4
|
+
# ruby script/sample.rb >> ~/.config/qutebrowser/quickmarks
|
|
5
|
+
|
|
6
|
+
require_relative '../lib/zillace'
|
|
7
|
+
|
|
8
|
+
Zillace::Bookmark.each do |bookmark|
|
|
9
|
+
url = bookmark.url or next
|
|
10
|
+
title = bookmark.title or next
|
|
11
|
+
title = title.lines.join(' ')
|
|
12
|
+
puts [title, url].join(' ')
|
|
13
|
+
end
|
data/sig/zillace.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: zillace
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- gemmaro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-12-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: ruby-sqlite3
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
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
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: Zillace is a database manipulation library for Mozilla Firefox. It reads
|
|
28
|
+
the places.sqlite file under the user's Firefox profile directory.
|
|
29
|
+
email:
|
|
30
|
+
- gemmaro.dev@gmail.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- ".rubocop.yml"
|
|
36
|
+
- CHANGELOG.md
|
|
37
|
+
- Gemfile
|
|
38
|
+
- README.md
|
|
39
|
+
- Rakefile
|
|
40
|
+
- lib/zillace.rb
|
|
41
|
+
- lib/zillace/version.rb
|
|
42
|
+
- manifest.scm
|
|
43
|
+
- script/sample.rb
|
|
44
|
+
- sig/zillace.rbs
|
|
45
|
+
homepage: https://codeberg.org/gemmaro/zillace
|
|
46
|
+
licenses: []
|
|
47
|
+
metadata:
|
|
48
|
+
homepage_uri: https://codeberg.org/gemmaro/zillace
|
|
49
|
+
source_code_uri: https://codeberg.org/gemmaro/zillace.git
|
|
50
|
+
changelog_uri: https://codeberg.org/gemmaro/zillace/src/branch/main/CHANGELOG.md
|
|
51
|
+
post_install_message:
|
|
52
|
+
rdoc_options: []
|
|
53
|
+
require_paths:
|
|
54
|
+
- lib
|
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '3.1'
|
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '0'
|
|
65
|
+
requirements: []
|
|
66
|
+
rubygems_version: 3.3.26
|
|
67
|
+
signing_key:
|
|
68
|
+
specification_version: 4
|
|
69
|
+
summary: Mozilla Firefox places SQLite3 database library
|
|
70
|
+
test_files: []
|