vehiclesdb 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ddd74fa0a497549ce1320d4859903850c50194a49cd6066f8f085d23fc6b02fb
4
+ data.tar.gz: bc0cc1609d2f8d7cf129b3f64fb85b99fd2c7d0c7e8a139e6c3580d125c1fac6
5
+ SHA512:
6
+ metadata.gz: 70fd6c47778a661e5d124aa4cae9507d755758912d9e80a250cbb7545c00e9ef6fcdd97eac6faf83476aef5a04467cc9c78d8944234133c1033e38a7cd2fdb76
7
+ data.tar.gz: 361c00023f83304dce6106cf0a78528f2473f342e5d090c716292cb53f4facf9b8423d5d375cb71120d443a9738d7326f36bfe67c966be8180b75f124f03abc9
data/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-06-23
11
+
12
+ Initial release — the shell. Reserves the gem and establishes its shape ahead of
13
+ the VehiclesDB API going public.
14
+
15
+ ### Added
16
+ - `VehiclesDB.configure` + `VehiclesDB::Configuration` (api_key — defaults from
17
+ `ENV["VEHICLESDB_API_KEY"]` — api_base_url, timeout, user_agent).
18
+ - `VehiclesDB::Client` with auth/JSON/timeout request plumbing and a
19
+ `configured?` check; `VehiclesDB.client` memoized default client.
20
+ - Error hierarchy: `VehiclesDB::Error` < `ConfigurationError` / `AuthenticationError` / `ApiError`.
21
+
22
+ Resource methods (model, image, …) land as the API ships.
23
+
24
+ [Unreleased]: https://github.com/rameerez/vehiclesdb-ruby/compare/v0.1.0...HEAD
25
+ [0.1.0]: https://github.com/rameerez/vehiclesdb-ruby/releases/tag/v0.1.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Javi R
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # 🚗 `vehiclesdb` – Official Ruby SDK for the VehiclesDB API
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/vehiclesdb.svg)](https://badge.fury.io/rb/vehiclesdb) [![Build Status](https://github.com/rameerez/vehiclesdb-ruby/workflows/Tests/badge.svg)](https://github.com/rameerez/vehiclesdb-ruby/actions)
4
+
5
+ > [!TIP]
6
+ > **🚀 Ship your next Rails app 10x faster!** I've built **[RailsFast](https://railsfast.com/?ref=vehiclesdb)**, a production-ready Rails boilerplate template that comes with everything you need to launch a software business in days, not weeks. Go [check it out](https://railsfast.com/?ref=vehiclesdb)!
7
+
8
+ `vehiclesdb` is the official Ruby client for the [**VehiclesDB API**](https://vehiclesdb.com) — a hosted service for rich vehicle data: production years, model images (year- and color-accurate), market segments, specifications, and more.
9
+
10
+ > [!NOTE]
11
+ > **This is an early shell release.** It reserves the gem and sets its shape; the VehiclesDB API isn't public yet, so resource methods (models, images, …) land as the service ships. Configuration, the client, and the error model are in place today.
12
+
13
+ ## `vehiclesdb` vs `vehicles` — which do I want?
14
+
15
+ Two gems, one product, and they're **fully independent** (each works on its own):
16
+
17
+ | | [`vehicles`](https://github.com/rameerez/vehicles) | `vehiclesdb` (this gem) |
18
+ |---|---|---|
19
+ | What | Bundled make/model dataset + a delightful local API | Thin client for the hosted VehiclesDB API |
20
+ | Data | Ships **inside the gem** (EU, offline) | Lives on the **server** (the paid API) |
21
+ | Setup | Zero — no key, no network | Needs an API key |
22
+ | Use it for | Make/model dropdowns, search, validation | Years, images, segments, specs |
23
+
24
+ Most apps want **`vehicles`** — it works offline with zero config. Add **`vehiclesdb`** (and a key) when you want the richer hosted data; `vehicles` will use it automatically for enrichment. Or use `vehiclesdb` directly if all you want is the raw API.
25
+
26
+ ## Installation
27
+
28
+ ```ruby
29
+ gem "vehiclesdb"
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```ruby
35
+ VehiclesDB.configure do |config|
36
+ config.api_key = ENV["VEHICLESDB_API_KEY"] # or just set ENV["VEHICLESDB_API_KEY"]
37
+ end
38
+
39
+ VehiclesDB.client.configured? # => true
40
+ ```
41
+
42
+ You can also build a client explicitly (handy for multiple keys / standalone use):
43
+
44
+ ```ruby
45
+ client = VehiclesDB::Client.new(api_key: "vdb_live_...")
46
+ client.configured? # => true
47
+ ```
48
+
49
+ ### Errors
50
+
51
+ Everything raises a subclass of `VehiclesDB::Error`, so you can rescue broadly or narrowly:
52
+
53
+ ```ruby
54
+ VehiclesDB::Error # rescue-all base
55
+ VehiclesDB::ConfigurationError # no API key configured
56
+ VehiclesDB::AuthenticationError # bad key (HTTP 401/403)
57
+ VehiclesDB::ApiError # other non-2xx — carries #status and #body
58
+ ```
59
+
60
+ ## Configuration
61
+
62
+ | Option | Default | Notes |
63
+ |---|---|---|
64
+ | `api_key` | `ENV["VEHICLESDB_API_KEY"]` | your VehiclesDB key |
65
+ | `api_base_url` | `https://api.vehiclesdb.com` | override for staging/self-host/tests |
66
+ | `timeout` | `5` | request timeout (seconds) |
67
+ | `user_agent` | `vehiclesdb-ruby/<version>` | sent with every request |
68
+
69
+ ## Development
70
+
71
+ After checking out the repo, run `bin/setup` to install dependencies. Then run
72
+ `rake test`. You can also run `bin/console` for an interactive prompt.
73
+
74
+ To install this gem onto your local machine, run `bundle exec rake install`.
75
+
76
+ ## Contributing
77
+
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rameerez/vehiclesdb-ruby. Our code of conduct is: just be nice and make your mom proud of what you do and post online.
79
+
80
+ ## License
81
+
82
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module VehiclesDB
6
+ # A thin client over the VehiclesDB HTTP API. Standalone: construct one
7
+ # directly, or use `VehiclesDB.client` (which reads the global configuration).
8
+ #
9
+ # client = VehiclesDB::Client.new(api_key: "vdb_...")
10
+ # client.configured? # => true
11
+ #
12
+ # The request plumbing (auth header, JSON, timeout, error mapping) is ready;
13
+ # resource methods (e.g. `model`, `image`) are added as the API ships — they'll
14
+ # build on the private `get` below. Kept deliberately small for now: this
15
+ # release reserves the gem and sets the shape.
16
+ class Client
17
+ attr_reader :api_key, :api_base_url, :timeout
18
+
19
+ def initialize(api_key: nil, api_base_url: nil, timeout: nil)
20
+ config = VehiclesDB.configuration
21
+ @api_key = api_key || config.api_key
22
+ @api_base_url = api_base_url || config.api_base_url
23
+ @timeout = timeout || config.timeout
24
+ end
25
+
26
+ # True when an API key is present (the client can authenticate).
27
+ def configured?
28
+ !api_key.to_s.empty?
29
+ end
30
+
31
+ private
32
+
33
+ # GET a JSON resource and return the parsed body. Raises ConfigurationError
34
+ # when unconfigured, AuthenticationError on 401/403, ApiError otherwise. The
35
+ # caller decides whether to rescue. Resource methods will wrap this.
36
+ def get(path, params = {})
37
+ raise ConfigurationError, "No VehiclesDB API key configured" unless configured?
38
+
39
+ handle(connection.get(path, params))
40
+ end
41
+
42
+ def handle(response)
43
+ return response.body if response.success?
44
+ raise AuthenticationError, "Invalid VehiclesDB API key" if [401, 403].include?(response.status)
45
+
46
+ raise ApiError.new("VehiclesDB API error (HTTP #{response.status})",
47
+ status: response.status, body: response.body)
48
+ end
49
+
50
+ def connection
51
+ @connection ||= Faraday.new(url: api_base_url) do |f|
52
+ f.request :json
53
+ f.response :json
54
+ f.headers["Authorization"] = "Bearer #{api_key}"
55
+ f.headers["User-Agent"] = VehiclesDB.configuration.user_agent
56
+ f.options.timeout = timeout
57
+ f.adapter Faraday.default_adapter
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VehiclesDB
4
+ # Global configuration. Sensible defaults; the API key is picked up from
5
+ # ENV["VEHICLESDB_API_KEY"] automatically, so the common case needs no setup.
6
+ #
7
+ # VehiclesDB.configure do |config|
8
+ # config.api_key = "vdb_live_..."
9
+ # end
10
+ class Configuration
11
+ # Your VehiclesDB API key. Defaults to ENV["VEHICLESDB_API_KEY"].
12
+ attr_accessor :api_key
13
+
14
+ # Base URL of the API. Overridable for self-hosting / staging / testing.
15
+ attr_accessor :api_base_url
16
+
17
+ # Request timeout in seconds.
18
+ attr_accessor :timeout
19
+
20
+ # Sent as the User-Agent header so VehiclesDB can see SDK usage.
21
+ attr_accessor :user_agent
22
+
23
+ def initialize
24
+ @api_key = ENV.fetch("VEHICLESDB_API_KEY", nil)
25
+ @api_base_url = "https://api.vehiclesdb.com"
26
+ @timeout = 5
27
+ @user_agent = "vehiclesdb-ruby/#{VehiclesDB::VERSION}"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VehiclesDB
4
+ # Base class for every error this gem raises — rescue `VehiclesDB::Error` to
5
+ # catch them all.
6
+ class Error < StandardError; end
7
+
8
+ # No API key configured (or an empty one).
9
+ class ConfigurationError < Error; end
10
+
11
+ # The API rejected the credentials (HTTP 401/403).
12
+ class AuthenticationError < Error; end
13
+
14
+ # Any other non-success API response. Carries the HTTP status and parsed body.
15
+ class ApiError < Error
16
+ attr_reader :status, :body
17
+
18
+ def initialize(message = nil, status: nil, body: nil)
19
+ @status = status
20
+ @body = body
21
+ super(message)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VehiclesDB
4
+ VERSION = "0.1.0"
5
+ end
data/lib/vehiclesdb.rb ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "vehiclesdb/version"
4
+ require_relative "vehiclesdb/error"
5
+ require_relative "vehiclesdb/configuration"
6
+ require_relative "vehiclesdb/client"
7
+
8
+ # VehiclesDB — the official Ruby SDK for the VehiclesDB API
9
+ # (https://vehiclesdb.com): a hosted service for rich vehicle data — production
10
+ # years, model images (year- and color-accurate), market segments, specs, and more.
11
+ #
12
+ # This is the low-level API wrapper. If you just want make/model dropdowns that
13
+ # work offline with zero setup, use the `vehicles` gem instead — it bundles the
14
+ # data locally and reaches for VehiclesDB only for optional hosted enrichment.
15
+ # The two are independent: `vehicles` works without this gem, and this gem works
16
+ # without `vehicles`.
17
+ #
18
+ # VehiclesDB.configure { |c| c.api_key = ENV["VEHICLESDB_API_KEY"] }
19
+ # VehiclesDB.client.configured? # => true
20
+ #
21
+ # NOTE: the VehiclesDB API is not public yet. This release reserves the gem and
22
+ # establishes its shape; resource methods land as the API ships.
23
+ module VehiclesDB
24
+ class << self
25
+ def configuration
26
+ @configuration ||= Configuration.new
27
+ end
28
+
29
+ def configure
30
+ yield(configuration)
31
+ end
32
+
33
+ # Reset config + the memoized default client. Mainly for tests.
34
+ def reset_configuration!
35
+ @configuration = Configuration.new
36
+ @client = nil
37
+ end
38
+
39
+ # Memoized default client, built from the global configuration.
40
+ def client
41
+ @client ||= Client.new
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,41 @@
1
+ # Type signatures for the public API. (Best-effort; the README and code are the
2
+ # source of truth.)
3
+
4
+ module VehiclesDB
5
+ VERSION: String
6
+
7
+ def self.configuration: () -> Configuration
8
+ def self.configure: () { (Configuration) -> void } -> void
9
+ def self.reset_configuration!: () -> void
10
+ def self.client: () -> Client
11
+
12
+ class Error < StandardError
13
+ end
14
+
15
+ class ConfigurationError < Error
16
+ end
17
+
18
+ class AuthenticationError < Error
19
+ end
20
+
21
+ class ApiError < Error
22
+ attr_reader status: Integer?
23
+ attr_reader body: untyped
24
+ def initialize: (?String?, ?status: Integer?, ?body: untyped) -> void
25
+ end
26
+
27
+ class Configuration
28
+ attr_accessor api_key: String?
29
+ attr_accessor api_base_url: String
30
+ attr_accessor timeout: Integer
31
+ attr_accessor user_agent: String
32
+ end
33
+
34
+ class Client
35
+ attr_reader api_key: String?
36
+ attr_reader api_base_url: String
37
+ attr_reader timeout: Integer
38
+ def initialize: (?api_key: String?, ?api_base_url: String?, ?timeout: Integer?) -> void
39
+ def configured?: () -> bool
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vehiclesdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - rameerez
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-06-23 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
32
+ description: 'vehiclesdb is the official Ruby client for the VehiclesDB API (https://vehiclesdb.com),
33
+ a hosted service for rich vehicle data: production years, model images (year- and
34
+ color-accurate), market segments, specifications, and more. It''s the low-level
35
+ API wrapper that the `vehicles` gem uses for optional hosted enrichment — but both
36
+ gems are fully independent and usable on their own.'
37
+ email:
38
+ - rubygems@rameerez.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - CHANGELOG.md
44
+ - LICENSE.txt
45
+ - README.md
46
+ - lib/vehiclesdb.rb
47
+ - lib/vehiclesdb/client.rb
48
+ - lib/vehiclesdb/configuration.rb
49
+ - lib/vehiclesdb/error.rb
50
+ - lib/vehiclesdb/version.rb
51
+ - sig/vehiclesdb.rbs
52
+ homepage: https://github.com/rameerez/vehiclesdb-ruby
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ allowed_push_host: https://rubygems.org
57
+ homepage_uri: https://github.com/rameerez/vehiclesdb-ruby
58
+ source_code_uri: https://github.com/rameerez/vehiclesdb-ruby/tree/main
59
+ changelog_uri: https://github.com/rameerez/vehiclesdb-ruby/blob/main/CHANGELOG.md
60
+ rubygems_mfa_required: 'true'
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.6.2
76
+ specification_version: 4
77
+ summary: Official Ruby SDK for the VehiclesDB API — rich vehicle data (years, images,
78
+ segments, specs).
79
+ test_files: []