fact_db 0.0.1 → 0.0.2
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +22 -7
- data/lib/fact_db/database.rb +1 -0
- data/lib/fact_db/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a87c848e8b274c26d7960e6ac91c5efaf3238b568fb264e2c92e3d37548aa398
|
|
4
|
+
data.tar.gz: 72d964331f79436f8efefc0627896709fe2a32487195da21a180504c15c67082
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74c901b77d7081e53ff87dc81800cc4cb862b83de96ce1e8b15de2f46e0b4d7b8e7b91daaaaedaca9fa723c36da9b0142fa68c2a9583a1f52731b7642ed29245
|
|
7
|
+
data.tar.gz: 6f7359db8aaaa3c60c8fba762d4c96157834f2427e4295e760b74671ca30dfa4340c2070078d287b9263d77be7e8f89cb6a6731792a4273cc3233d4bb11aba81
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,16 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
9
9
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
10
10
|
|
|
11
|
+
## [0.0.2] - 2025-01-08
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Database connection now validates configuration before connecting, providing a clear `ConfigurationError: Database URL required` message instead of confusing ActiveRecord errors when `database_url` is not set
|
|
16
|
+
- README Getting Started examples now work correctly when copied into IRB:
|
|
17
|
+
- Database URL uses `ENV['USER']` for the PostgreSQL role instead of defaulting to non-existent "postgres" role
|
|
18
|
+
- Added `FactDb::Database.migrate!` step to set up the schema
|
|
19
|
+
- Examples are now split into logical blocks that build on each other
|
|
20
|
+
|
|
11
21
|
## [0.0.1] - 2025-01-08
|
|
12
22
|
|
|
13
23
|
### Added
|
data/README.md
CHANGED
|
@@ -49,37 +49,52 @@ bundle install
|
|
|
49
49
|
```ruby
|
|
50
50
|
require 'fact_db'
|
|
51
51
|
|
|
52
|
-
# Configure
|
|
52
|
+
# Configure with a PostgreSQL database URL
|
|
53
53
|
FactDb.configure do |config|
|
|
54
|
-
config.database_url = ENV['
|
|
54
|
+
config.database_url = ENV.fetch("DATABASE_URL", "postgres://#{ENV['USER']}@localhost/fact_db_demo")
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
# Run migrations to create the schema (only needed once)
|
|
58
|
+
FactDb::Database.migrate!
|
|
59
|
+
|
|
57
60
|
# Create a facts instance
|
|
58
61
|
facts = FactDb.new
|
|
62
|
+
```
|
|
59
63
|
|
|
64
|
+
Once configured, you can ingest content and create facts:
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
60
67
|
# Ingest content
|
|
61
68
|
content = facts.ingest(
|
|
62
69
|
"Paula Chen joined Microsoft as Principal Engineer on January 10, 2024.",
|
|
63
70
|
type: :email,
|
|
64
|
-
captured_at: Time.
|
|
71
|
+
captured_at: Time.now
|
|
65
72
|
)
|
|
66
73
|
|
|
67
74
|
# Create entities
|
|
68
75
|
paula = facts.entity_service.create("Paula Chen", type: :person)
|
|
76
|
+
microsoft = facts.entity_service.create("Microsoft", type: :organization)
|
|
69
77
|
|
|
70
|
-
# Create a fact
|
|
78
|
+
# Create a fact with entity mentions
|
|
71
79
|
facts.fact_service.create(
|
|
72
80
|
"Paula Chen is Principal Engineer at Microsoft",
|
|
73
81
|
valid_at: Date.new(2024, 1, 10),
|
|
74
|
-
mentions: [
|
|
82
|
+
mentions: [
|
|
83
|
+
{ entity_id: paula.id, role: :subject, text: "Paula Chen" },
|
|
84
|
+
{ entity_id: microsoft.id, role: :object, text: "Microsoft" }
|
|
85
|
+
]
|
|
75
86
|
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Query facts temporally:
|
|
76
90
|
|
|
77
|
-
|
|
91
|
+
```ruby
|
|
92
|
+
# Query current facts about Paula
|
|
78
93
|
facts.current_facts_for(paula.id).each do |fact|
|
|
79
94
|
puts fact.fact_text
|
|
80
95
|
end
|
|
81
96
|
|
|
82
|
-
# Query facts at a point in time
|
|
97
|
+
# Query facts at a point in time (before she joined)
|
|
83
98
|
facts.facts_at(Date.new(2023, 6, 15), entity: paula.id)
|
|
84
99
|
```
|
|
85
100
|
|
data/lib/fact_db/database.rb
CHANGED
data/lib/fact_db/version.rb
CHANGED