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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b144f33248f3ccd78a6b98186e784495fedb0360
4
- data.tar.gz: 501a8853494e00a3cce9f0879b70e82c67ef1954
2
+ SHA256:
3
+ metadata.gz: 2106514aa626a7ef75bf6a594bbc02779773c23090e767bd03c5aed189c7a2a5
4
+ data.tar.gz: 1cfe711fa7c96affcf4c3c82aca4053df07a26da274b22a3fff9268932148fbf
5
5
  SHA512:
6
- metadata.gz: 58de576b8bde2111ead891cc97cd4a6bb4e5473ab5fa4449d98b6c34ae03811593691c26e0c88d49b7d291ebc25a6bc989df0477975a998ea8561f87b500bdb2
7
- data.tar.gz: f522886c6a8eb61199dd470e0101f30933106c1329e3a93148583a863ea0e074fe880a98b824e7695af65e438d29f08ba88b7b65afecabf188de40614d7f6464
6
+ metadata.gz: 9b9bbf4bfc747faa030416b51a3b0c02ce0c9ee0e549f58222e09b38d874c7b92920a1da49d408ed43b418d108d80c9198b4e932e8b384ea05b797083fb3e05f
7
+ data.tar.gz: 7b580e05c0be3afd5f3d340632212dc74bacecf48da3223fb46b95d4b6e6b3cdcb9838cc5c50714b001ed7184777caabb1fe5e2600c68530c772016b4378f5b2
@@ -0,0 +1 @@
1
+ 2.5.3
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.0
4
+ - 2.5.3
5
5
  before_install: gem install bundler -v 1.13.7
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
@@ -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
@@ -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
- if value.is_a?(JSONObject)
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
@@ -1,3 +1,3 @@
1
1
  module JSONSEQ
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -17,6 +17,8 @@ module JSONSEQ
17
17
  io.flush
18
18
  end
19
19
 
20
- alias write <<
20
+ def write(object)
21
+ self << object
22
+ end
21
23
  end
22
24
  end
@@ -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.1.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: 2017-04-30 00:00:00.000000000 Z
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.8
110
+ rubygems_version: 2.7.6
94
111
  signing_key:
95
112
  specification_version: 4
96
113
  summary: Read/write JSON Text Sequence.