polyglot 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.2.5 2009-03-04
2
+
3
+ * 1 significant fix:
4
+ * Polyglot's require may be called with a Pathname, or other object allowed by Kernel#require that doesn't support [] (Kernel#require uses to_str apparently)
5
+
1
6
  == 0.2.4 2008-05-29
2
7
 
3
8
  * 1 significant fix:
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.txt CHANGED
@@ -1,4 +1,9 @@
1
- Ruby Gem: Polyglot 0.2.0
1
+ = polyglot
2
+
3
+ * http://polyglot.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
2
7
  Author: Clifford Heath, 2007
3
8
 
4
9
  The Polyglot library allows a Ruby module to register a loader
@@ -10,7 +15,7 @@ appropriate to their purpose, instead of abusing the Ruby syntax.
10
15
 
11
16
  Files are sought using the normal Ruby search path.
12
17
 
13
- Example:
18
+ == EXAMPLE:
14
19
 
15
20
  In file rubyglot.rb, define and register a file type handler:
16
21
 
@@ -51,3 +56,32 @@ Run:
51
56
  Ready to go
52
57
  Hello, world
53
58
  $
59
+
60
+ == INSTALL:
61
+
62
+ sudo gem install polyglot
63
+
64
+ == LICENSE:
65
+
66
+ (The MIT License)
67
+
68
+ Copyright (c) 2007 Clifford Heath
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining
71
+ a copy of this software and associated documentation files (the
72
+ "Software"), to deal in the Software without restriction, including
73
+ without limitation the rights to use, copy, modify, merge, publish,
74
+ distribute, sublicense, and/or sell copies of the Software, and to
75
+ permit persons to whom the Software is furnished to do so, subject to
76
+ the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be
79
+ included in all copies or substantial portions of the Software.
80
+
81
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
82
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
83
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
84
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
85
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
86
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
87
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -28,16 +28,17 @@ module Polyglot
28
28
  end
29
29
 
30
30
  def self.load(*a, &b)
31
- return if @loaded[a[0]] # Check for $: changes or file time changes and reload?
31
+ file = a[0].to_str
32
+ return if @loaded[file] # Check for $: changes or file time changes and reload?
32
33
  begin
33
- source_file, loader = Polyglot.find(*a, &b)
34
+ source_file, loader = Polyglot.find(file, *a[1..-1], &b)
34
35
  if (loader)
35
36
  loader.load(source_file)
36
- @loaded[a[0]] = true
37
+ @loaded[file] = true
37
38
  else
38
- msg = "Failed to load #{a[0]} using extensions #{(@registrations.keys+["rb"]).sort*", "}"
39
+ msg = "Failed to load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}"
39
40
  if defined?(MissingSourceFile)
40
- raise MissingSourceFile.new(msg, a[0])
41
+ raise MissingSourceFile.new(msg, file)
41
42
  else
42
43
  raise LoadError.new(msg)
43
44
  end
@@ -2,7 +2,7 @@ module Polyglot #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -33,107 +33,63 @@
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.3</a>
36
+ <a href="http://rubyforge.org/projects/polyglot" class="numbers">0.2.5</a>
37
37
  </div>
38
- <h2>Poly &#x2192; many, glot &#x2192; languages</h2>
39
-
40
-
41
- <h2>What</h2>
42
-
43
-
44
- <p>Polyglot provides a registry of file types that can be loaded by
45
- calling its improved version of &#8216;require&#8217;. Each file extension
46
- that can be handled by a custom loader is registered by calling
47
- Polyglot.register(&#8220;ext&#8221;, &lt;class&gt;), and then you can simply
48
- require &#8220;somefile&#8221;, which will find and load &#8220;somefile.ext&#8221;
38
+ <h2>Poly =&gt; many, glot =&gt; languages</h2>
39
+ <h2>What</h2>
40
+ <p>Polyglot provides a registry of file types that can be loaded by<br />
41
+ calling its improved version of &#8216;require&#8217;. Each file extension<br />
42
+ that can be handled by a custom loader is registered by calling<br />
43
+ Polyglot.register(&#8220;ext&#8221;, &lt;class&gt;), and then you can simply<br />
44
+ require &#8220;somefile&#8221;, which will find and load &#8220;somefile.ext&#8221;<br />
49
45
  using your custom loader.</p>
50
-
51
-
52
- <p>This supports the creation of DSLs having a syntax that is most
46
+ <p>This supports the creation of DSLs having a syntax that is most<br />
53
47
  appropriate to their purpose, instead of abusing the Ruby syntax.</p>
54
-
55
-
56
- <p>Required files are attempted first using the normal Ruby loader,
57
- and if that fails, Polyglot conducts a search for a file having
48
+ <p>Required files are attempted first using the normal Ruby loader,<br />
49
+ and if that fails, Polyglot conducts a search for a file having<br />
58
50
  a supported extension.</p>
59
-
60
-
61
- <h2>Installing</h2>
62
-
63
-
64
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">polyglot</span></pre></p>
65
-
66
-
67
- <h2>Example</h2>
68
-
69
-
70
- <p>Define and register your file type loader in file rubyglot.rb:</p>
71
-
72
-
73
- <pre><code>require 'polyglot'
51
+ <h2>Installing</h2>
52
+ <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">polyglot</span></pre></p>
53
+ <h2>Example</h2>
54
+ <p>Define and register your file type loader in file rubyglot.rb:</p>
55
+ require &#8216;polyglot&#8217;
74
56
  class RubyglotLoader
75
- def self.load(filename, options = nil, &#38;block)
76
- File.open(filename) {|file|
77
- # Load the contents of file as Ruby code:
78
- # Implement your parser here instead!
79
- Kernel.eval(file.read)
80
- }
81
- end
57
+ def self.load(filename, options = nil, &amp;block)
58
+ File.open(filename) {|file|
59
+ # Load the contents of file as Ruby code:
60
+ # Implement your parser here instead!
61
+ Kernel.eval(file.read)
62
+ }
82
63
  end
83
- Polyglot.register("rgl", RubyglotLoader)</code></pre>
84
-
85
-
86
- <p>This file, hello.rgl, will be loaded (this simple example uses Ruby code):</p>
87
-
88
-
89
- <pre><code>puts "Initializing"
64
+ end
65
+ Polyglot.register(&#8220;rgl&#8221;, RubyglotLoader)
66
+ <p>This file, hello.rgl, will be loaded (this simple example uses Ruby code):</p>
67
+ puts &#8220;Initializing&#8221;
90
68
  class Hello
91
- def initialize()
92
- puts "Hello, world\n"
93
- end
94
- end</code></pre>
95
-
96
-
97
- <p>Call it from file test.rb:</p>
98
-
99
-
100
- <pre><code>require 'rubyglot' # Create my file type handler
101
- require 'hello' # Can add extra options or even a block here
102
- puts "Ready to go"
103
- Hello.new</code></pre>
104
-
105
-
106
- <p>Run:</p>
107
-
108
-
109
- <pre><code>$ ruby test.rb
69
+ def initialize()
70
+ puts &#8220;Hello, world\n&#8221;
71
+ end
72
+ end
73
+ <p>Call it from file test.rb:</p>
74
+ require &#8216;rubyglot&#8217; # Create my file type handler
75
+ require &#8216;hello&#8217; # Can add extra options or even a block here
76
+ puts &#8220;Ready to go&#8221;
77
+ Hello.new
78
+ <p>Run:</p>
79
+ $ ruby test.rb
110
80
  Initializing
111
81
  Ready to go
112
82
  Hello, world
113
- $</code></pre>
114
-
115
-
116
- <h2>How to submit patches</h2>
117
-
118
-
119
- <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8z-email">8z: Submit patch</a>, email me on the link below.</p>
120
-
121
-
122
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/polyglot/trunk</code> for anonymous access.</p>
123
-
124
-
125
- <h2>License</h2>
126
-
127
-
128
- <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
129
-
130
-
131
- <h2>Contact</h2>
132
-
133
-
134
- <p>Comments are welcome. Send an email to <a href="mailto:cjheath@rubyforge.org">Clifford Heath</a></p>
83
+ $
84
+ <h2>How to submit patches</h2>
85
+ <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8z-email">8z: Submit patch</a>, email me on the link below.</p>
86
+ <p>The trunk repository is <code>svn://rubyforge.org/var/svn/polyglot/trunk</code> for anonymous access.</p>
87
+ <h2>License</h2>
88
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
89
+ <h2>Contact</h2>
90
+ <p>Comments are welcome. Send an email to <a href="mailto:cjheath@rubyforge.org">Clifford Heath</a></p>
135
91
  <p class="coda">
136
- <a href="cjheath@rubyforge.org">Clifford Heath</a>, 22nd October 2007<br>
92
+ <a href="cjheath@rubyforge.org">Clifford Heath</a>, 29th January 2009<br>
137
93
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
138
94
  </p>
139
95
  </div>
@@ -1,6 +1,6 @@
1
1
  h1. polyglot
2
2
 
3
- h2. Poly &#x2192; many, glot &#x2192; languages
3
+ h2. Poly => many, glot => languages
4
4
 
5
5
 
6
6
  h2. What
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyglot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-29 00:00:00 +11:00
12
+ date: 2009-03-04 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements: []
83
83
 
84
84
  rubyforge_project: polyglot
85
- rubygems_version: 1.2.0
85
+ rubygems_version: 1.3.1
86
86
  signing_key:
87
87
  specification_version: 2
88
88
  summary: Allows custom language loaders for specified file extensions to be hooked into require