console1984 0.1.31 → 0.2.0

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: 534f4adb54490c9f5cb39a9e068e9d15ac2d84d05a7e7ed97e287b132021b52d
4
- data.tar.gz: 2d6d1f7059db9bb2c4561136b45ef57b74a8ab8f86dd59a2a80fd6c117bdd5f6
3
+ metadata.gz: dab24e3e5ca1a9640cc312b6466e8ec4b3f917435bd54df8cd44fe361eb19cf8
4
+ data.tar.gz: 9550f056b2252a148a1d5fff0eac6936ad75d4283827222503d754098d1c4b77
5
5
  SHA512:
6
- metadata.gz: ac7e2d0297fe375b638e8f1b1887889296fca195fd54cd489605420866399ff85506e525d4a173c95ccca988ed97767a7302d0a821cd7c0a36f7fe993a07d86a
7
- data.tar.gz: 69f8d533ea41a90b038b713875d125f156bfebdec950c1a4c72a326a05ea551d01c170766fe941d2cb69e5ff55ba564953834e2759afe453eece87ee4c2a8b08
6
+ metadata.gz: 70d3abebccbb42053c4071353a8db786bd50ef4f5faa3dde4357ff4f02b6e8a8fd0b1178ba3559fe832a1afa8d89c2f3a0531040d707ef6777e88c1ccfb583ec
7
+ data.tar.gz: 211e8a17167c63454007bd89a308a9e1d96aea58693fa33afba79105c266a9d39e4cf1a4665dc29188b9d09085d0c2f0fd6b680a59e269279cf75de7d8395883
@@ -1,4 +1,4 @@
1
- # Naming class with dot so that it doesn't get loaded eagerly by Zeitwork. We want to load
1
+ # Naming class with dot so that it doesn't get loaded eagerly by Zeitwerk. We want to load
2
2
  # only when a console session is started, when +parser+ is loaded.
3
3
  #
4
4
  # See +Console1984::Supervisor#require_dependencies+
@@ -0,0 +1,14 @@
1
+ require "irb/command"
2
+
3
+ module Console1984::Commands
4
+ class Decrypt < IRB::Command::Base
5
+ include Console1984::Ext::Irb::Commands
6
+
7
+ category "Console1984"
8
+ description "go back to protected mode, without access to encrypted information"
9
+
10
+ def execute(*)
11
+ decrypt!
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require "irb/command"
2
+
3
+ module Console1984::Commands
4
+ class Encrypt < IRB::Command::Base
5
+ include Console1984::Ext::Irb::Commands
6
+
7
+ category "Console1984"
8
+ description "go back to protected mode, without access to encrypted information"
9
+
10
+ def execute(*)
11
+ encrypt!
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,3 @@
1
- # Add Console 1984 commands to IRB sessions.
2
1
  module Console1984::Ext::Irb::Commands
3
2
  include Console1984::Freezeable
4
3
 
@@ -13,13 +12,4 @@ module Console1984::Ext::Irb::Commands
13
12
  def encrypt!
14
13
  shield.enable_protected_mode
15
14
  end
16
-
17
- # This returns the last error that prevented a command execution in the console
18
- # or nil if there isn't any.
19
- #
20
- # This is meant for internal usage when debugging legit commands that are wrongly
21
- # prevented.
22
- def _console_last_suspicious_command_error
23
- Console1984.command_executor.last_suspicious_command_error
24
- end
25
15
  end
@@ -12,8 +12,16 @@ module Console1984::Ext::Irb::Context
12
12
  end
13
13
 
14
14
  #
15
- def evaluate(line, ...)
16
- Console1984.command_executor.execute(Array(line)) do
15
+ def evaluate(line_or_statement, ...)
16
+ # irb < 1.13 passes String as parameter
17
+ # irb >= 1.13 passes IRB::Statement instead and method #code contains the actual code
18
+ code = if defined?(IRB::Statement) && line_or_statement.kind_of?(IRB::Statement)
19
+ line_or_statement.code
20
+ else
21
+ line_or_statement
22
+ end
23
+
24
+ Console1984.command_executor.execute(Array(code)) do
17
25
  super
18
26
  end
19
27
  end
@@ -34,7 +34,8 @@ class Console1984::Shield
34
34
 
35
35
  def extend_irb
36
36
  IRB::Context.prepend(Console1984::Ext::Irb::Context)
37
- Rails::ConsoleMethods.include(Console1984::Ext::Irb::Commands)
37
+ IRB::Command.register :decrypt!, Console1984::Commands::Decrypt
38
+ IRB::Command.register :encrypt!, Console1984::Commands::Encrypt
38
39
  end
39
40
 
40
41
  def extend_core_ruby
@@ -47,8 +48,12 @@ class Console1984::Shield
47
48
  socket_classes = [TCPSocket, OpenSSL::SSL::SSLSocket]
48
49
  OpenSSL::SSL::SSLSocket.include(SSLSocketRemoteAddress)
49
50
 
50
- if defined?(Redis::Connection)
51
- socket_classes.push(*[Redis::Connection::TCPSocket, Redis::Connection::SSLSocket])
51
+ if defined?(Redis::Connection::TCPSocket)
52
+ socket_classes.push(Redis::Connection::TCPSocket)
53
+ end
54
+
55
+ if defined?(Redis::Connection::SSLSocket)
56
+ socket_classes.push(Redis::Connection::SSLSocket)
52
57
  end
53
58
 
54
59
  socket_classes.compact.each do |socket_klass|
@@ -1,4 +1,4 @@
1
- require 'rails/console/app'
1
+ require "active_support/all"
2
2
 
3
3
  # Entry point to the system. In charge of installing everything
4
4
  # and starting and stopping sessions.
@@ -1,3 +1,3 @@
1
1
  module Console1984
2
- VERSION = "0.1.31"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console1984
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.31
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-24 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -45,13 +45,27 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '7.0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '7.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: irb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.13'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.13'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: benchmark-ips
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,20 @@ dependencies:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubyzip
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  description:
196
224
  email:
197
225
  - jorge@basecamp.com
@@ -219,6 +247,8 @@ files:
219
247
  - lib/console1984/command_validator/forbidden_reopening_validation.rb
220
248
  - lib/console1984/command_validator/parsed_command.rb
221
249
  - lib/console1984/command_validator/suspicious_terms_validation.rb
250
+ - lib/console1984/commands/decrypt.rb
251
+ - lib/console1984/commands/encrypt.rb
222
252
  - lib/console1984/config.rb
223
253
  - lib/console1984/engine.rb
224
254
  - lib/console1984/errors.rb
@@ -268,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
298
  - !ruby/object:Gem::Version
269
299
  version: '0'
270
300
  requirements: []
271
- rubygems_version: 3.2.32
301
+ rubygems_version: 3.5.6
272
302
  signing_key:
273
303
  specification_version: 4
274
304
  summary: Your Rails console, 1984 style