yaml_properties 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  Gemfile.lock
19
+
20
+ .rbenv-version
@@ -4,9 +4,13 @@ require "yaml"
4
4
 
5
5
  module YamlProperties
6
6
  def properties
7
+ reset! if dev_environment
8
+
7
9
  @properties ||= load_properties.with_indifferent_access
8
10
  end
9
11
 
12
+ attr_accessor :dev_environment
13
+
10
14
  def reset!
11
15
  reset_properties
12
16
  end
@@ -40,7 +44,9 @@ module YamlProperties
40
44
  end
41
45
 
42
46
  def load_properties
43
- YAML.load File.open(yaml_file)
47
+ yaml = YAML.load File.open(yaml_file)
48
+
49
+ yaml
44
50
  end
45
51
 
46
52
  extend self
@@ -1,3 +1,3 @@
1
1
  module YamlProperties
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -5,8 +5,9 @@ describe YamlProperties do
5
5
  context "in general" do
6
6
  before do
7
7
  File.stub(:open)
8
+ YamlProperties.dev_environment = false
8
9
 
9
- YAML.stub(:load).and_return properties
10
+ Psych.stub(:load).and_return properties
10
11
  end
11
12
 
12
13
  let(:properties) do
@@ -15,10 +16,40 @@ describe YamlProperties do
15
16
  "some_string_value" => "something",
16
17
  "a boolean" => true,
17
18
  "parent" => {
18
- "child"=>"Egg"}
19
+ "child"=>"Egg"}
19
20
  }
20
21
  end
21
22
 
23
+ context "in non dev" do
24
+ before do
25
+ YamlProperties.dev_environment = false
26
+ YamlProperties.reset!
27
+ end
28
+
29
+ specify "it caches yaml file" do
30
+ YamlProperties.should_receive(:load_properties).
31
+ exactly(1).times.and_return properties
32
+
33
+ YamlProperties.some_string_value
34
+ YamlProperties.some_string_value
35
+ end
36
+ end
37
+
38
+ context "in dev environment" do
39
+ before do
40
+ YamlProperties.dev_environment = true
41
+ YamlProperties.reset!
42
+ end
43
+
44
+
45
+ specify "reload so Rails/Sinatra don't need restarting" do
46
+ YamlProperties.should_receive(:load_properties).at_least(2).times.and_return properties
47
+ YamlProperties.some_string_value
48
+ YamlProperties.some_string_value
49
+
50
+ end
51
+ end
52
+
22
53
  specify "overriding attributes (in e.g. tests)" do
23
54
  YamlProperties.override_attribute :life_the_universe_and_everything, 13
24
55
  YamlProperties.life_the_universe_and_everything.should == 13
@@ -30,7 +61,7 @@ describe YamlProperties do
30
61
  ->{
31
62
  YamlProperties.override_attribute :unset_attribute,
32
63
  "let's not allow typos to cause us grief"}.
33
- should raise_error ArgumentError
64
+ should raise_error ArgumentError
34
65
  end
35
66
 
36
67
  specify do
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency 'activesupport'
28
28
 
29
29
  gem.add_development_dependency 'rspec'
30
- gem.add_development_dependency 'debugger'
30
+ gem.add_development_dependency 'debugger', '~> 1.4.0'
31
31
 
32
32
  gem.files = `git ls-files`.split($/)
33
33
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_properties
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-14 00:00:00.000000000 Z
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.4.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.4.0
62
62
  description: Easily add configurable variables for app config using YAML files
63
63
  email:
64
64
  - markthedeveloper@gmail.com
@@ -99,18 +99,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
- segments:
103
- - 0
104
- hash: 914913381452087712
105
102
  required_rubygems_version: !ruby/object:Gem::Requirement
106
103
  none: false
107
104
  requirements:
108
105
  - - ! '>='
109
106
  - !ruby/object:Gem::Version
110
107
  version: '0'
111
- segments:
112
- - 0
113
- hash: 914913381452087712
114
108
  requirements: []
115
109
  rubyforge_project:
116
110
  rubygems_version: 1.8.23