confstruct 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b51b8e9d7f488bed54703d187e607525d612b6f
4
- data.tar.gz: fa9d173751758a9350b44688501860000b72e3ab
3
+ metadata.gz: bced56b3d2b053a15f99a5fa1847c3dff09c79d2
4
+ data.tar.gz: 3bc0eda95a143b8d243f863d1a7e6ec0cb29034d
5
5
  SHA512:
6
- metadata.gz: c2172c939d94291dce4f89a051058ad7b0efd73d1aee1c3860f03ed1fa6f5501368cfd31423e014a9bcc8be82a52f6e9c6a76271ed927f1cc85469ff907947c2
7
- data.tar.gz: a12c4f850463b5c1549364575d63bffc667ac4ba47d45e9f1ab094e0581c8edf69aa869bc0b4e5ab333f9042dc8d5a81201fb8d89ff0e1379f7bd0c0a56198bc
6
+ metadata.gz: 7229c6f8ecede1d20e3a52d40f495d381c24983ca801595da1c6c9e9ac02a13be8c95e1623bf3fabebbb22d62da42dc36eea239345f4e5f8928ecb43684456ca
7
+ data.tar.gz: 1dea2b2f0b4b9bc05330361974442e5e40765aafa30a6bcc825aebad3c56fd3915e3ff0de182f1ef9be04a431925c0e0604b570687b3250c174de40e729c38ad
@@ -1,7 +1,10 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0.0
5
6
  - 2.1.0
6
7
  - 2.1.1
8
+ - 2.2.1
7
9
  - jruby-19mode
10
+ - jruby-9000
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "rake", ">=0.8.7"
26
26
  s.add_development_dependency "simplecov"
27
27
  s.add_development_dependency "rdoc"
28
- s.add_development_dependency "rspec", "~> 2.0"
28
+ s.add_development_dependency "rspec", "~> 2.99"
29
29
  s.add_development_dependency "yard"
30
30
 
31
31
  end
@@ -4,5 +4,5 @@ module Confstruct
4
4
  autoload :HashWithStructAccess, 'confstruct/hash_with_struct_access'
5
5
  autoload :Configuration, 'confstruct/configuration'
6
6
 
7
- VERSION = '1.0.1'
7
+ VERSION = '1.0.2'
8
8
  end
@@ -122,6 +122,14 @@ module Confstruct
122
122
  end
123
123
  return val
124
124
  end
125
+
126
+ def self.structurize hash
127
+ result = hash
128
+ if result.is_a?(Hash) and not result.is_a?(HashWithStructAccess)
129
+ result = HashWithStructAccess.new(result)
130
+ end
131
+ result
132
+ end
125
133
 
126
134
  def method_missing sym, *args, &block
127
135
  name = sym.to_s.chomp('=').to_sym
@@ -134,7 +142,7 @@ module Confstruct
134
142
  raise TypeError, "Cannot #add! to a #{self[name].class}"
135
143
  end
136
144
  if args.length > 0
137
- local_args = args.collect { |a| structurize! a }
145
+ local_args = args.collect { |a| self.class.structurize a }
138
146
  result = self[name].push *local_args
139
147
  elsif block_given?
140
148
  result = HashWithStructAccess.new
@@ -4,16 +4,16 @@ describe Confstruct::Configuration do
4
4
 
5
5
  it "should initialize empty" do
6
6
  conf = Confstruct::Configuration.new
7
- conf.is_a?(Hash).should be_true
8
- conf.is_a?(Confstruct::Configuration).should be_true
7
+ conf.is_a?(Hash).should be_truthy
8
+ conf.is_a?(Confstruct::Configuration).should be_truthy
9
9
  conf.should == {}
10
10
  end
11
11
 
12
12
  it "should initialize properly from a nested hash with string keys" do
13
13
  x = { 'a' => { 'b' => 'c' } }
14
14
  conf = Confstruct::Configuration.new(x)
15
- conf.is_a?(Hash).should be_true
16
- conf.is_a?(Confstruct::Configuration).should be_true
15
+ conf.is_a?(Hash).should be_truthy
16
+ conf.is_a?(Confstruct::Configuration).should be_truthy
17
17
  conf[:a][:b].should == 'c'
18
18
  conf['a']['b'].should == 'c'
19
19
  conf.a.b.should == 'c'
@@ -137,7 +137,7 @@ describe Confstruct::Configuration do
137
137
  end
138
138
 
139
139
  it "should call #after_config! when configuration is complete" do
140
- postconfigurator = RSpec::Mocks::Mock.new('after_config!')
140
+ postconfigurator = double('after_config!')
141
141
  postconfigurator.should_receive(:configured!).once.with(@config)
142
142
  def @config.after_config! obj
143
143
  obj.project.should == 'other-project'
@@ -4,8 +4,8 @@ describe Confstruct::HashWithStructAccess do
4
4
 
5
5
  it "should initialize empty" do
6
6
  hwsa = Confstruct::HashWithStructAccess.new
7
- hwsa.is_a?(Hash).should be_true
8
- hwsa.is_a?(Confstruct::HashWithStructAccess).should be_true
7
+ hwsa.is_a?(Hash).should be_truthy
8
+ hwsa.is_a?(Confstruct::HashWithStructAccess).should be_truthy
9
9
  hwsa.should == {}
10
10
  end
11
11
 
@@ -72,8 +72,8 @@ describe Confstruct::HashWithStructAccess do
72
72
  end
73
73
 
74
74
  it "should properly respond to #has?" do
75
- @hwsa.has?('github.url').should be_true
76
- @hwsa.has?('github.foo.bar.baz').should be_false
75
+ @hwsa.has?('github.url').should be_truthy
76
+ @hwsa.has?('github.foo.bar.baz').should be_falsey
77
77
  end
78
78
 
79
79
  it "should properly respond to #lookup!" do
@@ -204,9 +204,9 @@ describe Confstruct::HashWithStructAccess do
204
204
  end
205
205
 
206
206
  it "should only evaluate Confstruct::Deferred procs" do
207
- @hwsa.github.regular_proc.is_a?(Proc).should be_true
208
- @hwsa.github.upcase_url.is_a?(Proc).should be_false
209
- @hwsa.github.reverse_url.is_a?(Proc).should be_false
207
+ @hwsa.github.regular_proc.is_a?(Proc).should be_truthy
208
+ @hwsa.github.upcase_url.is_a?(Proc).should be_falsey
209
+ @hwsa.github.reverse_url.is_a?(Proc).should be_falsey
210
210
  end
211
211
 
212
212
  it "should instance_eval the proc with no params" do
@@ -233,9 +233,9 @@ describe Confstruct::HashWithStructAccess do
233
233
  defproc deferred! { reverse_url + upcase_url }
234
234
  regproc Kernel.lambda { reverse_url + upcase_url }
235
235
  end
236
- @hwsa.github.defproc.is_a?(Proc).should be_false
236
+ @hwsa.github.defproc.is_a?(Proc).should be_falsey
237
237
  @hwsa.github.defproc.should == @hwsa.github.reverse_url + @hwsa.github.upcase_url
238
- @hwsa.github.regproc.is_a?(Proc).should be_true
238
+ @hwsa.github.regproc.is_a?(Proc).should be_truthy
239
239
  end
240
240
 
241
241
  it "should handle i18n translations" do
@@ -269,7 +269,7 @@ describe Confstruct::HashWithStructAccess do
269
269
  end
270
270
 
271
271
  it "should gracefully handle being extended" do
272
- pending %{probably won't fix due to the unpredictable way ActiveSupport injects #presence()}
272
+ skip %{probably won't fix due to the unpredictable way ActiveSupport injects #presence()}
273
273
  @hwsa.a.b.presence.should be_a Confstruct::HashWithStructAccess
274
274
  end
275
275
  end
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "Kernel.eval_or_yield" do
4
- before :all do
5
- @obj = RSpec::Mocks::Mock.new('obj')
4
+ before :each do
5
+ @obj = double('obj')
6
6
  end
7
7
 
8
8
  it "should instance_eval when the block takes no params" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '2.99'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '2.99'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.2.2
139
+ rubygems_version: 2.4.5
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: A simple, hash/struct-based configuration object