epo-ops 0.2.6 → 0.3.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +6 -0
  4. data/README.md +78 -38
  5. data/epo-ops.gemspec +2 -2
  6. data/lib/epo_ops.rb +46 -0
  7. data/lib/epo_ops/client.rb +46 -0
  8. data/lib/epo_ops/error.rb +87 -0
  9. data/lib/epo_ops/factories.rb +9 -0
  10. data/lib/epo_ops/factories/name_and_address_factory.rb +54 -0
  11. data/lib/epo_ops/factories/patent_application_factory.rb +116 -0
  12. data/lib/epo_ops/factories/register_search_result_factory.rb +42 -0
  13. data/lib/epo_ops/ipc_class_hierarchy.rb +146 -0
  14. data/lib/epo_ops/ipc_class_hierarchy_loader.rb +60 -0
  15. data/lib/epo_ops/ipc_class_util.rb +71 -0
  16. data/lib/epo_ops/limits.rb +20 -0
  17. data/lib/epo_ops/logger.rb +15 -0
  18. data/lib/epo_ops/name_and_address.rb +58 -0
  19. data/lib/epo_ops/patent_application.rb +159 -0
  20. data/lib/epo_ops/rate_limit.rb +47 -0
  21. data/lib/epo_ops/register.rb +100 -0
  22. data/lib/epo_ops/register_search_result.rb +40 -0
  23. data/lib/epo_ops/search_query_builder.rb +65 -0
  24. data/lib/epo_ops/token_store.rb +33 -0
  25. data/lib/epo_ops/token_store/redis.rb +45 -0
  26. data/lib/epo_ops/util.rb +52 -0
  27. data/lib/epo_ops/version.rb +3 -0
  28. metadata +26 -20
  29. data/lib/epo/ops.rb +0 -43
  30. data/lib/epo/ops/address.rb +0 -60
  31. data/lib/epo/ops/bibliographic_document.rb +0 -196
  32. data/lib/epo/ops/client.rb +0 -27
  33. data/lib/epo/ops/error.rb +0 -89
  34. data/lib/epo/ops/ipc_class_hierarchy.rb +0 -148
  35. data/lib/epo/ops/ipc_class_hierarchy_loader.rb +0 -62
  36. data/lib/epo/ops/ipc_class_util.rb +0 -73
  37. data/lib/epo/ops/limits.rb +0 -22
  38. data/lib/epo/ops/logger.rb +0 -11
  39. data/lib/epo/ops/rate_limit.rb +0 -49
  40. data/lib/epo/ops/register.rb +0 -152
  41. data/lib/epo/ops/search_query_builder.rb +0 -65
  42. data/lib/epo/ops/token_store.rb +0 -35
  43. data/lib/epo/ops/token_store/redis.rb +0 -47
  44. data/lib/epo/ops/util.rb +0 -32
  45. data/lib/epo/ops/version.rb +0 -6
@@ -1,47 +0,0 @@
1
- require 'redis'
2
- require 'connection_pool'
3
-
4
- module Epo
5
- module Ops
6
- class TokenStore
7
- class Redis < TokenStore
8
- def initialize(redis_host)
9
- fail "Please install gems 'redis' and 'connection_pool' to use this feature" unless defined?(::Redis) && defined?(ConnectionPool)
10
-
11
- @redis = ConnectionPool.new(size: 5, timeout: 5) { ::Redis.new(host: redis_host) }
12
- end
13
-
14
- def token
15
- token = nil
16
- @redis.with do |conn|
17
- token = conn.get("epo_token_#{id}")
18
- end
19
-
20
- token.present? ? OAuth2::AccessToken.new(client, token) : generate_token
21
- end
22
-
23
- def reset
24
- @redis.with do |conn|
25
- conn.del("epo_token_#{id}")
26
- end
27
- end
28
-
29
- private
30
-
31
- def id
32
- Digest::MD5.hexdigest(Epo::Ops.config.consumer_key + Epo::Ops.config.consumer_secret)
33
- end
34
-
35
- def generate_token
36
- token = super
37
-
38
- @redis.with do |conn|
39
- conn.set("epo_token_#{id}", token.token, ex: token.expires_in, nx: true)
40
- end
41
-
42
- token
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,32 +0,0 @@
1
- module Epo
2
- module Ops
3
- class Util
4
- # the path should be an array of strings indicating the path you want to go in the hash
5
- def self.find_in_data(epo_hash, path)
6
- path.reduce(epo_hash) { |res, c| parse_hash_flat(res, c) }
7
- end
8
-
9
- def self.parse_hash_flat(hash_layer, target)
10
- result = []
11
- if hash_layer.nil?
12
- return []
13
- elsif hash_layer.class == String
14
- return []
15
- elsif hash_layer.class == Array
16
- result.concat(hash_layer.map { |x| parse_hash_flat(x, target) })
17
- elsif hash_layer[target]
18
- result << hash_layer[target]
19
- elsif hash_layer.class == Hash || hash_layer.respond_to?(:to_h)
20
- result.concat(hash_layer.to_h.map { |_x, y| parse_hash_flat(y, target) })
21
- end
22
- result.flatten
23
- end
24
-
25
- def self.parse_change_gazette_num(num)
26
- res = /^(?<year>\d{4})\/(?<week>\d{2})$/.match(num)
27
- return nil if res.nil?
28
- Date.commercial(Integer(res[:year], 10), week = Integer(res[:week], 10))
29
- end
30
- end
31
- end
32
- end
@@ -1,6 +0,0 @@
1
- module Epo
2
- module Ops
3
- VERSION = '0.2.6'.freeze
4
- API_VERSION = '3.2'
5
- end
6
- end