jsony 0.0.1
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.
- data/.gemspec +23 -0
- data/CHANGELOG.yaml +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +18 -0
- data/LICENSE +21 -0
- data/README.rdoc +86 -0
- data/Rakefile +64 -0
- data/ToDo +9 -0
- data/lib/jsony.rb +14 -0
- data/lib/jsony/grammar.rb +89 -0
- data/lib/jsony/receiver.rb +45 -0
- data/share/jsony.pgx +88 -0
- data/test/decode.rb +176 -0
- data/test/lib/test_helper.rb +10 -0
- metadata +98 -0
data/.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
GemSpec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'jsony'
|
5
|
+
gem.version = '0.0.1'
|
6
|
+
gem.license = 'MIT'
|
7
|
+
gem.required_ruby_version = '>= 1.9.1'
|
8
|
+
|
9
|
+
gem.authors << 'Ingy döt Net'
|
10
|
+
gem.email = 'ingy@ingy.net'
|
11
|
+
gem.summary = 'Relaxed JSON with a little bit of YAML'
|
12
|
+
gem.description = <<-'.'
|
13
|
+
JSONY is a data language that is simlar to JSON, just more chill. All valid
|
14
|
+
JSON is also valid JSONY (and represents the same thing when decoded), but
|
15
|
+
JSONY lets you omit a lot of the syntax that makes JSON a pain to write.
|
16
|
+
.
|
17
|
+
gem.homepage = 'http://jsony.org'
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.lines.map{|l|l.chomp}
|
20
|
+
|
21
|
+
gem.add_dependency 'pegex', '>= 0.0.2'
|
22
|
+
gem.add_development_dependency 'testml-lite', '>= 0.0.1'
|
23
|
+
end
|
data/CHANGELOG.yaml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright © 2012 Ingy döt Net
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the ‘Software’), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= JSONY - Relaxed JSON with a little bit of YAML
|
2
|
+
|
3
|
+
= Synopsis
|
4
|
+
|
5
|
+
require 'jsony'
|
6
|
+
|
7
|
+
data = JSONY.load jsony_string
|
8
|
+
|
9
|
+
= Description
|
10
|
+
|
11
|
+
JSONY is a data language that is simlar to JSON, just more chill. All valid
|
12
|
+
JSON is also valid JSONY (and represents the same thing when loaded), but
|
13
|
+
JSONY lets you omit a lot of the syntax that makes JSON a pain to write.
|
14
|
+
|
15
|
+
= API
|
16
|
+
|
17
|
+
JSONY has one method +JSON.load+. You pass it a JSONY string and it returns the
|
18
|
+
decoded Ruby data object.
|
19
|
+
|
20
|
+
Note: JSONY is basically hand-written format, so to serialize it back to disk
|
21
|
+
you can just use the JSON dump serialization (for now), and it will round-trip
|
22
|
+
safely.
|
23
|
+
|
24
|
+
= JSONY Syntax
|
25
|
+
|
26
|
+
Here is some examples of JSONY followed by equivalent JSON:
|
27
|
+
|
28
|
+
Words don't need quotes. A list of things is an array:
|
29
|
+
|
30
|
+
foo bar baz
|
31
|
+
|
32
|
+
[ "foo", "bar", "baz" ]
|
33
|
+
|
34
|
+
Strings with spaces can use single or double quotes:
|
35
|
+
|
36
|
+
'foo bar' # <= This is (a comment indicating) a string
|
37
|
+
# More commenting
|
38
|
+
"baz boom "
|
39
|
+
|
40
|
+
[ "foo bar ", "baz boom " ]
|
41
|
+
|
42
|
+
Top level hashes can either use ':' separated pairs or use curlies. Sub-hashes
|
43
|
+
require curlies.
|
44
|
+
|
45
|
+
foo: { bar baz }
|
46
|
+
num: -1.2e3
|
47
|
+
|
48
|
+
{ "foo": { "bar": "baz" }, "num": -1.2e3 }
|
49
|
+
|
50
|
+
Top level arrays can use +'- '+ at the start of lines. Those arrays go the
|
51
|
+
end of line. Lines can be continued using a trailing comma. Sub arrays require
|
52
|
+
square brackets.
|
53
|
+
|
54
|
+
- array of 4 scalars
|
55
|
+
- array with [ sub
|
56
|
+
array { of
|
57
|
+
things }]
|
58
|
+
- array of 7 things on,
|
59
|
+
two lines
|
60
|
+
|
61
|
+
[
|
62
|
+
[ "array", "of", 4, "scalars" ],
|
63
|
+
[ "array", "with", [ "sub", "array" { "of", "things" } ] ],
|
64
|
+
[ "array", "of", 7, "things", on, "two", "lines" ]
|
65
|
+
]
|
66
|
+
|
67
|
+
More soon...
|
68
|
+
|
69
|
+
NOTE: You may want to look at the tests (especially +test/decode.rb+) to see
|
70
|
+
the full abilities of JSONY.
|
71
|
+
|
72
|
+
= Status
|
73
|
+
|
74
|
+
*BEWARE!!!*
|
75
|
+
|
76
|
+
JSONY is mst's idea, and ingy's Pegex-based implementation. The language is
|
77
|
+
just a baby, and will change a lot, or may go away entirely.
|
78
|
+
|
79
|
+
Development people are currently working on this in +#jsony+ in
|
80
|
+
irc.freenode.net. Please drop by.
|
81
|
+
|
82
|
+
http://jsony.org/ coming soon.
|
83
|
+
|
84
|
+
= Copyright
|
85
|
+
|
86
|
+
Copyright (c) 2012 Ingy döt Net. See LICENSE for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Load Gem constants from the gemspec
|
2
|
+
GemSpecFile = '.gemspec'
|
3
|
+
load GemSpecFile
|
4
|
+
GemName = GemSpec.name
|
5
|
+
GemVersion = GemSpec.version
|
6
|
+
GemDir = "#{GemName}-#{GemVersion}"
|
7
|
+
GemFile = "#{GemDir}.gem"
|
8
|
+
DevNull = '2>/dev/null'
|
9
|
+
|
10
|
+
# Require the Rake libraries
|
11
|
+
require 'rake'
|
12
|
+
require 'rake/testtask'
|
13
|
+
require 'rake/clean'
|
14
|
+
|
15
|
+
task :default => 'help'
|
16
|
+
|
17
|
+
CLEAN.include GemDir, GemFile, 'data.tar.gz', 'metadata.gz'
|
18
|
+
|
19
|
+
desc 'Run the tests'
|
20
|
+
task :test do
|
21
|
+
Rake::TestTask.new do |t|
|
22
|
+
t.verbose = true
|
23
|
+
t.test_files = FileList['test/*.rb']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Build the gem'
|
28
|
+
task :build => [:clean, :test] do
|
29
|
+
sh "gem build #{GemSpecFile}"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Install the gem'
|
33
|
+
task :install => [:build] do
|
34
|
+
sh "gem install #{GemFile}"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Build, unpack and inspect the gem'
|
38
|
+
task :distdir => [:build] do
|
39
|
+
sh "tar xf #{GemFile} #{DevNull}"
|
40
|
+
Dir.mkdir GemDir
|
41
|
+
Dir.chdir GemDir
|
42
|
+
sh "tar xzf ../data.tar.gz #{DevNull}"
|
43
|
+
puts "\n>>> Entering sub-shell for #{GemDir}..."
|
44
|
+
system ENV['SHELL']
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Build and push the gem'
|
48
|
+
task :release => [:build] do
|
49
|
+
sh "gem push #{GemFile}"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'Print a description of the gem'
|
53
|
+
task :desc do
|
54
|
+
puts "Gem: '#{GemName}' (version #{GemVersion})"
|
55
|
+
puts
|
56
|
+
puts GemSpec.description.gsub /^/, ' '
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'List the Rakefile tasks'
|
60
|
+
task :help do
|
61
|
+
puts 'The following rake tasks are available:'
|
62
|
+
puts
|
63
|
+
puts `rake -T`.gsub /^/, ' '
|
64
|
+
end
|
data/ToDo
ADDED
data/lib/jsony.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'jsony/grammar'
|
2
|
+
require 'jsony/receiver'
|
3
|
+
require 'pegex/parser'
|
4
|
+
|
5
|
+
module JSONY
|
6
|
+
def self.load jsony_str
|
7
|
+
parser = Pegex::Parser.new do |p|
|
8
|
+
p.grammar = JSONY::Grammar.new
|
9
|
+
p.receiver = JSONY::Receiver.new
|
10
|
+
end
|
11
|
+
# parser.debug = true
|
12
|
+
parser.parse jsony_str
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module JSONY;end
|
2
|
+
require 'pegex/grammar'
|
3
|
+
class JSONY::Grammar < Pegex::Grammar
|
4
|
+
def make_tree
|
5
|
+
{"+toprule"=>"jsony",
|
6
|
+
"+grammar"=>"jsony",
|
7
|
+
"+version"=>"0.0.1",
|
8
|
+
"jsony"=>
|
9
|
+
{".any"=>
|
10
|
+
[{".ref"=>"seq"},
|
11
|
+
{".ref"=>"map"},
|
12
|
+
{".ref"=>"top_seq"},
|
13
|
+
{".ref"=>"top_map"},
|
14
|
+
{".ref"=>"list"}]},
|
15
|
+
"seq"=>
|
16
|
+
{".all"=>
|
17
|
+
[{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
18
|
+
{".ref"=>"LSQUARE"},
|
19
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
20
|
+
{".ref"=>"node",
|
21
|
+
"+min"=>0,
|
22
|
+
".sep"=>
|
23
|
+
{".rgx"=>
|
24
|
+
"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*,?(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*",
|
25
|
+
"+eok"=>true}},
|
26
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
27
|
+
{".ref"=>"RSQUARE"},
|
28
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"}]},
|
29
|
+
"LSQUARE"=>{".rgx"=>"\\["},
|
30
|
+
"node"=>{".any"=>[{".ref"=>"map"}, {".ref"=>"seq"}, {".ref"=>"scalar"}]},
|
31
|
+
"map"=>
|
32
|
+
{".all"=>
|
33
|
+
[{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
34
|
+
{".ref"=>"LCURLY"},
|
35
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
36
|
+
{".ref"=>"pair", "+min"=>0},
|
37
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
38
|
+
{".ref"=>"RCURLY"},
|
39
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"}]},
|
40
|
+
"LCURLY"=>{".rgx"=>"\\{"},
|
41
|
+
"pair"=>
|
42
|
+
{".all"=>
|
43
|
+
[{".ref"=>"string"},
|
44
|
+
{".rgx"=>
|
45
|
+
"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*:?(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
46
|
+
{".ref"=>"node"},
|
47
|
+
{".rgx"=>
|
48
|
+
"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*,?(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"}]},
|
49
|
+
"string"=>{".ref"=>"scalar"},
|
50
|
+
"scalar"=>
|
51
|
+
{".any"=>[{".ref"=>"double"}, {".ref"=>"single"}, {".ref"=>"bare"}]},
|
52
|
+
"double"=>
|
53
|
+
{".rgx"=>
|
54
|
+
"\"((?:\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})|[^\"\\x00-\\x1f])*)\""},
|
55
|
+
"single"=>{".rgx"=>"'([^']*)'"},
|
56
|
+
"bare"=>{".rgx"=>"([^\\s\\{\\}\\[\\]'\",]*[^\\s\\{\\}\\[\\]'\",:])"},
|
57
|
+
"RCURLY"=>{".rgx"=>"\\}"},
|
58
|
+
"RSQUARE"=>{".rgx"=>"\\]"},
|
59
|
+
"top_seq"=>{".ref"=>"top_seq_entry", "+min"=>1},
|
60
|
+
"top_seq_entry"=>
|
61
|
+
{".all"=>
|
62
|
+
[{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*\\-\\ +"},
|
63
|
+
{".all"=>
|
64
|
+
[{".ref"=>"node",
|
65
|
+
"+min"=>0,
|
66
|
+
".sep"=>
|
67
|
+
{".rgx"=>
|
68
|
+
"(?:\\ *,\\ *\\r?\\n(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*|\\ +)",
|
69
|
+
"+eok"=>true}},
|
70
|
+
{".any"=>[{".ref"=>"comment"}, {".ref"=>"EOL"}]}]}]},
|
71
|
+
"comment"=>{".rgx"=>"(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n)"},
|
72
|
+
"EOL"=>{".rgx"=>"\\r?\\n"},
|
73
|
+
"top_map"=>
|
74
|
+
{".all"=>
|
75
|
+
[{".ref"=>"string"},
|
76
|
+
{".rgx"=>
|
77
|
+
"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*:(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"},
|
78
|
+
{".ref"=>"node"},
|
79
|
+
{".rgx"=>"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*"}],
|
80
|
+
"+min"=>1},
|
81
|
+
"list"=>
|
82
|
+
{".ref"=>"node",
|
83
|
+
"+min"=>0,
|
84
|
+
".sep"=>
|
85
|
+
{".rgx"=>
|
86
|
+
"(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*,?(?:\\s|(?:\\#\\ .*\\r?\\n|\\#\\r?\\n|\\ *\\r?\\n))*",
|
87
|
+
"+eok"=>true}}}
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'pegex/tree'
|
2
|
+
|
3
|
+
class JSONY::Receiver < Pegex::Tree
|
4
|
+
def got_top_seq_entry got
|
5
|
+
got[0][0]
|
6
|
+
end
|
7
|
+
|
8
|
+
def got_top_map got
|
9
|
+
got_map [got]
|
10
|
+
end
|
11
|
+
|
12
|
+
def got_seq got
|
13
|
+
got[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def got_map got
|
17
|
+
Hash[got[0]]
|
18
|
+
end
|
19
|
+
|
20
|
+
def got_string got
|
21
|
+
got.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def got_bare got
|
25
|
+
case got
|
26
|
+
when 'true' # XXX is it a bug in jsony-pm that it's unanchored
|
27
|
+
true
|
28
|
+
when 'false'
|
29
|
+
false
|
30
|
+
when 'null'
|
31
|
+
'fake-nil'
|
32
|
+
# TODO golf this \ if possible
|
33
|
+
when \
|
34
|
+
/^(
|
35
|
+
-?
|
36
|
+
(?: 0 | [1-9] [0-9]* )
|
37
|
+
(?: \. [0-9]* )?
|
38
|
+
(?: [eE] [\-\+]? [0-9]+ )?
|
39
|
+
)$/x
|
40
|
+
got.to_i
|
41
|
+
else
|
42
|
+
got.to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/share/jsony.pgx
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
%grammar jsony
|
2
|
+
%version 0.0.1
|
3
|
+
|
4
|
+
jsony:
|
5
|
+
seq | map | top_seq | top_map | list
|
6
|
+
|
7
|
+
node: map | seq | scalar
|
8
|
+
|
9
|
+
map:
|
10
|
+
~LCURLY~
|
11
|
+
pair*
|
12
|
+
~RCURLY~
|
13
|
+
|
14
|
+
pair: string /~<COLON>?~/ node /~<COMMA>?~/
|
15
|
+
|
16
|
+
seq:
|
17
|
+
~LSQUARE~
|
18
|
+
node* %% /~<COMMA>?~/
|
19
|
+
~RSQUARE~
|
20
|
+
|
21
|
+
top_seq: top_seq_entry+
|
22
|
+
|
23
|
+
top_seq_entry:
|
24
|
+
/~ <DASH> <SPACE>+ /
|
25
|
+
(
|
26
|
+
node* %% / (: <SPACE>* <COMMA> <SPACE>* <EOL> ~ | <SPACE>+ ) /
|
27
|
+
( <comment> | <EOL> )
|
28
|
+
)
|
29
|
+
|
30
|
+
top_map:
|
31
|
+
(string /~<COLON>~/ node ~)+
|
32
|
+
|
33
|
+
list: node* %% /~<COMMA>?~/
|
34
|
+
|
35
|
+
scalar: double | single | bare
|
36
|
+
|
37
|
+
string: scalar
|
38
|
+
|
39
|
+
# Interpretation of http://www.json.org/
|
40
|
+
double: /
|
41
|
+
<DOUBLE>
|
42
|
+
(
|
43
|
+
(:
|
44
|
+
<BACK> (: # Backslash escapes
|
45
|
+
[
|
46
|
+
<DOUBLE> # Double Quote
|
47
|
+
<BACK> # Back Slash
|
48
|
+
<SLASH> # Foreward Slash
|
49
|
+
b # Back Space
|
50
|
+
f # Form Feed
|
51
|
+
n # New Line
|
52
|
+
r # Carriage Return
|
53
|
+
t # Horizontal Tab
|
54
|
+
]
|
55
|
+
|
|
56
|
+
u <HEX>{4} # Unicode octet pair
|
57
|
+
)
|
58
|
+
|
|
59
|
+
[^ <DOUBLE> <CONTROLS> ] # Anything else
|
60
|
+
)*
|
61
|
+
)
|
62
|
+
<DOUBLE>
|
63
|
+
/
|
64
|
+
|
65
|
+
# TODO: Support '' as escape for single quote
|
66
|
+
single: /
|
67
|
+
<SINGLE>
|
68
|
+
([^ <SINGLE> ]*)
|
69
|
+
<SINGLE>
|
70
|
+
/
|
71
|
+
|
72
|
+
bare: /( [^ <excludes> ]* [^ <excludes> <COLON> ] )/
|
73
|
+
|
74
|
+
excludes: /
|
75
|
+
<WS>
|
76
|
+
<LCURLY><RCURLY>
|
77
|
+
<LSQUARE><RSQUARE>
|
78
|
+
<SINGLE><DOUBLE>
|
79
|
+
<COMMA>
|
80
|
+
/
|
81
|
+
|
82
|
+
ws: /(: <WS> | <comment> )/
|
83
|
+
|
84
|
+
comment: /(:
|
85
|
+
<HASH> <SPACE> <ANY>* <EOL> |
|
86
|
+
<HASH> <EOL> |
|
87
|
+
<SPACE>* <EOL>
|
88
|
+
)/
|
data/test/decode.rb
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
require './test/lib/test_helper'
|
2
|
+
|
3
|
+
TestML.run do |t|
|
4
|
+
# Make sure the JSONY parses to what we expect:
|
5
|
+
t.eval '*jsony.jsony_load.String == *json.json_load.String'
|
6
|
+
|
7
|
+
# Make sure JSONY parses the JSON form the same as a JSON parser:
|
8
|
+
t.eval '*json.jsony_load.String == *json.json_load.String'
|
9
|
+
end
|
10
|
+
|
11
|
+
TestML.data <<'.'
|
12
|
+
#%TestML 1.0
|
13
|
+
#
|
14
|
+
## Make sure the JSONY parses to what we expect:
|
15
|
+
#*jsony.jsony_load.String == *json.json_load.String;
|
16
|
+
#
|
17
|
+
## Make sure JSONY parses the JSON form the same as a JSON parser:
|
18
|
+
#*json.jsony_load.String == *json.json_load.String;
|
19
|
+
|
20
|
+
=== String splitting 1
|
21
|
+
--- jsony: foo bar baz
|
22
|
+
--- json: [ "foo", "bar", "baz" ]
|
23
|
+
|
24
|
+
=== String splitting 2
|
25
|
+
--- jsony
|
26
|
+
foo bar
|
27
|
+
baz
|
28
|
+
--- json: [ "foo", "bar", "baz" ]
|
29
|
+
|
30
|
+
=== String splitting 3
|
31
|
+
--- jsony: foo "bar baz"
|
32
|
+
--- json: [ "foo", "bar baz" ]
|
33
|
+
|
34
|
+
=== Number conversion
|
35
|
+
--- jsony: foo 3 bar
|
36
|
+
--- json: [ "foo", 3, "bar" ]
|
37
|
+
|
38
|
+
=== Specials
|
39
|
+
--- SKIP
|
40
|
+
--- jsony: one true two false three null
|
41
|
+
--- json: [ "one", true, "two", false, "three", null ]
|
42
|
+
|
43
|
+
=== Object 1
|
44
|
+
--- jsony
|
45
|
+
{ foo bar baz 1 }
|
46
|
+
--- json
|
47
|
+
{
|
48
|
+
"foo": "bar",
|
49
|
+
"baz": 1
|
50
|
+
}
|
51
|
+
|
52
|
+
=== Object 2
|
53
|
+
--- jsony
|
54
|
+
plugin Server {
|
55
|
+
host example.com
|
56
|
+
port 8080
|
57
|
+
}
|
58
|
+
plugin Frobnicator {
|
59
|
+
harder true
|
60
|
+
}
|
61
|
+
--- json
|
62
|
+
[
|
63
|
+
"plugin", "Server", {
|
64
|
+
"host": "example.com",
|
65
|
+
"port": 8080
|
66
|
+
},
|
67
|
+
"plugin", "Frobnicator", {
|
68
|
+
"harder": true
|
69
|
+
}
|
70
|
+
]
|
71
|
+
|
72
|
+
=== Log line example
|
73
|
+
--- jsony
|
74
|
+
2012-09-10T17:00:34 /users/bob/edit { user admin }
|
75
|
+
--- json
|
76
|
+
[ "2012-09-10T17:00:34", "/users/bob/edit", { "user": "admin" } ]
|
77
|
+
|
78
|
+
=== Config file example
|
79
|
+
--- jsony
|
80
|
+
plugin Server {
|
81
|
+
host example.com
|
82
|
+
port 8080
|
83
|
+
}
|
84
|
+
dsn "dbi:SQLite:filename=my.db"
|
85
|
+
allow hosts [ jules sherlock kitty ]
|
86
|
+
|
87
|
+
--- json
|
88
|
+
[
|
89
|
+
"plugin", "Server", {
|
90
|
+
"host": "example.com",
|
91
|
+
"port": 8080
|
92
|
+
},
|
93
|
+
"dsn", "dbi:SQLite:filename=my.db",
|
94
|
+
"allow", "hosts", [ "jules", "sherlock", "kitty" ]
|
95
|
+
]
|
96
|
+
|
97
|
+
=== activitystrea.ms example
|
98
|
+
--- jsony
|
99
|
+
{
|
100
|
+
published 2011-02-10T15:04:55Z
|
101
|
+
actor {
|
102
|
+
url http://example.org/martin
|
103
|
+
objectType person
|
104
|
+
id 'tag:example.org,2011:martin'
|
105
|
+
image {
|
106
|
+
url http://example.org/martin/image
|
107
|
+
width 250
|
108
|
+
height 250
|
109
|
+
}
|
110
|
+
displayName "Martin Smith"
|
111
|
+
}
|
112
|
+
verb post
|
113
|
+
object {
|
114
|
+
url http://example.org/blog/2011/02/entry
|
115
|
+
id 'tag:example.org,2011:abc123/xyz'
|
116
|
+
}
|
117
|
+
target {
|
118
|
+
url http://example.org/blog/
|
119
|
+
objectType blog
|
120
|
+
id 'tag:example.org,2011:abc123'
|
121
|
+
displayName "Martin's Blog"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
--- json
|
126
|
+
{
|
127
|
+
"published": "2011-02-10T15:04:55Z",
|
128
|
+
"actor": {
|
129
|
+
"url": "http://example.org/martin",
|
130
|
+
"objectType" : "person",
|
131
|
+
"id": "tag:example.org,2011:martin",
|
132
|
+
"image": {
|
133
|
+
"url": "http://example.org/martin/image",
|
134
|
+
"width": 250,
|
135
|
+
"height": 250
|
136
|
+
},
|
137
|
+
"displayName": "Martin Smith"
|
138
|
+
},
|
139
|
+
"verb": "post",
|
140
|
+
"object" : {
|
141
|
+
"url": "http://example.org/blog/2011/02/entry",
|
142
|
+
"id": "tag:example.org,2011:abc123/xyz"
|
143
|
+
},
|
144
|
+
"target" : {
|
145
|
+
"url": "http://example.org/blog/",
|
146
|
+
"objectType": "blog",
|
147
|
+
"id": "tag:example.org,2011:abc123",
|
148
|
+
"displayName": "Martin's Blog"
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
=== Comments
|
153
|
+
--- jsony
|
154
|
+
foo bar # comment
|
155
|
+
\# Comment
|
156
|
+
url http://xyz.com#not_comment
|
157
|
+
--- json
|
158
|
+
[
|
159
|
+
"foo",
|
160
|
+
"bar",
|
161
|
+
"url",
|
162
|
+
"http://xyz.com#not_comment"
|
163
|
+
]
|
164
|
+
|
165
|
+
=== Top Level Mapping
|
166
|
+
--- jsony
|
167
|
+
foo: bar
|
168
|
+
baz: 42
|
169
|
+
--- json: {"foo": "bar", "baz": 42}
|
170
|
+
|
171
|
+
=== Top Level Sequence
|
172
|
+
--- jsony
|
173
|
+
- foo bar
|
174
|
+
- foo bar
|
175
|
+
--- json: [["foo", "bar"],["foo", "bar"]]
|
176
|
+
.
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsony
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ingy döt Net
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pegex
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: testml-lite
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.1
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.1
|
46
|
+
description: ! 'JSONY is a data language that is simlar to JSON, just more chill.
|
47
|
+
All valid
|
48
|
+
|
49
|
+
JSON is also valid JSONY (and represents the same thing when decoded), but
|
50
|
+
|
51
|
+
JSONY lets you omit a lot of the syntax that makes JSON a pain to write.
|
52
|
+
|
53
|
+
'
|
54
|
+
email: ingy@ingy.net
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
extra_rdoc_files: []
|
58
|
+
files:
|
59
|
+
- .gemspec
|
60
|
+
- CHANGELOG.yaml
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- LICENSE
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- ToDo
|
67
|
+
- lib/jsony.rb
|
68
|
+
- lib/jsony/grammar.rb
|
69
|
+
- lib/jsony/receiver.rb
|
70
|
+
- share/jsony.pgx
|
71
|
+
- test/decode.rb
|
72
|
+
- test/lib/test_helper.rb
|
73
|
+
homepage: http://jsony.org
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.9.1
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.8.23
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Relaxed JSON with a little bit of YAML
|
98
|
+
test_files: []
|