Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

simplified Gems -- Loads fewer things by default. using multi_json, w…

…ith (preferred but optional) Oj. Added Guardfile.
  • Loading branch information...
commit 436f9026dfddb094fe00c22015bdeaef7e5cca2e 1 parent 5ed9f8d
Philip (flip) Kromer authored
View
2  .rspec
@@ -0,0 +1,2 @@
+--color
+--format documentation
View
6 Gemfile
@@ -1,13 +1,12 @@
source "http://rubygems.org"
gem 'multi_json', "~> 1.1"
-gem 'yajl-ruby', "~> 1.1", :platform => :mri
-gem 'json', :platform => :jruby
+gem 'oj', "~> 1.2.9"
+gem 'json', :platform => :jruby
# Only necessary if you want to use Configliere::Prompt
gem 'highline', ">= 1.5.2"
-
group :development do
gem 'bundler', "~> 1"
gem 'jeweler', "~> 1.6"
@@ -21,7 +20,6 @@ group :docs do
end
group :test do
- gem 'spork', "~> 0.9.0.rc5"
gem 'rspec', "~> 2.8"
gem 'guard', ">= 1.0"
gem 'guard-rspec', ">= 0.6"
View
14 Guardfile
@@ -0,0 +1,14 @@
+# -*- ruby -*-
+
+format = 'progress' # 'doc' for more verbose, 'progress' for less
+tags = %w[ ] # builder_spec model_spec
+
+guard 'rspec', :version => 2, :cli => "--format #{format} #{ tags.map{|tag| "--tag #{tag}"}.join(' ') }" do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^examples/(\w+)/(.+)\.rb$}) { |m| "spec/examples/#{m[1]}_spec.rb" }
+ watch(%r{^examples/(\w+)\.rb$}) { |m| "spec/examples/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
+ watch(%r{^lib/(\w+)\.rb$}) { |m| "spec/#{m[1]}}_spec.rb" }
+ watch('spec/spec_helper.rb') { 'spec' }
+ watch(/spec\/support\/(.+)\.rb/) { 'spec' }
+end
View
1  lib/configliere.rb
@@ -1,6 +1,5 @@
require 'date' # type conversion
require 'time' # type conversion
-require 'yaml' # read files
require 'fileutils' # so save! can mkdir
require 'configliere/deep_hash' # magic hash for params
require 'configliere/param' # params container
View
5 lib/configliere/config_file.rb
@@ -33,7 +33,7 @@ def read filename, options={}
case filetype(filename)
when 'json' then read_json(File.open(filename), options)
when 'yaml' then read_yaml(File.open(filename), options)
- else read_yaml(File.open(filename), options)
+ else read_yaml(File.open(filename), options)
end
rescue Errno::ENOENT => e
warn "Loading empty configliere settings file #{filename}"
@@ -56,7 +56,8 @@ def read_yaml yaml_str, options={}
# we depend on you to require some sort of JSON
#
def read_json json_str, options={}
- new_data = JSON.load(json_str) || {}
+ require 'multi_json'
+ new_data = MultiJson.load(json_str) || {}
# Extract the :env (production/development/etc)
if options[:env]
new_data = new_data[options[:env]] || {}
View
2  spec/configliere/config_file_spec.rb
@@ -12,7 +12,7 @@
describe 'loading a yaml config file' do
before do
- @fake_file = '{ :my_param: val_from_file }'
+ @fake_file = "---\nmy_param: val_from_file"
end
describe 'successfully' do
View
2  spec/configliere_spec.rb
@@ -10,6 +10,6 @@
end
it 'requires corresponding plugins when you call use' do
- lambda{ Configliere.use(:param, :foo) }.should raise_error(LoadError, 'no such file to load -- configliere/foo')
+ lambda{ Configliere.use(:param, :foo) }.should raise_error(LoadError, /no.*load.*configliere\/foo/)
end
end
View
23 spec/spec_helper.rb
@@ -1,23 +1,8 @@
# encoding: UTF-8
-require 'rubygems'
-require 'spork'
+require 'rubygems' unless defined?(Gem)
require 'rspec'
-Spork.prefork do
- # Loading more in this block will cause your tests to run faster.
- # However, changes don't take effect until you restart spork.
-
- $LOAD_PATH.unshift(File.dirname(__FILE__))
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-
- require 'configliere'
-
- RSpec.configure do |config|
- end
-end
-
-Spork.each_run do
- # This code will be run each time you run your specs.
-
-end
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+require 'configliere'
Please sign in to comment.
Something went wrong with that request. Please try again.