Skip to content

Commit

Permalink
Remove OpenStruct usage from Pry::Command::Ls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehjr committed Apr 15, 2024
1 parent 2f8b257 commit 5a16027
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
14 changes: 12 additions & 2 deletions lib/pry/commands/ls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
class Pry
class Command
class Ls < Pry::ClassCommand
DEFAULT_OPTIONS = {
Config = Struct.new(:heading_color, :public_method_color,
:private_method_color, :protected_method_color,
:method_missing_color, :local_var_color,
:pry_var_color, :instance_var_color, :class_var_color,
:global_var_color, :builtin_global_color,
:pseudo_global_color, :constant_color,
:class_constant_color, :exception_constant_color,
:unloaded_constant_color, :separator,
:ceiling)

DEFAULT_CONFIG = Config.new(
heading_color: :bright_blue,
public_method_color: :default,
private_method_color: :blue,
Expand All @@ -22,7 +32,7 @@ class Ls < Pry::ClassCommand
unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
separator: " ",
ceiling: [Object, Module, Class]
}.freeze
).freeze

match 'ls'
group 'Context'
Expand Down
4 changes: 1 addition & 3 deletions lib/pry/config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'ostruct'

class Pry
# @api private
class Config
Expand Down Expand Up @@ -199,7 +197,7 @@ def initialize
extra_sticky_locals: {},
command_completions: proc { commands.keys },
file_completions: proc { Dir['.'] },
ls: OpenStruct.new(Pry::Command::Ls::DEFAULT_OPTIONS),
ls: Pry::Command::Ls::DEFAULT_CONFIG.dup,
completer: Pry::InputCompleter,
history_save: true,
history_load: true,
Expand Down
2 changes: 1 addition & 1 deletion spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
specify { expect(subject.extra_sticky_locals).to be_a(Hash) }
specify { expect(subject.command_completions).to be_a(Proc) }
specify { expect(subject.file_completions).to be_a(Proc) }
specify { expect(subject.ls).to be_an(OpenStruct) }
specify { expect(subject.ls).to be_an(Pry::Command::Ls::Config) }
specify { expect(subject.completer).to eq(Pry::InputCompleter) }
specify { expect(subject.history).to be_a(Pry::History) }
specify { expect(subject.history_save).to eq(true).or be(false) }
Expand Down

0 comments on commit 5a16027

Please sign in to comment.