polyglot 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  module Polyglot
4
- @registrations ||= {} # Guard against reloading
4
+ @registrations ||= {} # Guard against reloading
5
5
  @loaded ||= {}
6
6
 
7
7
  def self.register(extension, klass)
@@ -13,12 +13,15 @@ module Polyglot
13
13
 
14
14
  def self.find(file, *options, &block)
15
15
  extensions = @registrations.keys*","
16
- $:.each{|lib|
17
- matches = Dir[lib+"/"+file+".{"+extensions+"}"]
16
+ is_absolute = file[0] == File::SEPARATOR || file[0] == File::ALT_SEPARATOR || file =~ /\A[A-Z]:\\/i
17
+ (is_absolute ? [""] : $:).each{|lib|
18
+ base = is_absolute ? "" : lib+File::SEPARATOR
19
+ # In Windows, repeated SEPARATOR chars have a special meaning, avoid adding them
20
+ matches = Dir[base+file+".{"+extensions+"}"]
18
21
  # Revisit: Should we do more do if more than one candidate found?
19
22
  $stderr.puts "Polyglot: found more than one candidate for #{file}: #{matches*", "}" if matches.size > 1
20
23
  if path = matches[0]
21
- return [ path, @registrations[path.gsub(/.*\./,'')]]
24
+ return [ path, @registrations[path.gsub(/.*\./,'')]]
22
25
  end
23
26
  }
24
27
  return nil
@@ -29,10 +32,10 @@ module Polyglot
29
32
  begin
30
33
  source_file, loader = Polyglot.find(*a, &b)
31
34
  if (loader)
32
- loader.load(source_file)
33
- @loaded[a[0]] = true
35
+ loader.load(source_file)
36
+ @loaded[a[0]] = true
34
37
  else
35
- raise LoadError
38
+ raise LoadError.new("Polyglot failed to load '#{a[0]}' either directly or using extensions #{@registrations.keys.sort.inspect}")
36
39
  end
37
40
  end
38
41
  end
@@ -2,7 +2,7 @@ module Polyglot #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
File without changes
File without changes
File without changes
@@ -33,7 +33,7 @@
33
33
  <h1>polyglot</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/polyglot"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/polyglot" class="numbers">0.2.0</a>
36
+ <a href="http://rubyforge.org/projects/polyglot" class="numbers">0.2.2</a>
37
37
  </div>
38
38
  <h2>Poly &#x2192; many, glot &#x2192; languages</h2>
39
39
 
metadata CHANGED
@@ -1,33 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: polyglot
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2008-03-05 00:00:00 +11:00
8
- summary: Allows custom language loaders for specified file extensions to be hooked into require
9
- require_paths:
10
- - lib
11
- email: cjheath@rubyforge.org
12
- homepage: http://polyglot.rubyforge.org
13
- rubyforge_project: polyglot
14
- description: Allows custom language loaders for specified file extensions to be hooked into require
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.2.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Clifford Heath
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-12 00:00:00 +10:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Allows custom language loaders for specified file extensions to be hooked into require
17
+ email: cjheath@rubyforge.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - History.txt
24
+ - License.txt
25
+ - Manifest.txt
26
+ - README.txt
27
+ - website/index.txt
31
28
  files:
32
29
  - History.txt
33
30
  - License.txt
@@ -53,23 +50,33 @@ files:
53
50
  - website/javascripts/rounded_corners_lite.inc.js
54
51
  - website/stylesheets/screen.css
55
52
  - website/template.rhtml
56
- test_files:
57
- - test/test_helper.rb
58
- - test/test_polyglot.rb
53
+ has_rdoc: true
54
+ homepage: http://polyglot.rubyforge.org
55
+ post_install_message:
59
56
  rdoc_options:
60
57
  - --main
61
58
  - README.txt
62
- extra_rdoc_files:
63
- - History.txt
64
- - License.txt
65
- - Manifest.txt
66
- - README.txt
67
- - website/index.txt
68
- executables: []
69
-
70
- extensions: []
71
-
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
72
73
  requirements: []
73
74
 
74
- dependencies: []
75
-
75
+ rubyforge_project: polyglot
76
+ rubygems_version: 1.1.0
77
+ signing_key:
78
+ specification_version: 2
79
+ summary: Allows custom language loaders for specified file extensions to be hooked into require
80
+ test_files:
81
+ - test/test_helper.rb
82
+ - test/test_polyglot.rb