jsony 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  GemSpec = Gem::Specification.new do |gem|
4
4
  gem.name = 'jsony'
5
- gem.version = '0.0.1'
5
+ gem.version = '0.0.2'
6
6
  gem.license = 'MIT'
7
7
  gem.required_ruby_version = '>= 1.9.1'
8
8
 
@@ -18,6 +18,6 @@ JSONY lets you omit a lot of the syntax that makes JSON a pain to write.
18
18
 
19
19
  gem.files = `git ls-files`.lines.map{|l|l.chomp}
20
20
 
21
- gem.add_dependency 'pegex', '>= 0.0.2'
22
- gem.add_development_dependency 'testml-lite', '>= 0.0.1'
21
+ gem.add_dependency 'pegex', '>= 0.0.3'
22
+ gem.add_development_dependency 'testml', '>= 0.0.2'
23
23
  end
@@ -1,3 +1,6 @@
1
+ - version: 0.0.2
2
+ date: Sat Apr 20 07:08:34 CST 2013
3
+ changes: Integrate latest pegex and testml
1
4
  - version: 0.0.1
2
5
  date: Wed Dec 19 22:35:56 PST 2012
3
6
  changes: First release
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright © 2012 Ingy döt Net
3
+ Copyright © 2013 Ingy döt Net
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the ‘Software’), to deal in
@@ -83,4 +83,4 @@ http://jsony.org/ coming soon.
83
83
 
84
84
  = Copyright
85
85
 
86
- Copyright (c) 2012 Ingy döt Net. See LICENSE for further details.
86
+ Copyright (c) 2012, 2013 Ingy döt Net. See LICENSE for further details.
data/Rakefile CHANGED
@@ -11,6 +11,12 @@ DevNull = '2>/dev/null'
11
11
  require 'rake'
12
12
  require 'rake/testtask'
13
13
  require 'rake/clean'
14
+ if File.exists? 'test/testml.yaml'
15
+ if File.exists? 'lib/rake/testml.rb'
16
+ $:.unshift "#{Dir.getwd}/lib"
17
+ end
18
+ require 'rake/testml'
19
+ end
14
20
 
15
21
  task :default => 'help'
16
22
 
@@ -18,9 +24,12 @@ CLEAN.include GemDir, GemFile, 'data.tar.gz', 'metadata.gz'
18
24
 
19
25
  desc 'Run the tests'
20
26
  task :test do
27
+ load '.env' if File.exists? '.env'
21
28
  Rake::TestTask.new do |t|
22
29
  t.verbose = true
23
- t.test_files = FileList['test/*.rb']
30
+ t.test_files = ENV['DEV_TEST_FILES'] &&
31
+ FileList[ENV['DEV_TEST_FILES'].split] ||
32
+ FileList['test/**/*.rb'].sort
24
33
  end
25
34
  end
26
35
 
@@ -23,13 +23,12 @@ class JSONY::Receiver < Pegex::Tree
23
23
 
24
24
  def got_bare got
25
25
  case got
26
- when 'true' # XXX is it a bug in jsony-pm that it's unanchored
26
+ when 'true'
27
27
  true
28
28
  when 'false'
29
29
  false
30
30
  when 'null'
31
- 'fake-nil'
32
- # TODO golf this \ if possible
31
+ Pegex::Constant::Null
33
32
  when \
34
33
  /^(
35
34
  -?
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require 'testml'
3
+ $:.unshift "#{Dir.getwd}/test"
4
+ require 'testml_bridge'
5
+
6
+ class TestMLTestCase < Test::Unit::TestCase
7
+ (Dir.glob('test/testml/*.tml')
8
+ .collect {|f| f.sub(/^test\//, '')}
9
+ .select { |f| f !~ /edge/ }
10
+ ).each do |file|
11
+ method_name = 'test_' + file.gsub(/\W/, '_').sub(/_tml$/, '')
12
+ define_method(method_name.to_sym) do
13
+ TestML.new(
14
+ testml: file,
15
+ bridge: TestMLBridge,
16
+ ).run(self)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,2 @@
1
+ source_testml_dir: ../../jsony-tml
2
+ local_testml_dir: ./testml
@@ -0,0 +1,11 @@
1
+ %TestML 0.1.0
2
+
3
+ # Make sure the JSONY parses to what we expect:
4
+ *jsony.jsony_decode.yaml == *json.json_decode.yaml
5
+
6
+ === Trailing comment
7
+ --- SKIP
8
+ --- jsony
9
+ - foo # foo
10
+ - bar
11
+ --- json: [ "foo", "bar", "baz" ]
@@ -1,21 +1,10 @@
1
- require './test/lib/test_helper'
1
+ %TestML 0.1.0
2
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'
3
+ # Make sure the JSONY parses to what we expect:
4
+ *jsony.jsony_decode.yaml == *json.json_decode.yaml
6
5
 
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;
6
+ # Make sure JSONY parses the JSON form the same as a JSON parser:
7
+ *json.jsony_decode.yaml == *json.json_decode.yaml
19
8
 
20
9
  === String splitting 1
21
10
  --- jsony: foo bar baz
@@ -173,4 +162,4 @@ baz: 42
173
162
  - foo bar
174
163
  - foo bar
175
164
  --- json: [["foo", "bar"],["foo", "bar"]]
176
- .
165
+
@@ -0,0 +1,48 @@
1
+ # These JSONY streams need JSON equivalence, or need to be declared as
2
+ # decoding (parsing) errors:
3
+
4
+ %TestML 0.1.0
5
+
6
+ === Empty Stream
7
+ --- jsony: ''
8
+
9
+ === Whitespace Stream
10
+ --- jsony: ' '
11
+
12
+ === Collections as mapping keys
13
+ --- jsony
14
+ {
15
+ [foo bar] baz
16
+ {foo bar} baz
17
+ }
18
+
19
+ === Duplicate mapping keys
20
+ --- jsony: { foo foo foo foo }
21
+
22
+ === Odd number of nodes in mapping
23
+ --- jsony: { foo bar baz }
24
+
25
+ === Semis and commas in jsony
26
+ --- jsony
27
+ {
28
+ foo: bar, baz
29
+ do :re ,mi
30
+ oh : my , lord
31
+ }
32
+
33
+ === Comment syntax
34
+ --- jsony
35
+ /* comment */
36
+ # comment
37
+ What happens?
38
+
39
+ === Unterminated Quotes
40
+ --- jsony
41
+ {
42
+ name 'Ingy dot Net
43
+ size 42
44
+ }
45
+
46
+ === Unquoted punctuation
47
+ --- jsony
48
+ ! @ # $ % ^ { & * ( | }'}
@@ -0,0 +1,10 @@
1
+ %TestML 0.1.0
2
+
3
+ # Make sure these strings do not parse as JSONY.
4
+ *jsony.jsony_decode.Catch.OK
5
+
6
+ === Comma in bareword
7
+ --- jsony: { url: http://foo.com,2012 }
8
+
9
+ === Unmatched [
10
+ --- jsony: foo[bar
@@ -0,0 +1,11 @@
1
+ %TestML 0.1.0
2
+
3
+ # Test various json streams, to make sure jsony can parse it properly.
4
+ *json.jsony_decode.yaml == *json.json_decode.yaml
5
+
6
+ === Various Numbers
7
+ --- SKIP
8
+ --- json: [1,-2,3,4.5,67,0.8e-9]
9
+
10
+ === Object with no space
11
+ --- json: {"a":"b","c":{"d":"e"},"f":["g","h"],"i":[{},[],[[]]]}
@@ -0,0 +1,20 @@
1
+ require 'testml/bridge'
2
+ require 'testml/util'
3
+ include TestML::Util
4
+ require 'jsony'
5
+ require 'yaml'
6
+ require 'json'
7
+
8
+ class TestMLBridge < TestML::Bridge
9
+ def jsony_decode(jsony)
10
+ native JSONY.load(jsony.value)
11
+ end
12
+
13
+ def json_decode(json)
14
+ native JSON.parse(json.value)
15
+ end
16
+
17
+ def yaml(object)
18
+ str YAML.dump(object)
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pegex
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.0.2
21
+ version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,15 +26,15 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.0.2
29
+ version: 0.0.3
30
30
  - !ruby/object:Gem::Dependency
31
- name: testml-lite
31
+ name: testml
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.0.1
37
+ version: 0.0.2
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.0.1
45
+ version: 0.0.2
46
46
  description: ! 'JSONY is a data language that is simlar to JSON, just more chill.
47
47
  All valid
48
48
 
@@ -67,9 +67,14 @@ files:
67
67
  - lib/jsony.rb
68
68
  - lib/jsony/grammar.rb
69
69
  - lib/jsony/receiver.rb
70
- - share/jsony.pgx
71
- - test/decode.rb
72
- - test/lib/test_helper.rb
70
+ - test/testml.rb
71
+ - test/testml.yaml
72
+ - test/testml/comments.tml
73
+ - test/testml/decode.tml
74
+ - test/testml/edge.tml
75
+ - test/testml/fail.tml
76
+ - test/testml/json.tml
77
+ - test/testml_bridge.rb
73
78
  homepage: http://jsony.org
74
79
  licenses:
75
80
  - MIT
@@ -1,88 +0,0 @@
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
- )/
@@ -1,10 +0,0 @@
1
- require 'testml/lite'
2
- require 'jsony'
3
- require 'json'
4
-
5
- class TestPegex < TestML::Lite
6
- include TestML::Lite::TestCases
7
- def jsony_load str; JSONY.load str end
8
- def json_load str; JSON.load str end
9
- def String obj; obj.inspect end
10
- end