Permalink
Browse files

Cleanup

  • Loading branch information...
sferik committed May 14, 2011
1 parent 8fe925f commit d83002691a34a32b6d6d181817af7f8e68524638
Showing with 117 additions and 112 deletions.
  1. +3 −3 .document
  2. 0 .gemtest
  3. +2 −1 .rspec
  4. +5 −7 Gemfile
  5. +1 −1 LICENSE → LICENSE.md
  6. +66 −0 README.md
  7. +0 −30 README.rdoc
  8. +5 −19 Rakefile
  9. +17 −21 multi_json.gemspec
  10. +11 −0 spec/helper.rb
  11. +7 −13 spec/multi_json_spec.rb
  12. +0 −2 spec/spec.opts
  13. +0 −15 spec/spec_helper.rb
View
@@ -1,5 +1,5 @@
-README.rdoc
-lib/**/*.rb
+LICENSE.md
+README.md
bin/*
features/**/*.feature
-LICENSE
+lib/**/*.rb
View
No changes.
View
3 .rspec
@@ -1,2 +1,3 @@
--color
---format=nested
+--format=nested
+--backtrace
View
12 Gemfile
@@ -1,11 +1,9 @@
-source "http://rubygems.org"
+source 'http://rubygems.org'
-gemspec
-
-gem 'rake', '~> 0.8'
-gem 'rspec', '~> 2.5'
-gem 'rcov', '~> 0.9', :platforms => [:mri, :jruby]
+gem 'simplecov', '~> 0.4'
gem 'json', '~> 1.4', :require => nil
gem 'json_pure', '~> 1.4', :require => nil
-gem 'yajl-ruby', '~> 0.7', :require => nil, :platforms => :ruby
+gem 'yajl-ruby', '~> 0.7', :require => nil
+
+gemspec
View
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Michael Bleigh and Intridea, Inc.
+Copyright (c) 2010 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, and Intridea, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -0,0 +1,66 @@
+MultiJSON
+=========
+
+Lots of Ruby libraries utilize JSON parsing in some form, and everyone has
+their favorite JSON library. In order to best support multiple JSON parsers and
+libraries, <tt>multi_json</tt> is a general-purpose swappable JSON backend
+library. You use it like so:
+
+ require 'multi_json'
+
+ MultiJson.engine = :yajl
+ MultiJson.decode('{"abc":"def"}') # decoded using Yajl
+
+ MultiJson.engine = :json_gem
+ MultiJson.engine = MultiJson::Engines::JsonGem # equivalent to previous line
+ MultiJson.encode({:abc => 'def'}) # encoded using the JSON gem
+
+The <tt>engine</tt> setter takes either a symbol or a class (to allow for
+custom JSON parsers) that responds to both <tt>.decode</tt> and
+<tt>.encode</tt> at the class level.
+
+MultiJSON tries to have intelligent defaulting. That is, if you have any of the
+supported engines already loaded, it will utilize them before attempting to
+load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then
+the JSON gem, then JSON pure. If no JSON library is available, MultiJSON falls
+back to a bundled version of [OkJson](https://github.com/kr/okjson).
+
+Contributing
+------------
+In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
+
+Here are some ways *you* can contribute:
+
+* by using alpha, beta, and prerelease versions
+* by reporting bugs
+* by suggesting new features
+* by writing or editing documentation
+* by writing specifications
+* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
+* by refactoring code
+* by closing [issues](https://github.com/intridea/multi_json/issues)
+* by reviewing patches
+
+Submitting an Issue
+-------------------
+We use the [GitHub issue tracker](https://github.com/intridea/multi_json/issues) to track bugs and
+features. Before submitting a bug report or feature request, check to make sure it hasn't already
+been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
+bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
+details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
+operating system. Ideally, a bug report should include a pull request with failing specs.
+
+Submitting a Pull Request
+-------------------------
+1. Fork the project.
+2. Create a topic branch.
+3. Implement your feature or bug fix.
+4. Add specs for your feature or bug fix.
+5. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 4.
+6. Commit and push your changes.
+7. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
+
+Copyright
+---------
+Copyright (c) 2010 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, and Intridea, Inc.
+See [LICENSE](https://github.com/intridea/multi_json/blob/master/LICENSE.md) for details.
View
@@ -1,30 +0,0 @@
-= MultiJSON
-
-Lots of Ruby libraries utilize JSON parsing in some form, and everyone has their favorite JSON library. In order to best support multiple JSON parsers and libraries, <tt>multi_json</tt> is a general-purpose swappable JSON backend library. You use it like so:
-
- require 'multi_json'
-
- MultiJson.engine = :yajl
- MultiJson.decode('{"abc":"def"}') # decoded using Yajl
-
- MultiJson.engine = :json_gem
- MultiJson.engine = MultiJson::Engines::JsonGem # equivalent to previous line
- MultiJson.encode({:abc => 'def'}) # encoded using the JSON gem
-
-The <tt>engine</tt> setter takes either a symbol or a class (to allow for custom JSON parsers) that responds to both <tt>.decode</tt> and <tt>.encode</tt> at the class level.
-
-MultiJSON tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then the JSON gem, then JSON pure. If no JSON library is available, MultiJSON falls back to a bundled version of <a href="https://github.com/kr/okjson">OkJson</a>.
-
-== Note on Patches/Pull Requests
-
-* Fork the project.
-* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a
- future version unintentionally.
-* Commit, do not mess with rakefile, version, or history.
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-* Send me a pull request. Bonus points for topic branches.
-
-== Copyright
-
-Copyright (c) 2010 Michael Bleigh and Intridea, Inc. See LICENSE for details.
View
@@ -1,37 +1,23 @@
-require 'rubygems'
+#!/usr/bin/env rake
begin
require 'bundler'
Bundler::GemHelper.install_tasks
rescue LoadError => e
- puts "although not required, it's recommended that you use bundler during development"
+ warn "[WARNING]: It is recommended that you use bundler during development: gem install bundler"
end
require 'rspec/core/rake_task'
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
+task :test => :spec
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "multi_json #{MultiJson::VERSION}"
- rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('README.md')
+ rdoc.rdoc_files.include('LICENSE.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end
-
-task :cleanup_rcov_files do
- rm_rf 'coverage.data'
-end
-
-begin
- namespace :spec do
- desc "Run all examples using rcov"
- RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
- t.rcov = true
- t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
- t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
- end
- end
-rescue LoadError
-end
View
@@ -1,25 +1,21 @@
# -*- encoding: utf-8 -*-
require File.expand_path("../lib/multi_json/version", __FILE__)
-Gem::Specification.new do |s|
- s.name = "multi_json"
- s.version = MultiJson::VERSION
-
- s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
-
- s.authors = ["Michael Bleigh"]
- s.email = ["michael@intridea.com"]
- s.summary = %q{A gem to provide swappable JSON backends.}
- s.description = %q{A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem, JSON pure, or a vendored version of okjson.}
- s.homepage = "http://github.com/intridea/multi_json"
-
- s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
- s.rdoc_options = ["--charset=UTF-8"]
-
- s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
-
- s.require_paths = ["lib"]
+Gem::Specification.new do |gem|
+ gem.add_development_dependency 'rake', '~> 0.8'
+ gem.add_development_dependency 'rspec', '~> 2.6'
+ gem.authors = ["Michael Bleigh", "Josh Kalderimis", "Erik Michaels-Ober"]
+ gem.description = %q{A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem, JSON pure, or a vendored version of okjson.}
+ gem.email = ['michael@intridea.com', 'josh.kalderimis@gmail.com', 'sferik@gmail.com']
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
+ gem.extra_rdoc_files = ['LICENSE.md', 'README.md']
+ gem.files = `git ls-files`.split("\n")
+ gem.homepage = 'http://github.com/intridea/multi_json'
+ gem.name = 'multi_json'
+ gem.rdoc_options = ["--charset=UTF-8"]
+ gem.require_paths = ['lib']
+ gem.required_rubygems_version = Gem::Requirement.new(">= 1.3.6")
+ gem.summary = %q{A gem to provide swappable JSON backends.}
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.version = MultiJson::VERSION
end
-
View
@@ -0,0 +1,11 @@
+begin
+ require 'bundler'
+ Bundler.setup
+rescue LoadError
+ warn "[WARNING]: It is recommended that you use bundler during development: gem install bundler"
+end
+
+require 'simplecov'
+SimpleCov.start
+require 'rspec'
+require 'multi_json'
View
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require 'helper'
require 'stringio'
-
+
class MockDecoder
def self.decode(string, options = {})
- { 'abc' => 'def' }
+ {'abc' => 'def'}
end
def self.encode(string)
@@ -26,16 +26,10 @@ def self.encode(string)
end
end
end
-
+
it 'defaults to the best available gem' do
- # the yajl-ruby gem does not work on jruby, so the best engine is the JsonGem engine
- if jruby?
- require 'json'
- MultiJson.engine.name.should == 'MultiJson::Engines::JsonGem'
- else
- require 'yajl'
- MultiJson.engine.name.should == 'MultiJson::Engines::Yajl'
- end
+ require 'yajl'
+ MultiJson.engine.name.should == 'MultiJson::Engines::Yajl'
end
it 'is settable via a symbol' do
@@ -95,7 +89,7 @@ def self.encode(string)
encoded_json = MultiJson.encode(:a => 1, :b => {:c => 2})
MultiJson.decode(encoded_json).should == { "a" => 1, "b" => { "c" => 2 } }
end
-
+
it "properly decodes valid JSON in StringIOs" do
json = StringIO.new('{"abc":"def"}')
MultiJson.decode(json).should == { 'abc' => 'def' }
View
@@ -1,2 +0,0 @@
---color
---format=nested
View
@@ -1,15 +0,0 @@
-begin
- require 'bundler'
-rescue LoadError
- puts "although not required, it's recommended that you use bundler during development"
-end
-
-require 'rspec'
-require 'rspec/autorun'
-
-$VERBOSE = true
-require 'multi_json'
-
-def jruby?
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
-end

0 comments on commit d830026

Please sign in to comment.