librix 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -13
- data/lib/librix/configuration.rb +0 -2
- data/lib/librix/providers/factory.rb +2 -1
- data/lib/librix/providers/open_library.rb +47 -0
- data/lib/librix/version.rb +1 -1
- data/lib/librix.rb +1 -0
- data/node_modules/.yarn-integrity +10 -0
- data/yarn.lock +4 -0
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3300a4d8cf026dc962a22b8dd50d7ce60887d616e76c9153220c42b69132388e
|
|
4
|
+
data.tar.gz: abfc5f0760d21ecaea46451ad88506c3a48966a3ca58a5b1cc238a384cfc0421
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1baf48dc4e454176fa2bf6e58432806a1a71eb4dfe675fda092791ff630dd0ea99db3ef742443f854fb98aaf0a4a5f0577192f79941c96dee39dc28fab0c74aa
|
|
7
|
+
data.tar.gz: 0ce4eb5891ee7d2ba3d48b48cf4519a14c6e8e5cb8b02e2f84b119211652f9585da5123fd94aa81c2d6ce9ccd5c4a1e874d5d8a1ce33352f9055832919b9ae7c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
# Librix
|
|
1
|
+
# Librix — Your Friendly Book API Librarian
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Librix** is a Ruby gem that makes working with book APIs easy.
|
|
4
|
+
Instead of juggling different endpoints and data formats from places like Google Books, Open Library, or Goodreads, Librix gives you one clean, consistent interface to work with.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
With Librix, you can:
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
- Connect to multiple book APIs through a single, unified interface
|
|
9
|
+
- Search for titles, authors, descriptions, and covers without the usual API chaos
|
|
10
|
+
- Get clean, consistent responses no matter where the data comes from
|
|
11
|
+
- Add new API integrations easily, without touching your core logic
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## Installation
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
16
|
bundle add librix
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
OR
|
|
16
20
|
|
|
17
21
|
```bash
|
|
18
22
|
gem install librix
|
|
@@ -51,15 +55,11 @@ result = provider.search(title: "Clean Code")
|
|
|
51
55
|
# provider = Librix.provider(:my_provider)
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
## Development
|
|
55
|
-
|
|
56
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
57
|
-
|
|
58
|
-
To install this gem onto your local machine, run `bundle exec rake install`. 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).
|
|
59
|
-
|
|
60
58
|
## Contributing
|
|
61
59
|
|
|
62
|
-
Bug reports and pull requests are welcome
|
|
60
|
+
Bug reports and pull requests are welcome.
|
|
61
|
+
|
|
62
|
+
This is my first gem by the way, so feel free to give me any feedback or advise :).
|
|
63
63
|
|
|
64
64
|
## License
|
|
65
65
|
|
data/lib/librix/configuration.rb
CHANGED
|
@@ -2,7 +2,6 @@ module Librix
|
|
|
2
2
|
class Configuration
|
|
3
3
|
attr_accessor :google_books_api_key,
|
|
4
4
|
:goodreads_api_key,
|
|
5
|
-
:open_library_enabled,
|
|
6
5
|
:provider,
|
|
7
6
|
:http_open_timeout,
|
|
8
7
|
:http_read_timeout,
|
|
@@ -10,7 +9,6 @@ module Librix
|
|
|
10
9
|
:google_books_base_url
|
|
11
10
|
|
|
12
11
|
def initialize
|
|
13
|
-
@open_library_enabled = false
|
|
14
12
|
@http_open_timeout = 2
|
|
15
13
|
@http_read_timeout = 5
|
|
16
14
|
@user_agent = "librix/#{Librix::VERSION}"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
module Librix
|
|
5
|
+
module Providers
|
|
6
|
+
class OpenLibrary
|
|
7
|
+
include HTTParty
|
|
8
|
+
|
|
9
|
+
base_uri 'https://openlibrary.org'
|
|
10
|
+
COVER_BASE = 'https://covers.openlibrary.org/b'.freeze
|
|
11
|
+
|
|
12
|
+
def search(query, limit: 10)
|
|
13
|
+
response = self.class.get(
|
|
14
|
+
'/search.json',
|
|
15
|
+
query: {
|
|
16
|
+
q: query,
|
|
17
|
+
limit: limit
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
response.success? ? response.parsed_response['docs'] : []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def cover_url(isbn: nil, cover_id: nil, olid: nil, size: 'M')
|
|
25
|
+
return cover_by_isbn(isbn, size) if isbn.present?
|
|
26
|
+
return cover_by_cover_id(cover_id, size) if cover_id.present?
|
|
27
|
+
return cover_by_olid(olid, size) if olid.present?
|
|
28
|
+
|
|
29
|
+
nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def cover_by_isbn(isbn, size)
|
|
35
|
+
"#{COVER_BASE}/ISBN/#{isbn}-#{size}.jpg?default=false"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def cover_by_cover_id(cover_id, size)
|
|
39
|
+
"#{COVER_BASE}/id/#{cover_id}-#{size}.jpg?default=false"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def cover_by_olid(olid, size)
|
|
43
|
+
"#{COVER_BASE}/OLID/#{olid}-#{size}.jpg?default=false"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/librix/version.rb
CHANGED
data/lib/librix.rb
CHANGED
data/yarn.lock
ADDED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: librix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vinicius Coelho
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-01-09 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: httparty
|
|
@@ -86,8 +87,11 @@ files:
|
|
|
86
87
|
- lib/librix/configuration.rb
|
|
87
88
|
- lib/librix/providers/factory.rb
|
|
88
89
|
- lib/librix/providers/google_books.rb
|
|
90
|
+
- lib/librix/providers/open_library.rb
|
|
89
91
|
- lib/librix/version.rb
|
|
92
|
+
- node_modules/.yarn-integrity
|
|
90
93
|
- sig/librix.rbs
|
|
94
|
+
- yarn.lock
|
|
91
95
|
homepage: https://github.com/viniciusscoelho/librix
|
|
92
96
|
licenses:
|
|
93
97
|
- MIT
|
|
@@ -96,6 +100,7 @@ metadata:
|
|
|
96
100
|
homepage_uri: https://github.com/viniciusscoelho/librix
|
|
97
101
|
source_code_uri: https://github.com/viniciusscoelho/librix
|
|
98
102
|
changelog_uri: https://github.com/viniciusscoelho/librix/blob/main/CHANGELOG.md
|
|
103
|
+
post_install_message:
|
|
99
104
|
rdoc_options: []
|
|
100
105
|
require_paths:
|
|
101
106
|
- lib
|
|
@@ -110,7 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
115
|
- !ruby/object:Gem::Version
|
|
111
116
|
version: '0'
|
|
112
117
|
requirements: []
|
|
113
|
-
rubygems_version: 3.
|
|
118
|
+
rubygems_version: 3.5.16
|
|
119
|
+
signing_key:
|
|
114
120
|
specification_version: 4
|
|
115
121
|
summary: Gem to manage book search across multiple providers
|
|
116
122
|
test_files: []
|