waylon-core 0.1.0 → 0.1.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: 01c6d89ed4d79dba9305c9c83fd597fed10ace104592f7d8ae6ed2f630bb9351
4
- data.tar.gz: 83ac891dc983e61f76b5cd366062381b748dcc49c86d6177b4e245c8c29573e0
3
+ metadata.gz: '0381c0f70f922e5958355430bef0ec1c8fd5d966b77b032f866fa9ecdcd3dd18'
4
+ data.tar.gz: 13b63cef7b5e7575b5d564d43cb599bd326e0b9ed499be5df1b08a1c191fc073
5
5
  SHA512:
6
- metadata.gz: bd0fabfda6646c84cb17af27dd55bd8c70ad1c803a257e1e4ed992ce4298563a579705dff33b898519b82ed2123e59ab2259021bbdec320914914a7ee19291f0
7
- data.tar.gz: 5b2c06fc2c55256014f35e953465f21c11c6de9390e55c0a504f7fcb08c2fcff1898e583dac97b546b1d1a7c00650014562c2e678aff6832353a3c24f08527b8
6
+ metadata.gz: bf835c89b14aa09e591fd8ca11b7c27065d0ad8262c2248ca261d897f320c0c5128d15154454407c32d35021dead332bcfb0597507e337dd7ee9de186bea2f1f
7
+ data.tar.gz: 2eb7a29a02dcc44c85ed8dd0c74999299dae4ed1bb2736d6d076e9c1885ea80b96ffdc71288f730fe68de5c2487e23183d6adf0239f23112bec2cf9cf2e006ed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waylon-core (0.1.0)
4
+ waylon-core (0.1.1)
5
5
  addressable (~> 2.8)
6
6
  faraday (~> 1.8)
7
7
  i18n (~> 1.8)
@@ -19,25 +19,29 @@ GEM
19
19
  concurrent-ruby (1.1.9)
20
20
  diff-lcs (1.4.4)
21
21
  docile (1.4.0)
22
- faraday (1.8.0)
22
+ faraday (1.9.3)
23
23
  faraday-em_http (~> 1.0)
24
24
  faraday-em_synchrony (~> 1.0)
25
25
  faraday-excon (~> 1.1)
26
- faraday-httpclient (~> 1.0.1)
26
+ faraday-httpclient (~> 1.0)
27
+ faraday-multipart (~> 1.0)
27
28
  faraday-net_http (~> 1.0)
28
- faraday-net_http_persistent (~> 1.1)
29
+ faraday-net_http_persistent (~> 1.0)
29
30
  faraday-patron (~> 1.0)
30
31
  faraday-rack (~> 1.0)
31
- multipart-post (>= 1.2, < 3)
32
+ faraday-retry (~> 1.0)
32
33
  ruby2_keywords (>= 0.0.4)
33
34
  faraday-em_http (1.0.0)
34
35
  faraday-em_synchrony (1.0.0)
35
36
  faraday-excon (1.1.0)
36
37
  faraday-httpclient (1.0.1)
38
+ faraday-multipart (1.0.2)
39
+ multipart-post (>= 1.2, < 3)
37
40
  faraday-net_http (1.0.1)
38
41
  faraday-net_http_persistent (1.2.0)
39
42
  faraday-patron (1.0.0)
40
43
  faraday-rack (1.0.0)
44
+ faraday-retry (1.0.3)
41
45
  i18n (1.8.11)
42
46
  concurrent-ruby (~> 1.0)
43
47
  json (2.6.1)
@@ -23,6 +23,20 @@ module Waylon
23
23
 
24
24
  # Base Component utility methods
25
25
  module ClassUtilityMethods
26
+ # Allows caching from class methods
27
+ # @param [String] key How to store/retrieved the cached value
28
+ # @param [Integer] expires How long to cache the value
29
+ def cache(key, expires: 600)
30
+ cache_key = config_key_for(key)
31
+ if !Waylon::Cache.key?(cache_key) && block_given?
32
+ result = yield
33
+ Waylon::Cache.store(cache_key, result, expires: expires)
34
+ elsif !Waylon::Cache.key?(cache_key)
35
+ return nil
36
+ end
37
+ Waylon::Cache.load(cache_key, expires: expires)
38
+ end
39
+
26
40
  # The namespace used for this component's storage
27
41
  # @param value [String,nil] Sets this namespace unless set (without setting, returns a sane default)
28
42
  # @return [String] The namespace for this component
data/lib/waylon/config.rb CHANGED
@@ -86,6 +86,7 @@ module Waylon
86
86
  # @param key [String] The key to use for storing the value
87
87
  # @param [Object] value The value for the key
88
88
  def []=(key, value)
89
+ @schema ||= {}
89
90
  if (@schema[key] && validate_config(@schema[key], value)) || key.start_with?("global.")
90
91
  @config ||= {}
91
92
  @config[key] = value
@@ -101,6 +102,7 @@ module Waylon
101
102
  # @return [String,nil] The requested value
102
103
  def [](key)
103
104
  @config ||= {}
105
+ @schema ||= {}
104
106
  if @config.key?(key)
105
107
  @config[key].dup
106
108
  elsif @schema.key?(key) && @schema[key][:default]
@@ -111,6 +113,7 @@ module Waylon
111
113
  # Is the state of the config valid?
112
114
  # @return [Boolean]
113
115
  def valid?
116
+ @schema ||= {}
114
117
  missing = @schema.select { |_k, v| v[:required] }.reject { |k, _v| @config[k] }
115
118
  missing.each do |key, _value|
116
119
  ::Waylon::Logger.log("Missing config: #{key}", :debug)
data/lib/waylon/user.rb CHANGED
@@ -14,8 +14,8 @@ module Waylon
14
14
  # Class-level methods to be added to User subclasses
15
15
  module ClassMethods
16
16
  # This should be overridden by subclasses to provide a mechanism for looking up Users
17
- def find_by_email(_email)
18
- raise NotImplementedError, "find_by_email isn't implemented"
17
+ def find_by_handle(_email)
18
+ raise NotImplementedError, "find_by_handle isn't implemented"
19
19
  end
20
20
 
21
21
  # Provides a simple mechanism for referencing User subclass's Sense
@@ -6,7 +6,7 @@ module Waylon
6
6
  VERSION = [
7
7
  0, # Major
8
8
  1, # Minor
9
- 0 # Patch
9
+ 1 # Patch
10
10
  ].join(".")
11
11
  end
12
12
  end
data/waylon-core.gemspec CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- # Uncomment to register a new dependency of your gem
31
30
  spec.add_dependency "addressable", "~> 2.8"
32
31
  spec.add_dependency "faraday", "~> 1.8"
33
32
  spec.add_dependency "i18n", "~> 1.8"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waylon-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-31 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable