epo-ops 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 598720d94ba023a3a3e6b0e2b3f4b018a7f1983e
4
- data.tar.gz: d6861675f8ef8abd67a13664c881406a9a8e711a
3
+ metadata.gz: 61d513627347b49b4799e4fdf0081ff1f34cd712
4
+ data.tar.gz: 9dbef686b5c975cbc3b36b40bf741fd943db62a8
5
5
  SHA512:
6
- metadata.gz: 31e1b55be1850539337a550d831d1b63881b4248e8456dcbc1c6a4af1b32e6e289d92a76833434038f53dc97612bf214a1680388f955d7220bee2046e423b25c
7
- data.tar.gz: 50f29328406d721d8515cc0436cad653d1cf2e0fdf6f725f372b950c12401968ddaed942b1d57483ab594778b04c26533d5c3f5a8c47ba7606bd6e7240339dfb
6
+ metadata.gz: da76bac459cb2c43c4c0b018fc5fb5863a33b827de6f07f5ed6716276e6494a5a4b9e8f621fed4bfcefe066590c0b653cf734afe256059dedec87b6ed0ce8f27
7
+ data.tar.gz: 70a3f9a80c879c004a30e61344264482b2f004de679b62c84e9457fb9acf6c484ec2d3bdc8803a70555fc4b4f9704f65d6be29c2107895994dd9b9ae0b3c6e69
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.0"
4
- - "2.1"
5
- - "2.2"
6
- - "2.3.0"
3
+ - 2.2.7
4
+ - 2.3.4
5
+ - 2.4.1
data/README.md CHANGED
@@ -24,10 +24,13 @@ require 'epo_ops'
24
24
 
25
25
  patent_application = EpoOps::PatentApplication.find("EP14731659")
26
26
  patent_application.title # "DEVICE AND METHOD FOR INTRODUCING FIBRES INTO AN EXTRUDER"
27
- patent_application.classifications # ["B29C47/10", "B29C47/68", "B29C47/92", "B29C45/00", "B01D46/24"]
27
+ patent_application.classifications # ["B29C47/10", "B29C47/68", "B29C47/92", "B29C45/00", "B01D46/24"]
28
28
  patent_application.applicants.first.name # "Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V."
29
29
  ```
30
30
 
31
+ ## Supported Ruby Versions
32
+ For supported versions see _.travis.yml_. We try to keep it updated to officially supported Ruby versions.
33
+
31
34
  ## Advanced Usage
32
35
 
33
36
  ### OAuth
@@ -60,9 +63,9 @@ CQL search query
60
63
  For example to find all applications in IPC Class _A01_ (and all subclasses) that were updated on 2016-01-01
61
64
 
62
65
  ```ruby
63
- query = EpoOps::SearchQueryBuilder.build("A01", Date.parse("2016-01-02"))
66
+ query = EpoOps::SearchQueryBuilder.build("A01", Date.parse("2016-01-06"))
64
67
  applications = EpoOps::PatentApplication.search(query)
65
- puts applications.count # 1234
68
+ applications.count #=> 66
66
69
  applications.map {|application| puts application.application_nr } # print all application numbers
67
70
  applications.map {|application| application.fetch} # fetch complete bibliographic data for each document
68
71
 
@@ -89,8 +92,8 @@ EpoOps::Register.search(nil, Date.new(2016,2 ,3))
89
92
  You can now retrieve the bibliographic entries of all these:
90
93
 
91
94
  ```ruby
92
- references = EpoOps::Register.search(nil, Date.new(2016,2 ,3))
93
- references.map { |ref| EpoOps::Register.biblio(ref) }
95
+ patent_applications = EpoOps::Register.search(nil, Date.new(2016,2 ,3))
96
+ patent_applications.count == patent_applications.patents.count #=> true
94
97
  ```
95
98
 
96
99
  **Note: Both operations take a considerable amount of time. Also you may not
@@ -108,4 +111,4 @@ of the different endpoints and how to use them (see the 'Downloads' section).
108
111
 
109
112
  This gem is still an early version and it is far from covering the whole API.
110
113
  If you are interested to include different API endpoints than the register it should be easy to include those and we
111
- are happy to accept pull requests.
114
+ are happy to accept pull requests.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
- spec.add_development_dependency 'rake', '~> 10.5'
22
+ spec.add_development_dependency 'rake', '~> 11'
23
23
  spec.add_development_dependency 'minitest', '~> 5.8'
24
24
  spec.add_development_dependency 'mocha'
25
25
  spec.add_development_dependency 'vcr', '~> 2.9'
@@ -1,13 +1,28 @@
1
+ require 'oauth2'
2
+ require 'httparty'
3
+ require 'redis'
4
+ require 'connection_pool'
1
5
  require 'epo_ops/version'
2
6
  require 'epo_ops/token_store'
3
7
  require 'epo_ops/register'
4
8
  require 'epo_ops/search_query_builder'
5
9
  require 'epo_ops/ipc_class_hierarchy_loader'
6
10
  require 'epo_ops/ipc_class_util'
11
+ require 'epo_ops/ipc_class_hierarchy'
7
12
  require 'epo_ops/patent_application'
8
13
  require 'epo_ops/name_and_address'
9
14
  require 'epo_ops/factories'
10
15
  require 'epo_ops/register_search_result'
16
+ require 'epo_ops/client'
17
+ require 'epo_ops/util'
18
+ require 'epo_ops/logger'
19
+ require 'epo_ops/limits'
20
+ require 'epo_ops/error'
21
+ require 'epo_ops/rate_limit'
22
+ require 'epo_ops/factories/patent_application_factory'
23
+ require 'epo_ops/factories/name_and_address_factory'
24
+ require 'epo_ops/factories/register_search_result_factory'
25
+
11
26
 
12
27
  module EpoOps
13
28
  # Configure authentication method and credentials
@@ -1,6 +1,3 @@
1
- require 'epo_ops/token_store'
2
- require 'epo_ops/error'
3
-
4
1
  module EpoOps
5
2
 
6
3
  # This is a wrapper for OAuth
@@ -13,6 +10,7 @@ module EpoOps
13
10
  # @option options [Hash] :headers http request headers
14
11
  # @raise [EpoOps::Error] API Error if request was not successful
15
12
  def self.request(verb, url, options = {})
13
+ EpoOps::Logger.debug("Sending Request: #{verb} #{url}")
16
14
  response = case EpoOps.config.authentication
17
15
  when :oauth then do_oauth_request(verb, url, options)
18
16
  when :plain then do_plain_request(verb,url,options)
@@ -31,7 +29,7 @@ module EpoOps
31
29
  # @return [OAuth2::Response]
32
30
  def self.do_oauth_request(verb, url, options = {})
33
31
  token = EpoOps.config.token_store.token
34
- token.request(verb, URI.encode(url), options)
32
+ token.request(verb, url, options)
35
33
  end
36
34
 
37
35
  # Make an anonymous request to the EPO API
@@ -1,5 +1,3 @@
1
- require 'epo_ops/rate_limit'
2
-
3
1
  module EpoOps
4
2
  class Error < StandardError
5
3
  # @return [Integer]
@@ -1,7 +1,3 @@
1
- require 'epo_ops/factories/patent_application_factory'
2
- require 'epo_ops/factories/name_and_address_factory'
3
- require 'epo_ops/factories/register_search_result_factory'
4
-
5
1
  module EpoOps
6
2
  module Factories
7
3
 
@@ -32,12 +32,9 @@ module EpoOps
32
32
  :country_code,
33
33
  :cdsid
34
34
 
35
-
36
35
  def initialize(raw_data)
37
36
  @raw_data = raw_data
38
-
39
- @name = raw_data['name']
40
-
37
+ @name = raw_data['name']
41
38
  if raw_data['address'].is_a? Hash
42
39
  @address_1 = raw_data['address']['address_1']
43
40
  @address_2 = raw_data['address']['address_2']
@@ -46,8 +43,7 @@ module EpoOps
46
43
  @address_5 = raw_data['address']['address_5']
47
44
  @country_code = raw_data['address']['country']
48
45
  end
49
-
50
- @cdsid = raw_data['cdsid']
46
+ @cdsid = raw_data['cdsid']
51
47
  end
52
48
  end
53
49
  end
@@ -107,10 +107,9 @@ module EpoOps
107
107
  end
108
108
 
109
109
  private
110
- def data_path(*path)
111
- %w(bibliographic_data) + path
112
- end
113
-
110
+ def data_path(*path)
111
+ %w[bibliographic_data] + path
112
+ end
114
113
  end
115
114
  end
116
115
  end
@@ -34,7 +34,7 @@ module EpoOps
34
34
  def patents
35
35
  EpoOps::Util.flat_dig(
36
36
  @raw_data,
37
- %w(world_patent_data register_search register_documents register_document)
37
+ %w[world_patent_data register_search register_documents register_document]
38
38
  ).map {|patent_data| EpoOps::Factories::PatentApplicationFactory.build(patent_data)}
39
39
  end
40
40
  end
@@ -1,6 +1,3 @@
1
- require 'httparty'
2
- require 'epo_ops/ipc_class_util'
3
-
4
1
  module EpoOps
5
2
  # Usually this should only used internally.
6
3
  # Loads the Hierarchy from the WIPO.
@@ -33,7 +30,7 @@ module EpoOps
33
30
  # Process every line (There is a line for every class entry, name and description are separated by a \t)
34
31
  file.each_line.inject(Hash.new { |h, k| h[k] = [] }) do |mem, line|
35
32
  next if line.to_s.strip.empty?
36
- ipc_class_generic, description = line.split("\t")
33
+ ipc_class_generic, _description = line.split("\t")
37
34
 
38
35
  # Some entries in the files have the same ipc class, the first line is
39
36
  # just some kind of headline, the second is the description we want.
@@ -1,5 +1,3 @@
1
- require 'epo_ops/ipc_class_hierarchy'
2
-
3
1
  module EpoOps
4
2
  # Utility functions to work on Strings representing ipc classes.
5
3
  class IpcClassUtil
@@ -11,11 +11,11 @@ module EpoOps
11
11
  # (for example EP and WO) we pick the first one returned - thus the returned document may have a different number
12
12
  # @param application_number [String] identifies the application document at EPO
13
13
  # @return [PatentApplication] the application document, nil if it can't be found
14
- # @note API url: /3.1/rest-services/register/application/epodoc/#{application_number}/biblio
14
+ # @note API url: /3.2/rest-services/register/application/epodoc/#{application_number}/biblio
15
15
  def find(application_number)
16
16
  raw_data = EpoOps::Client.request(
17
17
  :get,
18
- "/3.1/rest-services/register/application/epodoc/#{application_number}/biblio"
18
+ "/#{EpoOps::API_VERSION}/rest-services/register/application/epodoc/#{application_number}/biblio"
19
19
  ).parsed
20
20
 
21
21
  data = EpoOps::Util.flat_dig(
@@ -41,7 +41,7 @@ module EpoOps
41
41
  def search(cql_query)
42
42
  data = Client.request(
43
43
  :get,
44
- '/3.1/rest-services/register/search?' + cql_query
44
+ "/#{EpoOps::API_VERSION}/rest-services/register/search?" + cql_query
45
45
  ).parsed
46
46
 
47
47
  EpoOps::Factories::RegisterSearchResultFactory.build(data)
@@ -117,6 +117,12 @@ module EpoOps
117
117
  @title[lang]
118
118
  end
119
119
 
120
+ # Return the applications title in all available languages
121
+ # @return [Hash] titles in all languagles
122
+ def titles
123
+ @title
124
+ end
125
+
120
126
  # Many fields of the XML the EPO provides have a field
121
127
  # `change_gazette_num`. It is a commercial date (year + week)
122
128
  # that describes in which week the element has been
@@ -131,7 +137,7 @@ module EpoOps
131
137
 
132
138
  # @return [String] The URL at which you can query the original document.
133
139
  def url
134
- @url ||= "https://ops.epo.org/3.1/rest-services/register/application/epodoc/#{application_nr}"
140
+ @url ||= "https://ops.epo.org/#{EpoOps::API_VERSION}/rest-services/register/application/epodoc/#{application_nr}"
135
141
  end
136
142
 
137
143
  # Fetches the same document from the register populating all available fields
@@ -1,11 +1,5 @@
1
- require 'epo_ops'
2
- require 'epo_ops/client'
3
- require 'epo_ops/util'
4
- require 'epo_ops/logger'
5
- require 'epo_ops/ipc_class_util'
6
-
7
1
  module EpoOps
8
- # Access to the {http://ops.epo.org/3.1/rest-services/register register}
2
+ # Access to the {http://ops.epo.org/#{EpoOps::API_VERSION}/rest-services/register register}
9
3
  # endpoint of the EPO OPS API.
10
4
  #
11
5
  # By now you can search and retrieve patents by using the type `application`
@@ -89,7 +83,7 @@ module EpoOps
89
83
  def self.raw_search(query, raw = false)
90
84
  data = Client.request(
91
85
  :get,
92
- '/3.1/rest-services/register/search?' + query
86
+ "/#{EpoOps::API_VERSION}/rest-services/register/search?" + query
93
87
  ).parsed
94
88
 
95
89
  EpoOps::Factories::RegisterSearchResultFactory.build(data)
@@ -1,6 +1,3 @@
1
- require 'epo_ops/limits'
2
- require 'epo_ops/logger'
3
-
4
1
  module EpoOps
5
2
  # This Builder helps creating a search query using
6
3
  # {https://www.loc.gov/standards/sru/cql/ CQL} (Common Query Language or
@@ -1,13 +1,10 @@
1
- require 'oauth2'
2
- require 'epo_ops'
3
-
4
1
  module EpoOps
5
2
  # This class saves the token in memory, you may want to subclass this and
6
3
  # overwrite #token if you want to store it somewhere else.
7
4
  #
8
5
  class TokenStore
9
6
  def token
10
- @token = generate_token if !@token || @token.expired?
7
+ @token = generate_token if @token.nil? || @token.expired?
11
8
 
12
9
  @token
13
10
  end
@@ -23,7 +20,7 @@ module EpoOps
23
20
  EpoOps.config.consumer_key,
24
21
  EpoOps.config.consumer_secret,
25
22
  site: 'https://ops.epo.org/',
26
- token_url: '/3.1/auth/accesstoken',
23
+ token_url: "/#{EpoOps::API_VERSION}/auth/accesstoken",
27
24
  raise_errors: false
28
25
  )
29
26
 
@@ -1,6 +1,3 @@
1
- require 'redis'
2
- require 'connection_pool'
3
-
4
1
  module EpoOps
5
2
  class TokenStore
6
3
  class Redis < TokenStore
@@ -46,7 +46,7 @@ module EpoOps
46
46
  def self.parse_change_gazette_num(num)
47
47
  res = /^(?<year>\d{4})\/(?<week>\d{2})$/.match(num)
48
48
  return nil if res.nil?
49
- Date.commercial(Integer(res[:year], 10), week = Integer(res[:week], 10))
49
+ Date.commercial(Integer(res[:year], 10), Integer(res[:week], 10))
50
50
  end
51
51
  end
52
52
  end
@@ -1,3 +1,4 @@
1
1
  module EpoOps
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.1'.freeze
3
+ API_VERSION = '3.2'.freeze
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epo-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Kießling
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-05-10 00:00:00.000000000 Z
13
+ date: 2017-06-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '10.5'
35
+ version: '11'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '10.5'
42
+ version: '11'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: minitest
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.4.8
224
+ rubygems_version: 2.6.11
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Ruby interface to the European Patent Office API (OPS)