hjson 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/README.md +4 -0
- data/lib/hjson/ast/node.rb +2 -3
- data/lib/hjson/ast/nodes/keyname.rb +12 -2
- data/lib/hjson/ast/nodes/string.rb +4 -2
- data/lib/hjson/ast/parser.rb +1 -1
- data/lib/hjson/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef1d3978c6f14b96499ee3ac407d6d0aa65452b4
|
4
|
+
data.tar.gz: 6611915a855a148c8e96e5eae25f3ea136308614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a4a92bf9a476644019b090ac3b7ddcfa36d4ab8f856511d4810fd58a3c10577b6a6aaa574e0f79b37d86066e3193ca792e35e5fc26ad0c2b95778acd77a74b3
|
7
|
+
data.tar.gz: 79a9cac58c75fde7de8850fc84938bf0b969bbe6e956db171953973a3f66e17286dee65296c68fe7ecd580d77d015bcbe6383c1ce38b47b95009b1b4ca095d2e
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Hjson, the Human JSON written in Ruby
|
2
2
|
|
3
|
+
[![Build Status](https://img.shields.io/travis/hjson/hjson-rb.svg?style=flat-square)](http://travis-ci.org/hjson/hjson-rb)
|
4
|
+
[![gem](https://img.shields.io/gem/v/hjson.svg?style=flat-square)](https://rubygems.org/gems/hjson)
|
5
|
+
[![License](https://img.shields.io/github/license/hjson/hjson-rb.svg?style=flat-square)](https://github.com/hjson/hjson-rb/blob/master/LICENSE.txt)
|
6
|
+
|
3
7
|
A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments for Ruby.
|
4
8
|
|
5
9
|
## Installation
|
data/lib/hjson/ast/node.rb
CHANGED
@@ -9,13 +9,12 @@ module Hjson
|
|
9
9
|
@names[type] ||= begin
|
10
10
|
namespace = name.split(/::/).slice(0..-2).join('::')
|
11
11
|
const_name = parser_name(type, namespace)
|
12
|
-
|
12
|
+
AST.const_get(const_name) if AST.const_defined?(const_name)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.parser_name(type, namespace)
|
17
|
-
|
18
|
-
"#{namespace}::#{type}"
|
17
|
+
type.to_s.split(?_).map(&:capitalize).join
|
19
18
|
end
|
20
19
|
|
21
20
|
def with_whitespaces
|
@@ -16,14 +16,14 @@ module Hjson
|
|
16
16
|
until eos?
|
17
17
|
if colon?
|
18
18
|
fail SyntaxError if payload.empty?
|
19
|
-
if
|
19
|
+
if positive?(space) && space != payload.length
|
20
20
|
buffer.pos = start + space
|
21
21
|
fail SyntaxError
|
22
22
|
end
|
23
23
|
halt(payload)
|
24
24
|
elsif char <= ' '
|
25
25
|
fail SyntaxError if eos?
|
26
|
-
self.space = payload.length if
|
26
|
+
self.space = payload.length if negative?(space)
|
27
27
|
elsif punctuator?
|
28
28
|
fail SyntaxError
|
29
29
|
else
|
@@ -32,6 +32,16 @@ module Hjson
|
|
32
32
|
read
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def positive?(number)
|
39
|
+
number.respond_to?(:positive?) ? number.positive? : (number > 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
def negative?(number)
|
43
|
+
number.respond_to?(:negative?) ? number.negative? : (number < 0)
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
@@ -16,6 +16,7 @@ module Hjson
|
|
16
16
|
rule(:escaped) { |c| c == ?\\ }
|
17
17
|
rule(:unicode) { |c| c == ?u }
|
18
18
|
rule(:escapee) { |c| !!ESCAPEE[c] }
|
19
|
+
rule(:hex) { |c| [(?0..?9),(?a..?f),(?A..?F)].include?(c) }
|
19
20
|
|
20
21
|
declare :payload, ''
|
21
22
|
|
@@ -45,11 +46,12 @@ module Hjson
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def read_unicode
|
48
|
-
uffff = 4.times.reduce(0) do |
|
49
|
+
uffff = 4.times.reduce(0) do |i, _|
|
49
50
|
read
|
51
|
+
fail SyntaxError unless hex?
|
50
52
|
hex = char.to_i(16)
|
51
53
|
break if hex.infinite?
|
52
|
-
|
54
|
+
i * 16 + hex
|
53
55
|
end
|
54
56
|
uffff.chr(Encoding::UTF_8)
|
55
57
|
end
|
data/lib/hjson/ast/parser.rb
CHANGED
data/lib/hjson/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hjson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- namusyaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
91
92
|
- Gemfile
|
92
93
|
- LICENSE.txt
|
93
94
|
- README.md
|
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
132
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.6.8
|
133
134
|
signing_key:
|
134
135
|
specification_version: 4
|
135
136
|
summary: Human JSON (Hjson) implementation for Ruby
|