rider-server 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.build.yml +3 -3
  3. data/CHANGELOG.md +23 -1
  4. data/COPYING +20 -0
  5. data/README.rdoc +39 -0
  6. data/Rakefile +5 -0
  7. data/exe/rider-server +3 -3
  8. data/lib/rider_server/config.rb +76 -0
  9. data/lib/rider_server/core_ext/array.rb +3 -1
  10. data/lib/rider_server/core_ext/class.rb +5 -0
  11. data/lib/rider_server/core_ext/env.rb +14 -0
  12. data/lib/rider_server/core_ext/hash.rb +3 -1
  13. data/lib/rider_server/core_ext/kernel.rb +5 -0
  14. data/lib/rider_server/core_ext/module.rb +18 -0
  15. data/lib/rider_server/core_ext/object.rb +7 -1
  16. data/lib/rider_server/core_ext/string.rb +3 -1
  17. data/lib/rider_server/core_ext/symbol.rb +3 -1
  18. data/lib/rider_server/exception_extension.rb +2 -0
  19. data/lib/rider_server/inspect.rb +115 -43
  20. data/lib/rider_server/logger.rb +11 -4
  21. data/lib/rider_server/operation.rb +39 -20
  22. data/lib/rider_server/{ops → operations}/clone.rb +3 -2
  23. data/lib/rider_server/{ops → operations}/close.rb +3 -2
  24. data/lib/rider_server/operations/completions.rb +146 -0
  25. data/lib/rider_server/operations/lookup.rb +102 -0
  26. data/lib/rider_server/operations/ls_sessions.rb +51 -0
  27. data/lib/rider_server/operations/toggle_catch_all_exceptions.rb +24 -0
  28. data/lib/rider_server/operations.rb +43 -69
  29. data/lib/rider_server/request.rb +61 -0
  30. data/lib/rider_server/response.rb +10 -2
  31. data/lib/rider_server/server.rb +29 -17
  32. data/lib/rider_server/services/capture_exceptions.rb +18 -2
  33. data/lib/rider_server/services/rails.rb +1 -1
  34. data/lib/rider_server/session.rb +77 -34
  35. data/lib/rider_server/session_operation.rb +17 -0
  36. data/lib/rider_server/session_operations/eval.rb +61 -0
  37. data/lib/rider_server/session_operations/inspect.rb +123 -0
  38. data/lib/rider_server/session_operations/inspect_exception.rb +46 -0
  39. data/lib/rider_server/session_operations/interrupt.rb +29 -0
  40. data/lib/rider_server/session_operations/load_path.rb +19 -0
  41. data/lib/rider_server/session_operations/ls_exceptions.rb +28 -0
  42. data/lib/rider_server/session_operations/ls_services.rb +18 -0
  43. data/lib/rider_server/session_operations/service.rb +42 -0
  44. data/lib/rider_server/session_operations/set_namespace.rb +82 -0
  45. data/lib/rider_server/session_operations/set_namespace_variable.rb +81 -0
  46. data/lib/rider_server/session_operations/stdin.rb +19 -0
  47. data/lib/rider_server/utils.rb +7 -7
  48. data/lib/rider_server/validate/array.rb +32 -0
  49. data/lib/rider_server/validate/base.rb +28 -0
  50. data/lib/rider_server/validate/boolean.rb +47 -0
  51. data/lib/rider_server/validate/hash.rb +32 -0
  52. data/lib/rider_server/validate/integer.rb +56 -0
  53. data/lib/rider_server/validate/predicates.rb +30 -0
  54. data/lib/rider_server/validate/string.rb +60 -0
  55. data/lib/rider_server/validate/symbol.rb +90 -0
  56. data/lib/rider_server/validate.rb +15 -0
  57. data/lib/rider_server/version.rb +1 -1
  58. data/lib/rider_server/workspace.rb +1 -1
  59. data/lib/rider_server.rb +3 -1
  60. metadata +55 -24
  61. data/README.md +0 -44
  62. data/lib/rider_server/ops/completions.rb +0 -100
  63. data/lib/rider_server/ops/eval.rb +0 -62
  64. data/lib/rider_server/ops/inspect.rb +0 -121
  65. data/lib/rider_server/ops/inspect_exception.rb +0 -47
  66. data/lib/rider_server/ops/interrupt.rb +0 -30
  67. data/lib/rider_server/ops/load_path.rb +0 -20
  68. data/lib/rider_server/ops/lookup.rb +0 -83
  69. data/lib/rider_server/ops/ls_exceptions.rb +0 -29
  70. data/lib/rider_server/ops/ls_services.rb +0 -19
  71. data/lib/rider_server/ops/ls_sessions.rb +0 -52
  72. data/lib/rider_server/ops/service.rb +0 -43
  73. data/lib/rider_server/ops/set_namespace.rb +0 -79
  74. data/lib/rider_server/ops/set_namespace_variable.rb +0 -80
  75. data/lib/rider_server/ops/stdin.rb +0 -20
  76. data/lib/rider_server/ops/toggle_catch_all_exceptions.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 302928be71e4f0608534e86f87c555a0f3507004c93c058947b74d480cfde558
4
- data.tar.gz: 80707ddff979bb2a92f7f696dcbc44ac68830d56dffa11cfc021aa5eec06d743
3
+ metadata.gz: 42460de42badb3c5e588c8f606d395f91b8c91f419f119983e18d9ee7833b6c6
4
+ data.tar.gz: 3a1b5c4b92bb2bfe630a01736aa75dfa7eb23cd058686faaa748589d62f95e96
5
5
  SHA512:
6
- metadata.gz: f9fcc56b8cbceaa6df781155af166873e66c0bfe1261041b6667759dfc5eb56c3c9dfd6943b45e1e7f302cb0737e21da048ba399f837dec4a77416cb7af037bf
7
- data.tar.gz: 74527b4e988b97b6ed527530bbdef94cc6b48776c74fef12930dbf70a59c648209f3afa615ebb835861acba0b0eba70884107268b65e7aa12da0adb7b63040f8
6
+ metadata.gz: f42e2bb3d67f2922b0fe7a06c027b17a5737361521aa73f41a9b2376d53217f2f81f54066b82ba168ec3f5046dc8b2b238d0c7e2d6d0d8f8db5a6ac1bd279654
7
+ data.tar.gz: 5518b9ca7125186c9c248606b219819b271aa35514518ee90384614c8ccb9e7f0d8e1d1bc22014129d11dda586d849fd31854a7b8309083a0c3f8ac35e4e0acc
data/.build.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  image: debian/stable
2
2
  sources:
3
- - https://git.sr.ht/~rsl/rider
3
+ - https://git.sr.ht/~rsl/rider-server
4
4
  packages:
5
5
  - bundler
6
6
  - curl
@@ -10,11 +10,11 @@ packages:
10
10
  - zlib1g-dev
11
11
  tasks:
12
12
  - lint: |
13
- cd rider
13
+ cd rider-server
14
14
  bundle install --path="../.gems"
15
15
  bundle exec rake standard
16
16
  - test: |
17
- cd rider
17
+ cd rider-server
18
18
  bundle install --path="../.gems"
19
19
  bundle exec rake test
20
20
  triggers:
data/CHANGELOG.md CHANGED
@@ -1,4 +1,26 @@
1
- ## [Unreleased]
1
+ ## [0.1.2] - 2024-08-14
2
+
3
+ - update to latest bencode and remove ruby version limitation
4
+ - request argument validation
5
+ - add a global configuration object and a mechanism to load
6
+ configuration at startup.
7
+ - support setting the caputured exception buffer size.
8
+ - allow setting of the log level
9
+ - enable setting of the current namespace to an element of an array
10
+ - add a separate inspect mechanism for the singleton class
11
+ - fill in missing parameter details in ruby. This is a port of the
12
+ elisp code, and simplifies the Emacs implementation.
13
+ - ENV object printing, previously the env object would print the
14
+ entire env value which is of an unknown size.
15
+ - printing of constant names along with values in inspect view.
16
+ Module constants have a name as a value, but this isn't true for
17
+ other constants.
18
+
19
+ ## [0.1.1] - 2024-07-31
20
+
21
+ - Basic completion
22
+ - Basic symbol lookup
23
+ - Fix ancestor lookup
2
24
 
3
25
  ## [0.1.0] - 2024-07-27
4
26
 
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2024 Russell Sim <rsl@simopolis.xyz>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ “Software”), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = RIDER -- RIDER Interactive Development Environment for Ruby
2
+
3
+ RIDER Server is the server component of the RIDER development
4
+ environment.
5
+
6
+ == Installation
7
+
8
+ Install the gem and add to the application's Gemfile by executing:
9
+
10
+ $ bundle add rider-server
11
+
12
+ If bundler is not being used to manage dependencies, install the gem by executing:
13
+
14
+ $ gem install rider-server
15
+
16
+ == Usage
17
+
18
+ TODO: Write usage instructions here
19
+
20
+ == Development
21
+
22
+ After checking out the repo, run <tt>bin/setup</tt> to install
23
+ dependencies. Then, run <tt>rake test</tt> to run the tests. You can also run
24
+ <tt>bin/console</tt> for an interactive prompt that will allow you to
25
+ experiment.
26
+
27
+ To install this gem onto your local machine, run <tt>bundle exec rake
28
+ install</tt>.
29
+
30
+ To release a new version run <tt>rake bump:patch</tt> and then run <tt>bundle
31
+ exec rake release</tt>, which will create a git tag for the version, push
32
+ git commits and the created tag, and push the <tt>.gem</tt> file to
33
+ http://rubygems.org.
34
+
35
+ == Contributing
36
+
37
+ Bug reports http://todo.sr.ht/~rsl/rider
38
+
39
+ Support or discussion http://lists.sr.ht/~rsl/rider-devel
data/Rakefile CHANGED
@@ -3,9 +3,14 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "minitest/test_task"
5
5
  require "bump/tasks"
6
+ require "rdoc/task"
6
7
 
7
8
  Bump.tag_by_default = true
8
9
  Minitest::TestTask.create
10
+ RDoc::Task.new do |rdoc|
11
+ rdoc.main = "README.rdoc"
12
+ rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
13
+ end
9
14
 
10
15
  require "standard/rake"
11
16
 
data/exe/rider-server CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
7
7
 
8
- require "rider_server/server"
9
-
10
- server = RiderServer::Server.new
8
+ require "rider_server"
9
+ config = RiderServer::Config.new
10
+ server = RiderServer::Server.new(config)
11
11
  server.run
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # config.rb -- A config class for global config
5
+ #
6
+ # Author: Russell Sim
7
+ # Copyright (c) 2024 Russell Sim
8
+ # SPDX-License-Identifier: MIT
9
+
10
+ require "rider_server/validate"
11
+
12
+ module RiderServer
13
+ class Config
14
+ DEFAULTS = {
15
+ host: "localhost",
16
+ port: 7888,
17
+
18
+ # Whether to capture RIDER exceptions and send them to the
19
+ # client.
20
+ capture_exceptions: false,
21
+
22
+ # The number of exceptions to keep in the history.
23
+ exception_history_size: 10,
24
+
25
+ # The log level
26
+ log_level: :INFO
27
+ }
28
+
29
+ def self.configure(&block)
30
+ instance = new
31
+ instance.instance_eval(&block)
32
+ instance
33
+ end
34
+
35
+ # Define a configuration option, +option_name+ is a symbol
36
+ # representing the name of the configuration option, and
37
+ # +validator+ is a Validate object that will be used to validate
38
+ # the value of the option.
39
+ def self.def_option(option_name, validator)
40
+ define_method :"#{option_name}" do |value = nil|
41
+ if value
42
+ @options[option_name] = validator.validate(value)
43
+ else
44
+ unless @options.key?(option_name)
45
+ raise ArgumentError, "Option #{option_name} not set"
46
+ end
47
+
48
+ @options[option_name]
49
+ end
50
+ end
51
+ end
52
+
53
+ def_option :host, Validate.string.not_empty
54
+ def_option :port, Validate.integer.greater_than(0)
55
+ def_option :capture_exceptions, Validate.bool
56
+ def_option :exception_history_size, Validate.integer.greater_than(0)
57
+
58
+ def_option :log_level, Validate.symbol.upcase.one_of(:DEBUG, :INFO, :WARN, :ERROR, :FATAL)
59
+
60
+ attr_reader :options
61
+
62
+ def initialize(config_file: "rider.rb")
63
+ @options = DEFAULTS.dup
64
+
65
+ if File.file?(config_file)
66
+ config.load_from(config_file)
67
+ end
68
+ end
69
+
70
+ # Load configuration from file +path+. The contents of the file
71
+ # will be evaluated within the context of this class instance.
72
+ def load_from(path)
73
+ instance_eval(File.read(path), path, 1)
74
+ end
75
+ end
76
+ end
@@ -8,7 +8,9 @@
8
8
  # SPDX-License-Identifier: MIT
9
9
 
10
10
  class Array
11
- def rider_inspect
11
+ # Return a +string+ representation of the object in a consistent
12
+ # manner that will not be excessivly long.
13
+ def rider_display
12
14
  max_length = 50
13
15
  sample = +""
14
16
 
@@ -0,0 +1,5 @@
1
+ class Class
2
+ def rider_descendants
3
+ ObjectSpace.each_object(::Class).select { |klass| klass < self }
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # env.rb -- ENV extensions
5
+ #
6
+ # Author: Russell Sim
7
+ # Copyright (c) 2024 Russell Sim
8
+ # SPDX-License-Identifier: MIT
9
+
10
+ # Return a +string+ representation of the object in a consistent
11
+ # manner that will not be excessivly long.
12
+ def ENV.rider_display
13
+ "#<ENV #{keys[..3].join(", ")}, ...>"
14
+ end
@@ -8,7 +8,9 @@
8
8
  # SPDX-License-Identifier: MIT
9
9
 
10
10
  class Hash
11
- def rider_inspect
11
+ # Return a +string+ representation of the object in a consistent
12
+ # manner that will not be excessivly long.
13
+ def rider_display
12
14
  "#<#{self.class}: #{length} items}>"
13
15
  end
14
16
  end
@@ -0,0 +1,5 @@
1
+ module Kernel
2
+ def rider_methods
3
+ Kernel.instance_method(:methods).bind_call(self)
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # module.rb -- Module extensions
5
+ #
6
+ # Author: Russell Sim
7
+ # Copyright (c) 2024 Russell Sim
8
+ # SPDX-License-Identifier: MIT
9
+
10
+ class Module
11
+ def rider_inspect
12
+ Module.instance_method(:inspect).bind_call(self)
13
+ end
14
+
15
+ def rider_instance_methods
16
+ Module.instance_method(:instance_methods).bind_call(self)
17
+ end
18
+ end
@@ -8,11 +8,17 @@
8
8
  # SPDX-License-Identifier: MIT
9
9
 
10
10
  class Object
11
- def rider_inspect
11
+ # Return a +string+ representation of the object in a consistent
12
+ # manner that will not be excessivly long.
13
+ def rider_display
12
14
  if defined?(inspect) && method(:inspect).owner != Object && method(:inspect).owner != Kernel
13
15
  inspect
14
16
  else
15
17
  "#<#{self.class} #{object_id}>"
16
18
  end
17
19
  end
20
+
21
+ def rider_inspect
22
+ Object.instance_method(:inspect).bind_call(self)
23
+ end
18
24
  end
@@ -8,7 +8,9 @@
8
8
  # SPDX-License-Identifier: MIT
9
9
 
10
10
  class String
11
- def rider_inspect
11
+ # Return a +string+ representation of the object in a consistent
12
+ # manner that will not be excessivly long.
13
+ def rider_display
12
14
  if length <= 50
13
15
  "#<String #{inspect}>"
14
16
  else
@@ -8,7 +8,9 @@
8
8
  # SPDX-License-Identifier: MIT
9
9
 
10
10
  class Symbol
11
- def rider_inspect
11
+ # Return a +string+ representation of the object in a consistent
12
+ # manner that will not be excessivly long.
13
+ def rider_display
12
14
  ":#{self}"
13
15
  end
14
16
  end
@@ -28,6 +28,8 @@ module RiderServer
28
28
  end
29
29
 
30
30
  unless ::Exception.included_modules.include?(RiderServer::ExceptionExtension)
31
+ # Extend the +exception+ class so that RIDER can capture the
32
+ # backtraces for inspection.
31
33
  class ::Exception
32
34
  prepend RiderServer::ExceptionExtension
33
35
  end
@@ -11,67 +11,139 @@ require "rider_server/utils"
11
11
 
12
12
  module RiderServer
13
13
  module Inspect
14
-
15
14
  def self.safely_eval(string, file, line)
16
15
  code = <<~HEREDOC
17
- begin
18
- #{string}
19
- rescue StandardError => e
20
- e
21
- end
16
+ begin
17
+ #{string}
18
+ rescue StandardError => e
19
+ e
20
+ end
22
21
  HEREDOC
23
22
  eval(code, TOPLEVEL_BINDING, file, line) # rubocop:disable Security/Eval
24
23
  end
25
24
 
26
- def self.class(obj)
25
+ def self.safely_location(src)
26
+ loc = safely_eval(src, __FILE__, __LINE__)
27
+ if loc.length == 2 && loc[0].is_a?(String) && loc[1].is_a?(Integer)
28
+ loc
29
+ else
30
+ []
31
+ end
32
+ end
33
+
34
+ def self.inspect_class(obj)
27
35
  klass = obj.class
28
36
  {
29
37
  "name" => klass.to_s,
30
- "value" => Utils.rider_inspect(safely_eval("Object.const_get('#{klass}')", __FILE__, __LINE__)),
38
+ "value" => Utils.rider_display(safely_eval("Object.const_get('#{klass}')", __FILE__, __LINE__)),
31
39
  "inspect-location" => "toplevel_const_get:#{klass.inspect}",
32
40
  "source-location" => safely_eval("Object.const_source_location('#{klass}')", __FILE__, __LINE__) || []
33
41
  }
34
42
  end
35
43
 
36
- def self.ancestors(obj)
37
- # Look for instance ancestors on the class.
38
- obj = obj.class if !obj.respond_to?(:ancestors) && obj.class.respond_to?(:ancestors)
39
-
40
- if obj.class.respond_to?(:ancestors)
41
- obj.class.ancestors.map do |item|
42
- {
43
- "name" => item.to_s,
44
- "value" => Utils.rider_inspect(item),
45
- "inspect-location" => "ancestor_find:#{item}",
46
- "source-location" => safely_eval("Object.const_source_location('#{item}')", __FILE__, __LINE__) || []
47
- }
44
+ def self.inspect_singleton_class(obj)
45
+ klass = obj.singleton_class
46
+ {
47
+ "name" => klass.to_s,
48
+ "value" => Utils.rider_display(klass),
49
+ "inspect-location" => "singleton_class",
50
+ "source-location" => []
51
+ }
52
+ rescue => e # integers have no singleton
53
+ {
54
+ "name" => e.to_s,
55
+ "value" => Utils.rider_display(e)
56
+ }
57
+ end
58
+
59
+ def self.inspect_ancestors(obj)
60
+ if obj.respond_to?(:ancestors)
61
+ obj.ancestors.map do |item|
62
+ if item.instance_of? ::Module
63
+ {
64
+ "name" => item.to_s,
65
+ "value" => Utils.rider_display(item),
66
+ "inspect-location" => "ancestor_find:#{item}",
67
+ "source-location" => safely_location("Object.const_source_location('#{item}')")
68
+ }
69
+ else
70
+ {
71
+ "name" => item.to_s,
72
+ "value" => Utils.rider_display(item),
73
+ "inspect-location" => "ancestor_find:#{item}",
74
+ "source-location" => []
75
+ }
76
+ end
48
77
  end
49
78
  else
50
79
  []
51
80
  end
52
81
  end
53
82
 
54
- def self.constants(obj)
83
+ def self.inspect_constants(obj)
55
84
  if obj.respond_to?(:constants)
56
- constants = safely_eval("#{obj.inspect}.constants", __FILE__, __LINE__)
85
+ constants = safely_eval("#{obj.rider_inspect}.constants", __FILE__, __LINE__)
57
86
  return [] if constants.nil? # Eigen classes have no constants
58
87
  constants.map do |item|
59
- {
60
- "name" => item.to_s,
61
- "value" => Utils.rider_inspect(safely_eval("#{obj.inspect}.const_get('#{item}')", __FILE__, __LINE__)),
62
- "inspect-location" => "const_get:#{obj.inspect}::#{item}",
63
- "source-location" => safely_eval("#{obj.inspect}.const_source_location('#{item}')", __FILE__, __LINE__) || []
64
- }
65
- end.sort_by { |hash| hash["name"] }
88
+ [
89
+ {
90
+ "name" => item.to_s
91
+ },
92
+ {
93
+ "name" => item.to_s,
94
+ "value" => Utils.rider_display(safely_eval("#{obj.rider_inspect}.const_get('#{item}')", __FILE__, __LINE__)),
95
+ "inspect-location" => "const_get:#{obj.rider_inspect}::#{item}",
96
+ "source-location" => safely_location("#{obj.rider_inspect}.const_source_location('#{item}')")
97
+ }
98
+ ]
99
+ end.sort_by { |hash| hash[0]["name"] }
66
100
  else
67
101
  []
68
102
  end
69
103
  end
70
104
 
105
+ def self.inspect_parameters(parameters)
106
+ alpha = Enumerator.new do |y|
107
+ ("a".."z").each { |char| y << char }
108
+ end
109
+
110
+ parameters.map do |params|
111
+ arg, name = params
112
+ if arg == :rest
113
+ "*#{name || "args"}"
114
+ elsif arg == :keyrest
115
+ if name.nil? || name == "**"
116
+ "**kwargs"
117
+ else
118
+ name
119
+ end
120
+ elsif arg == :req
121
+ name || alpha.next
122
+ elsif arg == :keyreq
123
+ "#{name || alpha.next}: ..."
124
+ elsif arg == :key
125
+ "#{name || alpha.next}:"
126
+ elsif arg == :opt
127
+ "#{name || alpha.next}=..."
128
+ elsif arg == :block
129
+ "&block"
130
+ else
131
+ raise "Unknown prameter format #{arg}"
132
+ end.to_s
133
+ end
134
+ end
135
+
71
136
  def self.describe_method(method)
137
+ loc = method.source_location
138
+ method_location = if !loc.nil? && loc.length == 2 && loc[0].is_a?(String) && loc[1].is_a?(Integer)
139
+ loc
140
+ else
141
+ []
142
+ end
143
+
72
144
  {
73
145
  "name" => method.name.to_s,
74
- "value" => Utils.rider_inspect(method),
146
+ "value" => Utils.rider_display(method),
75
147
  "visibility" => if method.private?
76
148
  ":private"
77
149
  elsif method.protected?
@@ -81,15 +153,15 @@ module RiderServer
81
153
  else
82
154
  ":unknown"
83
155
  end,
84
- "owner" => method.owner.inspect,
85
- "source-location" => method.source_location || [],
86
- "parameters" => method.parameters.map { |subarray| subarray.map(&:to_s) }
156
+ "owner" => method.owner.rider_inspect,
157
+ "source-location" => method_location,
158
+ "parameters" => inspect_parameters(method.parameters)
87
159
  }
88
160
  end
89
161
 
90
- def self.methods(obj)
91
- if obj.respond_to?(:methods)
92
- obj.methods.map do |name|
162
+ def self.inspect_methods(obj)
163
+ if obj.respond_to?(:rider_methods)
164
+ obj.rider_methods.map do |name|
93
165
  describe_method(obj.method(name))
94
166
  end
95
167
  else
@@ -97,9 +169,9 @@ module RiderServer
97
169
  end
98
170
  end
99
171
 
100
- def self.instance_methods(obj)
101
- if obj.respond_to?(:instance_methods)
102
- obj.instance_methods.map do |item|
172
+ def self.inspect_instance_methods(obj)
173
+ if obj.respond_to?(:rider_instance_methods)
174
+ obj.rider_instance_methods.map do |item|
103
175
  describe_method(obj.instance_method(item))
104
176
  end
105
177
  else
@@ -107,7 +179,7 @@ module RiderServer
107
179
  end
108
180
  end
109
181
 
110
- def self.instance_variables(obj)
182
+ def self.inspect_instance_variables(obj)
111
183
  if obj.respond_to?(:instance_variables)
112
184
  obj.instance_variables.map do |item|
113
185
  [
@@ -116,7 +188,7 @@ module RiderServer
116
188
  },
117
189
  {
118
190
  "name" => obj.instance_variable_get(item).to_s,
119
- "value" => Utils.rider_inspect(obj.instance_variable_get(item)),
191
+ "value" => Utils.rider_display(obj.instance_variable_get(item)),
120
192
  "inspect-location" => "instance_variable_get:#{item}"
121
193
  }
122
194
  ]
@@ -126,7 +198,7 @@ module RiderServer
126
198
  end
127
199
  end
128
200
 
129
- def self.class_variables(obj)
201
+ def self.inspect_class_variables(obj)
130
202
  if obj.respond_to?(:class_variables)
131
203
  obj.class_variables.map do |item|
132
204
  [
@@ -135,7 +207,7 @@ module RiderServer
135
207
  },
136
208
  {
137
209
  "name" => obj.class_variable_get(item).to_s,
138
- "value" => Utils.rider_inspect(obj.class_variable_get(item)),
210
+ "value" => Utils.rider_display(obj.class_variable_get(item)),
139
211
  "inspect-location" => "class_variable_get:#{item}"
140
212
  }
141
213
  ]
@@ -2,12 +2,19 @@ require "logger"
2
2
 
3
3
  module RiderServer
4
4
  module Logger
5
- def log
6
- @logger ||= begin
7
- log_level = (ENV["LOG_LEVEL"] || "INFO").upcase.to_sym
5
+ class << self
6
+ def configure_logger(logdev: ::STDERR, level: ENV["LOG_LEVEL"] || "INFO") # rubocop:disable Style/GlobalStdStream
7
+ log_level = level.upcase.to_sym
8
+ @@logger = ::Logger.new(logdev, level: log_level)
9
+ end
8
10
 
9
- ::Logger.new(STDERR, level: log_level) # rubocop:disable Style/GlobalStdStream
11
+ def log
12
+ @@logger ||= configure_logger
10
13
  end
11
14
  end
15
+
16
+ def log
17
+ Logger.log
18
+ end
12
19
  end
13
20
  end