patentscope 0.0.2 → 0.0.4
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/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/License.txt +1 -1
- data/README.md +2 -2
- data/lib/patentscope.rb +1 -0
- data/lib/patentscope/client.rb +11 -5
- data/lib/patentscope/version.rb +1 -1
- data/lib/patentscope/webservice.rb +7 -3
- data/lib/patentscope/webservice_soap_builder.rb +0 -22
- data/lib/patentscope/webservice_soap_stripper.rb +34 -0
- data/patentscope.gemspec +24 -20
- metadata +24 -44
- data/spec/client_spec.rb +0 -75
- data/spec/configuration_spec.rb +0 -226
- data/spec/patentscope_spec.rb +0 -91
- data/spec/pct_app_number_spec.rb +0 -256
- data/spec/pct_pub_number_spec.rb +0 -220
- data/spec/spec_helper.rb +0 -31
- data/spec/webservice_soap_builder_spec.rb +0 -318
- data/spec/webservice_spec.rb +0 -97
- data/spec/wipo_test_suite_doc_id_examples.yaml +0 -298
- data/spec/wipo_test_suite_ia_number_examples.yaml +0 -40
- data/spec/wipo_test_suite_spec.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c3ff619f0ad1778c36dbb2d04a945ad4c3e3cce
|
4
|
+
data.tar.gz: 5736b0e818ed2823b0dd5e3d6f180902c9e25796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ca863b3c8b598318503938c7d4596b1836585d353adee688452cd4a9dce669c41cbb7adb799bc9608876323e8735989fe780d5a7bb9ef8a5e032924b44717d
|
7
|
+
data.tar.gz: fd374c7216250fe7b8f37ac998188be5b9c32290351e70aff277fd31f7eed3861716720ca3c8c86529b07aae142110651471876d0da40f1aef140f0a50665000
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.2
|
data/Gemfile
CHANGED
data/License.txt
CHANGED
data/README.md
CHANGED
@@ -218,7 +218,7 @@ For support on the PATENTSCOPE Web Service, please see the resources in the sect
|
|
218
218
|
|
219
219
|
### PATENTSCOPE Search System
|
220
220
|
* [PATENTSCOPE](http://www.wipo.int/patentscope/en/)
|
221
|
-
* [Search Interface]
|
221
|
+
* [Search Interface](http://patentscope.wipo.int/search/)
|
222
222
|
* [Webinars](http://www.wipo.int/patentscope/en/webinar/)
|
223
223
|
* [Forum](http://wipo-patentscope-forum.2944828.n2.nabble.com)
|
224
224
|
|
@@ -240,7 +240,7 @@ More details on how to contribute can be found at this great Thoughtbot blogpost
|
|
240
240
|
|
241
241
|
## License
|
242
242
|
|
243
|
-
Copyright (c) 2013-
|
243
|
+
Copyright (c) 2013-2016 Chong-Yee Khoo. All rights reserved.
|
244
244
|
|
245
245
|
MIT License
|
246
246
|
|
data/lib/patentscope.rb
CHANGED
@@ -5,6 +5,7 @@ module Patentscope
|
|
5
5
|
require 'patentscope/configuration'
|
6
6
|
require 'patentscope/webservice'
|
7
7
|
require 'patentscope/webservice_soap_builder'
|
8
|
+
require 'patentscope/webservice_soap_stripper'
|
8
9
|
require 'patentscope/pct_doc_number'
|
9
10
|
|
10
11
|
class NoCredentialsError < StandardError; end
|
data/lib/patentscope/client.rb
CHANGED
@@ -18,15 +18,21 @@ module Patentscope
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def post_url(url, content_type = 'text/html', body = '')
|
21
|
-
uri = URI
|
22
|
-
|
23
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
21
|
+
uri = URI(url)
|
22
|
+
request = Net::HTTP::Post.new(uri)
|
24
23
|
request.basic_auth(username, password)
|
25
24
|
request["User-Agent"] = USER_AGENT_STRING
|
26
25
|
request["Content-Type"] = content_type
|
27
26
|
request.body = body
|
28
|
-
|
29
|
-
|
27
|
+
|
28
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
29
|
+
response = http.request(request)
|
30
|
+
if response.header["Content-Type"].include? "text/html"
|
31
|
+
response.body
|
32
|
+
elsif response.header["Content-Type"].include? "multipart/related"
|
33
|
+
response.body.split("\r\n\r\n")[1].split("\r\n")[0]
|
34
|
+
end
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/patentscope/version.rb
CHANGED
@@ -2,7 +2,7 @@ module Patentscope
|
|
2
2
|
|
3
3
|
class Webservice
|
4
4
|
|
5
|
-
PATENTSCOPE_WEBSERVICE_LOCATION = "
|
5
|
+
PATENTSCOPE_WEBSERVICE_LOCATION = "https://patentscope.wipo.int/patentscope-webservice/servicesPatentScope"
|
6
6
|
|
7
7
|
def wsdl
|
8
8
|
send_wsdl_request
|
@@ -44,12 +44,12 @@ module Patentscope
|
|
44
44
|
def perform_operation(operation, options_hash)
|
45
45
|
soap_envelope = soapbuilder.build_envelope(operation, options_hash)
|
46
46
|
response = send_soap_request(soap_envelope)
|
47
|
-
if response.include?('
|
47
|
+
if response.include?('Error') && response.include?('Unauthorized')
|
48
48
|
raise WrongCredentialsError
|
49
49
|
elsif response.include?('Business error during the execution of service')
|
50
50
|
raise BusinessError
|
51
51
|
else
|
52
|
-
|
52
|
+
soapstripper.strip_envelope(response, operation)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -70,5 +70,9 @@ module Patentscope
|
|
70
70
|
def soapbuilder
|
71
71
|
WebserviceSoapBuilder.new
|
72
72
|
end
|
73
|
+
|
74
|
+
def soapstripper
|
75
|
+
WebserviceSoapStripper.new
|
76
|
+
end
|
73
77
|
end
|
74
78
|
end
|
@@ -17,27 +17,5 @@ module Patentscope
|
|
17
17
|
end
|
18
18
|
end.to_xml
|
19
19
|
end
|
20
|
-
|
21
|
-
def strip_envelope(response, operation)
|
22
|
-
case operation
|
23
|
-
when :getAvailableDocuments
|
24
|
-
result_tag = 'doc'
|
25
|
-
when :getDocumentContent
|
26
|
-
result_tag = 'documentContent'
|
27
|
-
when :getDocumentOcrContent
|
28
|
-
result_tag = 'documentContent'
|
29
|
-
when :getIASR
|
30
|
-
result_tag = 'wo-international-application-status'
|
31
|
-
when :getDocumentTableOfContents
|
32
|
-
result_tag = 'content'
|
33
|
-
when :getDocumentContentPage
|
34
|
-
result_tag = 'pageContent'
|
35
|
-
end
|
36
|
-
doc = Nokogiri::XML(response)
|
37
|
-
stripped_response = doc.xpath("//iasr:#{result_tag}", 'iasr' => "http://www.wipo.org/wsdl/ps").to_xml
|
38
|
-
# this seems to be the only way to add back the XML declaration to the XML!
|
39
|
-
stripped_response_with_declaration = Nokogiri::XML(stripped_response).to_s
|
40
|
-
stripped_response_with_declaration
|
41
|
-
end
|
42
20
|
end
|
43
21
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Patentscope
|
2
|
+
|
3
|
+
class WebserviceSoapStripper
|
4
|
+
|
5
|
+
def strip_envelope(response, operation)
|
6
|
+
case operation
|
7
|
+
when :getAvailableDocuments
|
8
|
+
result_tag = 'getAvailableDocumentsResponse'
|
9
|
+
when :getDocumentContent
|
10
|
+
result_tag = 'getDocumentContentResponse'
|
11
|
+
when :getDocumentOcrContent
|
12
|
+
result_tag = 'getDocumentOcrContentResponse'
|
13
|
+
when :getIASR
|
14
|
+
result_tag = 'getIASRResponse'
|
15
|
+
when :getDocumentTableOfContents
|
16
|
+
result_tag = 'getDocumentTableOfContentsResponse'
|
17
|
+
when :getDocumentContentPage
|
18
|
+
result_tag = 'getDocumentContentPageResponse'
|
19
|
+
end
|
20
|
+
|
21
|
+
doc = Nokogiri::XML(response)
|
22
|
+
stripped_response = doc.xpath("//iasr:#{result_tag}", 'iasr' => "http://www.wipo.org/wsdl/ps").children
|
23
|
+
|
24
|
+
# add back the XML declaration to the XML with a namespace
|
25
|
+
stripped_response_with_declaration = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
26
|
+
xml.send(result_tag, "xmlns" => "http://www.wipo.org/wsdl/ps") do
|
27
|
+
xml.parent << stripped_response
|
28
|
+
end
|
29
|
+
end.to_xml
|
30
|
+
|
31
|
+
stripped_response_with_declaration
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/patentscope.gemspec
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'patentscope/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
gem.summary = %q{Ruby interface with WIPO PATENTSCOPE Web Service}
|
13
|
-
gem.homepage = "http://www.cantab-ip.com"
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "patentscope"
|
8
|
+
spec.version = Patentscope::VERSION
|
9
|
+
spec.licenses = "MIT"
|
10
|
+
spec.authors = ["Chong-Yee Khoo"]
|
11
|
+
spec.email = ["mail@cykhoo.com"]
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
gem.require_paths = ["lib"]
|
13
|
+
spec.summary = %q{Ruby interface with WIPO PATENTSCOPE Web Service}
|
14
|
+
spec.description = %q{Ruby interface to the PATENTSCOPE Web Service provided by the World Intellectual Property Organisation. Requires a subscription to the Patentscope Web Service}
|
15
|
+
spec.homepage = "http://www.cantab-ip.com"
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
spec.add_development_dependency 'dotenv', '~> 2.2'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.2'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
27
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
28
|
+
spec.add_development_dependency 'webmock', '~> 3.1'
|
29
|
+
|
30
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.8'
|
31
|
+
spec.add_runtime_dependency 'unicode_titlecase', '~> 0'
|
28
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patentscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chong-Yee Khoo
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -16,96 +16,96 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.7'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1
|
75
|
+
version: '3.1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1
|
82
|
+
version: '3.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.8'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.8'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: unicode_titlecase
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Ruby interface to the PATENTSCOPE Web Service provided by the World Intellectual
|
@@ -131,20 +131,11 @@ files:
|
|
131
131
|
- lib/patentscope/version.rb
|
132
132
|
- lib/patentscope/webservice.rb
|
133
133
|
- lib/patentscope/webservice_soap_builder.rb
|
134
|
+
- lib/patentscope/webservice_soap_stripper.rb
|
134
135
|
- patentscope.gemspec
|
135
|
-
- spec/client_spec.rb
|
136
|
-
- spec/configuration_spec.rb
|
137
|
-
- spec/patentscope_spec.rb
|
138
|
-
- spec/pct_app_number_spec.rb
|
139
|
-
- spec/pct_pub_number_spec.rb
|
140
|
-
- spec/spec_helper.rb
|
141
|
-
- spec/webservice_soap_builder_spec.rb
|
142
|
-
- spec/webservice_spec.rb
|
143
|
-
- spec/wipo_test_suite_doc_id_examples.yaml
|
144
|
-
- spec/wipo_test_suite_ia_number_examples.yaml
|
145
|
-
- spec/wipo_test_suite_spec.rb
|
146
136
|
homepage: http://www.cantab-ip.com
|
147
|
-
licenses:
|
137
|
+
licenses:
|
138
|
+
- MIT
|
148
139
|
metadata: {}
|
149
140
|
post_install_message:
|
150
141
|
rdoc_options: []
|
@@ -162,19 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
153
|
version: '0'
|
163
154
|
requirements: []
|
164
155
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.6.13
|
166
157
|
signing_key:
|
167
158
|
specification_version: 4
|
168
159
|
summary: Ruby interface with WIPO PATENTSCOPE Web Service
|
169
|
-
test_files:
|
170
|
-
- spec/client_spec.rb
|
171
|
-
- spec/configuration_spec.rb
|
172
|
-
- spec/patentscope_spec.rb
|
173
|
-
- spec/pct_app_number_spec.rb
|
174
|
-
- spec/pct_pub_number_spec.rb
|
175
|
-
- spec/spec_helper.rb
|
176
|
-
- spec/webservice_soap_builder_spec.rb
|
177
|
-
- spec/webservice_spec.rb
|
178
|
-
- spec/wipo_test_suite_doc_id_examples.yaml
|
179
|
-
- spec/wipo_test_suite_ia_number_examples.yaml
|
180
|
-
- spec/wipo_test_suite_spec.rb
|
160
|
+
test_files: []
|
data/spec/client_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Patentscope
|
4
|
-
|
5
|
-
describe Client, :core, :vcr do
|
6
|
-
|
7
|
-
before { Patentscope.configure_from_env}
|
8
|
-
|
9
|
-
let(:client) { Client.new(username: Patentscope.configuration.username, password: Patentscope.configuration.password) }
|
10
|
-
|
11
|
-
it "exists" do
|
12
|
-
expect(client).to_not be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "methods" do
|
16
|
-
|
17
|
-
it "has its own attribute reader methods" do
|
18
|
-
expect(client).to respond_to(:username)
|
19
|
-
expect(client).to respond_to(:password)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "has other methods" do
|
23
|
-
expect(client).to respond_to(:get_url)
|
24
|
-
expect(client).to respond_to(:post_url)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "attribute reader methods" do
|
29
|
-
|
30
|
-
describe "username method" do
|
31
|
-
it "returns the right username" do
|
32
|
-
expect(client.username).to eq(Patentscope.configuration.username)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "password method" do
|
37
|
-
it "returns the right password" do
|
38
|
-
expect(client.password).to eq(Patentscope.configuration.password)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "attribute writer methods" do
|
44
|
-
|
45
|
-
it "is not possible to set username" do
|
46
|
-
expect { client.username = 'foo' }.to raise_error()
|
47
|
-
end
|
48
|
-
|
49
|
-
it "is not possible to set password" do
|
50
|
-
expect { client.password = 'foo' }.to raise_error()
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "get_url method" do
|
55
|
-
it "fetches the Cantab website by GET" do
|
56
|
-
site = client.get_url('http://www.cantab-ip.com')
|
57
|
-
expect(site).to include('<html')
|
58
|
-
end
|
59
|
-
|
60
|
-
it "fetches the Patentscope WSDL by GET" do
|
61
|
-
site = client.get_url('http://www.wipo.int/patentscope-webservice/servicesPatentScope?wsdl')
|
62
|
-
expect(site).to include('<?xml')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "post_url method" do
|
67
|
-
it "fetches a URL by POST" do
|
68
|
-
Patentscope.configure_from_env
|
69
|
-
soap_envelope_xml = '<?xml version="1.0"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><getIASR xmlns="http://www.wipo.org/wsdl/ps"><iaNumber>SG2009000062</iaNumber></getIASR></S:Body></S:Envelope>'
|
70
|
-
site = client.post_url('http://www.wipo.int/patentscope-webservice/servicesPatentScope', 'text/xml', soap_envelope_xml)
|
71
|
-
expect(site).to include('<?xml')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|