sxp 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 260eea82314284fc8e0065f50b9abf9afc054b45
4
- data.tar.gz: e9aaa797bc6234b5efa8a7b1478aee087ee38635
2
+ SHA256:
3
+ metadata.gz: 8ac25f66cc3d44ef1ea0ee37141ce092c9740ada5d58e000472043ed0e53dec7
4
+ data.tar.gz: 3969e76131d5e12a512a182ba9f03de3f1dcc098b60cd067089f0d75443117ce
5
5
  SHA512:
6
- metadata.gz: 24aaf256d61ee089bb278a57cf30695a2e5ca23eb60a0549ab310d6f3327c0cc7b1d677f53acd858dddfba4002b8933c105183d6df39ef6d65144bb805a47f6c
7
- data.tar.gz: 34a98411d37e8f0217ba2bb305f15c7bb449c2379cdfab84a67a6a598210eabdc9f6a40853264f45d9576b27b3517f5592834f8c3913046c0e74304833decb70
6
+ metadata.gz: da0445f22b06f2ed5cb31a44dd37bc4c49a078205335f420857b1105b30f1d95296254e4d7f0ce80c5d4779862f0792c45e409758c893eb0131eced633df243c
7
+ data.tar.gz: f8018ae5ffb2740cf12e0ca28f67c4f3b92dd466b0a2a2db73ed896f6fdb801a4a3148daf3c575474890db74d278ad2cecd114336fd9f85e021555456ea7393b
data/AUTHORS CHANGED
@@ -1,2 +1,2 @@
1
1
  * Arto Bendiken <arto@bendiken.net>
2
- * Gregg Kellogg <gregg@kellogg-assoc.com>
2
+ * Gregg Kellogg <gregg@greggkellogg.net>
data/README.md CHANGED
@@ -1,18 +1,169 @@
1
- #SXP.rb: S-Expressions for Ruby
1
+ # SXP.rb: S-Expressions for Ruby
2
2
 
3
3
  This is a Ruby implementation of a universal [S-expression][] parser.
4
4
 
5
- * <http://sxp.rubyforge.org/>
6
- * <http://github.com/bendiken/sxp-ruby>
5
+ [![Gem Version](https://badge.fury.io/rb/sxp.png)](https:/badge.fury.io/rb/sxp)
6
+ [![Build Status](https://github.com/dryruby/sxp.rb/workflows/CI/badge.svg?branch=develop)](https://github.com/dryruby/sxp.rb/actions?query=workflow%3ACI)
7
+ [![Coverage Status](https://coveralls.io/repos/dryruby/sxp.rb/badge.svg?branch=develop)](https://coveralls.io/r/dryruby/sxp.rb?branch=develop)
7
8
 
8
- ##Features
9
+ ## Features
9
10
 
10
11
  * Parses S-expressions in universal, [Scheme][], [Common Lisp][], or
11
12
  [SPARQL][] syntax.
12
13
  * Adds a `#to_sxp` method to Ruby objects.
13
- * Compatible with Ruby Ruby 2.x, Ruby 2.x, and JRuby 9+.
14
-
15
- ##Examples
14
+ * Compatible with Ruby >= 2.6, Rubinius >= 3.0, and JRuby 9+.
15
+
16
+ ## Basic syntax
17
+
18
+ S-Expressions derive from LISP, and include some basic datatypes common to all variants:
19
+
20
+ <dl>
21
+ <dt>Pairs</dt>
22
+ <dd>Of the form <code>(2 . 3)</code></dd>
23
+ <dt>Lists</dt>
24
+ <dd>Of the form <code>(1 (2 3))</code></dd>
25
+ <dt>Symbols</dt>
26
+ <dd>Of the form <code>with-hyphen ?@!$ a\ symbol\ with\ spaces</code></dd>
27
+ <dt>Strings</dt>
28
+ <dd>Of the form <code>"Hello, world!"</code><br/>
29
+ Strings may include the following special characters:
30
+ <ul>
31
+ <li><code>\b</code> &mdash; Backspace</li>
32
+ <li><code>\f</code> &mdash; Form Feed</li>
33
+ <li><code>\n</code> &mdash; New Line</li>
34
+ <li><code>\r</code> &mdash; Carriage Return</li>
35
+ <li><code>\t</code> &mdash; Horizontal Tab</li>
36
+ <li><code>\u<i>xxxx</i></code> &mdash; 2-byte Unicode character escape</li>
37
+ <li><code>\U<i>xxxxxxxx</i></code> &mdash; 4-byte Unicode character escape</li>
38
+ <li><code>\"</code> &mdash; Double-quote character</li>
39
+ <li><code>\\</code> &mdash; Backspace</li>
40
+ </ul>
41
+ Additionally, any other character may follow <code>\</code>, representing the character itself.
42
+ </dd>
43
+ <dt>Characters</dt>
44
+ <dd>Of the form <code>...</code></dd>
45
+ <dt>Integers</dt>
46
+ <dd>Of the form <code>-9876543210</code></dd>
47
+ <dt>Floating-point numbers</dt>
48
+ <dd>Of the form <code>-0.0 6.28318 6.022e23</code></dd>
49
+ <dt>Rationals</dt>
50
+ <dd>Of the form <code>1/3</code></dd>
51
+ </dl>
52
+
53
+ Additionally, variation-specific formats support additional datatypes:
54
+
55
+ ### Scheme
56
+
57
+ In addition to the standard datatypes, the Scheme dialect supports the following:
58
+
59
+ <dl>
60
+ <dt>Lists</dt>
61
+ <dd>In addition to <code>( ... )</code>, a square bracket pair may be used for reading lists of the form <code>[ ... ]</code>.
62
+ </dd>
63
+ <dt>Comments</dt>
64
+ <dd>A comment starts with <code>;</code> and continues to the end of the line.
65
+ <dt>Sharp character sequences</dt>
66
+ <dd>Such as <code>#t</code>, <code>#n</code>, and <code>#xXXX</code>.<br>
67
+ <ul>
68
+ <li><code>#n</code> &mdash; Null</li>
69
+ <li><code>#f</code> &mdash; False</li>
70
+ <li><code>#t</code> &mdash; True</li>
71
+ <li><code>#b<i>BBB</i></code> &mdash; Binary number</li>
72
+ <li><code>#o<i>OOO</i></code> &mdash; Octal number</li>
73
+ <li><code>#d<i>DDD</i></code> &mdash; Decimal number</li>
74
+ <li><code>#x<i>XXX</i></code> &mdash; Hexadecimal number</li>
75
+ <li><code>#\<i>C</i></code> &mdash; A single Unicode character</li>
76
+ <li><code>#\space</code> &mdash; A space character</li>
77
+ <li><code>#\newline</code> &mdash; A newline character</li>
78
+ <li><code>#;</code> &mdash; Skipped character</li>
79
+ <li><code>#!</code> &mdash; Skipped to end of line</li>
80
+ </ul>
81
+ </dd>
82
+ </dl>
83
+
84
+ ### Common Lisp
85
+
86
+ In addition to the standard datatypes, the Common Lisp dialect supports the following:
87
+
88
+ <dl>
89
+ <dt>Comments</dt>
90
+ <dd>A comment starts with <code>;</code> and continues to the end of the line.
91
+ <dt>Symbols</dt>
92
+ <dd>In addition to base symbols, any character sequence delimited by <code>|</code> is treated as a symbol.</dd>
93
+ <dt>Sharp character sequences</dt>
94
+ <dd>Such as <code>#t</code>, <code>#n</code>, and <code>#xXXX</code>.<br>
95
+ <ul>
96
+ <li><code>#b<i>BBB</i></code> &mdash; Binary number</li>
97
+ <li><code>#o<i>OOO</i></code> &mdash; Octal number</li>
98
+ <li><code>#x<i>XXX</i></code> &mdash; Hexadecimal number</li>
99
+ <li><code>#C</code> &mdash; A single Unicode character</li>
100
+ <li><code>#\newline</code> &mdash; A newline character</li>
101
+ <li><code>#\space</code> &mdash; A space character</li>
102
+ <li><code>#\backspace</code> &mdash; A backspace character</li>
103
+ <li><code>#\tab</code> &mdash; A tab character</li>
104
+ <li><code>#\linefeed</code> &mdash; A linefeed character</li>
105
+ <li><code>#\page</code> &mdash; A page feed character</li>
106
+ <li><code>#\return</code> &mdash; A carriage return character</li>
107
+ <li><code>#\rubout</code> &mdash; A rubout character</li>
108
+ <li><code>#'<i>function</i></code> &mdash; A function definition</li>
109
+ </ul>
110
+ </dd>
111
+ </dl>
112
+
113
+ ### SPARQL/RDF
114
+
115
+ In addition to the standard datatypes, the SPARQL dialect supports the following:
116
+
117
+ <dl>
118
+ <dt>Lists</dt>
119
+ <dd>In addition to <code>( ... )</code>, a square bracket pair may be used for reading lists of the form <code>[ ... ]</code>.
120
+ </dd>
121
+ <dt>Comments</dt>
122
+ <dd>A comment starts with <code>#</code> or <code>;</code> and continues to the end of the line.
123
+ <dt>Literals</dt>
124
+ <dd>Strings are interpreted as an RDF Literal with datatype <code>xsd:string</code>. It can be followed by <code>@<i>lang</i></code> to create a language-tagged string, or <code>^^<i>IRI</i></code> to create a datatyped-literal. Examples:
125
+ <ul>
126
+ <li><code>"a plain literal"</code></li>
127
+ <li><code>"a literal with a language"@en</code></li>
128
+ <li><code>"a typed literal"^^&lt;http://example/></code></li>
129
+ <li><code>"a typed literal with a PNAME"^^xsd:string</code></li>
130
+ </ul>
131
+ </dd>
132
+ <dt>IRIs</dt>
133
+ <dd>An IRI is formed as in SPARQL, either enclosed by <code>&lt;...></code>, or having the form of a <code>PNAME</code>. If a <var>base iri</var> is defined in a containing <var>base</var> expression, IRIs using the <code>&lt;...></code> are resolved against that base iri. If the <code>PNAME</code> form is used, the prefix must be defined in a containing <var>prefix</var> expression. Examples:
134
+ <ul>
135
+ <li><code>&lt;http://example/foo></code></li>
136
+ <li><code>(base &lthttp://example.com> &lt;foo>)</code></li>
137
+ <li><code>(prefix ((foo: &lt;http://example.com/>)) foo:bar)</code></li>
138
+ <li><code>a</code> # synonym for rdf:type</li>
139
+ </ul>
140
+ </dd>
141
+ <dt>Blank Nodes</dt>
142
+ <dd>An blank node is formed as in SPARQL. Examples:
143
+ <ul>
144
+ <li><code>_:</code></li>
145
+ <li><code>_:id</code></li>
146
+ </ul>
147
+ </dd>
148
+ <dt>Variables</dt>
149
+ <dd>A SPARQL variable is defined using either <code>?</code> or <code>$</code> prefixes, as in SPARQL. Examples:
150
+ <ul>
151
+ <li><code>?var</code></li>
152
+ <li><code>$var</code></li>
153
+ </ul>
154
+ </dd>
155
+ <dt>Numbers and booleans</dt>
156
+ <dd>As with SPARQL. Examples:
157
+ <ul>
158
+ <li>true, false</li>
159
+ <li>123, -18</li>
160
+ <li>123.0, 456.</li>
161
+ <li>1.0e0, 1.0E+6</li>
162
+ </ul>
163
+ </dd>
164
+ </dl>
165
+
166
+ ## Examples
16
167
 
17
168
  require 'sxp'
18
169
 
@@ -44,15 +195,15 @@ This is a Ruby implementation of a universal [S-expression][] parser.
44
195
 
45
196
  require 'rdf'
46
197
 
47
- SXP::Reader::SPARQL.read %q((base <http://ar.to/>)) #=> [:base, RDF::URI('http://ar.to/')]
198
+ SXP::Reader::SPARQL.read %q((base <https://ar.to/>)) #=> [:base, RDF::URI('https://ar.to/')]
48
199
 
49
200
  ### Writing an SXP with formatting
50
201
 
51
202
  SXP::Generator.print([:and, true, false]) #=> (and #t #f)
52
203
 
53
- ##Documentation
204
+ ## Documentation
54
205
 
55
- * <http://sxp.rubyforge.org/>
206
+ * Full documentation available on [RubyDoc](https:/rubydoc.info/gems/sxp/file/README.md)
56
207
 
57
208
  * {SXP}
58
209
 
@@ -71,62 +222,70 @@ This is a Ruby implementation of a universal [S-expression][] parser.
71
222
  ### Generating SXP
72
223
  * {SXP::Generator}
73
224
 
74
- Dependencies
75
- ------------
225
+ # Dependencies
76
226
 
77
- * [Ruby](http://ruby-lang.org/) (>= 1.9.3)
78
- * [RDF.rb](http://rubygems.org/gems/rdf) (>= 1.1), only needed for SPARQL
227
+ * [Ruby](https:/ruby-lang.org/) (>= 2.6)
228
+ * [RDF.rb](https:/rubygems.org/gems/rdf) (~> 3.2), only needed for SPARQL
79
229
  S-expressions
80
230
 
81
- Installation
82
- ------------
231
+ # Installation
83
232
 
84
- The recommended installation method is via [RubyGems](http://rubygems.org/).
233
+ The recommended installation method is via [RubyGems](https:/rubygems.org/).
85
234
  To install the latest official release of the SXP.rb gem, do:
86
235
 
87
236
  % [sudo] gem install sxp
88
237
 
89
- Download
90
- --------
238
+ ## Download
91
239
 
92
240
  To get a local working copy of the development repository, do:
93
241
 
94
- % git clone git://github.com/bendiken/sxp-ruby.git
242
+ % git clone git://github.com/dryruby/sxp.rb.git
95
243
 
96
244
  Alternatively, you can download the latest development version as a tarball
97
245
  as follows:
98
246
 
99
- % wget http://github.com/bendiken/sxp-ruby/tarball/master
247
+ % wget https:/github.com/dryruby/sxp.rb/tarball/master
100
248
 
101
- Resources
102
- ---------
249
+ ## Resources
103
250
 
104
- * <http://sxp.rubyforge.org/>
105
- * <http://github.com/bendiken/sxp>
106
- * <http://github.com/bendiken/sxp-ruby>
107
- * <http://rubygems.org/gems/sxp>
108
- * <http://rubyforge.org/projects/sxp/>
109
- * <http://raa.ruby-lang.org/project/sxp>
251
+ * <https://rubydoc.info/gems/sxp.rb>
252
+ * <https://github.com/dryruby/sxp.rb>
253
+ * <https://rubygems.org/gems/sxp.rb>
110
254
 
111
- Authors
112
- -------
255
+ ## Authors
113
256
 
114
- * [Arto Bendiken](https://github.com/bendiken) - <http://ar.to/>
115
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
257
+ * [Arto Bendiken](https://github.com/artob) - <https://ar.to/>
258
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
116
259
 
117
- Contributors
118
- ------------
260
+ ## Contributors
119
261
 
120
- * [Ben Lavender](https://github.com/bhuga) - <http://bhuga.net/>
262
+ * [Ben Lavender](https://github.com/bhuga) - <https://bhuga.net/>
121
263
 
122
- License
123
- -------
264
+ ## Contributing
265
+ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
124
266
 
125
- SXP.rb is free and unencumbered public domain software. For more
126
- information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
267
+ * Do your best to adhere to the existing coding conventions and idioms.
268
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
269
+ * Do document every method you add using [YARD][] annotations. Read the
270
+ [tutorial][YARD-GS] or just look at the existing code for examples.
271
+ * Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
272
+ change them, do so on your private branch only.
273
+ * Do feel free to add yourself to the `CREDITS` file and the corresponding
274
+ list in the the `README`. Alphabetical order applies.
275
+ * Do note that in order for us to merge any non-trivial changes (as a rule
276
+ of thumb, additions larger than about 15 lines of code), we need an
277
+ explicit [public domain dedication][PDD] on record from you,
278
+ which you will be asked to agree to on the first commit to a repo within the organization.
127
279
 
128
- [S-expression]: http://en.wikipedia.org/wiki/S-expression
129
- [Scheme]: http://scheme.info/
130
- [Common Lisp]: http://en.wikipedia.org/wiki/Common_Lisp
131
- [SPARQL]: http://openjena.org/wiki/SSE
132
- [Backports]: http://rubygems.org/gems/backports
280
+ ## License
281
+
282
+ SXP.rb is free and unencumbered public domain software. For more
283
+ information, see <https://unlicense.org/> or the accompanying UNLICENSE file.
284
+
285
+ [S-expression]: https://en.wikipedia.org/wiki/S-expression
286
+ [Scheme]: https://scheme.info/
287
+ [Common Lisp]: https://en.wikipedia.org/wiki/Common_Lisp
288
+ [SPARQL]: https://jena.apache.org/documentation/notes/sse.html
289
+ [YARD]: https://yardoc.org/
290
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
291
+ [PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
data/UNLICENSE CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- For more information, please refer to <http://unlicense.org/>
24
+ For more information, please refer to <https:/unlicense.org/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.2.0
data/bin/sxp2json CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby -rubygems
2
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
1
+ #!/usr/bin/env ruby
2
+ $::unshift(File.expand_path("../../lib", __FILE__))
3
3
  require 'sxp'
4
4
 
5
5
  abort "Usage: #{File.basename($0)} input.sxp > output.json" if ARGV.empty?
data/bin/sxp2rdf CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby -rubygems
2
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
1
+ #!/usr/bin/env ruby
2
+ $::unshift(File.expand_path("../../lib", __FILE__))
3
3
  require 'sxp'
4
4
 
5
5
  abort "Usage: #{File.basename($0)} input.sxp > output.rdf" if ARGV.empty?
data/bin/sxp2xml CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby -rubygems
2
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
1
+ #!/usr/bin/env ruby
2
+ $::unshift(File.expand_path("../../lib", __FILE__))
3
3
  require 'sxp'
4
4
 
5
5
  abort "Usage: #{File.basename($0)} input.sxp > output.xml" if ARGV.empty?
data/bin/sxp2yaml CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby -rubygems
2
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
1
+ #!/usr/bin/env ruby
2
+ $::unshift(File.expand_path("../../lib", __FILE__))
3
3
  require 'sxp'
4
4
 
5
5
  abort "Usage: #{File.basename($0)} input.sxp > output.yaml" if ARGV.empty?