shaf 1.2.0 → 1.2.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
  SHA256:
3
- metadata.gz: 63fafb2ab34a4535e8d5ff38476ffcd43051bdcbeb397b9e9b06bc2c5fa855af
4
- data.tar.gz: 8ce6362451525448857762bbfb016c80d698615dbf436549b3a600cf2521e72a
3
+ metadata.gz: b19e78676b4dc759b28198902633a7a66bde814d88b0ca7d442052fa62326ccd
4
+ data.tar.gz: 66c8a419a5590ad713f74a0d704439bf282cded99a5f5e0d30eabd26d8ab4d7d
5
5
  SHA512:
6
- metadata.gz: 1f9fdf99ec948ac02e171efdb6be8d0f71c6e8231e8f9e27546f97f62c38b1d3365716d6e14a51f01676a0432e4b09be06db70a3ba8df571118dc2d8bba2266f
7
- data.tar.gz: 737e3f828105a47ff124a02d0ccff2f8c9f2b60ec1202fab9ac695a860d3444a31147a90d6b3faa8120e1effe15f849941d883bc7f4d0e23d46e1ef8fa0302c2
6
+ metadata.gz: 183f94b5e51e365d431033c6b2b4d55dfec717c1b3808a5957751667e11a92d1e97b29ebcd5184b8140c2202d71de006e1cb2108c1438e746a0893275527264a
7
+ data.tar.gz: e9c812b5db8032ee330faeaba47e8d535f87f5321506f1f4e2a393b79d8118cf5d832f3ac43d84c2244834b294a7f448c542c4df9ab125f2b43a5901a9ba7569
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -74,6 +74,8 @@ module Shaf
74
74
  end
75
75
 
76
76
  def self.base_uri
77
+ return Settings.base_uri if Settings.base_uri
78
+
77
79
  protocol = Settings.protocol || 'http'
78
80
  host = Settings.hostname || 'localhost'
79
81
  port = Settings.port ? ":#{Settings.port}" : ""
@@ -56,6 +56,10 @@ module Shaf
56
56
  @settings[key] = arg
57
57
  end
58
58
  end
59
+
60
+ def to_h
61
+ @settings.dup
62
+ end
59
63
  end
60
64
  end
61
65
  end
@@ -56,15 +56,33 @@ module Shaf
56
56
  end
57
57
 
58
58
  def deep_symbolize_keys(value)
59
- case value
59
+ deep_transform_keys(value) { |key| key.to_sym }
60
+ end
61
+
62
+ def deep_transform_keys(hash, &block)
63
+ case hash
60
64
  when Hash
61
- value.each_with_object({}) do |(k, v), h|
62
- h[k.to_sym] = deep_symbolize_keys(v)
65
+ hash.each_with_object({}) do |(k, v), h|
66
+ key = block.call(k)
67
+ h[key] = deep_transform_keys(v, &block)
63
68
  end
64
69
  when Array
65
- value.map { |v| deep_symbolize_keys(v) }
70
+ hash.map { |v| deep_transform_keys(v, &block) }
66
71
  else
67
- value
72
+ hash
73
+ end
74
+ end
75
+
76
+ def deep_transform_values(hash, &block)
77
+ case hash
78
+ when Hash
79
+ hash.each_with_object({}) do |(k, v), h|
80
+ h[k] = deep_transform_values(v, &block)
81
+ end
82
+ when Array
83
+ hash.map { |v| deep_transform_values(v, &block) }
84
+ else
85
+ block.call(hash)
68
86
  end
69
87
  end
70
88
 
@@ -72,14 +90,16 @@ module Shaf
72
90
  return {} unless File.exist? file
73
91
 
74
92
  yaml = File.read(file)
75
- yaml = erb(yaml, binding: erb_binding) if erb || erb_binding
93
+ load_args = [yaml, {aliases: true, symbolize_names: true}]
76
94
  if RUBY_VERSION < '2.6.0'
77
- Utils.deep_symbolize_keys(YAML.safe_load(yaml, [], [], true))
78
- else
79
- YAML.safe_load(yaml, aliases: true, symbolize_names: true)
95
+ load_args.pop
96
+ load_args += [[], [], true]
80
97
  end
98
+ YAML.safe_load(*load_args)
81
99
  end
82
100
 
101
+ private
102
+
83
103
  def erb(content, binding: nil)
84
104
  bindings = binding ? [binding] : []
85
105
  return ERB.new(content, 0, '%-<>').result(*bindings) if RUBY_VERSION < '2.6.0'
@@ -1,3 +1,3 @@
1
1
  module Shaf
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- $:.unshift __dir__
1
+ $:.unshift File.expand_path(__dir__)
2
2
  require 'config/bootstrap'
3
3
 
4
4
  Shaf::App.run!
@@ -20,8 +20,8 @@ default: &default
20
20
 
21
21
  production:
22
22
  <<: *default
23
- port: 443
24
- protocol: https
23
+ port: <%= ENV.fetch('PORT', 443) %>
24
+ base_uri: https://my.public.shaf.api.com
25
25
 
26
26
  development:
27
27
  <<: *default
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Henningsson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
31
31
  M40=
32
32
  -----END CERTIFICATE-----
33
- date: 2019-09-23 00:00:00.000000000 Z
33
+ date: 2019-10-04 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: minitest
@@ -276,6 +276,7 @@ files:
276
276
  - upgrades/1.0.4.tar.gz
277
277
  - upgrades/1.1.0.tar.gz
278
278
  - upgrades/1.2.0.tar.gz
279
+ - upgrades/1.2.1.tar.gz
279
280
  homepage:
280
281
  licenses:
281
282
  - MIT
metadata.gz.sig CHANGED
Binary file