rospatent 1.3.0 → 1.3.1

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: 1834dfe049a29dc3991bfd687dc030d3ac1c8115fd650b295ebe123f76367285
4
- data.tar.gz: 126863c21587c0246503f57d6dab07262e46d2332da6468a7a29d48b9736eb8a
3
+ metadata.gz: 01cd0ab72ae339b3dab5372eebb311b6aef97fbc17f4fe8c4c00466aee363abe
4
+ data.tar.gz: d279cbbe0944f3f55890b62593b4480359222bae51b2c3c132baaf07d55c0347
5
5
  SHA512:
6
- metadata.gz: 57c293f3d982670811e1bd3691e4f1feb8c3c7911eac411d92561a4e104695eba8bdfa043fead62aaa8367034d491b8e8699cc14cf23c13cb6285056c4865de5
7
- data.tar.gz: 8bc73ec16b985041ba87944c3e4cb248f5508cecaa3f663f39fc21bfb2fcc196c40382d359e9a9faf43aa902145d4a88357514f49fad87577194be5d033b12ea
6
+ metadata.gz: d9f33a05a5c1b57b87baf0091300c0b46587b0567ba4def4ae1e635449a9ac7ec0d077bb630b32b2445111429ce7e86c9291daceb5ac75182bf44eb1beb5d16c
7
+ data.tar.gz: 950400777375b018839a8a1090db421994c36a28d0e3881b783236e50d6d5dd43ef5d0a65f9c010cd878f54aa31cb55af74b540c8240676dbcf65bc74ea39743
data/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ 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.1] - 2025-06-06
9
+
10
+ ### Fixed
11
+ - **Include Facets Parameter Handling**: Fixed critical bug in `include_facets` parameter validation and API format conversion
12
+ - Fixed boolean validation logic that incorrectly converted `false` values to `true`
13
+ - Added proper boolean-to-numeric conversion for API compliance (true → 1, false → 0)
14
+ - Enhanced validation to handle various input formats ("true", "false", 0, 1, etc.)
15
+ - Updated documentation with conversion behavior notes
16
+ - **Rails Logger Compatibility**: Fixed TypeError when using `Rails.logger` with `Rospatent::Logger`
17
+ - Added intelligent duck typing to detect existing logger instances vs IO objects
18
+ - `Rails.logger` can now be passed directly without creating wrapper Logger instances
19
+ - Maintains full compatibility with file paths, IO objects, and custom loggers
20
+ - Added comprehensive test coverage for Rails integration scenarios
21
+
22
+ ### Changed
23
+ - Enhanced `Rospatent::Logger` to accept existing logger instances (Rails.logger, custom loggers) in addition to IO objects
24
+ - Improved boolean parameter validation across the gem with better edge case handling
25
+ - Updated README documentation with Rails.logger usage examples and boolean parameter conversion notes
26
+
27
+ ### Added
28
+ - New comprehensive test suite for Logger class covering Rails integration scenarios
29
+ - Test coverage for include_facets boolean-to-numeric conversion with various input types
30
+
8
31
  ## [1.3.0] - 2025-01-02
9
32
 
10
33
  ### 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** - 219 tests with 465 assertions, comprehensive integration 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)
@@ -1101,7 +1101,7 @@ $ bundle exec rake release
1101
1101
  - 📊 **Структурированное логирование** - JSON/текстовое логирование с отслеживанием запросов/ответов
1102
1102
  - 🚀 **Пакетные операции** - параллельная обработка множества патентов
1103
1103
  - ⚙️ **Адаптивные окружения** - различные конфигурации для development/staging/production
1104
- - 🧪 **Комплексное тестирование** - 219 тестов с 465 проверками, комплексное интеграционное тестирование
1104
+ - 🧪 **Комплексное тестирование** - 232 теста с 483 проверками, комплексное интеграционное тестирование
1105
1105
  - 📚 **Отличная документация** - подробные примеры и документация API
1106
1106
 
1107
1107
  ## Установка
@@ -1353,7 +1353,7 @@ results = client.search(
1353
1353
  },
1354
1354
  sort: "publication_date:desc", # то же самое, что 'sort: :pub_date'; см. варианты параметров сортировки в Search#validate_sort_parameter
1355
1355
  group_by: "family:dwpi", # Группировка по семействам: "family:docdb" или "family:dwpi"
1356
- include_facets: true,
1356
+ include_facets: true, # Boolean: true/false (автоматически конвертируется в 1/0 для API)
1357
1357
  pre_tag: "<mark>", # Оба тега должны быть указаны вместе
1358
1358
  post_tag: "</mark>", # Могут быть строками или массивами
1359
1359
  highlight: { # Продвинутая настройка подсветки (независимо от тегов)
@@ -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
- @logger.formatter = case formatter
30
- when :json
31
- method(:json_formatter)
32
- else
33
- method(:text_formatter)
34
- end
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
@@ -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
- validated[:include_facets] = !params[:include_facets].nil? if params.key?(:include_facets)
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
- payload[:include_facets] = params[:include_facets] if params.key?(:include_facets)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rospatent
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
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.0
4
+ version: 1.3.1
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-05 00:00:00.000000000 Z
11
+ date: 2025-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday