json_pure 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +14 -0
  3. data/VERSION +1 -1
  4. data/json_pure.gemspec +47 -19
  5. data/lib/json/version.rb +1 -1
  6. data/tests/fixtures/fail29.json +1 -0
  7. data/tests/fixtures/fail30.json +1 -0
  8. data/tests/fixtures/fail31.json +1 -0
  9. data/tests/fixtures/fail32.json +1 -0
  10. metadata +16 -48
  11. data/.gitignore +0 -18
  12. data/.travis.yml +0 -23
  13. data/README-json-jruby.md +0 -33
  14. data/Rakefile +0 -334
  15. data/diagrams/.keep +0 -0
  16. data/ext/json/ext/fbuffer/fbuffer.h +0 -187
  17. data/ext/json/ext/generator/depend +0 -1
  18. data/ext/json/ext/generator/extconf.rb +0 -4
  19. data/ext/json/ext/generator/generator.c +0 -1612
  20. data/ext/json/ext/generator/generator.h +0 -174
  21. data/ext/json/ext/parser/depend +0 -1
  22. data/ext/json/ext/parser/extconf.rb +0 -31
  23. data/ext/json/ext/parser/parser.c +0 -2164
  24. data/ext/json/ext/parser/parser.h +0 -92
  25. data/ext/json/ext/parser/parser.rl +0 -924
  26. data/ext/json/extconf.rb +0 -3
  27. data/install.rb +0 -23
  28. data/java/src/json/ext/ByteListTranscoder.java +0 -166
  29. data/java/src/json/ext/Generator.java +0 -447
  30. data/java/src/json/ext/GeneratorMethods.java +0 -231
  31. data/java/src/json/ext/GeneratorService.java +0 -42
  32. data/java/src/json/ext/GeneratorState.java +0 -520
  33. data/java/src/json/ext/OptionsReader.java +0 -113
  34. data/java/src/json/ext/Parser.java +0 -2374
  35. data/java/src/json/ext/Parser.rl +0 -905
  36. data/java/src/json/ext/ParserService.java +0 -34
  37. data/java/src/json/ext/RuntimeInfo.java +0 -116
  38. data/java/src/json/ext/StringDecoder.java +0 -166
  39. data/java/src/json/ext/StringEncoder.java +0 -117
  40. data/java/src/json/ext/Utils.java +0 -88
  41. data/json-java.gemspec +0 -38
  42. data/json.gemspec +0 -140
  43. data/references/rfc7159.txt +0 -899
  44. data/tools/diff.sh +0 -18
  45. data/tools/fuzz.rb +0 -131
  46. data/tools/server.rb +0 -62
@@ -1,18 +0,0 @@
1
- #!/bin/sh
2
-
3
- files=`find ext -name '*.[ch]' -o -name parser.rl`
4
-
5
- for f in $files
6
- do
7
- b=`basename $f`
8
- g=`find ../ruby/ext/json -name $b`
9
- d=`diff -u $f $g`
10
- test -z "$d" && continue
11
- echo "$d"
12
- read -p "Edit diff of $b? " a
13
- case $a in
14
- [yY]*)
15
- vimdiff $f $g
16
- ;;
17
- esac
18
- done
@@ -1,131 +0,0 @@
1
- require 'json'
2
-
3
- class Fuzzer
4
- def initialize(n, freqs = {})
5
- sum = freqs.inject(0.0) { |s, x| s + x.last }
6
- freqs.each_key { |x| freqs[x] /= sum }
7
- s = 0.0
8
- freqs.each_key do |x|
9
- freqs[x] = s .. (s + t = freqs[x])
10
- s += t
11
- end
12
- @freqs = freqs
13
- @n = n
14
- @alpha = (0..0xff).to_a
15
- end
16
-
17
- def random_string
18
- s = ''
19
- 30.times { s << @alpha[rand(@alpha.size)] }
20
- s
21
- end
22
-
23
- def pick
24
- r = rand
25
- found = @freqs.find { |k, f| f.include? rand }
26
- found && found.first
27
- end
28
-
29
- def make_pick
30
- k = pick
31
- case
32
- when k == Hash, k == Array
33
- k.new
34
- when k == true, k == false, k == nil
35
- k
36
- when k == String
37
- random_string
38
- when k == Fixnum
39
- rand(2 ** 30) - 2 ** 29
40
- when k == Bignum
41
- rand(2 ** 70) - 2 ** 69
42
- end
43
- end
44
-
45
- def fuzz(current = nil)
46
- if @n > 0
47
- case current
48
- when nil
49
- @n -= 1
50
- current = fuzz [ Hash, Array ][rand(2)].new
51
- when Array
52
- while @n > 0
53
- @n -= 1
54
- current << case p = make_pick
55
- when Array, Hash
56
- fuzz(p)
57
- else
58
- p
59
- end
60
- end
61
- when Hash
62
- while @n > 0
63
- @n -= 1
64
- current[random_string] = case p = make_pick
65
- when Array, Hash
66
- fuzz(p)
67
- else
68
- p
69
- end
70
- end
71
- end
72
- end
73
- current
74
- end
75
- end
76
-
77
- class MyState < JSON.state
78
- WS = " \r\t\n"
79
-
80
- def initialize
81
- super(
82
- :indent => make_spaces,
83
- :space => make_spaces,
84
- :space_before => make_spaces,
85
- :object_nl => make_spaces,
86
- :array_nl => make_spaces,
87
- :max_nesting => false
88
- )
89
- end
90
-
91
- def make_spaces
92
- s = ''
93
- rand(1).times { s << WS[rand(WS.size)] }
94
- s
95
- end
96
- end
97
-
98
- n = (ARGV.shift || 500).to_i
99
- loop do
100
- fuzzer = Fuzzer.new(n,
101
- Hash => 25,
102
- Array => 25,
103
- String => 10,
104
- Fixnum => 10,
105
- Bignum => 10,
106
- nil => 5,
107
- true => 5,
108
- false => 5
109
- )
110
- o1 = fuzzer.fuzz
111
- json = JSON.generate o1, MyState.new
112
- if $DEBUG
113
- puts "-" * 80
114
- puts json, json.size
115
- else
116
- puts json.size
117
- end
118
- begin
119
- o2 = JSON.parse(json, :max_nesting => false)
120
- rescue JSON::ParserError => e
121
- puts "Caught #{e.class}: #{e.message}\n#{e.backtrace * "\n"}"
122
- puts "o1 = #{o1.inspect}", "json = #{json}", "json_str = #{json.inspect}"
123
- puts "locals = #{local_variables.inspect}"
124
- exit
125
- end
126
- if o1 != o2
127
- puts "mismatch", "o1 = #{o1.inspect}", "o2 = #{o2.inspect}",
128
- "json = #{json}", "json_str = #{json.inspect}"
129
- puts "locals = #{local_variables.inspect}"
130
- end
131
- end
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'webrick'
5
- include WEBrick
6
- $:.unshift 'ext'
7
- $:.unshift 'lib'
8
- require 'json'
9
-
10
- class JSONServlet < HTTPServlet::AbstractServlet
11
- @@count = 1
12
-
13
- def do_GET(req, res)
14
- obj = {
15
- "TIME" => Time.now.strftime("%FT%T"),
16
- "foo" => "Bär",
17
- "bar" => "© ≠ €!",
18
- 'a' => 2,
19
- 'b' => 3.141,
20
- 'COUNT' => @@count += 1,
21
- 'c' => 'c',
22
- 'd' => [ 1, "b", 3.14 ],
23
- 'e' => { 'foo' => 'bar' },
24
- 'g' => "松本行弘",
25
- 'h' => 1000.0,
26
- 'i' => 0.001,
27
- 'j' => "\xf0\xa0\x80\x81",
28
- }
29
- res.body = JSON.generate obj
30
- res['Content-Type'] = "application/json"
31
- end
32
- end
33
-
34
- def create_server(err, dir, port)
35
- dir = File.expand_path(dir)
36
- err.puts "Surf to:", "http://#{Socket.gethostname}:#{port}"
37
-
38
- s = HTTPServer.new(
39
- :Port => port,
40
- :DocumentRoot => dir,
41
- :Logger => WEBrick::Log.new(err),
42
- :AccessLog => [
43
- [ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
44
- [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
45
- [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ]
46
- ]
47
- )
48
- s.mount("/json", JSONServlet)
49
- s
50
- end
51
-
52
- default_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
53
- dir = ARGV.shift || default_dir
54
- port = (ARGV.shift || 6666).to_i
55
- s = create_server(STDERR, dir, 6666)
56
- t = Thread.new { s.start }
57
- trap(:INT) do
58
- s.shutdown
59
- t.join
60
- exit
61
- end
62
- sleep