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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 366d437bac93188689e47aaa27989e39ff0460440c26c03d8452ec4600790bdb
4
- data.tar.gz: 469c50a37a1316cef4f0a792d07478f4429909f668eff8ce53aed2a15ac7e1dd
3
+ metadata.gz: a87c848e8b274c26d7960e6ac91c5efaf3238b568fb264e2c92e3d37548aa398
4
+ data.tar.gz: 72d964331f79436f8efefc0627896709fe2a32487195da21a180504c15c67082
5
5
  SHA512:
6
- metadata.gz: f0da5fd32ac9bf5d2df045938e268cf99e10f10babf6809ef752138dfa0f0dcc26c7751e1ca8578fdb35c1eaf15b0dd69dd3bfd38734c05bec10b12b75ea3572
7
- data.tar.gz: 3e77ff65b642ae413b6527d0576018f9c73fb856a93e95444d278b856ec5ccf58ebbf9b43efbea15ff4248e2d7a17c416027ba93ec428778f38d29132bb1f2a3
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['DATABASE_URL']
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.current
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: [{ entity_id: paula.id, role: :subject, text: "Paula Chen" }]
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
- # Query current facts
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
 
@@ -7,6 +7,7 @@ module FactDb
7
7
  module Database
8
8
  class << self
9
9
  def establish_connection!(config = FactDb.config)
10
+ config.validate!
10
11
  ActiveRecord::Base.establish_connection(config.database_url)
11
12
  ActiveRecord::Base.logger = config.logger if config.logger
12
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FactDb
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fact_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer