rospatent 1.3.0 → 1.3.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 +28 -0
- data/README.md +12 -4
- data/lib/rospatent/logger.rb +19 -9
- data/lib/rospatent/search.rb +15 -3
- data/lib/rospatent/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a67e6d87f80561b12663934f8f521318ffba4a91bfcc2d9e8f0da69a37bb941
|
4
|
+
data.tar.gz: 144209fec90c09ef12ec3b8bfbe8ce25ef869956d42a4c99932c0ee8b8cd2152
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f04c183c8b4896ebce31c73adfb59cf5134256feb075d881138e1e54547241216abda98c63500106a8649c6a6b2b18562cf40acddeed6d926b08162887de9dca
|
7
|
+
data.tar.gz: 0d3f2c86cc5cbfb58c69d0db1100e796adb42664251cd1812118889604a897b4c43b6986a0104660b6ce4cc8c3ea39adab1c27ffbbf0fa815f733da5466e1f72
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.3.2] - 2025-06-07
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Notes about logger `formatter` parameter behavior when using `Rails.logger` as `output`
|
12
|
+
|
13
|
+
## [1.3.1] - 2025-06-06
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- **Include Facets Parameter Handling**: Fixed critical bug in `include_facets` parameter validation and API format conversion
|
17
|
+
- Fixed boolean validation logic that incorrectly converted `false` values to `true`
|
18
|
+
- Added proper boolean-to-numeric conversion for API compliance (true → 1, false → 0)
|
19
|
+
- Enhanced validation to handle various input formats ("true", "false", 0, 1, etc.)
|
20
|
+
- Updated documentation with conversion behavior notes
|
21
|
+
- **Rails Logger Compatibility**: Fixed TypeError when using `Rails.logger` with `Rospatent::Logger`
|
22
|
+
- Added intelligent duck typing to detect existing logger instances vs IO objects
|
23
|
+
- `Rails.logger` can now be passed directly without creating wrapper Logger instances
|
24
|
+
- Maintains full compatibility with file paths, IO objects, and custom loggers
|
25
|
+
- Added comprehensive test coverage for Rails integration scenarios
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
- Enhanced `Rospatent::Logger` to accept existing logger instances (Rails.logger, custom loggers) in addition to IO objects
|
29
|
+
- Improved boolean parameter validation across the gem with better edge case handling
|
30
|
+
- Updated README documentation with Rails.logger usage examples and boolean parameter conversion notes
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- New comprehensive test suite for Logger class covering Rails integration scenarios
|
34
|
+
- Test coverage for include_facets boolean-to-numeric conversion with various input types
|
35
|
+
|
8
36
|
## [1.3.0] - 2025-01-02
|
9
37
|
|
10
38
|
### Added
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ A comprehensive Ruby client for the Rospatent patent search API with advanced fe
|
|
15
15
|
- 📊 **Structured Logging** - JSON/text logging with request/response tracking
|
16
16
|
- 🚀 **Batch Operations** - Process multiple patents concurrently
|
17
17
|
- ⚙️ **Environment-Aware** - Different configurations for dev/staging/production
|
18
|
-
- 🧪 **Comprehensive Testing** -
|
18
|
+
- 🧪 **Comprehensive Testing** - 232 tests with 483 assertions, comprehensive integration testing
|
19
19
|
- 📚 **Excellent Documentation** - Detailed examples and API documentation
|
20
20
|
|
21
21
|
## Installation
|
@@ -270,7 +270,7 @@ results = client.search(
|
|
270
270
|
},
|
271
271
|
sort: "publication_date:desc", # same as 'sort: :pub_date'; see Search#validate_sort_parameter for other sort options
|
272
272
|
group_by: "family:dwpi", # Patent family grouping: "family:docdb" or "family:dwpi"
|
273
|
-
include_facets: true,
|
273
|
+
include_facets: true, # Boolean: true/false (automatically converted to 1/0 for API)
|
274
274
|
pre_tag: "<mark>", # Both pre_tag and post_tag must be provided together
|
275
275
|
post_tag: "</mark>", # Can be strings or arrays for multi-color highlighting
|
276
276
|
highlight: { # Advanced highlight configuration (independent of pre_tag/post_tag)
|
@@ -676,6 +676,10 @@ client = Rospatent.client(logger: logger)
|
|
676
676
|
shared_logger = Rospatent.shared_logger(level: :debug)
|
677
677
|
```
|
678
678
|
|
679
|
+
**Notes**:
|
680
|
+
- When using `Rails.logger`, formatting is controlled by Rails configuration, `formatter` parameter ignored
|
681
|
+
- When using IO objects, `formatter` parameter controls output format
|
682
|
+
|
679
683
|
### Error Handling
|
680
684
|
|
681
685
|
Comprehensive error handling with specific error types and improved error message extraction:
|
@@ -1101,7 +1105,7 @@ $ bundle exec rake release
|
|
1101
1105
|
- 📊 **Структурированное логирование** - JSON/текстовое логирование с отслеживанием запросов/ответов
|
1102
1106
|
- 🚀 **Пакетные операции** - параллельная обработка множества патентов
|
1103
1107
|
- ⚙️ **Адаптивные окружения** - различные конфигурации для development/staging/production
|
1104
|
-
- 🧪 **Комплексное тестирование** -
|
1108
|
+
- 🧪 **Комплексное тестирование** - 232 теста с 483 проверками, комплексное интеграционное тестирование
|
1105
1109
|
- 📚 **Отличная документация** - подробные примеры и документация API
|
1106
1110
|
|
1107
1111
|
## Установка
|
@@ -1353,7 +1357,7 @@ results = client.search(
|
|
1353
1357
|
},
|
1354
1358
|
sort: "publication_date:desc", # то же самое, что 'sort: :pub_date'; см. варианты параметров сортировки в Search#validate_sort_parameter
|
1355
1359
|
group_by: "family:dwpi", # Группировка по семействам: "family:docdb" или "family:dwpi"
|
1356
|
-
include_facets: true,
|
1360
|
+
include_facets: true, # Boolean: true/false (автоматически конвертируется в 1/0 для API)
|
1357
1361
|
pre_tag: "<mark>", # Оба тега должны быть указаны вместе
|
1358
1362
|
post_tag: "</mark>", # Могут быть строками или массивами
|
1359
1363
|
highlight: { # Продвинутая настройка подсветки (независимо от тегов)
|
@@ -1758,6 +1762,10 @@ client = Rospatent.client(logger: logger)
|
|
1758
1762
|
shared_logger = Rospatent.shared_logger(level: :debug)
|
1759
1763
|
```
|
1760
1764
|
|
1765
|
+
**Комментарии**:
|
1766
|
+
- При использовании `Rails.logger`, форматирование контролируется конфигурацией Rails, параметр `formatter` игнорируется
|
1767
|
+
- При использовании IO объекта, формат определяется параметром `formatter`
|
1768
|
+
|
1761
1769
|
### Обработка ошибок
|
1762
1770
|
|
1763
1771
|
Комплексная обработка ошибок с конкретными типами ошибок и улучшенным извлечением сообщений об ошибках:
|
data/lib/rospatent/logger.rb
CHANGED
@@ -18,20 +18,30 @@ module Rospatent
|
|
18
18
|
attr_reader :logger, :level
|
19
19
|
|
20
20
|
# Initialize a new logger
|
21
|
-
# @param output [IO, String] Output destination (STDOUT, file path, etc.)
|
21
|
+
# @param output [IO, String, Logger] Output destination (STDOUT, file path, existing logger, etc.)
|
22
22
|
# @param level [Symbol] Log level (:debug, :info, :warn, :error, :fatal)
|
23
23
|
# @param formatter [Symbol] Log format (:json, :text)
|
24
24
|
def initialize(output: $stdout, level: :info, formatter: :text)
|
25
|
-
@logger = ::Logger.new(output)
|
26
25
|
@level = level
|
27
|
-
@logger.level = LEVELS[level] || ::Logger::INFO
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
# Handle different types of output
|
28
|
+
@logger = if output.respond_to?(:debug) && output.respond_to?(:info) && output.respond_to?(:error)
|
29
|
+
# If it's already a logger instance (like Rails.logger), use it directly
|
30
|
+
output
|
31
|
+
else
|
32
|
+
# If it's an IO object or file path, create a new Logger
|
33
|
+
new_logger = ::Logger.new(output)
|
34
|
+
new_logger.formatter = case formatter
|
35
|
+
when :json
|
36
|
+
method(:json_formatter)
|
37
|
+
else
|
38
|
+
method(:text_formatter)
|
39
|
+
end
|
40
|
+
new_logger
|
41
|
+
end
|
42
|
+
|
43
|
+
# Set the log level
|
44
|
+
@logger.level = LEVELS[level] || ::Logger::INFO
|
35
45
|
end
|
36
46
|
|
37
47
|
# Log an API request
|
data/lib/rospatent/search.rb
CHANGED
@@ -45,7 +45,7 @@ module Rospatent
|
|
45
45
|
# @param post_tag [String, Array<String>] HTML tag(s) to append to highlighted matches
|
46
46
|
# @param sort [Symbol, String] Sort option (:relevance, :pub_date, :filing_date)
|
47
47
|
# @param group_by [String] Grouping option ("family:docdb", "family:dwpi")
|
48
|
-
# @param include_facets [Boolean] Whether to include facet information
|
48
|
+
# @param include_facets [Boolean] Whether to include facet information (true/false, converted to 1/0 for API)
|
49
49
|
# @param filter [Hash] Filters to apply to the search
|
50
50
|
# @param datasets [Array<String>] Datasets to search within
|
51
51
|
# @param highlight [Hash] Advanced highlight configuration with profiles
|
@@ -136,7 +136,16 @@ module Rospatent
|
|
136
136
|
end
|
137
137
|
|
138
138
|
# Validate boolean parameters (only if provided)
|
139
|
-
|
139
|
+
if params.key?(:include_facets)
|
140
|
+
value = params[:include_facets]
|
141
|
+
# Convert various representations to boolean
|
142
|
+
validated[:include_facets] = case value
|
143
|
+
when nil then nil
|
144
|
+
when true, "true", "1", 1, "yes", "on" then true
|
145
|
+
when false, "false", "0", 0, "no", "off", "" then false
|
146
|
+
else !!value # For any other truthy values
|
147
|
+
end
|
148
|
+
end
|
140
149
|
|
141
150
|
# Validate filter parameter
|
142
151
|
validated[:filter] = validate_filter(params[:filter], "filter") if params[:filter]
|
@@ -181,7 +190,10 @@ module Rospatent
|
|
181
190
|
payload[:group_by] = params[:group_by] if params[:group_by]
|
182
191
|
|
183
192
|
# Add other parameters (only if explicitly provided)
|
184
|
-
|
193
|
+
# Convert boolean to numeric format for API (true → 1, false → 0)
|
194
|
+
if params.key?(:include_facets)
|
195
|
+
payload[:include_facets] = params[:include_facets] ? 1 : 0
|
196
|
+
end
|
185
197
|
payload[:filter] = params[:filter] if params[:filter]
|
186
198
|
payload[:datasets] = params[:datasets] if params[:datasets]
|
187
199
|
|
data/lib/rospatent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rospatent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksandr Dryzhuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|