Skip to content

Commit

Permalink
Fix #65
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronC81 committed Jun 30, 2019
1 parent 127361d commit fc140b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion exe/sord
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ command :gen do |c|
end
end

Sord::RbiGenerator.new(options).run(args.first)
Sord::RbiGenerator.new(options.__hash__).run(args.first)

This comment has been minimized.

Copy link
@connorshea

connorshea Jun 30, 2019

Contributor

what in the world is this?

This comment has been minimized.

Copy link
@AaronC81

AaronC81 Jun 30, 2019

Author Owner

The easy way to get a hash out of an Commander::Command::Options instance! It's not pretty, but it provides this instead of #to_h. (https://github.com/commander-rb/commander/blob/06a9f6458a013cad4723086d85dd12f6f69a1be0/lib/commander/command.rb#L18-L20) Would it be better to manually convert the keys we care about?

This comment has been minimized.

Copy link
@connorshea

connorshea Jun 30, 2019

Contributor

nah, this is fine, it's just crazy they implemented it this way.

end
end
8 changes: 4 additions & 4 deletions lib/sord/rbi_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def object_count
attr_accessor :next_item_is_first_in_namespace

# Create a new RBI generator.
# @param [Commander::Command::Options] options
# @param [Hash] options
# @option options [Integer] break_params
# @option options [Boolean] replace_errors_with_untyped
# @option options [Boolean] comments
Expand All @@ -36,15 +36,15 @@ def initialize(options)
@rbi_contents = ['# typed: strong']
@namespace_count = 0
@method_count = 0
@break_params = options.break_params
@replace_errors_with_untyped = options.replace_errors_with_untyped
@break_params = options[:break_params]
@replace_errors_with_untyped = options[:replace_errors_with_untyped]
@warnings = []
@next_item_is_first_in_namespace = true

# Hook the logger so that messages are added as comments to the RBI file
Logging.add_hook do |type, msg, item, indent_level = 0|
rbi_contents << "#{' ' * (indent_level + 1)}# sord #{type} - #{msg}"
end if options.comments
end if options[:comments]

# Hook the logger so that warnings are collected
Logging.add_hook do |type, msg, item, indent_level = 0|
Expand Down
10 changes: 5 additions & 5 deletions spec/rbi_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

subject do
# Create an unnamed class to emulate everything required in "options"
Sord::RbiGenerator.new(Class.new do
def comments; true; end
def break_params; 4; end
def replace_errors_with_untyped; false; end
end.new)
Sord::RbiGenerator.new(
comments: true,
break_params: 4,
replace_errors_with_untyped: false,
)
end

def fix_heredoc(x)
Expand Down

0 comments on commit fc140b8

Please sign in to comment.