fun_with_files 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,10 +7,10 @@ source "http://rubygems.org"
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
 
9
9
  group :development do
10
- gem "shoulda", ">= 0"
10
+ gem "shoulda", ">= 3.5"
11
11
  gem "rdoc", "~> 3.12"
12
- gem "bundler", "~> 1.3.0"
13
- gem "jeweler", "~> 1.8.4"
12
+ gem "bundler", "~> 1.3.5"
13
+ gem "jeweler", "~> 1.8.7"
14
14
  end
15
15
 
16
16
  gem "xdg"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -359,10 +359,46 @@ module FunWith
359
359
  end
360
360
  end
361
361
 
362
-
362
+ # Require ALL THE RUBY!
363
+ # This may be a bad idea...
364
+ #
365
+ # Sometimes it fails to require a file because one of the necessary prerequisites
366
+ # hasn't been required yet (NameError). requir catches this failure and stores
367
+ # the failed requirement in order to try it later. Doesn't fail until it goes through
368
+ # a full loop where none of the required files were successful.
363
369
  def requir
364
370
  if self.directory?
365
- self.glob( :recursive => true, :ext => "rb" ).map(&:requir)
371
+ requirements = self.glob( :recursive => true, :ext => "rb" )
372
+ successfully_required = 1337 # need to break into initial loop
373
+ failed_requirements = []
374
+ error_messages = []
375
+
376
+ while requirements.length > 0 && successfully_required > 0
377
+ successfully_required = 0
378
+ failed_requirements = []
379
+ error_messages = []
380
+
381
+ for requirement in requirements
382
+ begin
383
+ requirement.requir
384
+ successfully_required += 1
385
+ rescue Exception => e
386
+ failed_requirements << requirement
387
+ error_messages << "#{e.message} (#{e.class})"
388
+ end
389
+ end
390
+
391
+ requirements = failed_requirements
392
+ end
393
+
394
+ if failed_requirements.length > 0
395
+ msg = "requiring directory #{self} failed:\n"
396
+ for message in error_messages
397
+ msg << "\n\terror message: #{message}"
398
+ end
399
+
400
+ raise NameError.new(msg)
401
+ end
366
402
  else
367
403
  require self.expand.gsub( /\.rb$/, '' )
368
404
  end
@@ -0,0 +1,2 @@
1
+ class A < B
2
+ end
@@ -0,0 +1,2 @@
1
+ class B < C
2
+ end
@@ -0,0 +1,2 @@
1
+ class C < D
2
+ end
@@ -0,0 +1,4 @@
1
+ # class D should be the last one it tries to load, but the first that doesn't
2
+ # fail because of a missing parent class.
3
+ class D
4
+ end
@@ -6,6 +6,6 @@ class TestGlobbing < FunWith::Files::TestCase
6
6
  @loadable_dir = FunWith::Files.root("test", "loadable_dir")
7
7
  assert @loadable_dir.directory?
8
8
  @globs = @loadable_dir.glob( :recursive => true, :ext => "rb" )
9
- assert_equal 4, @globs.length
9
+ assert_equal 8, @globs.length
10
10
  end
11
11
  end
@@ -24,4 +24,12 @@ class TestLoading < FunWith::Files::TestCase
24
24
  FunWith::Files.root( "test", "loadable_dir", "dir4" ).load
25
25
  assert defined?( LoadedOrRequiredModule::Loaded4 ), "FunWith::Files::LoadedOrRequiredModule::Loaded4 should be defined now."
26
26
  end
27
+
28
+ should "requir a directory which requires multiple passes to complete" do
29
+ FunWith::Files.root( "test", "loadable_dir", "dir5" ).requir
30
+ assert defined?(A)
31
+ assert defined?(B)
32
+ assert defined?(C)
33
+ assert defined?(D)
34
+ end
27
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_with_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: '3.5'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.5'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rdoc
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.3.0
85
+ version: 1.3.5
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.3.0
93
+ version: 1.3.5
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: jeweler
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.8.4
101
+ version: 1.8.7
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.8.4
109
+ version: 1.8.7
110
110
  description: ! " A more intuitive syntax for performing a variety of file actions.
111
111
  Examples:\n \"/\".fwf_filepath.join('usr', 'bin', 'bash').touch\n FunWith::Files::FilePath.home(\"Music\").glob(:ext
112
112
  => \"mp3\", :recurse => true)\n home = FunWith::Files::FilePath.home\n home.touch(
@@ -140,6 +140,10 @@ files:
140
140
  - ./test/loadable_dir/dir2/file2.rb
141
141
  - ./test/loadable_dir/dir3/file3.rb
142
142
  - ./test/loadable_dir/dir4/file4.rb
143
+ - ./test/loadable_dir/dir5/a.rb
144
+ - ./test/loadable_dir/dir5/b.rb
145
+ - ./test/loadable_dir/dir5/c.rb
146
+ - ./test/loadable_dir/dir5/d.rb
143
147
  - ./test/test_descent.rb
144
148
  - ./test/test_directory_builder.rb
145
149
  - ./test/test_file_path.rb
@@ -167,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
171
  version: '0'
168
172
  segments:
169
173
  - 0
170
- hash: -363617118462161826
174
+ hash: 1257082353176487045
171
175
  required_rubygems_version: !ruby/object:Gem::Requirement
172
176
  none: false
173
177
  requirements: