Skip to content

Commit b80da3f

Browse files
committed
Change Stackdriver::Core::Configuration#add_nested to #add_options
1 parent fbccd6b commit b80da3f

File tree

7 files changed

+42
-32
lines changed

7 files changed

+42
-32
lines changed

google-cloud-debugger/lib/google/cloud/debugger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ module Debugger
323323
# Initialize :error_reporting as a nested Configuration under
324324
# Google::Cloud if haven't already
325325
unless Google::Cloud.configure.option? :debugger
326-
Google::Cloud.configure.add_nested :debugger
326+
Google::Cloud.configure.add_options :debugger
327327
end
328328

329329
##

google-cloud-debugger/test/google/cloud/debugger_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@
137137
end
138138
end
139139

140+
describe ".configure" do
141+
it "has Google::Cloud.configure.debugger initialized already" do
142+
Google::Cloud.configure.option?(:debugger).must_equal true
143+
end
144+
145+
it "operates on the same Configuration object as Google::Cloud.configure.debugger" do
146+
Google::Cloud::Debugger.configure.must_equal Google::Cloud.configure.debugger
147+
end
148+
end
149+
140150
describe "Debugger.new" do
141151
let(:default_credentials) { OpenStruct.new empty: true }
142152
let(:default_module_name) { "default-utest-service" }

google-cloud-error_reporting/lib/google/cloud/error_reporting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module ErrorReporting
7474
# Initialize :error_reporting as a nested Configuration under
7575
# Google::Cloud if haven't already
7676
unless Google::Cloud.configure.option? :error_reporting
77-
Google::Cloud.configure.add_nested :error_reporting
77+
Google::Cloud.configure.add_options :error_reporting
7878
end
7979

8080
##

google-cloud-logging/lib/google/cloud/logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ module Logging
332332
# Initialize :error_reporting as a nested Configuration under
333333
# Google::Cloud if haven't already
334334
unless Google::Cloud.configure.option? :logging
335-
Google::Cloud.configure.add_nested logging: {
335+
Google::Cloud.configure.add_options logging: {
336336
monitored_resource: :labels
337337
}
338338
end

google-cloud-trace/lib/google/cloud/trace.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ module Trace
194194
# Initialize :error_reporting as a nested Configuration under
195195
# Google::Cloud if haven't already
196196
unless Google::Cloud.configure.option? :trace
197-
Google::Cloud.configure.add_nested :trace
197+
Google::Cloud.configure.add_options :trace
198198
end
199199

200200
##

stackdriver-core/lib/stackdriver/core/configuration.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,55 @@ module Core
1818
##
1919
# @private Helps organize configuration options for Stackdriver
2020
# instrumentation libraries. It's initialized with a nested list of
21-
# predefined option keys, then only allows getting and setting these
21+
# predefined category keys, then only allows getting and setting these
2222
# predefined options.
2323
#
2424
# @example
25-
# nested_categories = [:nested1, {nested2: [:nested3]}]
26-
# config = Stackdriver::Core::Configuration.new nested: nested_categories
25+
# nested_categories = [:cat1, {cat2: [:cat3]}]
26+
# config = Stackdriver::Core::Configuration.new nested_categories
2727
#
2828
# config.opt1 #=> nil
2929
# config.opt1 = true #=> true
3030
# config.opt1 #=> true
3131
#
32-
# config.nested1 #=> <Stackdriver::Core::Configuration>
33-
# config.nested2.nested3 #=> <Stackdriver::Core::Configuration>
32+
# config.cat1 #=> <Stackdriver::Core::Configuration>
33+
# config.cat2.cat3 #=> <Stackdriver::Core::Configuration>
3434
#
3535
class Configuration < Hash
3636
##
3737
# Constructs a new instance of Configuration object.
3838
#
39-
# @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>] nested
40-
# A Symbol, or nested Array and Hash of sub configuration categories.
41-
# A single symbol, or symbols in array, will be key(s) to next level of
42-
# categories. Nested hash represent sub categories with further nested
43-
# sub categories.
39+
# @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>]
40+
# categories A Symbol, or nested Array and Hash of sub configuration
41+
# categories. A single symbol, or symbols in array, will be key(s) to
42+
# next level of categories. Nested hash represent sub categories with
43+
# further nested sub categories.
4444
#
45-
def initialize nested = {}
45+
def initialize categories = {}
4646
super()
4747

48-
add_nested nested
48+
add_options categories
4949
end
5050

5151
##
52-
# Add nested sub configurations to a Configuration object
52+
# Add nested sub configuration categories to a Configuration object
5353
#
54-
# @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>] nested
55-
# A Symbol, or nested Array and Hash of sub configuration categories.
56-
# A single symbol, or symbols in array, will be key(s) to next level of
57-
# categories. Nested hash represent sub categories with further nested
58-
# sub categories.
54+
# @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>]
55+
# categories A Symbol, or nested Array and Hash of sub configuration
56+
# categories. A single symbol, or symbols in array, will be key(s) to
57+
# next level of categories. Nested hash represent sub categories with
58+
# further nested sub categories.
5959
#
6060
# @example
6161
# config = Stackdriver::Core::Configuration.new
62-
# config.nest1 #=> nil
63-
# config.add_nested {nest1: [nest2]}
64-
# config.nest1 #=> <Stackdriver::Core::Configuration>
65-
# config.nest1.nest2 #=> <Stackdriver::Core::Configuration>
62+
# config.cat1 #=> nil
63+
# config.add_options {cat1: [:cat2]}
64+
# config.cat1 #=> <Stackdriver::Core::Configuration>
65+
# config.cat1.cat2 #=> <Stackdriver::Core::Configuration>
6666
#
67-
def add_nested nested
68-
nested = [nested].flatten(1)
69-
nested.each do |sub_key|
67+
def add_options categories
68+
categories = [categories].flatten(1)
69+
categories.each do |sub_key|
7070
case sub_key
7171
when Symbol
7272
self[sub_key] = self.class.new

stackdriver-core/test/stackdriver/core/configuration_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
end
5454
end
5555

56-
describe "#add_nested" do
56+
describe "#add_options" do
5757
it "introduces new nested categories" do
5858
configuration.k4.must_be_nil
5959

60-
configuration.add_nested [:k4, {k5: [:k6]}]
60+
configuration.add_options [:k4, {k5: [:k6]}]
6161

6262
configuration.k4.must_be_kind_of Stackdriver::Core::Configuration
6363
configuration.k5.must_be_kind_of Stackdriver::Core::Configuration
@@ -67,7 +67,7 @@
6767
it "accepts simple hash with one symbol" do
6868
configuration.k4.must_be_nil
6969

70-
configuration.add_nested k4: :k5
70+
configuration.add_options k4: :k5
7171

7272
configuration.k4.must_be_kind_of Stackdriver::Core::Configuration
7373
configuration.k4.k5.must_be_kind_of Stackdriver::Core::Configuration

0 commit comments

Comments
 (0)