rest_dsl 0.1.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a37783f662f90bf063aa89a5d2ec129c6b165348f9f5809f3718479310d5e1d
4
- data.tar.gz: a5c427a4fde05951a1d5f899b9c9b3e2c105c66b493a4d7048e3d3993bdf42e0
3
+ metadata.gz: a391433ed18e7b84cd3d4f47065e9ed861d9d7d7d0fc5d0a58d2352753631d16
4
+ data.tar.gz: 0a96ac8af22c162c815487eaa57cf79b8f84a44355e67e1b072a84d3393c1b62
5
5
  SHA512:
6
- metadata.gz: abb0aedc0b963db58a13dab20569fcccd03da08d8f1a7d93deddfa2eff3b446360f21741e4d17248d1b82d72da29b573684d20aed02dbaa4c6d599ed781979ea
7
- data.tar.gz: fe19a5b06ab8a2986d8a2225dfab90d18cabef6e37e2691764026532105e6f692cedbdd6d35a85984550cf8c342b173e658edeb61d7f568a9075810177852578
6
+ metadata.gz: 2afa1d1237863054781187e56dbead899b2a6ed5e635340c309042317de0a42b22a91a14d573583628340d3b721f78296e684dd8f5341ae1116b2a56d170133b
7
+ data.tar.gz: 2f97e19928e5e049f03fd7db323c1c1d1390de9c6b23869dad7a85fb1074826224ca4f6a444de2bb002d24b68a6771e1695bcea60a6307e0834e8fa6976abad3
@@ -41,19 +41,23 @@ module RestDSL
41
41
  # Can by wrapped manually to create more complicated logic than what's supported by the default generators
42
42
  def execute_request(method, rest_method_call, *args, headers: nil, payload: nil, params: nil, url_args: nil, **hash_args, &block)
43
43
  headers ||= self.headers
44
- params ||= {}
45
44
  url_args ||= {}
46
- params = "?#{params.map{|key,value| "#{key}=#{value}"}.join('&')}"
47
45
  service_name = "#{@service_name}/" unless @service_name&.empty?
48
46
  hash_args.merge!(auth)
49
47
  hash_args.merge!(payload: payload) if payload
50
48
  sub_url_args!(url_args, rest_method_call)
51
- arg_list = [method, "#{service_name}#{rest_method_call}#{params}", headers]
49
+ arg_list = [method, "#{service_name}#{rest_method_call}#{build_params(params)}", headers]
52
50
  response = @client.execute(*arg_list, *args, **hash_args, &block)
53
51
  @last_response = response[:response]
54
52
  response[:parsed]
55
53
  end
56
54
 
55
+ def build_params(params)
56
+ params ||= {}
57
+ return "" if params.empty?
58
+ "?#{params.map{|key,value| "#{key}=#{value}"}.join('&')}" unless params.empty?
59
+ end
60
+
57
61
  def sub_url_args!(arg_list, rest_method_call)
58
62
  # Given the protocol is handled by the client and not service_base, this should be a safe enough pattern in most cases
59
63
  arg_list.each{ |arg_name, value| rest_method_call.gsub!(":#{arg_name}", value) }
@@ -71,6 +75,7 @@ module RestDSL
71
75
  def reload_config
72
76
  @config = Psych.load_file(@config_file)[@environment] if File.exist?(@config_file)
73
77
  @config = {} unless File.exist?(@config_file)
78
+ @config
74
79
  end
75
80
 
76
81
  def auth
@@ -1,3 +1,3 @@
1
1
  module RestDSL
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Ridge
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-02 00:00:00.000000000 Z
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler