rbs_active_hash 1.0.1 → 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: 57044cf3bbe008c0523f22f062fb7936a43ddce6a03e17f04e02daef661c092d
4
- data.tar.gz: b6533e6014fcef654e87d2187e381dced145f2f4828567e0e226b241d7258233
3
+ metadata.gz: 29417b6830a461114cf3825a04a76747c16e936a6b3bc6a1e7385393dd26333c
4
+ data.tar.gz: 8382e0a1f22ff0d6e653bfe2d095d437551768d379e82680ddc142ca4c8d6554
5
5
  SHA512:
6
- metadata.gz: ba76fab12f70ac6cb4bae32d6861657f4932f5e7509a2b33e273d6bd7ed954eab626af709fcc91780c6f68caad7de36c05796f4aa2cb17befd7708200a99ef79
7
- data.tar.gz: ac00937fc78c4fd2e098ab1154aedf79a1626ab48e810ee543143087a4d83424b5547708c7b9edf7fcf5431f5d9e8e2eea54a17562e01a961fab0e1a5196908e
6
+ metadata.gz: aa87db3f4f6c2cf132f9be5697ad69feeb7fbc2a380eb864ed6f32a3748eaef7803433e00e4abccbd0ca4499caf09b07c29e90b70760a98d8117a36b6648ce7c
7
+ data.tar.gz: 9d2a71a1429971f679160fab88f61aa2ec38a2553c397163448c60c6685955c5dff77da19f7acb10866b5f22ee097f93c9bfd51a77e4d714e947a20271e8ab57
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "rubocop", "~> 1.52"
10
+ gem "rubocop", "~> 1.54"
11
11
 
12
12
  group :development do
13
13
  gem "rspec", require: false
data/Gemfile.lock CHANGED
@@ -1,34 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_active_hash (1.0.1)
4
+ rbs_active_hash (1.1.0)
5
5
  active_hash
6
+ rbs
6
7
  rbs_rails
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- actionpack (7.0.5)
12
- actionview (= 7.0.5)
13
- activesupport (= 7.0.5)
12
+ actionpack (7.0.6)
13
+ actionview (= 7.0.6)
14
+ activesupport (= 7.0.6)
14
15
  rack (~> 2.0, >= 2.2.4)
15
16
  rack-test (>= 0.6.3)
16
17
  rails-dom-testing (~> 2.0)
17
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (7.0.5)
19
- activesupport (= 7.0.5)
19
+ actionview (7.0.6)
20
+ activesupport (= 7.0.6)
20
21
  builder (~> 3.1)
21
22
  erubi (~> 1.4)
22
23
  rails-dom-testing (~> 2.0)
23
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
25
  active_hash (3.2.0)
25
26
  activesupport (>= 5.0.0)
26
- activemodel (7.0.5)
27
- activesupport (= 7.0.5)
28
- activerecord (7.0.5)
29
- activemodel (= 7.0.5)
30
- activesupport (= 7.0.5)
31
- activesupport (7.0.5)
27
+ activemodel (7.0.6)
28
+ activesupport (= 7.0.6)
29
+ activerecord (7.0.6)
30
+ activemodel (= 7.0.6)
31
+ activesupport (= 7.0.6)
32
+ activesupport (7.0.6)
32
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
34
  i18n (>= 1.6, < 2)
34
35
  minitest (>= 5.1)
@@ -38,12 +39,12 @@ GEM
38
39
  coderay (1.1.3)
39
40
  concurrent-ruby (1.2.2)
40
41
  crass (1.0.6)
41
- csv (3.2.6)
42
+ csv (3.2.7)
42
43
  diff-lcs (1.5.0)
43
44
  erubi (1.12.0)
44
45
  ffi (1.15.5)
45
46
  fileutils (1.7.1)
46
- i18n (1.14.0)
47
+ i18n (1.14.1)
47
48
  concurrent-ruby (~> 1.0)
48
49
  json (2.6.3)
49
50
  language_server-protocol (3.17.0.3)
@@ -55,7 +56,7 @@ GEM
55
56
  crass (~> 1.0.2)
56
57
  nokogiri (>= 1.12.0)
57
58
  method_source (1.0.0)
58
- minitest (5.18.0)
59
+ minitest (5.18.1)
59
60
  nokogiri (1.15.2-x86_64-darwin)
60
61
  racc (~> 1.4)
61
62
  nokogiri (1.15.2-x86_64-linux)
@@ -67,19 +68,20 @@ GEM
67
68
  pry (0.14.2)
68
69
  coderay (~> 1.1)
69
70
  method_source (~> 1.0)
70
- racc (1.7.0)
71
+ racc (1.7.1)
71
72
  rack (2.2.7)
72
73
  rack-test (2.1.0)
73
74
  rack (>= 1.3)
74
- rails-dom-testing (2.0.3)
75
- activesupport (>= 4.2.0)
75
+ rails-dom-testing (2.1.1)
76
+ activesupport (>= 5.0.0)
77
+ minitest
76
78
  nokogiri (>= 1.6)
77
79
  rails-html-sanitizer (1.6.0)
78
80
  loofah (~> 2.21)
79
81
  nokogiri (~> 1.14)
80
- railties (7.0.5)
81
- actionpack (= 7.0.5)
82
- activesupport (= 7.0.5)
82
+ railties (7.0.6)
83
+ actionpack (= 7.0.6)
84
+ activesupport (= 7.0.6)
83
85
  method_source
84
86
  rake (>= 12.2)
85
87
  thor (~> 1.0)
@@ -89,7 +91,7 @@ GEM
89
91
  rb-fsevent (0.11.2)
90
92
  rb-inotify (0.10.1)
91
93
  ffi (~> 1.0)
92
- rbs (3.1.0)
94
+ rbs (3.1.1)
93
95
  rbs_rails (0.12.0)
94
96
  parser
95
97
  rbs (>= 1)
@@ -111,8 +113,9 @@ GEM
111
113
  diff-lcs (>= 1.2.0, < 2.0)
112
114
  rspec-support (~> 3.12.0)
113
115
  rspec-support (3.12.0)
114
- rubocop (1.52.1)
116
+ rubocop (1.54.2)
115
117
  json (~> 2.3)
118
+ language_server-protocol (>= 3.17.0)
116
119
  parallel (~> 1.10)
117
120
  parser (>= 3.2.2.3)
118
121
  rainbow (>= 2.2.2, < 4.0)
@@ -125,9 +128,9 @@ GEM
125
128
  parser (>= 3.2.1.0)
126
129
  ruby-progressbar (1.13.0)
127
130
  securerandom (0.2.2)
128
- steep (1.4.0)
131
+ steep (1.5.1)
129
132
  activesupport (>= 5.1)
130
- concurrent-ruby (>= 1.2.2)
133
+ concurrent-ruby (>= 1.1.10)
131
134
  csv (>= 3.0.9)
132
135
  fileutils (>= 1.1.0)
133
136
  json (>= 2.1.0)
@@ -136,7 +139,7 @@ GEM
136
139
  logger (>= 1.3.0)
137
140
  parser (>= 3.1)
138
141
  rainbow (>= 2.2.2, < 4.0)
139
- rbs (>= 2.8.0)
142
+ rbs (>= 3.1.0)
140
143
  securerandom (>= 0.1)
141
144
  strscan (>= 1.0.0)
142
145
  terminal-table (>= 2, < 4)
@@ -160,7 +163,7 @@ DEPENDENCIES
160
163
  rbs_active_hash!
161
164
  rspec
162
165
  rspec-daemon
163
- rubocop (~> 1.52)
166
+ rubocop (~> 1.54)
164
167
  steep
165
168
 
166
169
  BUNDLED WITH
data/Steepfile CHANGED
@@ -5,8 +5,7 @@ D = Steep::Diagnostic
5
5
  target :lib do
6
6
  signature "sig"
7
7
 
8
- check "lib" # Directory name
9
- check "Gemfile" # File name
8
+ check "lib"
10
9
 
11
- configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
10
+ configure_code_diagnostics(D::Ruby.lenient)
12
11
  end
@@ -102,7 +102,7 @@ module RbsActiveHash
102
102
  method_type = stringify_type(method_types.fetch(method, "untyped"))
103
103
  <<~RBS
104
104
  def #{method}: () -> #{method_type}
105
- def #{method}=: (#{method_type} value) -> void
105
+ def #{method}=: (#{method_type} value) -> #{method_type}
106
106
  def #{method}?: () -> bool
107
107
  def self.find_by_#{method}: (#{method_type} value) -> self?
108
108
  def self.find_all_by_#{method}: (#{method_type} value) -> Array[self]
@@ -121,7 +121,7 @@ module RbsActiveHash
121
121
  method_types = Hash.new { |hash, key| hash[key] = [] }
122
122
  (klass.data || []).each do |record|
123
123
  record.symbolize_keys.each do |key, value|
124
- method_types[key] << value.class
124
+ method_types[key] << identify_class(value)
125
125
  end
126
126
  end
127
127
  method_types.transform_values(&:uniq)
@@ -135,13 +135,27 @@ module RbsActiveHash
135
135
  "end\n" * klass.module_parents.size
136
136
  end
137
137
 
138
+ def identify_class(obj)
139
+ case obj
140
+ when Array
141
+ args = obj.map(&:class)
142
+ "#{obj.class}[#{stringify_type(args)}]"
143
+ when Hash
144
+ keys = obj.keys.map(&:class)
145
+ values = obj.values.map(&:class)
146
+ "#{obj.class}[#{stringify_type(keys)}, #{stringify_type(values)}]"
147
+ else
148
+ obj.class
149
+ end
150
+ end
151
+
138
152
  def stringify_type(type)
139
153
  if [TrueClass, FalseClass].include?(type)
140
154
  "bool"
141
155
  elsif type == NilClass
142
156
  "nil"
143
157
  elsif type.is_a? Class
144
- type.name
158
+ type.name.to_s
145
159
  elsif type.is_a? Array
146
160
  types = type.map { |t| stringify_type(t) }.uniq.sort
147
161
  if types.delete("nil")
@@ -7,7 +7,7 @@ require "rbs_active_hash"
7
7
 
8
8
  module RbsActiveHash
9
9
  class RakeTask < Rake::TaskLib
10
- attr_accessor :name, :signature_root_dir
10
+ attr_accessor :name, :signature_root_dir
11
11
 
12
12
  def initialize(name = :"rbs:active_hash", &block)
13
13
  super()
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsActiveHash
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "active_hash"
31
+ spec.add_dependency "rbs"
31
32
  spec.add_dependency "rbs_rails"
32
33
 
33
34
  # For more information and examples about making a new gem, check out our
@@ -2,7 +2,7 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 280d44d7671abfa909f2966fbef94bca5be082de
5
+ revision: aeede7258d020bfd509541e0c8075ce833292409
6
6
  remote: https://github.com/ruby/gem_rbs_collection.git
7
7
  repo_dir: gems
8
8
  path: ".gem_rbs_collection"
@@ -168,7 +168,7 @@ gems:
168
168
  remote: https://github.com/ruby/gem_rbs_collection.git
169
169
  repo_dir: gems
170
170
  - name: rbs
171
- version: 3.1.0
171
+ version: 3.1.1
172
172
  source:
173
173
  type: rubygems
174
174
  - name: rbs_rails
data/rbs_collection.yaml CHANGED
@@ -14,8 +14,5 @@ sources:
14
14
  path: .gem_rbs_collection
15
15
 
16
16
  gems:
17
- # Skip loading rbs gem's RBS.
18
- # It's unnecessary if you don't use rbs as a library.
19
- - name: rbs
20
17
  - name: steep
21
18
  ignore: true
@@ -0,0 +1,5 @@
1
+ module RbsActiveHash
2
+ class InstallGenerator < Rails::Generators::Base
3
+ def create_raketask: () -> void
4
+ end
5
+ end
@@ -1,13 +1,13 @@
1
1
  module RbsActiveHash
2
2
  module ActiveHash
3
- def self.user_defined_model?: (Class klass) -> bool
4
- def self.class_to_rbs: (Class klass) -> String
3
+ def self.user_defined_model?: (singleton(ActiveHash::Base) klass) -> bool
4
+ def self.class_to_rbs: (singleton(ActiveHash::Base) klass) -> String
5
5
 
6
6
  class Generator
7
- attr_reader klass: Class
7
+ attr_reader klass: singleton(ActiveHash::Base)
8
8
  attr_reader klass_name: String
9
9
 
10
- def initialize: (Class class) -> void
10
+ def initialize: (singleton(ActiveHash::Base) klass) -> void
11
11
  def generate: () -> String
12
12
 
13
13
  private
@@ -22,6 +22,7 @@ module RbsActiveHash
22
22
  def valid_field_name?: (String) -> boolish
23
23
  def footer: () -> String
24
24
 
25
+ def identify_class: (untyped value) -> (String | singleton(Class))
25
26
  def stringify_type: (untyped type) -> String
26
27
  end
27
28
  end
@@ -1,6 +1,18 @@
1
1
  module RbsActiveHash
2
- module RakeTask
2
+ class RakeTask < Rake::TaskLib
3
+ attr_accessor name: Symbol
4
+ attr_accessor signature_root_dir: Pathname
5
+
3
6
  @name: Symbol
4
7
  @signature_root_dir: Pathname
8
+
9
+ def initialize: (Symbol name) { (RakeTask) -> void } -> void
10
+ def define_setup_task: () -> void
11
+ def define_clean_task: () -> void
12
+ def define_generate_task: () -> void
13
+
14
+ private
15
+
16
+ def setup_signature_root_dir!: () -> void
5
17
  end
6
18
  end
@@ -1,4 +1,6 @@
1
1
  module RbsActiveHash
2
+ class Error < StandardError
3
+ end
4
+
2
5
  VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
6
  end
@@ -0,0 +1,19 @@
1
+ module Rake
2
+ class TaskLib
3
+ include Rake::DSL
4
+ end
5
+
6
+ module DSL
7
+ private
8
+
9
+ def desc: (String description) -> void
10
+ def file: (*untyped args) ?{ () -> void } -> void
11
+ def import: (*String fns) -> void
12
+ def multitask: (*untyped args) ?{ () -> void } -> void
13
+ def namespace: (?String? name) ?{ () -> void } -> void
14
+ def rule: (*untyped args) ?{ () -> void } -> void
15
+ def task: (*untyped args) ?{ () -> void } -> void
16
+ def sh: (*String cmd) ?{ (bool, Process::Status) -> void } -> void
17
+ end
18
+ end
19
+
@@ -0,0 +1,5 @@
1
+ class Thor
2
+ module Actions
3
+ def create_file: (String destination, *String? args, ?config: bool) ?{ () -> void } -> untyped
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_hash
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rbs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rbs_rails
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -63,9 +77,12 @@ files:
63
77
  - rbs_active_hash.gemspec
64
78
  - rbs_collection.lock.yaml
65
79
  - rbs_collection.yaml
80
+ - sig/generators/rbs_active_hash/install_generator.rbs
66
81
  - sig/rbs_active_hash.rbs
67
82
  - sig/rbs_active_hash/active_hash.rbs
68
83
  - sig/rbs_active_hash/rake_task.rbs
84
+ - sig/shims/rake.rbs
85
+ - sig/shims/thor.rbs
69
86
  homepage: https://github.com/tk0miya/rbs_active_hash
70
87
  licenses:
71
88
  - MIT