From 1eda0036a94739118eb1634b1b6fad8ca0ede7cc Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Fri, 25 Jan 2013 12:41:55 -0500 Subject: [PATCH] Adding .gempsec to project, fixed Rakefile so that the tasks work, fixed test suite so that it runs properly in Ruby1.9 --- .gitignore | 6 +- Gemfile | 2 + Rakefile | 340 +----------------- aws-s3.gemspec | 31 ++ support/faster-xml-simple/COPYING | 18 - support/faster-xml-simple/README | 8 - support/faster-xml-simple/Rakefile | 54 --- .../lib/faster_xml_simple.rb | 187 ---------- .../test/fixtures/test-1.rails.yml | 4 - .../test/fixtures/test-1.xml | 3 - .../test/fixtures/test-1.yml | 4 - .../test/fixtures/test-2.rails.yml | 6 - .../test/fixtures/test-2.xml | 3 - .../test/fixtures/test-2.yml | 6 - .../test/fixtures/test-3.rails.yml | 6 - .../test/fixtures/test-3.xml | 5 - .../test/fixtures/test-3.yml | 6 - .../test/fixtures/test-4.rails.yml | 5 - .../test/fixtures/test-4.xml | 7 - .../test/fixtures/test-4.yml | 5 - .../test/fixtures/test-5.rails.yml | 8 - .../test/fixtures/test-5.xml | 7 - .../test/fixtures/test-5.yml | 8 - .../test/fixtures/test-6.rails.yml | 43 --- .../test/fixtures/test-6.xml | 29 -- .../test/fixtures/test-6.yml | 41 --- .../test/fixtures/test-7.rails.yml | 23 -- .../test/fixtures/test-7.xml | 22 -- .../test/fixtures/test-7.yml | 22 -- .../test/fixtures/test-8.rails.yml | 14 - .../test/fixtures/test-8.xml | 8 - .../test/fixtures/test-8.yml | 11 - .../faster-xml-simple/test/regression_test.rb | 47 --- support/faster-xml-simple/test/test_helper.rb | 17 - .../test/xml_simple_comparison_test.rb | 46 --- test/acl_test.rb | 2 +- test/authentication_test.rb | 2 +- test/base_test.rb | 2 +- test/bucket_test.rb | 2 +- test/connection_test.rb | 2 +- test/error_test.rb | 2 +- test/extensions_test.rb | 12 +- test/logging_test.rb | 2 +- test/object_test.rb | 2 +- test/parsing_test.rb | 2 +- test/remote/acl_test.rb | 2 +- test/remote/bittorrent_test.rb | 2 +- test/remote/bucket_test.rb | 2 +- test/remote/logging_test.rb | 2 +- test/remote/object_test.rb | 2 +- test/response_test.rb | 3 +- test/service_test.rb | 2 +- test/test_helper.rb | 17 +- 53 files changed, 85 insertions(+), 1029 deletions(-) create mode 100644 Gemfile create mode 100644 aws-s3.gemspec delete mode 100644 support/faster-xml-simple/COPYING delete mode 100644 support/faster-xml-simple/README delete mode 100644 support/faster-xml-simple/Rakefile delete mode 100644 support/faster-xml-simple/lib/faster_xml_simple.rb delete mode 100644 support/faster-xml-simple/test/fixtures/test-1.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-1.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-1.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-2.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-2.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-2.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-3.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-3.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-3.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-4.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-4.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-4.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-5.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-5.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-5.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-6.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-6.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-6.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-7.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-7.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-7.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-8.rails.yml delete mode 100644 support/faster-xml-simple/test/fixtures/test-8.xml delete mode 100644 support/faster-xml-simple/test/fixtures/test-8.yml delete mode 100644 support/faster-xml-simple/test/regression_test.rb delete mode 100644 support/faster-xml-simple/test/test_helper.rb delete mode 100644 support/faster-xml-simple/test/xml_simple_comparison_test.rb diff --git a/.gitignore b/.gitignore index cf4e1e4..0762b95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .rake_tasks site/public/index.html -pkg/ +pkg/* +.bundle +*.gem +Gemfile.lock +.rvmrc diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e45e65f --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source :rubygems +gemspec diff --git a/Rakefile b/Rakefile index 4d097df..8c56a1d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,334 +1,26 @@ require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' - -require File.dirname(__FILE__) + '/lib/aws/s3' -def library_root - File.dirname(__FILE__) +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end +Bundler::GemHelper.install_tasks -task :default => :test - -Rake::TestTask.new do |test| +require 'rake/testtask' +Rake::TestTask.new(:test) do |test| test.pattern = 'test/*_test.rb' test.verbose = true end -namespace :doc do - Rake::RDocTask.new do |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "AWS::S3 -- Support for Amazon S3's REST api" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('COPYING') - rdoc.rdoc_files.include('INSTALL') - rdoc.rdoc_files.include('lib/**/*.rb') - end - - task :rdoc => 'doc:readme' - - task :refresh => :rerdoc do - system 'open doc/index.html' - end - - task :readme do - require 'support/rdoc/code_info' - RDoc::CodeInfo.parse('lib/**/*.rb') - - strip_comments = lambda {|comment| comment.gsub(/^# ?/, '')} - docs_for = lambda do |location| - info = RDoc::CodeInfo.for(location) - raise RuntimeError, "Couldn't find documentation for `#{location}'" unless info - strip_comments[info.comment] - end - - open('README', 'w') do |file| - file.write ERB.new(IO.read('README.erb')).result(binding) - end - end - - task :deploy => :rerdoc do - sh %(scp -r doc marcel@rubyforge.org:/var/www/gforge-projects/amazon/) - end -end - -namespace :dist do - spec = Gem::Specification.new do |s| - s.name = 'aws-s3' - s.version = Gem::Version.new(AWS::S3::Version) - s.summary = "Client library for Amazon's Simple Storage Service's REST API" - s.description = s.summary - s.email = 'marcel@vernix.org' - s.author = 'Marcel Molina Jr.' - s.has_rdoc = true - s.extra_rdoc_files = %w(README COPYING INSTALL) - s.homepage = 'http://amazon.rubyforge.org' - s.rubyforge_project = 'amazon' - s.files = FileList['Rakefile', 'lib/**/*.rb', 'bin/*', 'support/**/*.rb'] - s.executables << 's3sh' - s.test_files = Dir['test/**/*'] - - s.add_dependency 'xml-simple' - s.add_dependency 'builder' - s.add_dependency 'mime-types' - s.rdoc_options = ['--title', "AWS::S3 -- Support for Amazon S3's REST api", - '--main', 'README', - '--line-numbers', '--inline-source'] - end - - # Regenerate README before packaging - task :package => 'doc:readme' - Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar_gz = true - pkg.package_files.include('{lib,script,test,support}/**/*') - pkg.package_files.include('README') - pkg.package_files.include('COPYING') - pkg.package_files.include('INSTALL') - pkg.package_files.include('Rakefile') - end - - desc 'Install with gems' - task :install => :repackage do - sh "sudo gem i pkg/#{spec.name}-#{spec.version}.gem" - end - - desc 'Uninstall gem' - task :uninstall do - sh "sudo gem uninstall #{spec.name} -x" - end - - desc 'Reinstall gem' - task :reinstall => [:uninstall, :install] - - task :confirm_release do - print "Releasing version #{spec.version}. Are you sure you want to proceed? [Yn] " - abort if STDIN.getc == ?n - end - - desc 'Tag release' - task :tag do - sh %(git tag -a '#{spec.version}-release' -m 'Tagging #{spec.version} release') - sh 'git push --tags' - end - - desc 'Update changelog to include a release marker' - task :add_release_marker_to_changelog do - changelog = IO.read('CHANGELOG') - changelog.sub!(/^head:/, "#{spec.version}:") - - open('CHANGELOG', 'w') do |file| - file.write "head:\n\n#{changelog}" - end - end - - task :commit_changelog do - sh %(git commit CHANGELOG -m "Bump changelog version marker for release") - sh 'git push' - end - - package_name = lambda {|specification| File.join('pkg', "#{specification.name}-#{specification.version}")} - - desc 'Push a release to rubyforge' - task :release => [:confirm_release, :clean, :add_release_marker_to_changelog, :package, :commit_changelog, :tag] do - require 'rubyforge' - package = package_name[spec] - - rubyforge = RubyForge.new.configure - rubyforge.login - - user_config = rubyforge.userconfig - user_config['release_changes'] = YAML.load_file('CHANGELOG')[spec.version.to_s].join("\n") - - version_already_released = lambda do - releases = rubyforge.autoconfig['release_ids'] - releases.has_key?(spec.name) && releases[spec.name][spec.version.to_s] - end - - abort("Release #{spec.version} already exists!") if version_already_released.call - - begin - rubyforge.add_release(spec.rubyforge_project, spec.name, spec.version.to_s, "#{package}.tar.gz", "#{package}.gem") - puts "Version #{spec.version} released!" - rescue Exception => exception - puts 'Release failed!' - raise - end - end - - desc 'Upload a beta gem' - task :push_beta_gem => [:clobber_package, :package] do - beta_gem = package_name[spec] - sh %(scp #{beta_gem}.gem marcel@rubyforge.org:/var/www/gforge-projects/amazon/beta) - end - - task :spec do - puts spec.to_ruby - end -end - -desc 'Check code to test ratio' -task :stats do - library_files = FileList["#{library_root}/lib/**/*.rb"] - test_files = FileList["#{library_root}/test/**/*_test.rb"] - count_code_lines = Proc.new do |lines| - lines.inject(0) do |code_lines, line| - next code_lines if [/^\s*$/, /^\s*#/].any? {|non_code_line| non_code_line === line} - code_lines + 1 - end - end - - count_code_lines_for_files = Proc.new do |files| - files.inject(0) {|code_lines, file| code_lines + count_code_lines[IO.read(file)]} - end - - library_code_lines = count_code_lines_for_files[library_files] - test_code_lines = count_code_lines_for_files[test_files] - ratio = Proc.new { sprintf('%.2f', test_code_lines.to_f / library_code_lines)} - - puts "Code LOC: #{library_code_lines} Test LOC: #{test_code_lines} Code to Test Ratio: 1:#{ratio.call}" -end - -namespace :test do - find_file = lambda do |name| - file_name = lambda {|path| File.join(path, "#{name}.rb")} - root = $:.detect do |path| - File.exist?(file_name[path]) - end - file_name[root] if root - end - - TEST_LOADER = find_file['rake/rake_test_loader'] - multiruby = lambda do |glob| - system 'multiruby', TEST_LOADER, *Dir.glob(glob) - end - - desc 'Check test coverage' - task :coverage do - system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/*_test.rb')}") - show_test_coverage_results - end - - Rake::TestTask.new(:remote) do |test| - test.pattern = 'test/remote/*_test.rb' - test.verbose = true - end - - Rake::TestTask.new(:all) do |test| - test.pattern = 'test/**/*_test.rb' - test.verbose = true - end +task :default => :test - desc 'Check test coverage of full stack remote tests' - task :full_coverage do - system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/remote/*_test.rb')} #{File.join(library_root, 'test/*_test.rb')}") - show_test_coverage_results - end - - desc 'Run local tests against multiple versions of Ruby' - task :version_audit do - multiruby['test/*_test.rb'] - end - - namespace :version_audit do - desc 'Run remote tests against multiple versions of Ruby' - task :remote do - multiruby['test/remote/*_test.rb'] - end - - desc 'Run all tests against multiple versions of Ruby' - task :all do - multiruby['test/**/*_test.rb'] - end - end - - def show_test_coverage_results - system("open #{File.join(library_root, 'coverage/index.html')}") if PLATFORM['darwin'] - end - - desc 'Remove coverage products' - task :clobber_coverage do - rm_r 'coverage' rescue nil - end +require 'rdoc/task' +RDoc::Task.new do |rdoc| + rdoc.rdoc_dir = 'doc' + rdoc.title = "AWS::S3 -- Support for Amazon S3's REST api" + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('COPYING') + rdoc.rdoc_files.include('INSTALL') + rdoc.rdoc_files.include('lib/**/*.rb') end - -namespace :todo do - class << TODOS = IO.read(File.join(library_root, 'TODO')) - def items - split("\n").grep(/^\[\s|X\]/) - end - - def completed - find_items_matching(/^\[X\]/) - end - - def uncompleted - find_items_matching(/^\[\s\]/) - end - - def find_items_matching(regexp) - items.grep(regexp).instance_eval do - def display - puts map {|item| "* #{item.sub(/^\[[^\]]\]\s/, '')}"} - end - self - end - end - end - - desc 'Completed todo items' - task :completed do - TODOS.completed.display - end - - desc 'Incomplete todo items' - task :uncompleted do - TODOS.uncompleted.display - end -end if File.exists?(File.join(library_root, 'TODO')) - -namespace :site do - require 'erb' - require 'rdoc/markup/simple_markup' - require 'rdoc/markup/simple_markup/to_html' - - readme = lambda { IO.read('README')[/^== Getting started\n(.*)/m, 1] } - - readme_to_html = lambda do - handler = SM::ToHtml.new - handler.instance_eval do - require 'syntax' - require 'syntax/convertors/html' - def accept_verbatim(am, fragment) - syntax = Syntax::Convertors::HTML.for_syntax('ruby') - @res << %(
#{syntax.convert(fragment.txt, true)}
) - end - end - SM::SimpleMarkup.new.convert(readme.call, handler) - end - - desc 'Regenerate the public website page' - task :build => 'doc:readme' do - open('site/public/index.html', 'w') do |file| - erb_data = {} - erb_data[:readme] = readme_to_html.call - file.write ERB.new(IO.read('site/index.erb')).result(binding) - end - end - - task :refresh => :build do - system 'open site/public/index.html' - end - - desc 'Update the live website' - task :deploy => :build do - site_files = FileList['site/public/*'] - site_files.delete_if {|file| File.directory?(file)} - sh %(scp #{site_files.join ' '} marcel@rubyforge.org:/var/www/gforge-projects/amazon/) - end -end - -task :clean => ['dist:clobber_package', 'doc:clobber_rdoc', 'test:clobber_coverage'] diff --git a/aws-s3.gemspec b/aws-s3.gemspec new file mode 100644 index 0000000..bfb30c5 --- /dev/null +++ b/aws-s3.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +require File.expand_path('../lib/aws/s3/version', __FILE__) + +Gem::Specification.new do |s| + s.name = 'aws-s3' + s.version = AWS::S3::Version + s.platform = Gem::Platform::RUBY + s.authors = ['Marcel Molina Jr.'] + s.email = ['marcel@vernix.org'] + s.summary = "Client library for Amazon's Simple Storage Service's REST API" + s.description = s.summary + s.homepage = 'http://amazon.rubyforge.org' + s.rubyforge_project = 'amazon' + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } + s.require_paths = ['lib'] + + s.extra_rdoc_files = %w(README COPYING INSTALL) + s.rdoc_options = ['--title', "AWS::S3 -- Support for Amazon S3's REST api", + '--main', 'README', + '--line-numbers', '--inline-source'] + + s.add_dependency 'xml-simple' + s.add_dependency 'builder' + s.add_dependency 'mime-types' + + s.add_development_dependency 'rake' + s.add_development_dependency 'flexmock' +end diff --git a/support/faster-xml-simple/COPYING b/support/faster-xml-simple/COPYING deleted file mode 100644 index 860483b..0000000 --- a/support/faster-xml-simple/COPYING +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2006 Michael Koziarski - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in the -Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/support/faster-xml-simple/README b/support/faster-xml-simple/README deleted file mode 100644 index 9473efc..0000000 --- a/support/faster-xml-simple/README +++ /dev/null @@ -1,8 +0,0 @@ -FasterXmlSimple - -FasterXS is intended to be a drop in replacement for the xml input functionality -from XmlSimple. Instead of using rexml, it uses libxml and the associated ruby -bindings. This reduces CPU utilisation and memory consumption considerably. - -Preliminary benchmarks show it between 3 and 10 times as fast, and using a -fraction of the ram. \ No newline at end of file diff --git a/support/faster-xml-simple/Rakefile b/support/faster-xml-simple/Rakefile deleted file mode 100644 index d042aac..0000000 --- a/support/faster-xml-simple/Rakefile +++ /dev/null @@ -1,54 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' -require 'lib/faster_xml_simple' - -task :default => :test - -Rake::TestTask.new do |test| - test.pattern = 'test/*_test.rb' - test.verbose = true -end - - -Rake::RDocTask.new do |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "FasterXmlSimple, a libxml based replacement for XmlSimple" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('COPYING') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -namespace :dist do - - spec = Gem::Specification.new do |s| - s.name = 'faster_xml_simple' - s.version = Gem::Version.new(FasterXmlSimple::Version) - s.summary = "A libxml based replacement for XmlSimple" - s.description = s.summary - s.email = 'michael@koziarski.com' - s.author = 'Michael Koziarski' - s.has_rdoc = true - s.extra_rdoc_files = %w(README COPYING) - s.homepage = 'http://fasterxs.rubyforge.org' - s.rubyforge_project = 'fasterxs' - s.files = FileList['Rakefile', 'lib/**/*.rb'] - s.test_files = Dir['test/**/*'] - - s.add_dependency 'libxml-ruby', '>= 0.3.8.4' - s.rdoc_options = ['--title', "", - '--main', 'README', - '--line-numbers', '--inline-source'] - end - Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar_gz = true - pkg.package_files.include('{lib,test}/**/*') - pkg.package_files.include('README') - pkg.package_files.include('COPYING') - pkg.package_files.include('Rakefile') - end -end \ No newline at end of file diff --git a/support/faster-xml-simple/lib/faster_xml_simple.rb b/support/faster-xml-simple/lib/faster_xml_simple.rb deleted file mode 100644 index 98326ed..0000000 --- a/support/faster-xml-simple/lib/faster_xml_simple.rb +++ /dev/null @@ -1,187 +0,0 @@ -# -# Copyright (c) 2006 Michael Koziarski -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in the -# Software without restriction, including without limitation the rights to use, -# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -# Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -require 'rubygems' -require 'xml/libxml' - -class FasterXmlSimple - Version = '0.5.0' - class << self - # Take an string containing XML, and returns a hash representing that - # XML document. For example: - # - # FasterXmlSimple.xml_in("1") - # {"root"=>{"something"=>{"__content__"=>"1"}}} - # - # Faster XML Simple is designed to be a drop in replacement for the xml_in - # functionality of http://xml-simple.rubyforge.org - # - # The following options are supported: - # - # * contentkey: The key to use for the content of text elements, - # defaults to '\_\_content__' - # * forcearray: The list of elements which should always be returned - # as arrays. Under normal circumstances single element arrays are inlined. - # * suppressempty: The value to return for empty elements, pass +true+ - # to remove empty elements entirely. - # * keeproot: By default the hash returned has a single key with the - # name of the root element. If the name of the root element isn't - # interesting to you, pass +false+. - # * forcecontent: By default a text element with no attributes, will - # be collapsed to just a string instead of a hash with a single key. - # Pass +true+ to prevent this. - # - # - def xml_in(string, options={}) - new(string, options).out - end - end - - def initialize(string, options) #:nodoc: - @doc = parse(string) - @options = default_options.merge options - end - - def out #:nodoc: - if @options['keeproot'] - {@doc.root.name => collapse(@doc.root)} - else - collapse(@doc.root) - end - end - - private - def default_options - {'contentkey' => '__content__', 'forcearray' => [], 'keeproot'=>true} - end - - def collapse(element) - result = hash_of_attributes(element) - if text_node? element - text = collapse_text(element) - result[content_key] = text if text =~ /\S/ - elsif element.children? - element.inject(result) do |hash, child| - unless child.text? - child_result = collapse(child) - (hash[child.name] ||= []) << child_result - end - hash - end - end - if result.empty? - return empty_element - end - # Compact them to ensure it complies with the user's requests - inline_single_element_arrays(result) - remove_empty_elements(result) if suppress_empty? - if content_only?(result) && !force_content? - result[content_key] - else - result - end - end - - def content_only?(result) - result.keys == [content_key] - end - - def content_key - @options['contentkey'] - end - - def force_array?(key_name) - Array(@options['forcearray']).include?(key_name) - end - - def inline_single_element_arrays(result) - result.each do |key, value| - if value.size == 1 && value.is_a?(Array) && !force_array?(key) - result[key] = value.first - end - end - end - - def remove_empty_elements(result) - result.each do |key, value| - if value == empty_element - result.delete key - end - end - end - - def suppress_empty? - @options['suppressempty'] == true - end - - def empty_element - if !@options.has_key? 'suppressempty' - {} - else - @options['suppressempty'] - end - end - - # removes the content if it's nothing but blanks, prevents - # the hash being polluted with lots of content like "\n\t\t\t" - def suppress_empty_content(result) - result.delete content_key if result[content_key] !~ /\S/ - end - - def force_content? - @options['forcecontent'] - end - - # a text node is one with 1 or more child nodes which are - # text nodes, and no non-text children, there's no sensible - # way to support nodes which are text and markup like: - #

Something Bold

- def text_node?(element) - !element.text? && element.all? {|c| c.text?} - end - - # takes a text node, and collapses it into a string - def collapse_text(element) - element.map {|c| c.content } * '' - end - - def hash_of_attributes(element) - result = {} - element.each_attr do |attribute| - name = attribute.name - name = [attribute.ns, attribute.name].join(':') if attribute.ns? - result[name] = attribute.value - end - result - end - - def parse(string) - if string == '' - string = ' ' - end - XML::Parser.string(string).parse - end -end - -class XmlSimple # :nodoc: - def self.xml_in(*args) - FasterXmlSimple.xml_in *args - end -end \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-1.rails.yml b/support/faster-xml-simple/test/fixtures/test-1.rails.yml deleted file mode 100644 index b058f3e..0000000 --- a/support/faster-xml-simple/test/fixtures/test-1.rails.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -something: - something-else: - __content__: testing diff --git a/support/faster-xml-simple/test/fixtures/test-1.xml b/support/faster-xml-simple/test/fixtures/test-1.xml deleted file mode 100644 index cd2c07b..0000000 --- a/support/faster-xml-simple/test/fixtures/test-1.xml +++ /dev/null @@ -1,3 +0,0 @@ - - testing - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-1.yml b/support/faster-xml-simple/test/fixtures/test-1.yml deleted file mode 100644 index 502e7f8..0000000 --- a/support/faster-xml-simple/test/fixtures/test-1.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -something: - something-else: - - __content__: testing diff --git a/support/faster-xml-simple/test/fixtures/test-2.rails.yml b/support/faster-xml-simple/test/fixtures/test-2.rails.yml deleted file mode 100644 index d5f09dc..0000000 --- a/support/faster-xml-simple/test/fixtures/test-2.rails.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -something: - something-else: - __content__: testing - child_attribute: "15" - root_attribute: "12" diff --git a/support/faster-xml-simple/test/fixtures/test-2.xml b/support/faster-xml-simple/test/fixtures/test-2.xml deleted file mode 100644 index 5405647..0000000 --- a/support/faster-xml-simple/test/fixtures/test-2.xml +++ /dev/null @@ -1,3 +0,0 @@ - - testing - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-2.yml b/support/faster-xml-simple/test/fixtures/test-2.yml deleted file mode 100644 index 89c3d11..0000000 --- a/support/faster-xml-simple/test/fixtures/test-2.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -something: - something-else: - - __content__: testing - child_attribute: "15" - root_attribute: "12" diff --git a/support/faster-xml-simple/test/fixtures/test-3.rails.yml b/support/faster-xml-simple/test/fixtures/test-3.rails.yml deleted file mode 100644 index dddff1e..0000000 --- a/support/faster-xml-simple/test/fixtures/test-3.rails.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -something: - something-else: - __content__: "\n\ - \t\ttesting\n\ - \t" diff --git a/support/faster-xml-simple/test/fixtures/test-3.xml b/support/faster-xml-simple/test/fixtures/test-3.xml deleted file mode 100644 index 6e77829..0000000 --- a/support/faster-xml-simple/test/fixtures/test-3.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - testing - - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-3.yml b/support/faster-xml-simple/test/fixtures/test-3.yml deleted file mode 100644 index ae1e05e..0000000 --- a/support/faster-xml-simple/test/fixtures/test-3.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -something: - something-else: - - __content__: "\n\ - \t\ttesting\n\ - \t" diff --git a/support/faster-xml-simple/test/fixtures/test-4.rails.yml b/support/faster-xml-simple/test/fixtures/test-4.rails.yml deleted file mode 100644 index 7e9e06c..0000000 --- a/support/faster-xml-simple/test/fixtures/test-4.rails.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -something: - something-else: - another_child: - attribute: "4" diff --git a/support/faster-xml-simple/test/fixtures/test-4.xml b/support/faster-xml-simple/test/fixtures/test-4.xml deleted file mode 100644 index ff98fa6..0000000 --- a/support/faster-xml-simple/test/fixtures/test-4.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - testing - - testing - - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-4.yml b/support/faster-xml-simple/test/fixtures/test-4.yml deleted file mode 100644 index 8d62c26..0000000 --- a/support/faster-xml-simple/test/fixtures/test-4.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -something: - something-else: - - another_child: - attribute: "4" diff --git a/support/faster-xml-simple/test/fixtures/test-5.rails.yml b/support/faster-xml-simple/test/fixtures/test-5.rails.yml deleted file mode 100644 index c8e4387..0000000 --- a/support/faster-xml-simple/test/fixtures/test-5.rails.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -something: - something-else: - - __content__: testing - - __content__: testing - - __content__: testing - - __content__: testing - - __content__: testing diff --git a/support/faster-xml-simple/test/fixtures/test-5.xml b/support/faster-xml-simple/test/fixtures/test-5.xml deleted file mode 100644 index 3a22ab2..0000000 --- a/support/faster-xml-simple/test/fixtures/test-5.xml +++ /dev/null @@ -1,7 +0,0 @@ - - testing - testing - testing - testing - testing - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-5.yml b/support/faster-xml-simple/test/fixtures/test-5.yml deleted file mode 100644 index c8e4387..0000000 --- a/support/faster-xml-simple/test/fixtures/test-5.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -something: - something-else: - - __content__: testing - - __content__: testing - - __content__: testing - - __content__: testing - - __content__: testing diff --git a/support/faster-xml-simple/test/fixtures/test-6.rails.yml b/support/faster-xml-simple/test/fixtures/test-6.rails.yml deleted file mode 100644 index 1ceb02c..0000000 --- a/support/faster-xml-simple/test/fixtures/test-6.rails.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -ListBucketResult: - Prefix: {} - - Name: - __content__: projectionist - MaxKeys: - __content__: "1000" - Contents: - - StorageClass: - __content__: STANDARD - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - Size: - __content__: "186870" - ETag: - __content__: "\"2ac1aa042e20ab7e1a9879b0df9f17b7\"" - LastModified: - __content__: "2006-11-15T05:49:39.000Z" - Key: - __content__: 1973-plymouth-satellite-sebring.jpg - - StorageClass: - __content__: STANDARD - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - Size: - __content__: "43562" - ETag: - __content__: "\"4ead118ba91491f9c9697153264a1943\"" - LastModified: - __content__: "2006-11-15T05:51:20.000Z" - Key: - __content__: 37-cluster.jpg - Marker: {} - - IsTruncated: - __content__: "false" diff --git a/support/faster-xml-simple/test/fixtures/test-6.xml b/support/faster-xml-simple/test/fixtures/test-6.xml deleted file mode 100644 index 10967ee..0000000 --- a/support/faster-xml-simple/test/fixtures/test-6.xml +++ /dev/null @@ -1,29 +0,0 @@ - - projectionist - - - 1000 - false - - 1973-plymouth-satellite-sebring.jpg - 2006-11-15T05:49:39.000Z - "2ac1aa042e20ab7e1a9879b0df9f17b7" - 186870 - - bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - noradio - - STANDARD - - - 37-cluster.jpg - 2006-11-15T05:51:20.000Z - "4ead118ba91491f9c9697153264a1943" - 43562 - - bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - noradio - - STANDARD - - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-6.yml b/support/faster-xml-simple/test/fixtures/test-6.yml deleted file mode 100644 index f180c4e..0000000 --- a/support/faster-xml-simple/test/fixtures/test-6.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -ListBucketResult: - Prefix: - Name: - __content__: projectionist - MaxKeys: - __content__: "1000" - Contents: - - StorageClass: - __content__: STANDARD - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - Size: - __content__: "186870" - ETag: - __content__: "\"2ac1aa042e20ab7e1a9879b0df9f17b7\"" - LastModified: - __content__: "2006-11-15T05:49:39.000Z" - Key: - __content__: 1973-plymouth-satellite-sebring.jpg - - StorageClass: - __content__: STANDARD - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - Size: - __content__: "43562" - ETag: - __content__: "\"4ead118ba91491f9c9697153264a1943\"" - LastModified: - __content__: "2006-11-15T05:51:20.000Z" - Key: - __content__: 37-cluster.jpg - Marker: - IsTruncated: - __content__: "false" diff --git a/support/faster-xml-simple/test/fixtures/test-7.rails.yml b/support/faster-xml-simple/test/fixtures/test-7.rails.yml deleted file mode 100644 index 1e2c149..0000000 --- a/support/faster-xml-simple/test/fixtures/test-7.rails.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -AccessControlPolicy: - AccessControlList: - Grant: - - Permission: - __content__: FULL_CONTROL - Grantee: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - xsi:type: CanonicalUser - - Permission: - __content__: READ - Grantee: - URI: - __content__: http://acs.amazonaws.com/groups/global/AllUsers - xsi:type: Group - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 diff --git a/support/faster-xml-simple/test/fixtures/test-7.xml b/support/faster-xml-simple/test/fixtures/test-7.xml deleted file mode 100644 index f3ce35e..0000000 --- a/support/faster-xml-simple/test/fixtures/test-7.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - noradio - - - - - bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - noradio - - FULL_CONTROL - - - - http://acs.amazonaws.com/groups/global/AllUsers - - READ - - - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-7.yml b/support/faster-xml-simple/test/fixtures/test-7.yml deleted file mode 100644 index 41d0254..0000000 --- a/support/faster-xml-simple/test/fixtures/test-7.yml +++ /dev/null @@ -1,22 +0,0 @@ -AccessControlPolicy: - Owner: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - AccessControlList: - Grant: - - Permission: - __content__: FULL_CONTROL - Grantee: - DisplayName: - __content__: noradio - ID: - __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 - xsi:type: CanonicalUser - - Permission: - __content__: READ - Grantee: - URI: - __content__: http://acs.amazonaws.com/groups/global/AllUsers - xsi:type: Group diff --git a/support/faster-xml-simple/test/fixtures/test-8.rails.yml b/support/faster-xml-simple/test/fixtures/test-8.rails.yml deleted file mode 100644 index 7893b45..0000000 --- a/support/faster-xml-simple/test/fixtures/test-8.rails.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -topic: - parent-id: {} - - title: {} - - approved: - type: boolean - id: - type: integer - viewed-at: - type: datetime - written-on: - type: date diff --git a/support/faster-xml-simple/test/fixtures/test-8.xml b/support/faster-xml-simple/test/fixtures/test-8.xml deleted file mode 100644 index 1191e8f..0000000 --- a/support/faster-xml-simple/test/fixtures/test-8.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/support/faster-xml-simple/test/fixtures/test-8.yml b/support/faster-xml-simple/test/fixtures/test-8.yml deleted file mode 100644 index 8ed125b..0000000 --- a/support/faster-xml-simple/test/fixtures/test-8.yml +++ /dev/null @@ -1,11 +0,0 @@ -topic: - title: - id: - type: integer - approved: - type: boolean - parent-id: - viewed-at: - type: datetime - written-on: - type: date \ No newline at end of file diff --git a/support/faster-xml-simple/test/regression_test.rb b/support/faster-xml-simple/test/regression_test.rb deleted file mode 100644 index 5fde070..0000000 --- a/support/faster-xml-simple/test/regression_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' - -class RegressionTest < FasterXSTest - def test_content_nil_regressions - expected = {"asdf"=>{"jklsemicolon"=>{}}} - assert_equal expected, FasterXmlSimple.xml_in("") - assert_equal expected, FasterXmlSimple.xml_in("", 'forcearray'=>['asdf']) - end - - def test_s3_regression - str = File.read("test/fixtures/test-7.xml") - assert_nil FasterXmlSimple.xml_in(str)["AccessControlPolicy"]["AccessControlList"]["__content__"] - end - - def test_xml_simple_transparency - assert_equal XmlSimple.xml_in(""), FasterXmlSimple.xml_in("") - end - - def test_suppress_empty_variations - str = "" - - assert_equal Hash.new, FasterXmlSimple.xml_in(str)["asdf"]["fdsa"] - assert_nil FasterXmlSimple.xml_in(str, 'suppressempty'=>nil)["asdf"]["fdsa"] - assert_equal '', FasterXmlSimple.xml_in(str, 'suppressempty'=>'')["asdf"]["fdsa"] - assert !FasterXmlSimple.xml_in(str, 'suppressempty'=>true)["asdf"].has_key?("fdsa") - end - - def test_empty_string_doesnt_crash - assert_raise(XML::Parser::ParseError) do - silence_stderr do - FasterXmlSimple.xml_in('') - end - end - end - - def test_keeproot_false - str = "1" - expected = {"fdsa"=>"1"} - assert_equal expected, FasterXmlSimple.xml_in(str, 'keeproot'=>false) - end - - def test_keeproot_false_with_force_content - str = "1" - expected = {"fdsa"=>{"__content__"=>"1"}} - assert_equal expected, FasterXmlSimple.xml_in(str, 'keeproot'=>false, 'forcecontent'=>true) - end -end \ No newline at end of file diff --git a/support/faster-xml-simple/test/test_helper.rb b/support/faster-xml-simple/test/test_helper.rb deleted file mode 100644 index 3e62384..0000000 --- a/support/faster-xml-simple/test/test_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ - -require 'test/unit' -require 'faster_xml_simple' - -class FasterXSTest < Test::Unit::TestCase - def default_test - end - - def silence_stderr - str = STDERR.dup - STDERR.reopen("/dev/null") - STDERR.sync=true - yield - ensure - STDERR.reopen(str) - end -end diff --git a/support/faster-xml-simple/test/xml_simple_comparison_test.rb b/support/faster-xml-simple/test/xml_simple_comparison_test.rb deleted file mode 100644 index 13dcc55..0000000 --- a/support/faster-xml-simple/test/xml_simple_comparison_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' -require 'yaml' - -class XmlSimpleComparisonTest < FasterXSTest - - # Define test methods - - Dir["test/fixtures/test-*.xml"].each do |file_name| - xml_file_name = file_name - method_name = File.basename(file_name, ".xml").gsub('-', '_') - yml_file_name = file_name.gsub('xml', 'yml') - rails_yml_file_name = file_name.gsub('xml', 'rails.yml') - class_eval <<-EOV, __FILE__, __LINE__ - def #{method_name} - assert_equal YAML.load(File.read('#{yml_file_name}')), - FasterXmlSimple.xml_in(File.read('#{xml_file_name}'), default_options ) - end - - def #{method_name}_rails - assert_equal YAML.load(File.read('#{rails_yml_file_name}')), - FasterXmlSimple.xml_in(File.read('#{xml_file_name}'), rails_options) - end - EOV - end - - def default_options - { - 'keeproot' => true, - 'contentkey' => '__content__', - 'forcecontent' => true, - 'suppressempty' => nil, - 'forcearray' => ['something-else'] - } - end - - def rails_options - { - 'forcearray' => false, - 'forcecontent' => true, - 'keeproot' => true, - 'contentkey' => '__content__' - } - end - - -end \ No newline at end of file diff --git a/test/acl_test.rb b/test/acl_test.rb index 434d80d..6d44fda 100644 --- a/test/acl_test.rb +++ b/test/acl_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class PolicyReadingTest < Test::Unit::TestCase diff --git a/test/authentication_test.rb b/test/authentication_test.rb index ad5998d..f7d1169 100644 --- a/test/authentication_test.rb +++ b/test/authentication_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class HeaderAuthenticationTest < Test::Unit::TestCase def test_encoded_canonical diff --git a/test/base_test.rb b/test/base_test.rb index 515e6a9..c1c0db0 100644 --- a/test/base_test.rb +++ b/test/base_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class BaseTest < Test::Unit::TestCase def test_connection_established diff --git a/test/bucket_test.rb b/test/bucket_test.rb index d241534..d5491d1 100644 --- a/test/bucket_test.rb +++ b/test/bucket_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class BucketTest < Test::Unit::TestCase def test_bucket_name_validation diff --git a/test/connection_test.rb b/test/connection_test.rb index 5098881..6b086d0 100644 --- a/test/connection_test.rb +++ b/test/connection_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class ConnectionTest < Test::Unit::TestCase attr_reader :keys diff --git a/test/error_test.rb b/test/error_test.rb index 8b32159..811f88e 100644 --- a/test/error_test.rb +++ b/test/error_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class ErrorTest < Test::Unit::TestCase def setup diff --git a/test/extensions_test.rb b/test/extensions_test.rb index 1c868ee..df972cc 100644 --- a/test/extensions_test.rb +++ b/test/extensions_test.rb @@ -1,4 +1,6 @@ -require File.dirname(__FILE__) + '/test_helper' +# encoding: utf-8 + +require File.expand_path('../test_helper', __FILE__) class HashExtensionsTest < Test::Unit::TestCase def test_to_query_string @@ -66,13 +68,13 @@ def test_to_header end def test_valid_utf8? - assert !"318597/620065/GTL_75\24300_A600_A610.zip".valid_utf8? - assert "318597/620065/GTL_75£00_A600_A610.zip".valid_utf8? + assert(!"318597/620065/GTL_75\24300_A600_A610.zip".valid_utf8?) + assert("318597/620065/GTL_75£00_A600_A610.zip".valid_utf8?) end def test_remove_extended - assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8? - assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8? + assert("318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8?) + assert("318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8?) end def test_tap diff --git a/test/logging_test.rb b/test/logging_test.rb index ffee79b..0b41765 100644 --- a/test/logging_test.rb +++ b/test/logging_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class LoggingStatusReadingTest < Test::Unit::TestCase diff --git a/test/object_test.rb b/test/object_test.rb index 0228b13..9b09e56 100644 --- a/test/object_test.rb +++ b/test/object_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class ObjectTest < Test::Unit::TestCase def setup diff --git a/test/parsing_test.rb b/test/parsing_test.rb index 5410dbd..c5c862a 100644 --- a/test/parsing_test.rb +++ b/test/parsing_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class TypecastingTest < Test::Unit::TestCase # Make it easier to call methods in tests diff --git a/test/remote/acl_test.rb b/test/remote/acl_test.rb index 8bc9862..18fd410 100644 --- a/test/remote/acl_test.rb +++ b/test/remote/acl_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class RemoteACLTest < Test::Unit::TestCase diff --git a/test/remote/bittorrent_test.rb b/test/remote/bittorrent_test.rb index 6cd9ff0..92c025c 100644 --- a/test/remote/bittorrent_test.rb +++ b/test/remote/bittorrent_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class RemoteBittorrentTest < Test::Unit::TestCase def setup diff --git a/test/remote/bucket_test.rb b/test/remote/bucket_test.rb index 8c84f78..01fe763 100644 --- a/test/remote/bucket_test.rb +++ b/test/remote/bucket_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class RemoteBucketTest < Test::Unit::TestCase diff --git a/test/remote/logging_test.rb b/test/remote/logging_test.rb index 1a4209c..98c538f 100644 --- a/test/remote/logging_test.rb +++ b/test/remote/logging_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class RemoteLoggingTest < Test::Unit::TestCase def setup diff --git a/test/remote/object_test.rb b/test/remote/object_test.rb index c63076c..524adc6 100644 --- a/test/remote/object_test.rb +++ b/test/remote/object_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class RemoteS3ObjectTest < Test::Unit::TestCase def setup diff --git a/test/response_test.rb b/test/response_test.rb index 4dfd543..75b6ad7 100644 --- a/test/response_test.rb +++ b/test/response_test.rb @@ -1,4 +1,5 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) + class BaseResponseTest < Test::Unit::TestCase def setup @headers = {'content-type' => 'text/plain', 'date' => Time.now} diff --git a/test/service_test.rb b/test/service_test.rb index f8b4820..80d2df1 100644 --- a/test/service_test.rb +++ b/test/service_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) class ServiceTest < Test::Unit::TestCase def test_bucket_list_with_empty_bucket_list diff --git a/test/test_helper.rb b/test/test_helper.rb index 04d51d7..eea0846 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,15 +1,12 @@ require 'test/unit' -$:.unshift File.dirname(__FILE__) + '/../lib' -require 'aws/s3' -require File.dirname(__FILE__) + '/mocks/fake_response' -require File.dirname(__FILE__) + '/fixtures' -begin - require_library_or_gem 'ruby-debug' -rescue LoadError -end -require_library_or_gem 'flexmock' -require_library_or_gem 'flexmock/test_unit' +require 'flexmock/test_unit' + +require File.expand_path('../../lib/aws/s3', __FILE__) +require File.expand_path('../mocks/fake_response', __FILE__) +require File.expand_path('../fixtures', __FILE__) +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } # Data copied from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAuthentication.html module AmazonDocExampleData