orthoses-rails 0.9.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -65
  3. data/lib/generators/orthoses/rails/install_generator.rb +18 -0
  4. data/lib/generators/orthoses/rails/templates/rails.rake +31 -0
  5. data/lib/orthoses/active_record/belongs_to.rb +15 -4
  6. data/lib/orthoses/active_record/enum.rb +5 -0
  7. data/lib/orthoses/active_record/generated_attribute_methods.rb +47 -55
  8. data/lib/orthoses/active_record/has_many.rb +15 -4
  9. data/lib/orthoses/active_record/has_one.rb +12 -2
  10. data/lib/orthoses/active_record/relation.rb +56 -0
  11. data/lib/orthoses/active_record/secure_token.rb +28 -0
  12. data/lib/orthoses/active_record.rb +37 -0
  13. data/lib/orthoses/active_storage/attached/model.rb +47 -0
  14. data/lib/orthoses/active_storage.rb +3 -0
  15. data/lib/orthoses/active_support/aliasing.rb +34 -0
  16. data/lib/orthoses/active_support/delegation.rb +17 -6
  17. data/lib/orthoses/active_support/time_with_zone.rb +30 -21
  18. data/lib/orthoses/active_support.rb +1 -0
  19. data/lib/orthoses/rails/application.rb +47 -0
  20. data/lib/orthoses/rails/version.rb +1 -1
  21. data/lib/orthoses/rails.rb +4 -2
  22. metadata +13 -45
  23. data/examples/rails/Gemfile +0 -16
  24. data/examples/rails/Gemfile.lock +0 -179
  25. data/examples/rails/Rakefile +0 -328
  26. data/examples/rails/config/database.yml +0 -8
  27. data/examples/rails/config/storage.yml +0 -3
  28. data/examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs +0 -4
  29. data/examples/rails/known_sig/activemodel/7.0/active_model/serialization.rbs +0 -4
  30. data/examples/rails/known_sig/activemodel/7.0/active_model/validations.rbs +0 -4
  31. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs +0 -49
  32. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs +0 -45
  33. data/examples/rails/known_sig/activerecord/6.0/active_record/result.rbs +0 -5
  34. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs +0 -49
  35. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs +0 -45
  36. data/examples/rails/known_sig/activerecord/6.1/active_record/result.rbs +0 -5
  37. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs +0 -49
  38. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs +0 -45
  39. data/examples/rails/known_sig/activerecord/7.0/active_record/encryption/context.rbs +0 -9
  40. data/examples/rails/known_sig/activerecord/7.0/active_record/result.rbs +0 -5
  41. data/examples/rails/known_sig/activesupport/7.0/active_support/callbacks/callback_chain.rbs +0 -9
  42. data/examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs +0 -4
  43. data/examples/rails/known_sig/activesupport/7.0/active_support/hash_with_indifferent_access.rbs +0 -6
  44. data/examples/rails/known_sig/activesupport/7.0/active_support/multibyte/chars.rbs +0 -7
  45. data/examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs +0 -5
  46. data/examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs +0 -3
  47. data/examples/rails/known_sig/activesupport/7.0/date.rbs +0 -6
  48. data/examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs +0 -4
  49. data/examples/rails/known_sig/activesupport/7.0/hash_with_indifferent_access.rbs +0 -2
  50. data/examples/rails/known_sig/activesupport/7.0/integer.rbs +0 -9
  51. data/examples/rails/known_sig/activesupport/7.0/numeric.rbs +0 -15
  52. data/examples/rails/known_sig/activesupport/7.0/string.rbs +0 -4
  53. data/examples/rails/known_sig/activesupport/7.0/time.rbs +0 -46
  54. data/examples/rails/tasks/action_pack.rake +0 -141
  55. data/examples/rails/tasks/action_view.rake +0 -77
  56. data/examples/rails/tasks/active_job.rake +0 -99
  57. data/examples/rails/tasks/active_model.rake +0 -46
  58. data/examples/rails/tasks/active_record.rake +0 -88
  59. data/examples/rails/tasks/active_storage.rake +0 -94
  60. data/examples/rails/tasks/active_support.rake +0 -99
  61. data/examples/rails/tasks/railties.rake +0 -34
  62. data/orthoses-rails.gemspec +0 -36
@@ -1,94 +0,0 @@
1
- require 'rbs'
2
-
3
- stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest forwardable did_you_mean openssl socket minitest]
4
- gem_dependencies = %w[nokogiri]
5
- rails_dependencies = %w[activesupport activemodel activejob activerecord]
6
-
7
- VERSIONS.each do |version|
8
- namespace version do
9
- namespace :active_storage do
10
- export = "export/activestorage/#{version}"
11
-
12
- desc "export to #{export}"
13
- task :export do
14
- sh "rm -fr #{export}"
15
- sh "mkdir -p #{export}"
16
-
17
- # base
18
- sh "cp -a out/#{version}/active_storage.rbs #{export}"
19
- sh "cp -a out/#{version}/active_storage #{export}"
20
- sh "rm #{export}/active_storage/engine.rbs"
21
- decls = RBS::Parser.parse_signature(RBS::Buffer.new(
22
- content: File.read("out/#{version}/active_record/base.rbs"),
23
- name: "out/#{version}/active_record/base.rbs"
24
- )).map do |decl|
25
- decl.members.select! do |member|
26
- case member
27
- when RBS::AST::Members::Mixin
28
- # Remove ActiveStorage
29
- member.name.to_s.include?("ActiveStorage")
30
- end
31
- end
32
- decl
33
- end
34
- File.open("#{export}/active_record_base.rbs", "w+") do |f|
35
- RBS::Writer.new(out: f).write(decls)
36
- end
37
-
38
- # TODO: remove after support action_controller
39
- sh "rm -fr #{export}/active_storage/blobs"
40
- sh "rm -fr #{export}/active_storage/representations"
41
- Dir.glob("#{export}/active_storage/*_controller.rbs").each do |controller|
42
- sh "rm -f #{controller}"
43
- end
44
- sh "rm -f #{export}/active_storage/streaming.rbs"
45
-
46
- generate_test_script(
47
- gem: :activestorage,
48
- version: version,
49
- export: export,
50
- stdlib_dependencies: stdlib_dependencies,
51
- gem_dependencies: gem_dependencies,
52
- rails_dependencies: rails_dependencies,
53
- )
54
-
55
- Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
56
- # !!! GENERATED CODE !!!
57
- # Please see generators/rails-generator
58
-
59
- class User < ActiveRecord::Base
60
- has_one_attached :one_image
61
- has_many_attached :many_image
62
- end
63
-
64
- user = User.new
65
- one = ActiveStorage::Attached::One.new("one_image", user)
66
- one.url
67
- RUBY
68
-
69
- Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
70
- # !!! GENERATED CODE !!!
71
- # Please see generators/rails-generator
72
-
73
- class User < ActiveRecord::Base
74
- end
75
- RBS
76
- end
77
-
78
- desc "validate version=#{version} gem=active_storage"
79
- task :validate do
80
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
81
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
82
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
83
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
84
- end
85
-
86
- desc "install to ../../../gems/activestorage/#{version}"
87
- task :install do
88
- install_to = File.expand_path("../../../gems/activestorage/#{version}", __dir__)
89
- sh "rm -fr #{install_to}"
90
- sh "cp -a #{export} #{install_to}"
91
- end
92
- end
93
- end
94
- end
@@ -1,99 +0,0 @@
1
- stdlib_dependencies = %w[benchmark date digest json logger monitor mutex_m pathname singleton time minitest]
2
- gem_dependencies = %w[nokogiri]
3
- rails_dependencies = %w[]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :active_support do
8
- export = "export/activesupport/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- # minimum
16
- sh "cp -a out/#{version}/active_support.rbs #{export}"
17
- sh "cp -a out/#{version}/active_support #{export}"
18
- sh "rm #{export}/active_support/railtie.rbs"
19
-
20
- # core_ext
21
- %w[
22
- array benchmark big_decimal class date date_and_time date_time digest
23
- enumerable file hash integer kernel load_error marshal module name_error numeric
24
- object pathname range regexp securerandom string symbol time uri
25
- ].each do |lib|
26
- out = "out/#{version}/#{lib}"
27
- sh "cp -a #{out} #{export}" if File.exist?(out)
28
- sh "cp -a #{out}.rbs #{export}" if File.exist?("#{out}.rbs")
29
- end
30
-
31
- # 5.2
32
- sh "cp -a out/#{version}/logger_silence.rbs #{export}" if File.exist?("out/#{version}/logger_silence.rbs")
33
-
34
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
35
- # !!! GENERATED CODE !!!
36
- # Please see generators/rails-generator
37
-
38
- module DRb
39
- module DRbUndumped
40
- end
41
- end
42
- module Concurrent
43
- class Map
44
- end
45
- end
46
- RBS
47
-
48
- case version
49
- when "6.0", "6.1"
50
- sh "rm -fr #{export}/uri"
51
- when "7.0"
52
- # deprecated
53
- sh "rm -fr #{export}/uri{,.rbs}"
54
- end
55
-
56
- generate_manifest(
57
- export: export,
58
- stdlib_dependencies: stdlib_dependencies
59
- )
60
- generate_test_script(
61
- gem: :activesupport,
62
- version: version,
63
- export: export,
64
- stdlib_dependencies: stdlib_dependencies,
65
- gem_dependencies: gem_dependencies,
66
- rails_dependencies: rails_dependencies,
67
- )
68
-
69
- Pathname(export).join('_test').join('test.rb').write(<<~'RUBY')
70
- # !!! GENERATED CODE !!!
71
- # Please see generators/rails-generator
72
-
73
- require 'active_support/all'
74
-
75
- # Test ActiveSupport::NumericWithFormat
76
- 42.to_s
77
- 42.to_s(:phone)
78
-
79
- 3.days.ago + 1.minute
80
- RUBY
81
- end
82
-
83
- desc "validate version=#{version} gem=active_support"
84
- task :validate do
85
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
86
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
87
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
88
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
89
- end
90
-
91
- desc "install to ../../../gems/activesupport/#{version}"
92
- task :install do
93
- install_to = File.expand_path("../../../gems/activesupport/#{version}", __dir__)
94
- sh "rm -fr #{install_to}"
95
- sh "cp -a #{export} #{install_to}"
96
- end
97
- end
98
- end
99
- end
@@ -1,34 +0,0 @@
1
- stdlib_dependencies = %w[benchmark date digest json logger monitor mutex_m pathname singleton time minitest securerandom ipaddr did_you_mean forwardable openssl socket]
2
- gem_dependencies = %w[nokogiri i18n rack rails-dom-testing]
3
- rails_dependencies = %w[actionpack actionview activejob activemodel activerecord activestorage activesupport]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :railties do
8
- export = "export/railties/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/railties_mixin #{export}"
16
- end
17
-
18
- desc "validate version=#{version} gem=railties"
19
- task :validate do
20
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
21
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
22
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
23
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
24
- end
25
-
26
- desc "install to ../../../gems/railties/#{version}"
27
- task :install do
28
- install_to = File.expand_path("../../../gems/railties/#{version}", __dir__)
29
- sh "rm -fr #{install_to}"
30
- sh "cp -a #{export} #{install_to}"
31
- end
32
- end
33
- end
34
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/orthoses/rails/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "orthoses-rails"
7
- spec.version = Orthoses::Rails::VERSION
8
- spec.authors = ["ksss"]
9
- spec.email = ["co000ri@gmail.com"]
10
-
11
- spec.summary = "Orthoses middleware collection for Ruby on Rails"
12
- spec.description = "Orthoses middleware collection for Ruby on Rails"
13
- spec.homepage = "https://github.com/ksss/orthoses-rails"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = spec.homepage
20
-
21
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject do |f|
23
- next true if (f == __FILE__)
24
- next true if f.match?(%r{\A(?:bin|known_sig)/}) # dir
25
- next true if f.match?(%r{\A\.(?:git)}) # git
26
- next true if f.match?(%r{\A(?:rbs_collection|Steepfile|Rakefile|Gemfile)}) # top file
27
- next true if f.match?(%r{_test\.rb\z}) # test
28
- false
29
- end
30
- end
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
34
-
35
- spec.add_dependency "orthoses", ">= 1.6"
36
- end