From 28acd739544c59e75ac43b3668c8e83cde1850da Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Tue, 3 Nov 2015 21:33:33 +0700 Subject: [PATCH] Bring build toolchain up to current standards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a first minimal pass for developing on modern Rubies like 2.2.x: - Test::Unit hasn’t been in the standard lib for awhile, switch to minitest since it seems to be the preferred community equivalent these days versus the test-unit backport. - Update mocha for current minutest support. - Current Rake versions don’t have RDocTask, so use RDoc::Task and put rdoc in the dev dependencies. --- Gemfile | 2 +- LICENSE | 2 +- README.rdoc | 35 ++++++++++++++++++++++++++++------- Rakefile | 16 +++++++++------- rack-gridfs.gemspec | 10 ++++++---- test/caching_test.rb | 2 +- test/config_test.rb | 4 ++-- test/exceptions_test.rb | 2 +- test/gridfs_test.rb | 2 +- test/test_helper.rb | 6 +++--- 10 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index 3a9a830..c706a19 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source :rubygems +source 'https://rubygems.org' gemspec gem 'ruby-debug', :platforms => :mri_18 diff --git a/LICENSE b/LICENSE index 73cdc95..a1044ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2011 Blake Carlson +Copyright (c) 2009-2015 Blake Carlson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.rdoc b/README.rdoc index aa12488..be89287 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,6 +1,6 @@ = Rack::GridFS -Rack:GridFS is a Rack middleware for creating HTTP endpoints for files +Rack::GridFS is a Rack middleware for creating HTTP endpoints for files stored in MongoDB's GridFS. You can configure a prefix string which will be used to match the path of a request, and further look up GridFS files based on either their +ObjectId+ or +filename+ field. @@ -12,13 +12,21 @@ For example, If the prefix is "gridfs", then the id will be be "someobjectid". You can also use Rack::GridFS::Endpoint as a rack endpoint if you want to -handle routing another way +handle routing another way. -== Mongo Driver Compatibility Notes +== Ruby Version and Mongo Driver Compatibility Notes -This version is currently based on mongo-1.2+. As there were significant changes -to the GridFS API prior to v1.0, you may have luck with the git-tagged version -0.2.0 of this library with earlier versions of the driver. +The library hasn't been updated for some time and is in the process of being +brought up to modern standards on the `master` branch. It probably does not yet +work with current versions of the `mongo` and `bson` gems (patches welcome if +you need it faster than we can deliver it). Support for Ruby 1.8 is almost +certainly already dropped on master—it was supported up to gem release/git tag +v0.4.1. + +If for some reason you need support for ancient versions of the `mongo` driver +prior to v1.2, these were supported in rack-gridfs 0.3.0 and below. 0.4.x +supports `mongo` 1.2(.x?) which made substantial changes to the earlier GridFS +API. == Installation @@ -147,6 +155,19 @@ these files as such: config.middleware.insert_after Rack::Runtime, Rack::GridFS, :prefix => 'uploads', :lookup => :path, :database => "my_app_#{Rails.env}" +== Development and Contributing + +Running the project and unit tests in development follows typical procedure for +a Ruby project: + + $ git clone https://github.com/skinandbones/rack-gridfs.git + $ cd rack-gridfs + $ bundle install + $ bundle exec rake test + +Note that the test suite expects that you have MongoDB running locally on the +default port and will use a database called `test`. + == Copyright -Copyright (c) 2010-2011 Blake Carlson. See LICENSE for details. +Copyright (c) 2010-2015 Blake Carlson. See LICENSE for details. diff --git a/Rakefile b/Rakefile index 5e3eae8..ee7d56a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,19 @@ require 'bundler/setup' +require 'rake/testtask' +require 'rdoc/task' + +require File.expand_path("../lib/rack/gridfs/version", __FILE__) + Bundler::GemHelper.install_tasks -require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/**/*_test.rb' test.verbose = true end +task :default => :test + begin require 'rcov/rcovtask' Rcov::RcovTask.new do |test| @@ -22,12 +28,8 @@ rescue LoadError end end -task :default => :test - -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - require File.expand_path("../lib/rack/gridfs/version", __FILE__) - +RDoc::Task.new do |rdoc| + rdoc.main = 'README.rdoc' rdoc.rdoc_dir = 'rdoc' rdoc.title = "Rack::GridFS #{Rack::GridFS::VERSION}" rdoc.rdoc_files.include(%w[ README* CHANGES* ]) diff --git a/rack-gridfs.gemspec b/rack-gridfs.gemspec index b3e7909..511c5b4 100644 --- a/rack-gridfs.gemspec +++ b/rack-gridfs.gemspec @@ -5,8 +5,8 @@ Gem::Specification.new do |s| s.name = "rack-gridfs" s.version = Rack::GridFS::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["Blake Carlson"] - s.email = ['blake@coin-operated.net'] + s.authors = ['Blake Carlson', 'Ches Martin'] + s.email = ['blake@coin-operated.net', 'ches@whiskeyandgrits.net'] s.homepage = "http://github.com/skinandbones/rack-gridfs" s.summary = "Serve MongoDB GridFS files from Rack" s.description = "Rack middleware for creating HTTP endpoints for files stored in MongoDB's GridFS" @@ -19,10 +19,12 @@ Gem::Specification.new do |s| s.add_dependency('mime-types') s.add_development_dependency('bundler', '>= 1.0.0') - s.add_development_dependency('mocha', '0.9.12') + s.add_development_dependency('minitest', '~> 5.8') + s.add_development_dependency('mocha', '~> 1.1') s.add_development_dependency('rack-test') s.add_development_dependency('rake') - s.add_development_dependency('shoulda') + s.add_development_dependency('rdoc', '>= 2.4.2') + s.add_development_dependency('shoulda-context', '~> 1.2') s.files = Dir.glob("lib/**/*") + %w(LICENSE README.rdoc Rakefile) s.require_path = 'lib' diff --git a/test/caching_test.rb b/test/caching_test.rb index 30398c1..f57ba23 100644 --- a/test/caching_test.rb +++ b/test/caching_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class CachingTest < Test::Unit::TestCase +class CachingTest < Minitest::Test include Rack::Test::Methods include Rack::GridFS::Test::Methods diff --git a/test/config_test.rb b/test/config_test.rb index 11560c9..c682705 100644 --- a/test/config_test.rb +++ b/test/config_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ConfigTest < Test::Unit::TestCase +class ConfigTest < Minitest::Test include Rack::Test::Methods include Rack::GridFS::Test::Methods @@ -92,7 +92,7 @@ class ConfigTest < Test::Unit::TestCase should "have a default mapper" do mware = Rack::GridFS::Endpoint.new(@options.except(:mapper)) - assert_not_nil mware.instance_variable_get(:@options)[:mapper] + refute_nil mware.instance_variable_get(:@options)[:mapper] end should "connect to the MongoDB server" do diff --git a/test/exceptions_test.rb b/test/exceptions_test.rb index 3870a99..c952974 100644 --- a/test/exceptions_test.rb +++ b/test/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ExceptionsTest < Test::Unit::TestCase +class ExceptionsTest < Minitest::Test include Rack::Test::Methods include Rack::GridFS::Test::Methods diff --git a/test/gridfs_test.rb b/test/gridfs_test.rb index 296566b..d0c3311 100644 --- a/test/gridfs_test.rb +++ b/test/gridfs_test.rb @@ -3,7 +3,7 @@ require 'test_helper' require 'pp' -class Rack::GridFSTest < Test::Unit::TestCase +class Rack::GridFSTest < Minitest::Test include Rack::Test::Methods include Rack::GridFS::Test::Methods diff --git a/test/test_helper.rb b/test/test_helper.rb index bcdfe77..fdf4869 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,6 @@ -require 'test/unit' -require 'shoulda' -require 'mocha' +require 'minitest/autorun' +require 'shoulda/context' +require 'mocha/mini_test' require 'rack/builder' require 'rack/mock'