orthoses-rails 0.7.0 → 0.8.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: 721183c8c3c14666265aa24ecfe51ba9703afe1ed99bf5e320b6c57c2e995722
4
- data.tar.gz: deabd621c4483c341b687dc5562c72aa52a49c4b983544244dc9e2b736cd056d
3
+ metadata.gz: 70f9def2ba0ccd5b1537ee8aa3ee68c2700e99d0f134d313069939cc1db3277d
4
+ data.tar.gz: 922e2e304b3aa7f5cd34cb215ea3656c6a4c79c34875b7fd7ed691743230ea10
5
5
  SHA512:
6
- metadata.gz: ed8956fbfd018c4dbd650c1c20c9d46172c1cabafd286de074dbcda62d5f898125d66b12a4b461097eb6134dd3dd9dac9546157a794152064201d12261bc3365
7
- data.tar.gz: c4154bd4a83864ebf2f8a13fa7cffd4bb721374f9d05674a234565efc3676ac0a837aef866233ef9f256351b70022cc60bd07f199f588d57e6bba50f0edca819
6
+ metadata.gz: 42f23b91ba796e225541f7da52cc74916a53ef584f1711d95457b0cc239441146678c4ebbb5a271a52710d928f55edba2d5032bec56a4fe9f9b0e47bf7e44c6a
7
+ data.tar.gz: 1f9c63c9d2b9b8f11d820a27ef660d61cb727d3a3b3b644afa93fb3b7bdb48dbd150ca7ab96f636d02fb330e2de27c902862e04b89a514f20d5e3d51d5172dc8
data/README.md CHANGED
@@ -48,34 +48,35 @@ If bundler is not being used to manage dependencies, install the gem by executin
48
48
 
49
49
  ## Usage
50
50
 
51
+ Build your Rake task for RBS generation.
52
+
51
53
  ```rb
52
- Orthoses::Builder.new do
53
- use Orthoses::CreateFileByName
54
- base_dir: Rails.root.join("sig/out"),
55
- header: "# !!! GENERATED CODE !!!"
56
- use Orthoses::Filter,
57
- if: -> (name, _content) {
54
+ task :rbs_generate => :environment do
55
+ Orthoses::Builder.new do
56
+ use Orthoses::CreateFileByName
57
+ base_dir: Rails.root.join("sig/out"),
58
+ header: "# !!! GENERATED CODE !!!"
59
+ use Orthoses::Filter do |name, _content|
58
60
  path, _lineno = Object.const_source_location(name)
59
61
  return false unless path
60
62
  %r{app/models}.match?(path)
63
+ end
64
+ use YourCustom::Middleware
65
+ use Orthoses::ActiveModel::HasSecurePassword
66
+ use Orthoses::ActiveRecord::BelongsTo
67
+ use Orthoses::ActiveRecord::HasMany
68
+ use Orthoses::ActiveRecord::HasOne
69
+ use Orthoses::ActiveSupport::ClassAttribute
70
+ use Orthoses::ActiveSupport::MattrAccessor
71
+ use Orthoses::Mixin
72
+ use Orthoses::Constant, strict: false
73
+ use Orthoses::ObjectSpaceAll
74
+ use Orthoses::Autoload
75
+ run -> {
76
+ Rails.application.eager_load!
61
77
  }
62
- use YourCustom::Middleware
63
- use Orthoses::ActiveModel::HasSecurePassword
64
- use Orthoses::ActiveRecord::BelongsTo
65
- use Orthoses::ActiveRecord::HasMany
66
- use Orthoses::ActiveRecord::HasOne
67
- use Orthoses::ActiveSupport::ClassAttribute
68
- use Orthoses::ActiveSupport::MattrAccessor
69
- use Orthoses::Mixin
70
- use Orthoses::Constant, strict: false
71
- use Orthoses::ObjectSpaceAll
72
- use Orthoses::Autoload
73
- run -> () {
74
- Rake::Task[:environment].invoke
75
- Rails.application.eager_load!
76
- Orthoses::Utils.unautoload!
77
- }
78
- end.call
78
+ end.call
79
+ end
79
80
  ```
80
81
 
81
82
  ## Development
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- orthoses-rails (0.6.0)
5
- orthoses (>= 0.10)
4
+ orthoses-rails (0.7.0)
5
+ orthoses (~> 1.0)
6
6
 
7
7
  PATH
8
8
  remote: _src
@@ -134,9 +134,9 @@ GEM
134
134
  nokogiri (1.13.8)
135
135
  mini_portile2 (~> 2.8.0)
136
136
  racc (~> 1.4)
137
- orthoses (0.11.0)
137
+ orthoses (1.0.0)
138
138
  rbs (~> 2.0)
139
- psych (3.3.2)
139
+ psych (3.3.3)
140
140
  racc (1.6.0)
141
141
  rack (2.2.4)
142
142
  rack-test (2.0.2)
@@ -148,7 +148,8 @@ GEM
148
148
  loofah (~> 2.3)
149
149
  rake (13.0.6)
150
150
  rbs (2.6.0)
151
- sqlite3 (1.4.4)
151
+ sqlite3 (1.5.0)
152
+ mini_portile2 (~> 2.8.0)
152
153
  strscan (3.0.4)
153
154
  thor (1.2.1)
154
155
  timeout (0.3.0)
@@ -67,22 +67,21 @@ def generate(out_dir, version)
67
67
  use Orthoses::CreateFileByName,
68
68
  base_dir: "#{out_dir}/#{version}",
69
69
  header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
70
- use Orthoses::Filter,
71
- if: -> (name, content) {
72
- # OMG, both ERB and Erb are exist...
73
- return false if name.start_with?("Erb")
70
+ use Orthoses::Filter do |name, content|
71
+ # OMG, both ERB and Erb are exist...
72
+ return false if name.start_with?("Erb")
74
73
 
75
- # ArgumentError
76
- return false if name.start_with?("I18n::Tests")
74
+ # ArgumentError
75
+ return false if name.start_with?("I18n::Tests")
77
76
 
78
- # FIXME: too hard
79
- return false if name.include?("::Generators")
77
+ # FIXME: too hard
78
+ return false if name.include?("::Generators")
80
79
 
81
- # Ignore known sig
82
- return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
80
+ # Ignore known sig
81
+ return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
83
82
 
84
- true
85
- }
83
+ true
84
+ end
86
85
  use Orthoses::Constant,
87
86
  strict: false,
88
87
  if: -> (current, const, _val, _rbs) {
@@ -1,21 +1,4 @@
1
- module DateAndTime
2
- module Calculations
3
- end
4
- module Zones
5
- end
6
- module Compatibility
7
- end
8
- end
9
- module ActiveSupport
10
- class TimeZone
11
- end
12
- class Duration
13
- end
14
- end
15
-
16
1
  class Time
17
- include DateAndTime::Calculations
18
-
19
2
  # Returns <tt>Time.zone.now</tt> when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns <tt>Time.now</tt>.
20
3
  def self.current: () -> ActiveSupport::TimeWithZone # strictly `(ActiveSupport::TimeWithZone | Time)` but it's inconvenient
21
4
  def self.zone: () -> ActiveSupport::TimeZone # strictly `ActiveSupport::TimeWithZone?` but it's inconvenient
@@ -29,16 +12,6 @@ class Time
29
12
  | ...
30
13
  def -: (ActiveSupport::Duration other) -> self
31
14
  | ...
32
- alias at_beginning_of_day beginning_of_day
33
- alias at_beginning_of_hour beginning_of_hour
34
- alias at_beginning_of_minute beginning_of_minute
35
- alias at_end_of_day end_of_day
36
- alias at_end_of_hour end_of_hour
37
- alias at_end_of_minute end_of_minute
38
- alias at_midday middle_of_day
39
- alias at_middle_of_day middle_of_day
40
- alias at_midnight beginning_of_day
41
- alias at_noon middle_of_day
42
15
  def beginning_of_day: () -> self
43
16
  def beginning_of_hour: () -> self
44
17
  def beginning_of_minute: () -> self
@@ -49,9 +22,7 @@ class Time
49
22
  def end_of_minute: () -> self
50
23
  def eql_with_coercion: (untyped other) -> bool
51
24
  def eql_without_coercion: (untyped other) -> bool
52
- alias midday middle_of_day
53
25
  def middle_of_day: () -> self
54
- alias midnight beginning_of_day
55
26
  def minus_with_coercion: (Time | self arg0) -> Float
56
27
  | (Numeric arg0) -> self
57
28
  def minus_with_duration: (Time | self arg0) -> Float
@@ -63,7 +34,6 @@ class Time
63
34
  def next_day: () -> self
64
35
  def next_month: () -> self
65
36
  def next_year: () -> self
66
- alias noon middle_of_day
67
37
  def plus_without_duration: (Time | self arg0) -> Float
68
38
  | (Numeric arg0) -> self
69
39
  def prev_day: () -> self
@@ -12,10 +12,7 @@ VERSIONS.each do |version|
12
12
  sh "rm -fr #{export}"
13
13
  sh "mkdir -p #{export}"
14
14
 
15
- if File.exist?("out/#{version}/active_record/destroy_association_async_job.rbs")
16
- sh "mkdir -p #{export}/active_record"
17
- sh "cp out/#{version}/active_record/destroy_association_async_job.rbs #{export}/active_record/destroy_association_async_job.rbs"
18
- end
15
+ sh "cp -a out/#{version}/railties_mixin #{export}"
19
16
  end
20
17
 
21
18
  desc "validate version=#{version} gem=railties"
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ module ActiveSupport
5
+ class Concern
6
+ def initialize(loader)
7
+ @loader = loader
8
+ end
9
+
10
+ def call
11
+ lazy_tracer = Orthoses::CallTracer::Lazy.new
12
+
13
+ store = lazy_tracer.trace('ActiveSupport::Concern#class_methods') do
14
+ @loader.call
15
+ end
16
+
17
+ lazy_tracer.captures.each do |capture|
18
+ receiver_name = Orthoses::Utils.module_name(capture.method.receiver)
19
+ next unless receiver_name
20
+
21
+ class_methods_name = "#{receiver_name}::ClassMethods"
22
+ members = members_prototype_of(class_methods_name)
23
+
24
+ writer = ::RBS::Writer.new(out: StringIO.new)
25
+ members.each do |member|
26
+ writer.write_member(member)
27
+ end
28
+ out = writer.out
29
+ # NOTE: Should I remove the method that is accidentally added in prototype rb?
30
+ store[class_methods_name].concat(out.string.each_line.to_a)
31
+ end
32
+
33
+ store
34
+ end
35
+
36
+ def members_prototype_of(mod_name)
37
+ mod = Object.const_get(mod_name)
38
+ runtime = ::RBS::Prototype::Runtime.new(patterns: nil, env: nil, merge: false)
39
+ type_name = runtime.to_type_name(mod_name)
40
+ [].tap do |members|
41
+ runtime.generate_methods(mod, type_name, members)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'active_support/class_attribute'
4
+ require_relative 'active_support/concern'
4
5
  require_relative 'active_support/configurable'
5
6
  require_relative 'active_support/delegation'
6
7
  require_relative 'active_support/mattr_accessor'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Orthoses
4
4
  module Rails
5
- VERSION = "0.7.0"
5
+ VERSION = "0.8.0"
6
6
  end
7
7
  end
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
34
34
 
35
- spec.add_dependency "orthoses", ">= 0.11"
35
+ spec.add_dependency "orthoses", "~> 1.0"
36
36
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthoses-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-28 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orthoses
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.11'
26
+ version: '1.0'
27
27
  description: Orthoses middleware collection for Ruby on Rails
28
28
  email:
29
29
  - co000ri@gmail.com
@@ -87,6 +87,7 @@ files:
87
87
  - lib/orthoses/active_record/scope.rb
88
88
  - lib/orthoses/active_support.rb
89
89
  - lib/orthoses/active_support/class_attribute.rb
90
+ - lib/orthoses/active_support/concern.rb
90
91
  - lib/orthoses/active_support/configurable.rb
91
92
  - lib/orthoses/active_support/delegation.rb
92
93
  - lib/orthoses/active_support/mattr_accessor.rb
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  - !ruby/object:Gem::Version
120
121
  version: '0'
121
122
  requirements: []
122
- rubygems_version: 3.4.0.dev
123
+ rubygems_version: 3.3.16
123
124
  signing_key:
124
125
  specification_version: 4
125
126
  summary: Orthoses middleware collection for Ruby on Rails