rospatent 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8da1e945c9c210cef707bd01b1c603a98ce95e9a7df67428214d08653282abc
4
- data.tar.gz: 487776845930d34da3198ecb52a8a1fb0e8690dae4d099409721990c20ac7f70
3
+ metadata.gz: c95c34be848baa76a4286b680399c4b76a10b5d4e699776c9d6d735ccbcf4e07
4
+ data.tar.gz: fdc55a2649fbaa37d4af103929a1cd25747aae7a409512e052da187b832197ef
5
5
  SHA512:
6
- metadata.gz: 7f5b2739d6c9c5759383e4439b8ffc3f3e17cc1384e5778dfd93b795b6da39bce8ab7887a6dd18a4294671741fccb731c0deaa475c8a04b0c42286ebcb75cee3
7
- data.tar.gz: 5582c35ea773a88d4187c79ffa16d0b7cbed19d2915375b4740980fa716daff15a07c3730936562683fc8c7093e75d68d833e7dbe697ecf79ee5079b68887a23
6
+ metadata.gz: cdf8239372f22f997aaca78ec400574a6ad26e470f2827e8c465aba6e6a15958c6f3caf6efa602245d58be3f7612929da720cfb77ffe12a871bb77878b084bc1
7
+ data.tar.gz: d852ecfd4103fb1d4bd22b6bc64b1c22f5e63ea8329c01dabd554e8503f647b7f049680fc35ff43d5b30e5e3ca7d94e3f6daf83ea6446d3f6d20e4debe51ed54
data/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ 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.1.0] - 2025-06-04
9
+
10
+ ### Added
11
+ - Word count validation for `similar_patents_by_text` method (minimum 50 words required)
12
+ - New `validate_text_with_word_count` validation method with configurable minimum word requirements
13
+ - Staging environment configuration documentation and examples
14
+ - Enhanced Russian documentation sections
15
+
16
+ ### Changed
17
+ - Improved error handling for insufficient word count with descriptive messages showing current vs required count
18
+ - Error type changed from `InvalidRequestError` to `ValidationError` for text validation consistency
19
+
20
+ ### Fixed
21
+ - Documentation clarifications for similar patents API response format (`data` vs `hits` naming)
22
+ - Updated README examples to use correct API response structure
23
+ - Corrected minimum word requirements documentation for text-based similarity search
24
+
8
25
  ## [1.0.0] - 2025-06-03
9
26
 
10
27
  ### Added
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rospatent
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rospatent.svg)](https://badge.fury.io/rb/rospatent)
4
+
3
5
  A comprehensive Ruby client for the Rospatent patent search API with advanced features including intelligent caching, input validation, structured logging, and robust error handling.
4
6
 
5
7
  > 🇷🇺 **[Документация на русском языке](#-документация-на-русском-языке)** доступна ниже
@@ -211,13 +213,13 @@ similar = client.similar_patents_by_id("RU134694U1_20131120", count: 50)
211
213
 
212
214
  # Find similar patents by text description
213
215
  similar = client.similar_patents_by_text(
214
- "Ракетный двигатель с улучшенной тягой",
216
+ "Ракетный двигатель с улучшенной тягой ...", # 50 words in request minimum
215
217
  count: 25
216
218
  )
217
219
 
218
220
  # Process similar patents
219
- similar["hits"]&.each do |patent|
220
- puts "Similar: #{patent['id']} (score: #{patent['_score']})"
221
+ similar["data"]&.each do |patent|
222
+ puts "Similar: #{patent['id']} (score: #{patent['similarity']} (#{patent['similarity_norm']}))"
221
223
  end
222
224
  ```
223
225
 
@@ -437,6 +439,20 @@ Rospatent.configure do |config|
437
439
  end
438
440
  ```
439
441
 
442
+ ### Staging Environment
443
+
444
+ ```ruby
445
+ # Optimized for staging
446
+ Rospatent.configure do |config|
447
+ config.environment = "staging"
448
+ config.token = ENV['ROSPATENT_TOKEN']
449
+ config.log_level = :info
450
+ config.cache_ttl = 300 # Longer cache for performance
451
+ config.timeout = 45 # Longer timeouts for reliability
452
+ config.retry_count = 3 # More retries for resilience
453
+ end
454
+ ```
455
+
440
456
  ### Production Environment
441
457
 
442
458
  ```ruby
@@ -597,8 +613,10 @@ The library uses **Faraday** as the HTTP client with redirect support for all en
597
613
  - **All endpoints** (`/search`, `/docs/{id}`, `/similar_search`, `/datasets/tree`, etc.) - ✅ Working perfectly with Faraday
598
614
  - **Redirect handling**: Configured with `faraday-follow_redirects` middleware to handle server redirects automatically
599
615
 
600
- ⚠️ **Minor server-side limitation**:
601
- - **Similar Patents by Text**: Occasionally returns `503 Service Unavailable` (server-side issue, not client implementation)
616
+ ⚠️ **Minor server-side limitations**:
617
+ - **Similar Patents by Text**: Occasionally returns `503 Service Unavailable` (a server-side issue, not a client implementation issue)
618
+ ⚠️ **Documentation inconsistencies**:
619
+ - **Similar Patents**: According to the documentation, the array of hits is named `hits`, but the real implementation uses the name `data`
602
620
 
603
621
  All core functionality works perfectly and is production-ready with a unified HTTP approach.
604
622
 
@@ -885,13 +903,13 @@ similar = client.similar_patents_by_id("RU134694U1_20131120", count: 50)
885
903
 
886
904
  # Поиск похожих патентов по описанию текста
887
905
  similar = client.similar_patents_by_text(
888
- "Ракетный двигатель с улучшенной тягой",
906
+ "Ракетный двигатель с улучшенной тягой ...", # минимум 50 слов в запросе
889
907
  count: 25
890
908
  )
891
909
 
892
910
  # Обработка похожих патентов
893
- similar["hits"]&.each do |patent|
894
- puts "Похожий: #{patent['id']} (оценка: #{patent['_score']})"
911
+ similar["data"]&.each do |patent|
912
+ puts "Похожий: #{patent['id']} (оценка: #{patent['similarity']} (#{patent['similarity_norm']}))"
895
913
  end
896
914
  ```
897
915
 
@@ -1004,25 +1022,43 @@ end
1004
1022
  ### Разработка
1005
1023
 
1006
1024
  ```ruby
1025
+ # Оптимизировано для разработки
1007
1026
  Rospatent.configure do |config|
1008
1027
  config.environment = "development"
1009
1028
  config.token = ENV['ROSPATENT_DEV_TOKEN']
1010
1029
  config.log_level = :debug
1011
1030
  config.log_requests = true
1012
- config.cache_ttl = 60
1031
+ config.log_responses = true
1032
+ config.cache_ttl = 60 # Короткий кеш для разработки
1033
+ config.timeout = 10 # Быстрые таймауты для быстрой обратной связи
1034
+ end
1035
+ ```
1036
+
1037
+ ### Staging
1038
+
1039
+ ```ruby
1040
+ # Оптимизировано для staging
1041
+ Rospatent.configure do |config|
1042
+ config.environment = "staging"
1043
+ config.token = ENV['ROSPATENT_TOKEN']
1044
+ config.log_level = :info
1045
+ config.cache_ttl = 300 # Более длительный кеш для производительности
1046
+ config.timeout = 45 # Более длительные таймауты для надежности
1047
+ config.retry_count = 3 # Больше повторов для устойчивости
1013
1048
  end
1014
1049
  ```
1015
1050
 
1016
1051
  ### Продакшн
1017
1052
 
1018
1053
  ```ruby
1054
+ # Оптимизировано для продакшна
1019
1055
  Rospatent.configure do |config|
1020
1056
  config.environment = "production"
1021
1057
  config.token = ENV['ROSPATENT_TOKEN']
1022
1058
  config.log_level = :warn
1023
- config.cache_ttl = 600
1024
- config.timeout = 60
1025
- config.retry_count = 5
1059
+ config.cache_ttl = 600 # Более длительный кеш для производительности
1060
+ config.timeout = 60 # Более длительные таймауты для надежности
1061
+ config.retry_count = 5 # Больше повторов для устойчивости
1026
1062
  end
1027
1063
  ```
1028
1064
 
@@ -1056,8 +1092,10 @@ end
1056
1092
  - **Все endpoints** (`/search`, `/docs/{id}`, `/similar_search`, `/datasets/tree`, и т.д.) - ✅ Работают идеально с Faraday
1057
1093
  - **Обработка редиректов**: Настроена с middleware `faraday-follow_redirects` для автоматической обработки серверных редиректов
1058
1094
 
1059
- ⚠️ **Незначительное серверное ограничение**:
1095
+ ⚠️ **Незначительные серверные ограничения**:
1060
1096
  - **Поиск похожих патентов по тексту**: Иногда возвращает `503 Service Unavailable` (проблема сервера, не клиентской реализации)
1097
+ ⚠️ **Неточности документации**:
1098
+ - **Поиск похожих патентов**: Массив совпадений в документации назван `hits`, фактическая реализация использует `data`
1061
1099
 
1062
1100
  Вся основная функциональность реализована и готова для продакшена.
1063
1101
 
@@ -147,13 +147,14 @@ module Rospatent
147
147
  end
148
148
 
149
149
  # Find patents similar to a given text
150
- # @param text [String] The text to find similar patents to
150
+ # @param text [String] The text to find similar patents to (minimum 50 words required)
151
151
  # @param count [Integer] Maximum number of results to return (default: 100)
152
152
  # @return [Hash] The similar search results
153
- # @raise [Rospatent::Errors::InvalidRequestError] If text is not provided
153
+ # @raise [Rospatent::Errors::ValidationError] If text has insufficient words or other validation errors
154
154
  def similar_patents_by_text(text, count: 100)
155
- # Validate inputs
156
- validated_text = validate_string(text, "search_text", max_length: 10_000)
155
+ # Validate inputs - text must have at least 50 words for the API
156
+ validated_text = validate_text_with_word_count(text, "search_text", min_words: 50,
157
+ max_length: 10_000)
157
158
  validated_count = validate_positive_integer(count, "count", max_value: 1000)
158
159
 
159
160
  # Check cache first (using hash of text for key)
@@ -100,6 +100,29 @@ module Rospatent
100
100
  value.strip
101
101
  end
102
102
 
103
+ # Validate text with word count requirements
104
+ # @param value [String, nil] Text to validate
105
+ # @param field_name [String] Name of the field for error messages
106
+ # @param min_words [Integer] Minimum required word count
107
+ # @param max_length [Integer, nil] Maximum allowed character length
108
+ # @return [String] Validated text
109
+ # @raise [ValidationError] If text is invalid or has insufficient words
110
+ def validate_text_with_word_count(value, field_name, min_words:, max_length: nil)
111
+ # First, apply standard string validation
112
+ validated_text = validate_string(value, field_name, max_length: max_length)
113
+ return nil if validated_text.nil?
114
+
115
+ # Count words by splitting on whitespace
116
+ word_count = count_words(validated_text)
117
+
118
+ if word_count < min_words
119
+ raise Errors::ValidationError,
120
+ "#{field_name.capitalize} must contain at least #{min_words} words (currently has #{word_count})"
121
+ end
122
+
123
+ validated_text
124
+ end
125
+
103
126
  # Validate required non-empty string (does not allow nil)
104
127
  # @param value [String, nil] String to validate
105
128
  # @param field_name [String] Name of the field for error messages
@@ -302,5 +325,14 @@ module Rospatent
302
325
 
303
326
  validated.compact
304
327
  end
328
+
329
+ private
330
+
331
+ # Count words in a text by splitting on whitespace
332
+ # @param text [String] Text to count words in
333
+ # @return [Integer] Number of words
334
+ def count_words(text)
335
+ text.split.size
336
+ end
305
337
  end
306
338
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rospatent
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
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.0.0
4
+ version: 1.1.0
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-03 00:00:00.000000000 Z
11
+ date: 2025-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -134,16 +134,16 @@ files:
134
134
  - lib/rospatent/railtie.rb
135
135
  - lib/rospatent/search.rb
136
136
  - lib/rospatent/version.rb
137
- homepage: https://hub.mos.ru/ad/rospatent
137
+ homepage: https://github.com/amdest/rospatent
138
138
  licenses:
139
139
  - MIT
140
140
  metadata:
141
- homepage_uri: https://hub.mos.ru/ad/rospatent
142
- source_code_uri: https://hub.mos.ru/ad/rospatent
143
- changelog_uri: https://hub.mos.ru/ad/rospatent/blob/main/CHANGELOG.md
144
- documentation_uri: https://hub.mos.ru/ad/rospatent/blob/main/README.md
145
- bug_tracker_uri: https://hub.mos.ru/ad/rospatent/issues
146
- wiki_uri: https://hub.mos.ru/ad/rospatent/wiki
141
+ homepage_uri: https://github.com/amdest/rospatent
142
+ source_code_uri: https://github.com/amdest/rospatent
143
+ changelog_uri: https://github.com/amdest/rospatent/blob/main/CHANGELOG.md
144
+ documentation_uri: https://github.com/amdest/rospatent/blob/main/README.md
145
+ bug_tracker_uri: https://github.com/amdest/rospatent/issues
146
+ wiki_uri: https://github.com/amdest/rospatent/wiki
147
147
  rubygems_mfa_required: 'true'
148
148
  post_install_message:
149
149
  rdoc_options: []