ask-web-search 0.7.0 → 0.8.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: 0e72b7a5d69234d5b2a98512629e00c7887e690abf6cf312f02f24c092f9e464
4
- data.tar.gz: 37348a846dbf38c41f41df76d52b475d6fb94e29a0c70033b70bc6ca43b743fa
3
+ metadata.gz: 1b83b3aa3b4e051445e316284580fa85a0d478bb5256b60c87e14031e60c6130
4
+ data.tar.gz: '0168f632c9d32eb42996d55f197cf2a322ad86f839b7698788c9f0cfc2e8ba87'
5
5
  SHA512:
6
- metadata.gz: 489ae3316e2c88daf33cd31a478ec6a5e774fcd802a4b0c746577934af5db49fe94de9ffa12f1aa9ccde625e81129bc3d86263c9bc5ba259bf602c047153f046
7
- data.tar.gz: c99af3305cc4b3417dcfc15bf5f3752d55823fd8e73baac2923431b479ac23cfdee6f3f4d81789a88d2faa9aa3216c95d2c2254dde57dea2f3b5aaaa830728a8
6
+ metadata.gz: 5e5cb4c7817665ca81783898ea4709e7883786f5db18778ec09a7375ef4f2abadecc77c001900a48aea277e3b18859e11a9b2c1f1cc97ecb8ded1fb6e29478f7
7
+ data.tar.gz: 889707ff4c5f114ffbd2340cd667de622c281374e20fdee3023280706b8bad91ad3d46b02091274779a2e1ce8ed7acbb5bcad7669cb0f616765af50d6244a282
@@ -1,5 +1,5 @@
1
1
  module Ask
2
2
  module WebSearch
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -48,7 +48,9 @@ module Ask
48
48
 
49
49
  # TinyFish's hosted search endpoint — the primary backend for anyone
50
50
  # holding a (free) TINYFISH_API_KEY, so no SearXNG instance is needed.
51
- TINYFISH_SEARCH_URL = "https://api.search.tinyfish.ai/client.search.query"
51
+ # The bare host root per the official docs curl example; the
52
+ # /client.search.query path seen on the marketing pages 404s.
53
+ TINYFISH_SEARCH_URL = "https://api.search.tinyfish.ai"
52
54
 
53
55
  # Our time_range → TinyFish's recency_minutes (SearXNG's month/year
54
56
  # are approximate engine filters anyway; these are the equivalents).
@@ -70,13 +72,25 @@ module Ask
70
72
  "research_paper" => "research_paper"
71
73
  }.freeze
72
74
 
73
- # True when TinyFish should be the primary backend: a key is present
74
- # and TINYFISH_SEARCH=0 has not disabled it. Read fresh on every
75
- # call so tests and config reloads don't need memo resets.
75
+ # The TinyFish API key: ask-auth's chain when that gem is present
76
+ # (env override → ~/.ask/credentials.yml → …), raw ENV otherwise.
77
+ # nil when nothing resolves.
78
+ def self.tinyfish_api_key
79
+ return ENV["TINYFISH_API_KEY"] unless defined?(Ask::Auth)
80
+
81
+ Ask::Auth.resolve(:tinyfish_api_key)
82
+ rescue Ask::Auth::MissingCredential
83
+ nil
84
+ end
85
+
86
+ # True when TinyFish should be the primary backend: a key resolves
87
+ # (#tinyfish_api_key) and TINYFISH_SEARCH=0 has not disabled it.
88
+ # Read fresh on every call so tests and config reloads don't need
89
+ # memo resets.
76
90
  def self.use_tinyfish?
77
91
  return false if ENV["TINYFISH_SEARCH"] == "0"
78
92
 
79
- !ENV["TINYFISH_API_KEY"].to_s.empty?
93
+ !tinyfish_api_key.to_s.empty?
80
94
  end
81
95
 
82
96
  # True when a SearXNG endpoint was configured explicitly (SEARXNG_URL
@@ -210,7 +224,7 @@ module Ask
210
224
  http.open_timeout = 5
211
225
  http.read_timeout = 10
212
226
  req = Net::HTTP::Get.new(uri)
213
- req["X-API-Key"] = ENV["TINYFISH_API_KEY"]
227
+ req["X-API-Key"] = tinyfish_api_key
214
228
  req["User-Agent"] = "ask-web-search/#{Ask::WebSearch::VERSION}"
215
229
  res = http.request(req)
216
230
  raise Error, "TinyFish returned #{res.code}: #{res.body[0, 200]}" unless res.code.start_with?("2")
@@ -330,3 +344,15 @@ begin
330
344
  rescue LoadError => e
331
345
  raise unless e.path == "ask-tools"
332
346
  end
347
+
348
+ # ask-auth is an OPTIONAL credential source for the TinyFish key: when
349
+ # present, #tinyfish_api_key resolves through Ask::Auth (env override →
350
+ # ~/.ask/credentials.yml → …) instead of raw ENV alone, so the key can
351
+ # live in one canonical 0600 file instead of every config that spawns a
352
+ # server. Only the ask-auth miss is swallowed; any other LoadError is
353
+ # real.
354
+ begin
355
+ require "ask-auth"
356
+ rescue LoadError => e
357
+ raise unless e.path == "ask-auth"
358
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-web-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: ask-auth
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.3'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.3'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: vcr
28
42
  requirement: !ruby/object:Gem::Requirement