patentscope 0.0.2 → 0.0.4

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: 0b523ee313b0b12c65cb68e78290344465927835
4
- data.tar.gz: ba4a83db30178a6b82c356749732ff8850d96289
3
+ metadata.gz: 8c3ff619f0ad1778c36dbb2d04a945ad4c3e3cce
4
+ data.tar.gz: 5736b0e818ed2823b0dd5e3d6f180902c9e25796
5
5
  SHA512:
6
- metadata.gz: 4671bda95ce98bdb5258b33e65b8a2919e1489b8173d8a8d3cc167d9fab95af416e5de334344b551fa93a4e28df8c97621395998326bf56e60a74dd36c44a759
7
- data.tar.gz: b0d0a48b09c52f15b0d75c4763dc67981ce89d3c28049dad29d1accc74cbb840b471e4f10b7749ac282a36ee6963855bea8df96fde4328dd32f30dbf6a8a848b
6
+ metadata.gz: 77ca863b3c8b598318503938c7d4596b1836585d353adee688452cd4a9dce669c41cbb7adb799bc9608876323e8735989fe780d5a7bb9ef8a5e032924b44717d
7
+ data.tar.gz: fd374c7216250fe7b8f37ac998188be5b9c32290351e70aff277fd31f7eed3861716720ca3c8c86529b07aae142110651471876d0da40f1aef140f0a50665000
data/.gitignore CHANGED
@@ -20,7 +20,7 @@ test/version_tmp
20
20
  tmp
21
21
 
22
22
  # Ignore gems vendored by bundle install --path
23
- /vendor/ruby
23
+ /vendor
24
24
 
25
25
  # Ignore binstubs generated by bundle install --binstubs
26
26
  /bin
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.4.2
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ ruby '2.4.2'
4
+
3
5
  # Specify your gem's dependencies in patentscope.gemspec
4
6
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2014 Chong-Yee Khoo
1
+ Copyright (c) 2013-2017 Chong-Yee Khoo
2
2
 
3
3
  MIT License
4
4
 
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] (http://patentscope.wipo.int/search/)
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-2014 Chong-Yee Khoo. All rights reserved.
243
+ Copyright (c) 2013-2016 Chong-Yee Khoo. All rights reserved.
244
244
 
245
245
  MIT License
246
246
 
@@ -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
@@ -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.parse(url)
22
- http = Net::HTTP.new(uri.host, uri.port)
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
- response = http.request(request)
29
- response.body
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
@@ -1,5 +1,5 @@
1
1
  module Patentscope
2
2
 
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.4"
4
4
 
5
5
  end
@@ -2,7 +2,7 @@ module Patentscope
2
2
 
3
3
  class Webservice
4
4
 
5
- PATENTSCOPE_WEBSERVICE_LOCATION = "http://www.wipo.int/patentscope-webservice/servicesPatentScope"
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?('This request requires HTTP authentication')
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
- soapbuilder.strip_envelope(response, operation)
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
@@ -1,28 +1,32 @@
1
- # -*- encoding: utf-8 -*-
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 |gem|
7
- gem.name = "patentscope"
8
- gem.version = Patentscope::VERSION
9
- gem.authors = ["Chong-Yee Khoo"]
10
- gem.email = ["mail@cykhoo.com"]
11
- gem.description = %q{Ruby interface to the PATENTSCOPE Web Service provided by the World Intellectual Property Organisation. Requires a subscription to the Patentscope Web Service}
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
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
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
- gem.add_development_dependency 'dotenv', '~> 1.0'
21
- gem.add_development_dependency 'rake', '~> 10.3'
22
- gem.add_development_dependency 'rspec', '~> 3.1'
23
- gem.add_development_dependency 'vcr', '~> 2.9.2'
24
- gem.add_development_dependency 'webmock', '~> 1.19'
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
- gem.add_runtime_dependency 'nokogiri'
27
- gem.add_runtime_dependency 'unicode_titlecase'
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.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chong-Yee Khoo
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
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: '1.0'
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: '1.0'
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: '10.3'
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: '10.3'
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.1'
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.1'
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: 2.9.2
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: 2.9.2
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.19'
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.19'
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: '0'
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: '0'
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.2.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: []
@@ -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