waylon-core 0.2.0 → 0.2.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: 404fb7180c3c7b52c2bb3637fd3fb86d28cd5b4b1f1791e8b2fe0f94d7788ea9
4
- data.tar.gz: 6b1da741b15a5092cddf65e81623a348454289ecb496eef1dfee081e79bb5f0e
3
+ metadata.gz: 44b2586a3ba29a3b2da02d66f880a826b445d2658ea6f83fa3e8a0a9935d0898
4
+ data.tar.gz: b1d602e2f41f06c37752c31eb2d9a0a983f699f3bcd7c73372305719c6a68874
5
5
  SHA512:
6
- metadata.gz: f4852c99d93a726be2e21ec1a1cdf9fdf758508b09fed717ea1642b2f92c9c9adfe84e8fb922107f751859d2e3a331521d32f492911ffb6f5d82935a0ceef032
7
- data.tar.gz: 03747526f39170835b3ab67ffc294a3e3c914968001b40e24eb5ddcd74fb2746c28ca7bb95288ab67523cf25018fe9709aa16956a54ab507839b1fe05a252771
6
+ metadata.gz: 6d40939e62fa6c4a58c7bf31ec716fdde3d0d878e36aa6331dcfdabd73b67b02b441973243a3baefd9c96ad01681a1ab382146d26ffa4de83db3ea41355a060f
7
+ data.tar.gz: 581ba5ccbececbb637a09efab4bd202c3e8112edca8999e57e5fe3bda3b1cb40097f92c73d5e959c76c454039f9d7581fd13955580d5d72d0b3ba773b3991ca0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waylon-core (0.2.0)
4
+ waylon-core (0.2.3)
5
5
  addressable (~> 2.8)
6
6
  faraday (~> 1.8)
7
7
  i18n (~> 1.8)
@@ -14,13 +14,15 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- addressable (2.8.0)
18
- public_suffix (>= 2.0.2, < 5.0)
17
+ addressable (2.8.1)
18
+ public_suffix (>= 2.0.2, < 6.0)
19
19
  ast (2.4.2)
20
+ coderay (1.1.3)
20
21
  concurrent-ruby (1.1.10)
22
+ connection_pool (2.2.5)
21
23
  diff-lcs (1.5.0)
22
24
  docile (1.4.0)
23
- faraday (1.10.0)
25
+ faraday (1.10.2)
24
26
  faraday-em_http (~> 1.0)
25
27
  faraday-em_synchrony (~> 1.0)
26
28
  faraday-excon (~> 1.1)
@@ -44,34 +46,41 @@ GEM
44
46
  faraday-rack (1.0.0)
45
47
  faraday-retry (1.0.3)
46
48
  ffi (1.15.5)
47
- i18n (1.10.0)
49
+ i18n (1.12.0)
48
50
  concurrent-ruby (~> 1.0)
49
51
  json (2.6.2)
52
+ method_source (1.0.0)
50
53
  moneta (1.5.1)
51
54
  mono_logger (1.1.1)
52
55
  multi_json (1.15.0)
53
56
  multipart-post (2.2.3)
54
- mustermann (1.1.1)
57
+ mustermann (2.0.2)
55
58
  ruby2_keywords (~> 0.0.1)
56
59
  nio4r (2.5.8)
57
60
  parallel (1.22.1)
58
- parser (3.1.2.0)
61
+ parser (3.1.2.1)
59
62
  ast (~> 2.4.1)
60
- public_suffix (4.0.7)
61
- puma (5.6.4)
63
+ pry (0.14.1)
64
+ coderay (~> 1.1)
65
+ method_source (~> 1.0)
66
+ public_suffix (5.0.0)
67
+ puma (5.6.5)
62
68
  nio4r (~> 2.0)
63
- rack (2.2.3.1)
64
- rack-protection (2.2.0)
69
+ rack (2.2.4)
70
+ rack-protection (2.2.2)
65
71
  rack
66
72
  rainbow (3.1.1)
67
73
  rake (13.0.6)
68
74
  rbnacl (7.1.1)
69
75
  ffi
70
- redis (4.6.0)
71
- redis-namespace (1.8.2)
72
- redis (>= 3.0.4)
76
+ redis (5.0.1)
77
+ redis-client (~> 0.7)
78
+ redis-client (0.7.1)
79
+ connection_pool
80
+ redis-namespace (1.9.0)
81
+ redis (>= 4)
73
82
  regexp_parser (2.5.0)
74
- resque (2.2.1)
83
+ resque (2.3.0)
75
84
  mono_logger (~> 1.0)
76
85
  multi_json (~> 1.0)
77
86
  redis-namespace (~> 1.6)
@@ -90,21 +99,22 @@ GEM
90
99
  diff-lcs (>= 1.2.0, < 2.0)
91
100
  rspec-support (~> 3.11.0)
92
101
  rspec-support (3.11.0)
93
- rubocop (1.30.1)
102
+ rubocop (1.35.1)
103
+ json (~> 2.3)
94
104
  parallel (~> 1.10)
95
- parser (>= 3.1.0.0)
105
+ parser (>= 3.1.2.1)
96
106
  rainbow (>= 2.2.2, < 4.0)
97
107
  regexp_parser (>= 1.8, < 3.0)
98
108
  rexml (>= 3.2.5, < 4.0)
99
- rubocop-ast (>= 1.18.0, < 2.0)
109
+ rubocop-ast (>= 1.20.1, < 2.0)
100
110
  ruby-progressbar (~> 1.7)
101
111
  unicode-display_width (>= 1.4.0, < 3.0)
102
- rubocop-ast (1.18.0)
112
+ rubocop-ast (1.21.0)
103
113
  parser (>= 3.1.1.0)
104
114
  rubocop-rake (0.6.0)
105
115
  rubocop (~> 1.0)
106
- rubocop-rspec (2.11.1)
107
- rubocop (~> 1.19)
116
+ rubocop-rspec (2.12.1)
117
+ rubocop (~> 1.31)
108
118
  ruby-progressbar (1.11.0)
109
119
  ruby2_keywords (0.0.5)
110
120
  simplecov (0.21.2)
@@ -113,13 +123,13 @@ GEM
113
123
  simplecov_json_formatter (~> 0.1)
114
124
  simplecov-html (0.12.3)
115
125
  simplecov_json_formatter (0.1.4)
116
- sinatra (2.2.0)
117
- mustermann (~> 1.0)
126
+ sinatra (2.2.2)
127
+ mustermann (~> 2.0)
118
128
  rack (~> 2.2)
119
- rack-protection (= 2.2.0)
129
+ rack-protection (= 2.2.2)
120
130
  tilt (~> 2.0)
121
- tilt (2.0.10)
122
- unicode-display_width (2.1.0)
131
+ tilt (2.0.11)
132
+ unicode-display_width (2.2.0)
123
133
  webrick (1.7.0)
124
134
  yard (0.9.28)
125
135
  webrick (~> 1.7.0)
@@ -130,6 +140,7 @@ PLATFORMS
130
140
 
131
141
  DEPENDENCIES
132
142
  bundler (~> 2.3)
143
+ pry (~> 0.14)
133
144
  rake (~> 13.0)
134
145
  rspec (~> 3.10)
135
146
  rubocop (~> 1.23)
data/Rakefile CHANGED
@@ -19,5 +19,9 @@ end
19
19
  task default: %i[spec rubocop yard]
20
20
 
21
21
  task :demo do
22
+ require "pry"
23
+ Waylon::Logger.logger = ::Logger.new("/dev/null")
24
+ Waylon::Cache.storage = Moneta.new(:Cookie)
25
+ Waylon::Storage.storage = Moneta.new(:Cookie)
22
26
  require "waylon/rspec/test_server"
23
27
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Waylon
4
+ # Used for working with the Moneta store for caching
5
+ module Cache
6
+ DefaultStorage = Moneta.new(
7
+ :Redis,
8
+ url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
9
+ )
10
+
11
+ def self.clear
12
+ storage.clear
13
+ end
14
+
15
+ def self.delete(key)
16
+ storage.delete(key)
17
+ end
18
+
19
+ def self.key?(name)
20
+ storage.key?(name)
21
+ end
22
+
23
+ def self.load(key, expires: nil)
24
+ expires ? storage.load(key, expires: expires) : storage.load(key)
25
+ end
26
+
27
+ def self.store(key, value, expires: nil)
28
+ if expires
29
+ storage.store(key, value, expires: expires)
30
+ else
31
+ storage.store(key, value)
32
+ end
33
+ end
34
+
35
+ def self.storage
36
+ @storage ||= DefaultStorage
37
+ end
38
+
39
+ def self.storage=(storage)
40
+ @storage = storage
41
+ end
42
+ end
43
+ end
data/lib/waylon/core.rb CHANGED
@@ -27,6 +27,7 @@ require "sinatra"
27
27
 
28
28
  # Internal requirements
29
29
  require "waylon/version"
30
+ require "waylon/cache"
30
31
  require "waylon/config"
31
32
  require "waylon/generic_exception"
32
33
  require "waylon/exceptions/not_implemented_error"
@@ -19,8 +19,7 @@ require "waylon/rspec/test_worker"
19
19
  config = Waylon::Config.instance
20
20
  config.load_env
21
21
 
22
- Waylon::Cache = Moneta.new(:Cookie)
23
- p Waylon::Storage
22
+ Waylon::Cache.storage = Moneta.new(:Cookie)
24
23
  Waylon::Logger.log("Found Global Admins: #{config.admins}")
25
24
 
26
25
  Waylon::RSpec::TestUser.find_or_create(
@@ -101,6 +100,8 @@ def handle_input(body, from: this_user, privately: true)
101
100
  elsif ["su", "su -", "su admin", "su - admin"].include?(body)
102
101
  puts 'Admin enabled! Use "exit" to go back to a normal user.'
103
102
  @admin_enabled = true
103
+ elsif @admin_enabled && %w[irb pry].include?(body)
104
+ pry
104
105
  else
105
106
  message_count = Waylon::RSpec::TestSense.sent_messages.size
106
107
 
data/lib/waylon/rspec.rb CHANGED
@@ -46,5 +46,5 @@ module Waylon
46
46
  end
47
47
  end
48
48
 
49
- Waylon::Cache = Moneta.new(:Cookie)
50
- Waylon::Storage::Store = Moneta.new(:Cookie)
49
+ Waylon::Cache.storage = Moneta.new(:Cookie)
50
+ Waylon::Storage.storage = Moneta.new(:Cookie)
@@ -1,14 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Waylon::Cache = Moneta.new(
4
- :Redis,
5
- url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
6
- )
7
-
8
3
  module Waylon
9
4
  # Used for working with the Moneta store
10
5
  module Storage
11
- Store = Moneta.new(
6
+ DefaultStorage = Moneta.new(
12
7
  :Redis,
13
8
  url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
14
9
  )
@@ -19,20 +14,20 @@ module Waylon
19
14
  end
20
15
 
21
16
  def self.clear
22
- Store.clear
17
+ storage.clear
23
18
  end
24
19
 
25
20
  def self.delete(key)
26
- Store.delete(key)
21
+ storage.delete(key)
27
22
  end
28
23
 
29
24
  def self.key?(name)
30
- Store.key?(name)
25
+ storage.key?(name)
31
26
  end
32
27
 
33
28
  def self.load(key)
34
29
  this_cipher = cipher
35
- raw = Store.load(key)
30
+ raw = storage.load(key)
36
31
  return nil unless raw
37
32
 
38
33
  decoded = Base64.decode64(raw)
@@ -40,11 +35,19 @@ module Waylon
40
35
  JSON.parse(plain)
41
36
  end
42
37
 
38
+ def self.storage
39
+ @storage ||= DefaultStorage
40
+ end
41
+
42
+ def self.storage=(storage)
43
+ @storage = storage
44
+ end
45
+
43
46
  def self.store(key, value)
44
47
  this_cipher = cipher
45
48
  encrypted = this_cipher.encrypt(value.to_json)
46
49
  encoded = Base64.encode64(encrypted)
47
- Store.store(key, encoded)
50
+ storage.store(key, encoded)
48
51
  end
49
52
  end
50
53
  end
@@ -6,7 +6,7 @@ module Waylon
6
6
  VERSION = [
7
7
  0, # Major
8
8
  2, # Minor
9
- 0 # Patch
9
+ 3 # Patch
10
10
  ].join(".")
11
11
  end
12
12
  end
data/waylon-core.gemspec CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "resque", "~> 2.2"
38
38
 
39
39
  spec.add_development_dependency "bundler", "~> 2.3"
40
+ spec.add_development_dependency "pry", "~> 0.14"
40
41
  spec.add_development_dependency "rake", "~> 13.0"
41
42
  spec.add_development_dependency "rspec", "~> 3.10"
42
43
  spec.add_development_dependency "rubocop", "~> 1.23"
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.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-19 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '2.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.14'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.14'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rake
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -261,6 +275,7 @@ files:
261
275
  - bin/console
262
276
  - bin/setup
263
277
  - lib/waylon/base_component.rb
278
+ - lib/waylon/cache.rb
264
279
  - lib/waylon/condition.rb
265
280
  - lib/waylon/conditions/black_hole.rb
266
281
  - lib/waylon/conditions/default.rb