jsonseq 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/Rakefile +6 -1
- data/jsonseq.gemspec +3 -0
- data/lib/jsonseq/reader.rb +4 -5
- data/lib/jsonseq/version.rb +1 -1
- data/lib/jsonseq/writer.rb +3 -1
- data/sig/jsonseq.rbi +64 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2106514aa626a7ef75bf6a594bbc02779773c23090e767bd03c5aed189c7a2a5
|
4
|
+
data.tar.gz: 1cfe711fa7c96affcf4c3c82aca4053df07a26da274b22a3fff9268932148fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9bbf4bfc747faa030416b51a3b0c02ce0c9ee0e549f58222e09b38d874c7b92920a1da49d408ed43b418d108d80c9198b4e932e8b384ea05b797083fb3e05f
|
7
|
+
data.tar.gz: 7b580e05c0be3afd5f3d340632212dc74bacecf48da3223fb46b95d4b6e6b3cdcb9838cc5c50714b001ed7184777caabb1fe5e2600c68530c772016b4378f5b2
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -7,4 +7,9 @@ Rake::TestTask.new(:test) do |t|
|
|
7
7
|
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :default => :test
|
10
|
+
task :default => [:test, :typecheck]
|
11
|
+
|
12
|
+
task :typecheck do
|
13
|
+
sh("steep", "check", "lib")
|
14
|
+
sh("steep", "check", "-I", "sig", "-I", "test", "test")
|
15
|
+
end
|
data/jsonseq.gemspec
CHANGED
@@ -20,7 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.metadata = { "steep_types" => "sig" }
|
24
|
+
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.13"
|
24
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
spec.add_development_dependency "steep", "~> 0.8.2"
|
26
29
|
end
|
data/lib/jsonseq/reader.rb
CHANGED
@@ -42,6 +42,7 @@ module JSONSEQ
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def read
|
45
|
+
# @type var source: String
|
45
46
|
begin
|
46
47
|
source = io.readline(RS).chomp(RS)
|
47
48
|
end while source == ""
|
@@ -64,6 +65,7 @@ module JSONSEQ
|
|
64
65
|
EndOfFile.new
|
65
66
|
end
|
66
67
|
|
68
|
+
# @type method each: () ?{ (result) -> any } -> any
|
67
69
|
def each
|
68
70
|
if block_given?
|
69
71
|
while true
|
@@ -85,15 +87,14 @@ module JSONSEQ
|
|
85
87
|
nil
|
86
88
|
when JSONObject
|
87
89
|
value.object
|
88
|
-
else
|
89
|
-
raise "Unexpected value: #{value}"
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
def each_object
|
94
94
|
if block_given?
|
95
95
|
each do |value|
|
96
|
-
|
96
|
+
case value
|
97
|
+
when JSONObject
|
97
98
|
yield value.object
|
98
99
|
end
|
99
100
|
end
|
@@ -102,8 +103,6 @@ module JSONSEQ
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
|
-
private
|
106
|
-
|
107
106
|
def decode_string(string)
|
108
107
|
decoder[string]
|
109
108
|
rescue => exn
|
data/lib/jsonseq/version.rb
CHANGED
data/lib/jsonseq/writer.rb
CHANGED
data/sig/jsonseq.rbi
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
interface JSONSEQ::_ReadIO
|
2
|
+
def readline: (String) -> String
|
3
|
+
end
|
4
|
+
|
5
|
+
type JSONSEQ::Reader::decoder = ^(String) -> any
|
6
|
+
type JSONSEQ::Reader::result = JSONObject | EndOfFile | ParsingError | MaybeTruncated
|
7
|
+
|
8
|
+
class JSONSEQ::Reader
|
9
|
+
attr_reader io: _ReadIO
|
10
|
+
attr_reader decoder: decoder
|
11
|
+
|
12
|
+
def initialize: (io: _ReadIO, ?decoder: decoder) -> any
|
13
|
+
def read: () -> result
|
14
|
+
def each: () { (result) -> any } -> void
|
15
|
+
| () -> Enumerable<result, void>
|
16
|
+
def read_object: () -> any
|
17
|
+
def each_object: () ?{ (any) -> any } -> any
|
18
|
+
def decode_string: (String) -> any
|
19
|
+
def truncated?: (String) -> bool
|
20
|
+
end
|
21
|
+
|
22
|
+
JSONSEQ::Reader::DEFAULT_DECODER: decoder
|
23
|
+
|
24
|
+
class JSONSEQ::Reader::JSONObject
|
25
|
+
attr_reader object: any
|
26
|
+
def initialize: (object: any) -> any
|
27
|
+
end
|
28
|
+
|
29
|
+
class JSONSEQ::Reader::EndOfFile
|
30
|
+
end
|
31
|
+
|
32
|
+
class JSONSEQ::Reader::ParsingError
|
33
|
+
attr_reader source: String
|
34
|
+
attr_reader exception: any
|
35
|
+
def initialize: (source: String, exception: any) -> any
|
36
|
+
end
|
37
|
+
|
38
|
+
class JSONSEQ::Reader::MaybeTruncated
|
39
|
+
attr_reader source: String
|
40
|
+
attr_reader object: any
|
41
|
+
def initialize: (source: String, object: any) -> any
|
42
|
+
end
|
43
|
+
|
44
|
+
JSONSEQ::Reader::DEFAULT_DECODER: any
|
45
|
+
|
46
|
+
type JSONSEQ::Writer::encoder = ^(any) -> String
|
47
|
+
interface JSONSEQ::Writer::_WriteIO
|
48
|
+
def write: (String) -> void
|
49
|
+
def flush: () -> void
|
50
|
+
end
|
51
|
+
|
52
|
+
class JSONSEQ::Writer
|
53
|
+
attr_reader io: _WriteIO
|
54
|
+
attr_reader encoder: encoder
|
55
|
+
def initialize: (io: _WriteIO, ?encoder: encoder) -> any
|
56
|
+
def <<: (any) -> void
|
57
|
+
def write: (any) -> void
|
58
|
+
end
|
59
|
+
|
60
|
+
JSONSEQ::Writer::DEFAULT_ENCODER: encoder
|
61
|
+
|
62
|
+
JSONSEQ::VERSION: String
|
63
|
+
JSONSEQ::RS: String
|
64
|
+
JSONSEQ::LF: String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonseq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: steep
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.2
|
55
69
|
description: Read/write JSON text sequence based on RFC7464.
|
56
70
|
email:
|
57
71
|
- matsumoto@soutaro.com
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- ".ruby-version"
|
63
78
|
- ".travis.yml"
|
64
79
|
- Gemfile
|
65
80
|
- README.md
|
@@ -71,9 +86,11 @@ files:
|
|
71
86
|
- lib/jsonseq/reader.rb
|
72
87
|
- lib/jsonseq/version.rb
|
73
88
|
- lib/jsonseq/writer.rb
|
89
|
+
- sig/jsonseq.rbi
|
74
90
|
homepage: https://github.com/soutaro/jsonseq
|
75
91
|
licenses: []
|
76
|
-
metadata:
|
92
|
+
metadata:
|
93
|
+
steep_types: sig
|
77
94
|
post_install_message:
|
78
95
|
rdoc_options: []
|
79
96
|
require_paths:
|
@@ -90,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
107
|
version: '0'
|
91
108
|
requirements: []
|
92
109
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.6
|
110
|
+
rubygems_version: 2.7.6
|
94
111
|
signing_key:
|
95
112
|
specification_version: 4
|
96
113
|
summary: Read/write JSON Text Sequence.
|