ruby-conf 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.2
1
+ 2.6.3
data/lib/ruby-conf.rb CHANGED
@@ -89,10 +89,22 @@ module RubyConf
89
89
  end
90
90
 
91
91
  def [](name, *args)
92
- value = @__rc_attributes[name.to_sym]
92
+ name = name.to_sym
93
+ value = @__rc_attributes[name]
93
94
  if value.is_a?(Proc)
94
95
  args += [nil] * (value.arity.abs - args.size) if value.arity.abs > args.size
95
- __rc_root.instance_exec(*args, &value)
96
+ @@stack ||= []
97
+ if @@stack.include?(name)
98
+ RubyConf.err("[ruby-conf] Detected recursive proc: #{name}")
99
+ "[RECURSIVE]"
100
+ else
101
+ @@stack << name
102
+ begin
103
+ __rc_root.instance_exec(*args, &value)
104
+ ensure
105
+ @@stack.delete(name)
106
+ end
107
+ end
96
108
  else
97
109
  value
98
110
  end
@@ -217,7 +229,7 @@ module RubyConf
217
229
  "[UNRESOLVED:#{e}]"
218
230
  end
219
231
  str += "#{key}: "
220
- str += value.is_a?(Config) ? (value == self ? "[SELF]" : "{ #{value.__rc_build_inspect} }") : value.inspect
232
+ str += value.is_a?(RubyConf::Config) ? (value == self ? "[SELF]" : "{ #{value.__rc_build_inspect} }") : value.inspect
221
233
  str
222
234
  }.join(", ")
223
235
  istr
data/ruby-conf.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-conf"
8
- s.version = "2.6.2"
8
+ s.version = "2.6.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Curtis Schofield & Hollin Wilkins & Mason"]
@@ -1,5 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
+ module RubyConf
4
+ def self.puts(*args) end
5
+ end
6
+
3
7
  describe RubyConf do
4
8
 
5
9
  before do
@@ -57,8 +61,21 @@ var_args: var|[nil]
57
61
  end
58
62
  end
59
63
  end
64
+ other do
65
+ val "val"
66
+ inner do
67
+ value "correct"
68
+ end
69
+ self_refa ->{ self.inner.value }
70
+ self_refb ->{ self.val }
71
+ end
60
72
  end
61
73
 
74
+ other = RootTest.other.detach
75
+ other.inner.value.should == "correct"
76
+ other.self_refa.should == "correct"
77
+ other.self_refb.should == "val"
78
+
62
79
  RootTest.outer.middle.inner.val.should == "value"
63
80
 
64
81
  RootTest.__rc_parent.should be_nil
@@ -110,10 +127,12 @@ var_args: var|[nil]
110
127
  it "does it's best to print procs but will fail gracefully" do
111
128
  RubyConf.define :ProcStrings do
112
129
  valid ->{ "valid return" }
113
- valid_args ->(a, b, c){ "all empty > a:#{a} b:#{b} c:#{c}" }
130
+ valid_args ->(a, b, c){ "all empty > a:#{a} b:#{b} c:#{c} <" }
114
131
  broken ->{ raise "oops" }
115
- broken_args ->(a, b, c){ raise "oops: a:#{a} b:#{b} c:#{c}" }
132
+ broken_args ->(a, b, c){ raise "oops: a:#{a} b:#{b} c:#{c} <" }
116
133
  self_referential ->{self}
134
+ recursive_to_s ->{self.to_s.split("\n").join(" ")}
135
+ recursive_inspect ->{self.inspect}
117
136
  end
118
137
 
119
138
  tos = <<-STR
@@ -121,14 +140,16 @@ var_args: var|[nil]
121
140
 
122
141
  broken: [UNRESOLVED]
123
142
  broken_args: [UNRESOLVED]
143
+ recursive_inspect: [ProcStrings] broken: "[UNRESOLVED:oops]", broken_args: "[UNRESOLVED:oops: a: b: c: <]", recursive_inspect: "[RECURSIVE]", recursive_to_s: "[ProcStrings] broken: [UNRESOLVED] broken_args: [UNRESOLVED] recursive_inspect: [RECURSIVE] recursive_to_s: [RECURSIVE] self_referential: [SELF] valid: valid return valid_args: all empty > a: b: c: <", self_referential: [SELF], valid: "valid return", valid_args: "all empty > a: b: c: <"
144
+ recursive_to_s: [ProcStrings] broken: [UNRESOLVED] broken_args: [UNRESOLVED] recursive_inspect: [ProcStrings] broken: "[UNRESOLVED:oops]", broken_args: "[UNRESOLVED:oops: a: b: c: <]", recursive_inspect: "[RECURSIVE]", recursive_to_s: "[RECURSIVE]", self_referential: [SELF], valid: "valid return", valid_args: "all empty > a: b: c: <" recursive_to_s: [RECURSIVE] self_referential: [SELF] valid: valid return valid_args: all empty > a: b: c: <
124
145
  self_referential: [SELF]
125
146
  valid: valid return
126
- valid_args: all empty > a: b: c:
147
+ valid_args: all empty > a: b: c: <
127
148
  STR
128
149
 
129
150
  ProcStrings.to_s.should == tos
130
151
  ProcStrings.to_str.should == tos
131
- ProcStrings.inspect.should == '[ProcStrings] broken: "[UNRESOLVED:oops]", broken_args: "[UNRESOLVED:oops: a: b: c:]", self_referential: [SELF], valid: "valid return", valid_args: "all empty > a: b: c:"'
152
+ ProcStrings.inspect.should == "[ProcStrings] broken: \"[UNRESOLVED:oops]\", broken_args: \"[UNRESOLVED:oops: a: b: c: <]\", recursive_inspect: \"[ProcStrings] broken: \\\"[UNRESOLVED:oops]\\\", broken_args: \\\"[UNRESOLVED:oops: a: b: c: <]\\\", recursive_inspect: \\\"[RECURSIVE]\\\", recursive_to_s: \\\"[ProcStrings] broken: [UNRESOLVED] broken_args: [UNRESOLVED] recursive_inspect: [RECURSIVE] recursive_to_s: [RECURSIVE] self_referential: [SELF] valid: valid return valid_args: all empty > a: b: c: <\\\", self_referential: [SELF], valid: \\\"valid return\\\", valid_args: \\\"all empty > a: b: c: <\\\"\", recursive_to_s: \"[ProcStrings] broken: [UNRESOLVED] broken_args: [UNRESOLVED] recursive_inspect: [ProcStrings] broken: \\\"[UNRESOLVED:oops]\\\", broken_args: \\\"[UNRESOLVED:oops: a: b: c: <]\\\", recursive_inspect: \\\"[RECURSIVE]\\\", recursive_to_s: \\\"[RECURSIVE]\\\", self_referential: [SELF], valid: \\\"valid return\\\", valid_args: \\\"all empty > a: b: c: <\\\" recursive_to_s: [RECURSIVE] self_referential: [SELF] valid: valid return valid_args: all empty > a: b: c: <\", self_referential: [SELF], valid: \"valid return\", valid_args: \"all empty > a: b: c: <\""
132
153
  end
133
154
 
134
155
  it "prints out the config in a human readable way" do
@@ -409,9 +430,6 @@ TEXT
409
430
  end
410
431
 
411
432
  it "will autoload the first ruby-conf that it can find if none is provided" do
412
- module RubyConf
413
- def self.puts(*args) end
414
- end
415
433
 
416
434
  dir = Dir["./**/test_conf.rb.tmpl"].first[/^(.*?)\/test_conf.rb.tmpl$/, 1]
417
435
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-conf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  segments:
117
117
  - 0
118
- hash: 1471615913494062975
118
+ hash: -229567439722494491
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  none: false
121
121
  requirements: