rbs_active_hash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 233acb3a91cc07f0b2db21995c7906c43269c801fab32a1bd3192729e0d67bbd
4
+ data.tar.gz: 276ea886963014e06eff21094fa210953656c014b01fb07b0690f777934c0523
5
+ SHA512:
6
+ metadata.gz: ef51ed27e545012fe365856d645f554999b0eb5805936b57a3b478f4d67ef95d8084a66a07433d8283f51df7a0cb8337180fc9a4d19a2e3db3655d084f9270eb
7
+ data.tar.gz: 1f47c140e0b92b40abc9d534a9f45c5a387d100e59316514c269764d04936185a3f9566a1539a7833c202e0e1bf21ee8e1fedb7b3330ab806fe55a9e942394d8
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Style/StringLiterals:
8
+ Enabled: true
9
+ EnforcedStyle: double_quotes
10
+
11
+ Style/StringLiteralsInInterpolation:
12
+ Enabled: true
13
+ EnforcedStyle: double_quotes
14
+
15
+ Layout/LineLength:
16
+ Max: 120
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - spec/**/*_spec.rb
@@ -0,0 +1,7 @@
1
+ {
2
+ "recommendations": [
3
+ "shopify.ruby-lsp",
4
+ "soutaro.steep-vscode",
5
+ "tk0miya.rspec-daemon"
6
+ ]
7
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.defaultFormatter": "Shopify.ruby-lsp"
4
+ }
5
+ }
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at i.tkomiya@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rbs_active_hash.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.21"
11
+
12
+ group :development do
13
+ gem "rspec", require: false
14
+ gem "rspec-daemon", require: false
15
+
16
+ gem "steep"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,117 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rbs_active_hash (0.1.0)
5
+ active_hash
6
+ rbs_rails
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ active_hash (3.2.0)
12
+ activesupport (>= 5.0.0)
13
+ activesupport (7.0.5)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ ast (2.4.2)
19
+ coderay (1.1.3)
20
+ concurrent-ruby (1.2.2)
21
+ csv (3.2.6)
22
+ diff-lcs (1.5.0)
23
+ ffi (1.15.5)
24
+ fileutils (1.7.1)
25
+ i18n (1.14.0)
26
+ concurrent-ruby (~> 1.0)
27
+ json (2.6.3)
28
+ language_server-protocol (3.17.0.3)
29
+ listen (3.8.0)
30
+ rb-fsevent (~> 0.10, >= 0.10.3)
31
+ rb-inotify (~> 0.9, >= 0.9.10)
32
+ logger (1.5.3)
33
+ method_source (1.0.0)
34
+ minitest (5.18.0)
35
+ parallel (1.23.0)
36
+ parser (3.2.2.1)
37
+ ast (~> 2.4.1)
38
+ pry (0.14.2)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ rainbow (3.1.1)
42
+ rake (13.0.6)
43
+ rb-fsevent (0.11.2)
44
+ rb-inotify (0.10.1)
45
+ ffi (~> 1.0)
46
+ rbs (3.1.0)
47
+ rbs_rails (0.12.0)
48
+ parser
49
+ rbs (>= 1)
50
+ regexp_parser (2.8.0)
51
+ rexml (3.2.5)
52
+ rspec (3.12.0)
53
+ rspec-core (~> 3.12.0)
54
+ rspec-expectations (~> 3.12.0)
55
+ rspec-mocks (~> 3.12.0)
56
+ rspec-core (3.12.2)
57
+ rspec-support (~> 3.12.0)
58
+ rspec-daemon (0.1.5)
59
+ pry
60
+ rspec
61
+ rspec-expectations (3.12.3)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-mocks (3.12.5)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.12.0)
67
+ rspec-support (3.12.0)
68
+ rubocop (1.52.0)
69
+ json (~> 2.3)
70
+ parallel (~> 1.10)
71
+ parser (>= 3.2.0.0)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.8, < 3.0)
74
+ rexml (>= 3.2.5, < 4.0)
75
+ rubocop-ast (>= 1.28.0, < 2.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (>= 2.4.0, < 3.0)
78
+ rubocop-ast (1.29.0)
79
+ parser (>= 3.2.1.0)
80
+ ruby-progressbar (1.13.0)
81
+ securerandom (0.2.2)
82
+ steep (1.4.0)
83
+ activesupport (>= 5.1)
84
+ concurrent-ruby (>= 1.2.2)
85
+ csv (>= 3.0.9)
86
+ fileutils (>= 1.1.0)
87
+ json (>= 2.1.0)
88
+ language_server-protocol (>= 3.15, < 4.0)
89
+ listen (~> 3.0)
90
+ logger (>= 1.3.0)
91
+ parser (>= 3.1)
92
+ rainbow (>= 2.2.2, < 4.0)
93
+ rbs (>= 2.8.0)
94
+ securerandom (>= 0.1)
95
+ strscan (>= 1.0.0)
96
+ terminal-table (>= 2, < 4)
97
+ strscan (3.0.6)
98
+ terminal-table (3.0.2)
99
+ unicode-display_width (>= 1.1.1, < 3)
100
+ tzinfo (2.0.6)
101
+ concurrent-ruby (~> 1.0)
102
+ unicode-display_width (2.4.2)
103
+
104
+ PLATFORMS
105
+ x86_64-linux
106
+ x86_64-darwin-21
107
+
108
+ DEPENDENCIES
109
+ rake (~> 13.0)
110
+ rbs_active_hash!
111
+ rspec
112
+ rspec-daemon
113
+ rubocop (~> 1.21)
114
+ steep
115
+
116
+ BUNDLED WITH
117
+ 2.4.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Takeshi KOMIYA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # rbs_active_hash
2
+
3
+ rbs_active_hash is a generator for [ActiveHash](https://github.com/active-hash/active_hash/) models.
4
+
5
+ ## Installation
6
+
7
+ Add a new entry to your Gemfile and run `bundle install`:
8
+
9
+ group :development do
10
+ gem 'rbs_active_hash'
11
+ end
12
+
13
+ After the installation, please run rake task generator:
14
+
15
+ bundle exec rails g rbs_active_hash:install
16
+
17
+ ## Usage
18
+
19
+ Run `rbs:active_hash:setup` task:
20
+
21
+ bundle exec rake rbs:active_hash:setup
22
+
23
+ Then rbs_active_hash will scan your source code, and will generate RBS files into
24
+ `sig/active_hash` directory.
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. You can also
29
+ run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`.
32
+
33
+ To release a new version, update the version number in `version.rb`, and then put
34
+ a git tag (ex. `git tag v1.0.0`) and push it to the GitHub. Then GitHub Actions
35
+ will release a new package to [rubygems.org](https://rubygems.org) automatically.
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tk0miya/rbs_active_hash.
40
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are
41
+ expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rbs_active_hash/blob/main/CODE_OF_CONDUCT.md).
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Code of Conduct
48
+
49
+ Everyone interacting in the rbs_active_hash project's codebases, issue trackers is expected to
50
+ follow the [code of conduct](https://github.com/tk0miya/rbs_active_hash/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
data/Steepfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ D = Steep::Diagnostic
4
+
5
+ target :lib do
6
+ signature "sig"
7
+
8
+ check "lib" # Directory name
9
+ check "Gemfile" # File name
10
+
11
+ configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
12
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+
5
+ module RbsActiveHash
6
+ class InstallGenerator < Rails::Generators::Base
7
+ def create_raketask
8
+ create_file "lib/tasks/rbs_active_hash.rake", <<~RUBY
9
+ begin
10
+ require 'rbs_active_hash/rake_task'
11
+
12
+ RbsActiveHash::RakeTask.new
13
+ rescue LoadError
14
+ # failed to load rbs_rails. Skip to load rbs_rails tasks.
15
+ end
16
+ RUBY
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbs"
4
+ require "rbs_rails/util"
5
+ require "active_hash"
6
+
7
+ module RbsActiveHash
8
+ module ActiveHash
9
+ def self.user_defined_model?(klass)
10
+ klass.name !~ /^Active(Hash|File|JSON|Yaml)::/
11
+ end
12
+
13
+ def self.class_to_rbs(klass)
14
+ Generator.new(klass).generate
15
+ end
16
+
17
+ class Generator
18
+ def initialize(klass)
19
+ @klass = klass
20
+ end
21
+
22
+ def generate
23
+ if klass.ancestors.include? ::ActiveFile::Base
24
+ begin
25
+ klass.reload
26
+ rescue StandardError
27
+ nil
28
+ end
29
+ end
30
+
31
+ RbsRails::Util.format_rbs klass_decl
32
+ end
33
+
34
+ private
35
+
36
+ def klass_decl
37
+ <<~RBS
38
+ #{header}
39
+ #{enum_decls}
40
+ #{method_decls}
41
+ #{footer}
42
+ RBS
43
+ end
44
+
45
+ def header
46
+ module_defs = module_names.map { |module_name| "module #{module_name}" }
47
+
48
+ superclass_name = RbsRails::Util.module_name(klass.superclass)
49
+ class_name = klass.name.split("::").last
50
+ class_def = "class #{class_name} < ::#{superclass_name}"
51
+
52
+ (module_defs + [class_def]).join("\n")
53
+ end
54
+
55
+ def module_names
56
+ klass.module_parents.reverse[1..].map do |mod|
57
+ mod.name.split("::").last
58
+ end
59
+ end
60
+
61
+ def enum_decls
62
+ return unless klass.ancestors.include? ::ActiveHash::Enum
63
+
64
+ <<~RBS
65
+ include ActiveHash::Enum
66
+ extend ActiveHash::Enum::Methods
67
+
68
+ #{constants.map { |c| "#{c}: instance" }.join("\n")}
69
+ RBS
70
+ end
71
+
72
+ def constants
73
+ enum_accessors = klass.instance_eval { @enum_accessors }
74
+ return [] unless enum_accessors
75
+
76
+ klass.data.filter_map do |record|
77
+ constant = enum_accessors.map { |name| record[name] }.join("_")
78
+ next if constant.empty?
79
+
80
+ constant.gsub!(/\W+/, "_")
81
+ constant.gsub!(/^_|_$/, "")
82
+ constant.upcase!
83
+ constant
84
+ end
85
+ end
86
+
87
+ def method_decls
88
+ method_names.map do |method|
89
+ <<~RBS
90
+ def #{method}: () -> untyped
91
+ def #{method}=: (untyped value) -> void
92
+ def #{method}?: () -> bool
93
+ def self.find_by_#{method}: (untyped value) -> self?
94
+ def self.find_all_by_#{method}: (untyped value) -> Array[self]
95
+ RBS
96
+ end.join("\n")
97
+ end
98
+
99
+ def method_names
100
+ method_names = (klass.data || []).flat_map do |record|
101
+ record.symbolize_keys.keys
102
+ end
103
+ method_names.uniq.select { |k| k != :id && valid_field_name?(k) }
104
+ end
105
+
106
+ def valid_field_name?(name)
107
+ name.to_s =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
108
+ end
109
+
110
+ def footer
111
+ "end\n" * klass.module_parents.size
112
+ end
113
+
114
+ attr_reader :klass
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "rake"
5
+ require "rake/tasklib"
6
+ require "rbs_active_hash"
7
+
8
+ module RbsActiveHash
9
+ class RakeTask < Rake::TaskLib
10
+ attr_accessor :name, :signature_root_dir
11
+
12
+ def initialize(name = :"rbs:active_hash", &block)
13
+ super()
14
+
15
+ @name = name
16
+
17
+ block&.call(self)
18
+
19
+ setup_signature_root_dir!
20
+
21
+ define_clean_task
22
+ define_generate_task
23
+ define_setup_task
24
+ end
25
+
26
+ def define_setup_task
27
+ desc "Run all tasks of rbs_active_hash"
28
+
29
+ deps = [:"#{name}:clean", :"#{name}:generate"]
30
+ task("#{name}:setup": deps)
31
+ end
32
+
33
+ def define_clean_task
34
+ desc "Clean up generated RBS files"
35
+ task("#{name}:clean": :environment) do
36
+ sh "rm", "-rf", @signature_root_dir.to_s
37
+ end
38
+ end
39
+
40
+ def define_generate_task
41
+ desc "Generate RBS files for ActiveHash models"
42
+ task("#{name}:generate": :environment) do
43
+ Rails.application.eager_load!
44
+
45
+ ::ActiveHash::Base.descendants.each do |klass|
46
+ next unless RbsActiveHash::ActiveHash.user_defined_model?(klass)
47
+
48
+ path = signature_root_dir / "app/models/#{klass.name.underscore}.rbs"
49
+ path.dirname.mkpath
50
+ path.write RbsActiveHash::ActiveHash.class_to_rbs(klass)
51
+ end
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def setup_signature_root_dir!
58
+ @signature_root_dir ||= Pathname(Rails.root / "sig/active_hash")
59
+ @signature_root_dir.mkpath
60
+ @signature_root_dir
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsActiveHash
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rbs_active_hash/active_hash"
4
+ require_relative "rbs_active_hash/version"
5
+
6
+ module RbsActiveHash
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rbs_active_hash/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rbs_active_hash"
7
+ spec.version = RbsActiveHash::VERSION
8
+ spec.authors = ["Takeshi KOMIYA"]
9
+ spec.email = ["i.tkomiya@gmail.com"]
10
+
11
+ spec.summary = "A RBS files generator for ActiveHash models"
12
+ spec.description = "A RBS files generator for ActiveHash models"
13
+ spec.homepage = "https://github.com/tk0miya/rbs_active_hash"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.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(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
24
+ end
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "active_hash"
31
+ spec.add_dependency "rbs_rails"
32
+
33
+ # For more information and examples about making a new gem, check out our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
@@ -0,0 +1,114 @@
1
+ ---
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
6
+ remote: https://github.com/ruby/gem_rbs_collection.git
7
+ repo_dir: gems
8
+ path: ".gem_rbs_collection"
9
+ gems:
10
+ - name: abbrev
11
+ version: '0'
12
+ source:
13
+ type: stdlib
14
+ - name: activesupport
15
+ version: '7.0'
16
+ source:
17
+ type: git
18
+ name: ruby/gem_rbs_collection
19
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
20
+ remote: https://github.com/ruby/gem_rbs_collection.git
21
+ repo_dir: gems
22
+ - name: ast
23
+ version: '2.4'
24
+ source:
25
+ type: git
26
+ name: ruby/gem_rbs_collection
27
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
28
+ remote: https://github.com/ruby/gem_rbs_collection.git
29
+ repo_dir: gems
30
+ - name: concurrent-ruby
31
+ version: '1.1'
32
+ source:
33
+ type: git
34
+ name: ruby/gem_rbs_collection
35
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
36
+ remote: https://github.com/ruby/gem_rbs_collection.git
37
+ repo_dir: gems
38
+ - name: date
39
+ version: '0'
40
+ source:
41
+ type: stdlib
42
+ - name: i18n
43
+ version: '1.10'
44
+ source:
45
+ type: git
46
+ name: ruby/gem_rbs_collection
47
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
48
+ remote: https://github.com/ruby/gem_rbs_collection.git
49
+ repo_dir: gems
50
+ - name: json
51
+ version: '0'
52
+ source:
53
+ type: stdlib
54
+ - name: logger
55
+ version: '0'
56
+ source:
57
+ type: stdlib
58
+ - name: minitest
59
+ version: '0'
60
+ source:
61
+ type: stdlib
62
+ - name: monitor
63
+ version: '0'
64
+ source:
65
+ type: stdlib
66
+ - name: mutex_m
67
+ version: '0'
68
+ source:
69
+ type: stdlib
70
+ - name: optparse
71
+ version: '0'
72
+ source:
73
+ type: stdlib
74
+ - name: parallel
75
+ version: '1.20'
76
+ source:
77
+ type: git
78
+ name: ruby/gem_rbs_collection
79
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
80
+ remote: https://github.com/ruby/gem_rbs_collection.git
81
+ repo_dir: gems
82
+ - name: pathname
83
+ version: '0'
84
+ source:
85
+ type: stdlib
86
+ - name: rainbow
87
+ version: '3.0'
88
+ source:
89
+ type: git
90
+ name: ruby/gem_rbs_collection
91
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
92
+ remote: https://github.com/ruby/gem_rbs_collection.git
93
+ repo_dir: gems
94
+ - name: rbs
95
+ version: 3.1.0
96
+ source:
97
+ type: rubygems
98
+ - name: rdoc
99
+ version: '0'
100
+ source:
101
+ type: stdlib
102
+ - name: singleton
103
+ version: '0'
104
+ source:
105
+ type: stdlib
106
+ - name: time
107
+ version: '0'
108
+ source:
109
+ type: stdlib
110
+ - name: tsort
111
+ version: '0'
112
+ source:
113
+ type: stdlib
114
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,23 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
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
+ - name: steep
21
+ ignore: true
22
+ - name: rbs_rails
23
+ ignore: true
@@ -0,0 +1,26 @@
1
+ module RbsActiveHash
2
+ module ActiveHash
3
+ def self.user_defined_model?: (Class klass) -> bool
4
+ def self.class_to_rbs: (Class klass) -> String
5
+
6
+ class Generator
7
+ @klass: Class
8
+
9
+ def initialize: (Class class) -> void
10
+ def generate: () -> String
11
+
12
+ private
13
+
14
+ def klass_decl: () -> String
15
+ def header: () -> String
16
+ def enum_decls: () -> String?
17
+ def constants: () -> Array[String]
18
+ def method_decls: () -> String
19
+ def method_names: () -> Array[String]
20
+ def valid_field_name?: (String) -> boolish
21
+ def footer: () -> String
22
+
23
+ attr_reader klass: Class
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ module RbsActiveHash
2
+ module RakeTask
3
+ @name: Symbol
4
+ @signature_root_dir: Pathname
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module RbsActiveHash
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_active_hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takeshi KOMIYA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_hash
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: rbs_rails
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'
41
+ description: A RBS files generator for ActiveHash models
42
+ email:
43
+ - i.tkomiya@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rubocop.yml"
49
+ - ".vscode/extensions.json"
50
+ - ".vscode/settings.json"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - Steepfile
58
+ - lib/generators/rbs_active_hash/install_generator.rb
59
+ - lib/rbs_active_hash.rb
60
+ - lib/rbs_active_hash/active_hash.rb
61
+ - lib/rbs_active_hash/rake_task.rb
62
+ - lib/rbs_active_hash/version.rb
63
+ - rbs_active_hash.gemspec
64
+ - rbs_collection.lock.yaml
65
+ - rbs_collection.yaml
66
+ - sig/rbs_active_hash.rbs
67
+ - sig/rbs_active_hash/active_hash.rbs
68
+ - sig/rbs_active_hash/rake_task.rbs
69
+ homepage: https://github.com/tk0miya/rbs_active_hash
70
+ licenses:
71
+ - MIT
72
+ metadata:
73
+ homepage_uri: https://github.com/tk0miya/rbs_active_hash
74
+ source_code_uri: https://github.com/tk0miya/rbs_active_hash
75
+ changelog_uri: https://github.com/tk0miya/rbs_active_hash
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '3.0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.4.10
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A RBS files generator for ActiveHash models
95
+ test_files: []