type_struct 0.8.0 → 1.1.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
2
  SHA256:
3
- metadata.gz: 8e9c0711f51f4b07350d1e6626ee95c5700bdcda3135ccc868aadd2f39339e03
4
- data.tar.gz: 9d33ec7f4545520f3f8733124a785c8eb2eab9d935fc49835c66fc4ef2279507
3
+ metadata.gz: 5e71eb2d2e7f2cca02978426927745eef8cecc6b3f091f9418009e7b24c2155f
4
+ data.tar.gz: de47a1491a131ade2b3e7978e45008176ab10f514658dce5f05e50f0c7af6c80
5
5
  SHA512:
6
- metadata.gz: '0819f9514d820b7de819f7df65aeca74d7e4b4d1222fb9c0161559493840ec1251ab91ce3950736cb302db2dec989f228ec9f0fc6e68765e0dfb258c1350e1f9'
7
- data.tar.gz: 63b659f3188a6ab433308439812b0a0122a2ace07ee7b81162260fc8ddfaea75534b28f59682e388b1dd3a44ab72fc49ec01ce7cb62c83782c6888171d433e97
6
+ metadata.gz: a6fce6b7a938a3aee3f6cee47379243889e8f58b80d2246394e1b629c88956ec1bd162a3afc22f1c9c40faca9562be0cd91b11b07aeb5ccc13a16a8bfed56848
7
+ data.tar.gz: 3909d8b748d66dd266c7ef24e5693fc2965e2816183f4cfb1c52a30f1993996d24fa3550be7d5d515fa12eda06346d24fa301dc49d196730408e9181b949004b
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # TypeStruct
2
2
 
3
- [![Build Status](https://travis-ci.org/ksss/type_struct.svg)](https://travis-ci.org/ksss/type_struct)
4
-
5
3
  Imitating static typed struct.
6
4
 
7
5
  All type is checked by `===` method.
@@ -222,7 +220,7 @@ p Baz.from_hash(qux: [1, 2, false, true]) #=> #<A::Baz qux=[1, 2, false, true]>
222
220
 
223
221
  ## Auto Generator
224
222
 
225
- ```json
223
+ ```rb
226
224
  $ echo '{"posts": [{"number":10491,"name":"ksss"}]}' | ruby -r type_struct/generator/json
227
225
  Post = TypeStruct.new(
228
226
  number: Integer,
@@ -17,6 +17,7 @@ class TypeStruct
17
17
  b = e.backtrace_locations.find do |b|
18
18
  b.absolute_path !~ THIS_LIB_REGEXP
19
19
  end
20
+ next unless b&.absolute_path
20
21
  pathname = Pathname.new(b.absolute_path)
21
22
  relative_path = if pathname.absolute? && PWD.absolute?
22
23
  pathname.relative_path_from(PWD)
@@ -31,7 +31,9 @@ class TypeStruct
31
31
 
32
32
  module Ext
33
33
  refine Class do
34
- include Unionable
34
+ def |(other)
35
+ Union.new(self, other)
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -1,3 +1,3 @@
1
1
  class TypeStruct
2
- VERSION = "0.8.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/type_struct.rb CHANGED
@@ -64,7 +64,11 @@ class TypeStruct
64
64
  module ClassMethods
65
65
  def from_hash(arg)
66
66
  unless h = Hash.try_convert(arg)
67
- raise TypeError, "no implicit conversion from #{arg} to Hash"
67
+ begin
68
+ raise TypeError, "no implicit conversion from #{arg} to Hash"
69
+ rescue => e
70
+ raise TypeStruct::MultiTypeError, [e]
71
+ end
68
72
  end
69
73
  args = {}
70
74
  errors = []
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rgot
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
11
+ date: 2024-04-14 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: Pseudo type system on struct.
56
14
  email:
57
15
  - co000ri@gmail.com
@@ -59,12 +17,8 @@ executables: []
59
17
  extensions: []
60
18
  extra_rdoc_files: []
61
19
  files:
62
- - ".gitignore"
63
- - ".travis.yml"
64
- - Gemfile
65
20
  - LICENSE.txt
66
21
  - README.md
67
- - Rakefile
68
22
  - lib/type_struct.rb
69
23
  - lib/type_struct/array_of.rb
70
24
  - lib/type_struct/exceptions.rb
@@ -76,12 +30,11 @@ files:
76
30
  - lib/type_struct/interface.rb
77
31
  - lib/type_struct/union.rb
78
32
  - lib/type_struct/version.rb
79
- - type_struct.gemspec
80
33
  homepage: https://github.com/ksss/type_struct
81
34
  licenses:
82
35
  - MIT
83
36
  metadata: {}
84
- post_install_message:
37
+ post_install_message:
85
38
  rdoc_options: []
86
39
  require_paths:
87
40
  - lib
@@ -96,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
49
  - !ruby/object:Gem::Version
97
50
  version: '0'
98
51
  requirements: []
99
- rubygems_version: 3.0.6
100
- signing_key:
52
+ rubygems_version: 3.5.3
53
+ signing_key:
101
54
  specification_version: 4
102
55
  summary: Pseudo type system on struct.
103
56
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.6
4
- - 2.5.5
5
- - 2.6.3
6
- before_install: gem install bundler -v 2.0.2
7
- notifications:
8
- email: false
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in type_struct.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- task :test do
4
- sh "rgot -v --bench ."
5
- end
6
-
7
- task :default => [:test]
data/type_struct.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'type_struct/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "type_struct"
8
- spec.version = TypeStruct::VERSION
9
- spec.authors = ["ksss"]
10
- spec.email = ["co000ri@gmail.com"]
11
-
12
- spec.summary = %q{Pseudo type system on struct.}
13
- spec.description = %q{Pseudo type system on struct.}
14
- spec.homepage = "https://github.com/ksss/type_struct"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{_test.rb}) }
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "bundler"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rgot"
23
- end