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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0a9dccdbbdf54033ab8704f7155633b6e646a70
4
- data.tar.gz: 54d9147a318ef371f91d61fe4c0e30bd6e26d2ef
3
+ metadata.gz: ef1d3978c6f14b96499ee3ac407d6d0aa65452b4
4
+ data.tar.gz: 6611915a855a148c8e96e5eae25f3ea136308614
5
5
  SHA512:
6
- metadata.gz: 5db57fcc6a3d2410af1c8def6b1f4bee8cbdb6a65277a444bedc982ccb85bce9f57e8f3834e85316e337ef1afe9e13a949f0084e4ab6bb19b0306b7dad5298f7
7
- data.tar.gz: 08c3eb7ab497ab4ff5798ffa4ad6d745e9dafca6ea13fa8c0cb0357c1e86912306a70234e50be57ed65fa2efd643361495cad2e0d1f03b811afd46ac7d91d15c
6
+ metadata.gz: 3a4a92bf9a476644019b090ac3b7ddcfa36d4ab8f856511d4810fd58a3c10577b6a6aaa574e0f79b37d86066e3193ca792e35e5fc26ad0c2b95778acd77a74b3
7
+ data.tar.gz: 79a9cac58c75fde7de8850fc84938bf0b969bbe6e956db171953973a3f66e17286dee65296c68fe7ecd580d77d015bcbe6383c1ce38b47b95009b1b4ca095d2e
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1.5
5
+ - 2.2.5
6
+ - 2.3.1
7
+ before_install: gem install bundler -v 1.12.5
8
+ install: true
9
+ script:
10
+ - bundle install
11
+ - bundle exec rake
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
@@ -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
- Object.const_get(const_name) if Object.const_defined?(const_name)
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
- type = type.to_s.split(?_).map(&:capitalize).join
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 space.positive? && space != payload.length
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 space.negative?
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 |uffff, _|
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
- uffff * 16 + hex
54
+ i * 16 + hex
53
55
  end
54
56
  uffff.chr(Encoding::UTF_8)
55
57
  end
@@ -53,7 +53,7 @@ module Hjson
53
53
  case val
54
54
  when Proc then instance_eval(&val)
55
55
  when Symbol then send(val)
56
- when Fixnum then val
56
+ when Integer then val
57
57
  else val.dup
58
58
  end
59
59
  instance_variable_set(:"@#{var}", val)
@@ -1,3 +1,3 @@
1
1
  module Hjson
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
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.0
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: 2016-08-07 00:00:00.000000000 Z
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.5.1
133
+ rubygems_version: 2.6.8
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: Human JSON (Hjson) implementation for Ruby