firmenwissen 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: 576c03b35715563838d8d9a90e3505306f654ff797d0b9473f25d7e38179e4d5
4
- data.tar.gz: 8949337ac1b41fbc7c27e51149a9426b7171d829b8608654b65549d8a1b98003
3
+ metadata.gz: 6499228c4827e93416dd1c35718fb4ecd483c67e5ef14f1bd35be6596a6b8acd
4
+ data.tar.gz: 990c0a68b091c84e7d7046ee8606705c01ab8c67753afac1809621f2a94ba794
5
5
  SHA512:
6
- metadata.gz: 324ff805856360a06cc76b7176d768eed344d045fa856e119e5e24277a664e7b90bcc5731b5f82a73a6c7bb2c0639e498bf1a5aa282e6767ceecb01e1a08115f
7
- data.tar.gz: 61ff16571f767c6b5a53b3dea99d569cd8538e6c06ad5d0710ca0204f0c72494d2d340b06bbf7a2c4d6d4bafef823110d95d3b0c8a0b1643fa9a31c497b3b8cb
6
+ metadata.gz: f242d64753d4dd251562c8550b5e7b0547579acb8d53f338d42fa6e42ad5d48655d607925e3bcfb855b9c9d15f02e7b59ca09f24eb295b0e1fc63edfe0be3c9a
7
+ data.tar.gz: 55c3ca5f9fed873de5570fb0e80e70bee788bbbdf5e88372d365380ab67bca61af6d561a7513237aa6300f8043c7b312454024be16c74e3181dd46fdc18e6cf4
data/README.md CHANGED
@@ -51,9 +51,9 @@ Firmenwissen.configure do |config|
51
51
  config.user = 'username' # Username for Firmenwissen basic auth (required)
52
52
  config.password = 'password' # Password for Firmenwissen basic auth (required)
53
53
  config.timeout = 5 # Request timeout in seconds
54
-
54
+
55
55
  # Configure the endpoint yourself. %s will be replaced by the actual query
56
- config.endpoint = 'https://example.com/search?query=%s'
56
+ config.endpoint = 'https://example.com/search?query={query}'
57
57
  end
58
58
  ```
59
59
  ### Mocking results
@@ -62,10 +62,10 @@ In a non production-like environment you will not want to perform real requests
62
62
  ```ruby
63
63
  Firmenwissen.configure do |config|
64
64
  config.mock_requests = true
65
-
65
+
66
66
  # respond with a fixed array
67
67
  config.mock_data = [{ crefo_id: '1111111111', name: 'Test GmbH', ... }, { ... }, ...]
68
-
68
+
69
69
  # respond when a query matches an exact keyword
70
70
  # this will return a result mock when you search for 'compeon' or 'test', otherwise an empty result
71
71
  mock_data = {
@@ -74,20 +74,20 @@ Firmenwissen.configure do |config|
74
74
  }
75
75
 
76
76
  config.mock_data = mock_data
77
-
77
+
78
78
  # generate your own dynamic response
79
79
  config.mock_data = Proc.new do |query|
80
80
  # your code for mock data generation here
81
81
  end
82
-
82
+
83
83
  # or
84
-
84
+
85
85
  class DynamicMockData
86
86
  def call(query)
87
87
  # your code for mock data generation here
88
88
  end
89
89
  end
90
-
90
+
91
91
  config.mock_data = DynamicMockData.new
92
92
  end
93
93
  ```
@@ -7,6 +7,7 @@ require 'firmenwissen/http_request'
7
7
  require 'firmenwissen/key_mapper'
8
8
  require 'firmenwissen/request'
9
9
  require 'firmenwissen/suggestion'
10
+ require 'firmenwissen/uri_decorator'
10
11
  require 'firmenwissen/version'
11
12
 
12
13
  require 'firmenwissen/errors/credentials_error'
@@ -6,7 +6,7 @@ module Firmenwissen
6
6
  end
7
7
 
8
8
  def execute
9
- http = Net::HTTP.start(uri.host, use_ssl: true)
9
+ http = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.use_ssl?)
10
10
  http.read_timeout = config.timeout
11
11
  http.request(request)
12
12
  ensure
@@ -23,7 +23,7 @@ module Firmenwissen
23
23
 
24
24
  def uri
25
25
  template = Addressable::Template.new(config.endpoint)
26
- template.expand(query: query, **params)
26
+ URIDecorator.new(template.expand(query: query, **params))
27
27
  end
28
28
 
29
29
  def config
@@ -0,0 +1,9 @@
1
+ class URIDecorator < SimpleDelegator
2
+ def port
3
+ inferred_port
4
+ end
5
+
6
+ def use_ssl?
7
+ scheme == 'https'
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Firmenwissen
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firmenwissen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerrit Seger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -102,6 +102,7 @@ files:
102
102
  - lib/firmenwissen/response/base.rb
103
103
  - lib/firmenwissen/response/mock.rb
104
104
  - lib/firmenwissen/suggestion.rb
105
+ - lib/firmenwissen/uri_decorator.rb
105
106
  - lib/firmenwissen/version.rb
106
107
  homepage:
107
108
  licenses: