- 10 Feb, 2022 1 commit
-
-
Cuong Tran authored
-
- 01 Feb, 2022 1 commit
-
-
Hiroki Koike authored
-
- 31 Jan, 2022 1 commit
-
-
ocarta-l authored
Thanks!
-
- 14 Jun, 2021 1 commit
-
-
Junichi Sato authored
This commit partially reverts #801, which by declaring conditional return has turned `get_loaded_model_by_path` to a less safe method that can return nil when its the condition is not met. Apparently the very same condition has been brought to `annotate_model_file` by #774, which seems to cover the "bug" insisted in #801 as well. On the other hand #801 has brought an inconvenient behaviour as well: whenever a non-activerecord model file is found, `get_loaded_model_by_path` returns nil, which leads to raising `BadModelFileError` and ends up printing a bunch of "Unable to annotate ..." messages. Now it seems tests added by #801 are running right and I do not find a problem restoring the previous behaviour and turn it nil-safe again.
-
- 10 May, 2021 1 commit
-
-
Elijah Hamovitz authored
As currently implemented, `get_loaded_model` inspects the `$LOAD_PATH` global for path values when trying to find the path for a model file. This would be fine, except that variable is affected by userspace, which means that it will sometimes contain non-string values, often Pathnames. To avoid responding with the error `Unable to annotate #{model_path}: no implicit conversion of Pathname into String` in this situation, we simply add an explicit `to_s` call before performing string-specific operations. Fixes https://github.com/ctran/annotate_models/issues/758
-
- 03 Jan, 2021 1 commit
-
-
Takafumi ONAKA authored
ActiveRecord's migrate tasks are required since v2.7.5 (#588).
-
- 18 May, 2020 2 commits
-
-
Karl-Aksel Puulmann authored
This is a bugfix for the following case: ``` # app/models/foo.rb module Foo; end # app/models/bar/foo.rb class Bar::Foo < Activerecord::Base; end ``` Where `Bar::Foo` would never get annotated.
-
Alex Boyd authored
Make `annotate_routes` depend on `set_annotation_options` just as `annotate_models` does. Fixes #761.
-
- 17 May, 2020 1 commit
-
-
Paul authored
Rails 6 adds a new set of migration tasks for multi-database apps. This change makes the annotate_models_migrate hooks aware of them.
-
- 09 May, 2020 1 commit
-
-
Viktor Fonic authored
This is an addition to this PR: https://github.com/ctran/annotate_models/pull/692 I've seen it's been stale for a while and it's rather simple fix. I noticed my ActiveAdmin resources are not being annotated. I know ActiveAdmin uses plural model names, but, as far as I remember, they used to use singular model names in the past. We can see some "evidence" of that here: https://activeadmin.info/2-resource-customization.html#customizing-parent-menu-items Probably in other places as well. In order to keep the gem working as expected for singular ActiveAdmin resources, I suggest we annotate both singular and plural model names. I just tested this out in a project of mine where I renamed one file to be in singular form and left the other files in plural form. It worked like a charm. :)
-
- 08 May, 2020 1 commit
-
-
ethanbresler authored
Currently, the models annotator automatically attempts to find a class with a matching name at the bottom of project's directory tree before going up into specific engine's models. This causes issues with models that share names with classes in other engines or lower classes in the project's directory. This PR adds the option to skip attempts to load classes from lower directories and just uses the model's file path directly. #674
-
- 06 Apr, 2020 2 commits
-
-
Shu Fujita authored
AnnotateModels is fat and so hard to maintain. In order to reduce code lines of AnnotateModels, move constants and methods defined in AnnotateModels to another namespace AnnotateModels::FilePatterns.
-
Henrik Nyh authored
-
- 05 Apr, 2020 5 commits
-
-
Shu Fujita authored
cf. #790 In order to refactor `AnnoateRoutes`, I added methods to `AnnotateRoutes::HeaderGenerator` and refactor methods. I will add `AnnotateRoutes::AnnotationProcessor` and `AnnotateRoutes::RemovalProcessor` in next PR.
-
Troy Rosenberg authored
Closes #778 If a column comment includes the newline character, the newline character would be "printed" into the annotation block resulting in a line break and an uncommented line. For example, for the following table: ``` create_table "users", force: :cascade do |t| t.string "name", comment: "This is a comment.\nWith two lines!" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end ``` annotating the model with the `--with-comment` flag will result in: ``` \# == Schema Information \# \# Table name: users \# \# id :bigint not null, primary key \# name(This is a comment. With two lines!) :string \# created_at :datetime not null \# updated_at :datetime not null \# ``` This uncommented line would result in invalid Ruby and cause the file to no longer be valid. This fix replaces the newline character with an escaped version, so the output will look more like: ``` \# == Schema Information \# \# Table name: users \# \# id :bigint not null, primary key \# name(This is a comment.\nWith two lines!):string \# created_at :datetime not null \# updated_at :datetime not null \# ```
-
Troy Rosenberg authored
This is a bit of a cheat of a refactoring that simply extracts the logic for collecting a column's attributes out of `get_schema_info` and into its own method (`get_attributes`). I found that in PRs like #779 that the Rubocop ABC limit was being exceeded: ``` lib/annotate/annotate_models.rb:235:5: C: Metrics/AbcSize: Assignment Branch Condition size for get_schema_info is too high. [145/145] def get_schema_info(klass, header, options = {}) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Hopefully, this should break this up and reduce the complexity of the method. There are opportunities to go further, but I thought this could be a good place to start. I would be open and interested in discussing further refactoring opportunities if it would make sense (maybe creating some new classes to encapsulate some of this logic).
-
Shu Fujita authored
I noticed that `AnnotateRoutes` can be more maintainable by refactoring. I am planning to refactor `AnnotateRoutes` in this order. * separate logic of `AnnotateRoutes` into `AnnotateRoutes::HeaderGenerator`. * add methods to `AnnotateRoutes::HeaderGenerator` and refactor methods. * add `AnnotateRoutes::AnnotationProcessor` and `AnnotateRoutes::RemovalProcessor` The final goal of this refactoring is as follows. * https://github.com/nard-tech/annotate_models/blob/feature/refactor_annotate_routes/processors/lib/annotate/annotate_routes.rb * https://github.com/nard-tech/annotate_models/tree/feature/refactor_annotate_routes/processors/lib/annotate/annotate_routes So in the first I added `AnnotateRoutes::HeaderGenerator` in order to separate logic of `AnnotateRoutes` in this PR. When refactor of `AnnotateRoutes` is finished, I would like to refactor `AnnotateModels` in a like way.
-
Erik Kessler authored
## Problem I have some files in the "models" directory that are not true a `Class`. For example, a [`dry-types`](https://dry-rb.org/gems/dry-types/1.2/sum/) sum type: ```ruby # app/models/foo.rb Foo = Types::String | Types::Integer ``` This results in the following line when I annotate. ``` Unable to annotate app/models/foo.rb: undefined method `<' for #<Dry::Struct::Sum:0x00007ff2dd262988> ``` Not a blocking issue but somewhat annoying nonetheless. ## Solution When annotating a file, check that the file's object is a `Class` to ensure it has the interface we expect.
-
- 09 Mar, 2020 1 commit
-
-
Andrew W. Lee authored
-
- 08 Mar, 2020 2 commits
-
-
Shu Fujita authored
For further refactoring toward better architecture, I moved methods `.strip_annotations`, `.extract_magic_comments_from_array` and `.real_content_and_header_position` from `AnnotateRoutes` to `AnnotateRoutes::Helpers`.
-
Andrew W. Lee authored
It was reported in https://github.com/ctran/annotate_models/issues/762 that column defaults were broken. This reverts changes made in #677 to restore the expected behavior of column defaults. For the time being columns with associated enums won't be working.
-
- 22 Feb, 2020 1 commit
-
-
Henrik Nyh authored
-
- 20 Feb, 2020 1 commit
-
-
Andrew W. Lee authored
-
- 17 Feb, 2020 1 commit
-
-
Ryan authored
* Fix new lines after comments for rubocop compatability Fix #552, #607
-
- 13 Feb, 2020 1 commit
-
-
Ryan authored
-
- 27 Jan, 2020 2 commits
-
-
Shu Fujita authored
# Summary * Removed unnecessary variables * Renamed variables that have same name as reserved word (`p`) * Other tiny fixes
-
Shu Fujita authored
I fixed message to make them more natural English.
-
- 24 Jan, 2020 1 commit
-
-
tvallois authored
The scope of this pull request is to allow annotate_models to generate models documentation using YARD. This is the first step, I'll add more features later.
-
- 22 Jan, 2020 1 commit
-
-
Manuel Hoffmann authored
-
- 20 Jan, 2020 3 commits
-
-
Shu Fujita authored
I moved `puts` from `AnnotateRoutes.rewrite_contents` to `.do_annotations` and `.remove_annotations`.
-
Shu Fujita authored
I removed `AnnotateRoutes.rewrite_contents_with_header` because the logic of `AnnotateRoutes.rewrite_contents_with_header` is as same as `.rewrite_contents`.
-
Peter Gundel authored
* Add columns managed by Globalize gem Globalize hooks into the model and removes the translated columns from the `klass.columns`. This commit checks if globalize is hooked into the model and adds the necessary columns to the annotation array. * Disable Rubocop Metrics/BlockLength for spec files RSpec spec files can contain long blocks easily because of the outher describe methods. So this rule makes not too much sense for these files.
-
- 19 Jan, 2020 3 commits
-
-
Shu Fujita authored
I refactored `AnnotateRoutes.annotate_routes` and `.rewrite_contents_with_header` in order to add an empty string to `new_content` array in `.annotate_routes`. I will refactor `.rewrite_contents_with_header` more, and remove `. rewrite_contents_with_header` in the next PR.
-
Shu Fujita authored
# Summary * I replaced `#blank?` of ActiveSupport to `#present?` * I moved `AnnotateModels::Parser#commit` after `#parser ` because `#commit` is used after `#parser` in `#parse`.
-
Shu Fujita authored
I removed invalid document of AnnotateRoutes.rewrite_contents. I will add valid documents in YARD format in another PR.
-
- 18 Jan, 2020 2 commits
-
-
Shu Fujita authored
I refactored two methods in AnnotateModels::Helpers for readability.
-
Shu Fujita authored
I refactored `AnnotateRoutes.routes_exists?` and methods using this. The points are as follows. * Removing `puts` in `AnnotateRoutes.routes_exists?` * Using `File.exist?` instead of `File.exists?` because `File.exists?` is deprecated * Renaming `AnnotateRoutes.routes_exists?` to `AnnotateRoutes.routes_file_exists?` in order to make the name of method more explanatory
-
- 16 Jan, 2020 3 commits
-
-
Shu Fujita authored
* Refactor AnnotateRoutes.rewrite_contents and .remove_annotations * Refactor AnnotateRoutes.remove_annotations and .strip_on_removal
-
Shu Fujita authored
* Remove Annotate.#loaded_tasks= and .loaded_tasks * Remove unnecessary comment for Rubocop * Make Annotate.load_requires private * Refactor Annotate.load_tasks
-
Shu Fujita authored
-