Skip to content

Commit 4e47c1b

Browse files
authored
Merge pull request #102 from AlexWayfer/remove_ruby_warnings
Remove warnings from Ruby (MRI)
2 parents 6b65023 + dbe1e4a commit 4e47c1b

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--color
2+
--warnings

lib/clamp/attribute/definition.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def multivalued?
5454
end
5555

5656
def required?
57-
@required
57+
@required ||= false
5858
end
5959

6060
def hidden?
61-
@hidden
61+
@hidden ||= false
6262
end
6363

6464
def attribute_name

lib/clamp/messages.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ def messages=(new_messages)
1111
end
1212

1313
def message(key, options = {})
14-
format(messages.fetch(key), options)
14+
string = messages.fetch(key)
15+
return string if options.empty?
16+
17+
format string, options
1518
end
1619

1720
def clear_messages!

lib/clamp/option/declaration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def declared_options
2929
end
3030

3131
def recognised_options
32-
unless @implicit_options_declared
32+
unless @implicit_options_declared ||= false
3333
declare_implicit_help_option
3434
@implicit_options_declared = true
3535
end

lib/clamp/subcommand/declaration.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def default_subcommand=(name)
4747

4848
def default_subcommand(*args, &block)
4949
if args.empty?
50-
@default_subcommand
50+
@default_subcommand ||= false
5151
else
5252
$stderr.puts "WARNING: Clamp default_subcommand syntax has changed; check the README."
5353
$stderr.puts " (from #{caller(1..1).first})"
@@ -59,10 +59,10 @@ def default_subcommand(*args, &block)
5959
private
6060

6161
def declare_subcommand_parameters
62-
if @default_subcommand
62+
if default_subcommand
6363
parameter "[SUBCOMMAND]", "subcommand",
6464
attribute_name: :subcommand_name,
65-
default: @default_subcommand,
65+
default: default_subcommand,
6666
inheritable: false
6767
else
6868
parameter "SUBCOMMAND", "subcommand",

lib/clamp/subcommand/definition.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
module Clamp
44
module Subcommand
55

6-
Definition = Struct.new(:name, :description, :subcommand_class) do
6+
Definition = Struct.new(:names, :description, :subcommand_class) do
77

88
def initialize(names, description, subcommand_class)
9-
@names = Array(names)
10-
@description = description
11-
@subcommand_class = subcommand_class
9+
names = Array(names)
10+
super
1211
end
1312

14-
attr_reader :names, :description, :subcommand_class
15-
1613
def is_called?(name)
1714
names.member?(name)
1815
end

0 commit comments

Comments
 (0)