polyglot 0.1.0 → 0.2.0

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,3 +1,8 @@
1
+ == 0.2.0 2008-02-13
2
+
3
+ * 1 major enhancement:
4
+ * Doesn't reload on every require
5
+
1
6
  == 0.1.0 2007-10-22
2
7
 
3
8
  * 1 major enhancement:
data/README.txt CHANGED
@@ -1,4 +1,4 @@
1
- Ruby Gem: Polyglot 0.1.0
1
+ Ruby Gem: Polyglot 0.2.0
2
2
  Author: Clifford Heath, 2007
3
3
 
4
4
  The Polyglot library allows a Ruby module to register a loader
@@ -58,14 +58,14 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
58
58
  p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
59
 
60
60
  # == Optional
61
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
61
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
62
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
63
 
64
64
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
65
 
66
66
  end
67
67
 
68
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
69
69
  PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
70
  hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
71
71
  hoe.rsync_args = '-av --delete --ignore-errors'
@@ -2,6 +2,7 @@ $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  module Polyglot
4
4
  @registrations ||= {} # Guard against reloading
5
+ @loaded ||= {}
5
6
 
6
7
  def self.register(extension, klass)
7
8
  extension = [extension] unless Enumerable === extension
@@ -22,21 +23,27 @@ module Polyglot
22
23
  }
23
24
  return nil
24
25
  end
25
- end
26
-
27
- module Kernel
28
- alias polyglot_original_require require
29
26
 
30
- def require(*a, &b)
31
- polyglot_original_require(*a, &b)
32
- rescue LoadError => load_error
27
+ def self.load(*a, &b)
28
+ return if @loaded[a[0]] # Check for $: changes or file time changes and reload?
33
29
  begin
34
30
  source_file, loader = Polyglot.find(*a, &b)
35
31
  if (loader)
36
32
  loader.load(source_file)
33
+ @loaded[a[0]] = true
37
34
  else
38
35
  raise load_error
39
36
  end
40
37
  end
41
38
  end
42
39
  end
40
+
41
+ module Kernel
42
+ alias polyglot_original_require require
43
+
44
+ def require(*a, &b)
45
+ polyglot_original_require(*a, &b)
46
+ rescue LoadError => load_error
47
+ Polyglot.load(*a, &b)
48
+ end
49
+ end
@@ -1,7 +1,7 @@
1
1
  module Polyglot #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
4
+ MINOR = 2
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -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.1.0</a>
36
+ <a href="http://rubyforge.org/projects/polyglot" class="numbers">0.2.0</a>
37
37
  </div>
38
38
  <h2>Poly &#x2192; many, glot &#x2192; languages</h2>
39
39
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyglot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- platform: ""
4
+ version: 0.2.0
5
+ platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-03 00:00:00 +11:00
12
+ date: 2008-02-13 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements: []
74
74
 
75
75
  rubyforge_project: polyglot
76
- rubygems_version: 0.9.5
76
+ rubygems_version: 1.0.1
77
77
  signing_key:
78
78
  specification_version: 2
79
79
  summary: Allows custom language loaders for specified file extensions to be hooked into require