From 50e8cd0641a6af0a1069feb231dc2e8ac23fe190 Mon Sep 17 00:00:00 2001 From: Juz Date: Sun, 17 Jul 2016 00:08:05 +0100 Subject: [PATCH 1/3] Remove duplicate dependency on Gosu --- chingu.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/chingu.gemspec b/chingu.gemspec index b3461282..ddec1365 100644 --- a/chingu.gemspec +++ b/chingu.gemspec @@ -16,7 +16,6 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.rubyforge_project = "chingu" - s.add_dependency("gosu", [">= 0.7.45"]) s.add_runtime_dependency("gosu", [">= 0.7.45"]) s.add_development_dependency("rspec", [">= 2.1.0"]) s.add_development_dependency("watchr", [">= 0"]) From dd84426057a0e2a6e2a946f676f5fc51d6364d6c Mon Sep 17 00:00:00 2001 From: Juz Date: Sun, 17 Jul 2016 00:09:35 +0100 Subject: [PATCH 2/3] Use require_all gem --- Gemfile | 1 + lib/chingu.rb | 2 +- lib/chingu/require_all.rb | 140 -------------------------------------- 3 files changed, 2 insertions(+), 141 deletions(-) delete mode 100644 lib/chingu/require_all.rb diff --git a/Gemfile b/Gemfile index 959eb4d5..45f9941e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'http://rubygems.org' gem "gosu" +gem "require_all" group :test do gem "rspec", ">= 2.1.0" diff --git a/lib/chingu.rb b/lib/chingu.rb index 6a8affc0..1054d230 100644 --- a/lib/chingu.rb +++ b/lib/chingu.rb @@ -27,7 +27,7 @@ require 'yaml' require 'timeout' require 'socket' -require File.join(CHINGU_ROOT,"chingu","require_all") # Thanks to http://github.com/tarcieri/require_all ! +require 'require_all' # Seems like we need to include chingu/helpers first for BasicGameObject # and GameObject to get the correct class_inheritable_accssor diff --git a/lib/chingu/require_all.rb b/lib/chingu/require_all.rb deleted file mode 100644 index 7a7b39e2..00000000 --- a/lib/chingu/require_all.rb +++ /dev/null @@ -1,140 +0,0 @@ -#-- -# Copyright (C)2009 Tony Arcieri -# You can redistribute this under the terms of the MIT license -# See file LICENSE for details -#++ - -module RequireAll - # A wonderfully simple way to load your code. - # - # The easiest way to use require_all is to just point it at a directory - # containing a bunch of .rb files. These files can be nested under - # subdirectories as well: - # - # require_all 'lib' - # - # This will find all the .rb files under the lib directory and load them. - # The proper order to load them in will be determined automatically. - # - # If the dependencies between the matched files are unresolvable, it will - # throw the first unresolvable NameError. - # - # You can also give it a glob, which will enumerate all the matching files: - # - # require_all 'lib/**/*.rb' - # - # It will also accept an array of files: - # - # require_all Dir.glob("blah/**/*.rb").reject { |f| stupid_file(f) } - # - # Or if you want, just list the files directly as arguments: - # - # require_all 'lib/a.rb', 'lib/b.rb', 'lib/c.rb', 'lib/d.rb' - # - def require_all(*args) - # Handle passing an array as an argument - args.flatten! - - if args.size > 1 - # Expand files below directories - files = args.map do |path| - if File.directory? path - Dir[File.join(path, '**', '*.rb')] - else - path - end - end.flatten - else - arg = args.first - begin - # Try assuming we're doing plain ol' require compat - stat = File.stat(arg) - - if stat.file? - files = [arg] - elsif stat.directory? - files = Dir.glob File.join(arg, '**', '*.rb') - else - raise ArgumentError, "#{arg} isn't a file or directory" - end - rescue Errno::ENOENT - # If the stat failed, maybe we have a glob! - files = Dir.glob arg - - # Maybe it's an .rb file and the .rb was omitted - if File.file?(arg + '.rb') - require(arg + '.rb') - return true - end - - # If we ain't got no files, the glob failed - raise LoadError, "no such file to load -- #{arg}" if files.empty? - end - end - - # If there's nothing to load, you're doing it wrong! - raise LoadError, "no files to load" if files.empty? - - files.map! { |file| File.expand_path file } - files.sort! - - begin - failed = [] - first_name_error = nil - - # Attempt to load each file, rescuing which ones raise NameError for - # undefined constants. Keep trying to successively reload files that - # previously caused NameErrors until they've all been loaded or no new - # files can be loaded, indicating unresolvable dependencies. - files.each do |file| - begin - require file - rescue NameError => ex - failed << file - first_name_error ||= ex - rescue ArgumentError => ex - # Work around ActiveSuport freaking out... *sigh* - # - # ActiveSupport sometimes throws these exceptions and I really - # have no idea why. Code loading will work successfully if these - # exceptions are swallowed, although I've run into strange - # nondeterministic behaviors with constants mysteriously vanishing. - # I've gone spelunking through dependencies.rb looking for what - # exactly is going on, but all I ended up doing was making my eyes - # bleed. - # - # FIXME: If you can understand ActiveSupport's dependencies.rb - # better than I do I would *love* to find a better solution - raise unless ex.message["is not missing constant"] - - STDERR.puts "Warning: require_all swallowed ActiveSupport 'is not missing constant' error" - STDERR.puts ex.backtrace[0..9] - end - end - - # If this pass didn't resolve any NameErrors, we've hit an unresolvable - # dependency, so raise one of the exceptions we encountered. - if failed.size == files.size - raise first_name_error - else - files = failed - end - end until failed.empty? - - true - end - - # Works like require_all, but paths are relative to the caller rather than - # the current working directory - def require_rel(*paths) - # Handle passing an array as an argument - paths.flatten! - - source_directory = File.dirname caller.first.sub(/:\d+$/, '') - paths.each do |path| - require_all File.join(source_directory, path) - end - end -end - -include RequireAll \ No newline at end of file From 3e7b938f6d4f310a0d243e70bc110b5c25aec47d Mon Sep 17 00:00:00 2001 From: Juz Date: Sun, 17 Jul 2016 00:20:43 +0100 Subject: [PATCH 3/3] Remove test dependency on chingu's require_all --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d2cbd473..553f37d9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,7 @@ require 'rubygems' require 'rspec' -require 'chingu/require_all' +require 'require_all' require 'chingu'