1. 05 Apr, 2020 3 commits
    • Reactors AnnotateModels.get_schema_info (#791) · da1e6052
      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). 
    • Refactor AnnotateRoutes by adding AnnotateRoutes::HeaderGenerator (#790) · d89ddefa
      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.
    • Fix "undefined method `<'" error message (#774) · d9392d9e
      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.
  2. 09 Mar, 2020 1 commit
  3. 08 Mar, 2020 2 commits
  4. 22 Feb, 2020 1 commit
  5. 20 Feb, 2020 1 commit
  6. 17 Feb, 2020 1 commit
  7. 13 Feb, 2020 1 commit
  8. 27 Jan, 2020 2 commits
  9. 24 Jan, 2020 1 commit
    • Support YARD notation (#724) · 06255470
      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.
  10. 22 Jan, 2020 1 commit
  11. 20 Jan, 2020 3 commits
    • Refactor AnnotateRoutes.rewrite_contents (#734) · d4948432
      Shu Fujita authored
      I moved `puts` from `AnnotateRoutes.rewrite_contents` to `.do_annotations` and `.remove_annotations`.
    • Remove AnnotateRoutes.rewrite_contents_with_header (#730) · db8b0999
      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`.
    • Add columns managed by Globalize gem (#602) · d894fa29
      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.
  12. 19 Jan, 2020 3 commits
  13. 18 Jan, 2020 2 commits
    • Refactor AnnotateModels::Helpers (#723) · 1c5deb09
      Shu Fujita authored
      I refactored two methods in AnnotateModels::Helpers for readability.
    • Refactor AnnotateRoutes.routes_file_exist? (#716) · 9a8db1b7
      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
  14. 16 Jan, 2020 4 commits
  15. 15 Jan, 2020 3 commits
  16. 06 Jan, 2020 1 commit
    • Rename method and variable of AnnotateRoutes for readability (#709) · ee88f0fd
      Shu Fujita authored
      Before I commited, the method `AnnotateRoutes.where_header_found` returned an array of `real_content` and `header_found_at`.
      
      I fixed the name of method and variable because they did not match.
      
      I renamed the method `real_content_and_header_position` and unified related variable names to `header_position`.
  17. 30 Dec, 2019 1 commit
    • Refactor lib/annotate.rb (#707) · 3f0b6b32
      Andrew W. Lee authored
      This change converts .all_options into a constant and moves it into Annotate::Constants. It also changes usages of .all_options.
  18. 18 Dec, 2019 3 commits
    • Replace soft-deprecated constant `HashWithIndifferentAccess` to… · a05e4586
      naari3 authored
      Replace soft-deprecated constant `HashWithIndifferentAccess` to `ActiveSupport::HashWithIndifferentAccess` (#699)
      
    • [Fix #430] Handle columns from activerecord-postgis-adapter (#694) · c13fe49c
      inkstak authored
      Same problem returned by @janosrusiczki in #430
      
      Spatial columns with activerecord-postgis-adapter (5.2.2) are not displayed nice
      
      ```
      # name           :string(3)
      # active         :boolean          default(FALSE), not null
      # geom           :geometry({:srid= geometry, 4326
      ```
      
      That's come from activerecord-postgis-adapter, with redefined columns as such :
      
      ``` 
      #<ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumn 
        @sql_type="geometry(Geometry,4326)",
        @geo_type="Geometry",
        @geometric_type=RGeo::Feature::Geometry,
        @srid=4326,
        @limit={:srid=>4326, :type=>"geometry"}
        [...]
      >
      ```
      
      This fix displays them like this :
      
      ```
      # name           :string(3)
      # active         :boolean          default(FALSE), not null
      # geometry       :geometry         geometry, 4326
      ```
      
      Another possibility would have been to display them as below, but it involves a lot of extra-spaces for other columns.
      
      ```
      # name           :string(3)
      # active         :boolean                   default(FALSE), not null
      # geometry       :geometry(Geometry, 4326)
      ```
  19. 02 Dec, 2019 2 commits
  20. 09 Nov, 2019 4 commits