Skip to content
Browse files

updated to use yml_reader gem

  • Loading branch information...
1 parent 901e388 commit cb4393b0e344aa980fad092fc1ff19dc3d3377bd @cheezy committed
Showing with 15 additions and 40 deletions.
  1. +5 −0 fig_newton.gemspec
  2. +10 −21 lib/fig_newton.rb
  3. +0 −19 spec/fig_newton/fig_newton_spec.rb
View
5 fig_newton.gemspec
@@ -14,4 +14,9 @@ Gem::Specification.new do |gem|
gem.name = "fig_newton"
gem.require_paths = ["lib"]
gem.version = FigNewton::VERSION
+
+ gem.add_dependency 'yml_reader', '>= 0.1'
+
+ gem.add_development_dependency 'rspec', '>= 2.8.0'
+ gem.add_development_dependency 'cucumber', '>= 1.1.0'
end
View
31 lib/fig_newton.rb
@@ -1,28 +1,17 @@
require "fig_newton/version"
+require 'yml_reader'
module FigNewton
+ extend YmlReader
- class << self
-
- attr_reader :fig_newton_yml_directory
-
- def yml_directory
- @fig_newton_yml_directory ||= 'config/environments'
- end
-
- def yml_directory=(value)
- @fig_newton_yml_directory = value
- end
-
- def load(filename)
- @yaml = YAML.load_file "#{FigNewton.fig_newton_yml_directory}/#{filename}"
- end
+ def self.default_directory
+ 'config/environments'
+ end
- def method_missing(*args, &block)
- m = args.first
- value = @yaml[m.to_s]
- super unless value
- value
- end
+ def self.method_missing(*args, &block)
+ m = args.first
+ value = @yml[m.to_s]
+ super unless value
+ value
end
end
View
19 spec/fig_newton/fig_newton_spec.rb
@@ -1,25 +1,6 @@
require 'spec_helper'
describe FigNewton do
- context "when configuring the yml directory" do
- it "should default to a directory named config/environments" do
- FigNewton.yml_directory.should == 'config/environments'
- end
-
- it "should store a yml directory" do
- FigNewton.yml_directory = 'other_directory'
- FigNewton.yml_directory.should == 'other_directory'
- end
- end
-
- context "when reading yml files" do
- it "should read files from the yml_directory" do
- FigNewton.yml_directory = 'conf'
- YAML.should_receive(:load_file).with('conf/test').and_return({})
- FigNewton.load('test')
- end
- end
-
context "when asking for data" do
it "should retrieve the data by a key named after the method called" do
FigNewton.yml_directory = 'conf'

0 comments on commit cb4393b

Please sign in to comment.
Something went wrong with that request. Please try again.