1. 18 May, 2020 1 commit
  2. 09 May, 2020 1 commit
  3. 08 May, 2020 1 commit
    • Adding option to skip loading models from subdirectories (#767) · 508d06a8
      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 
  4. 06 Apr, 2020 1 commit
  5. 05 Apr, 2020 3 commits
    • Fix output for multiline column comments (#779) · 214da4f6
      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
      \#
      ```
    • 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.
  6. 30 Mar, 2020 1 commit
    • Some project clean up (#786) · 1c1c5850
      Andrew W. Lee authored
      This PR does the following:
      * moves code coverage generation to happen when `COVERAGE` environment variable is present.
      * makes integration tests run when when `INTEGRATION_TESTS` is present.
      * moves `ruby-head` from TravisCI build. Previously the configuration allowed for `ruby-head` to be ignored if it failed, but it conflicted with the gem release build job step.
  7. 08 Mar, 2020 1 commit
  8. 25 Feb, 2020 1 commit
  9. 17 Feb, 2020 1 commit
  10. 13 Feb, 2020 2 commits
  11. 06 Feb, 2020 1 commit
  12. 04 Feb, 2020 1 commit
  13. 27 Jan, 2020 1 commit
  14. 26 Jan, 2020 2 commits
  15. 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.
  16. 20 Jan, 2020 3 commits
    • AnnotateModels.get_schema_info (with custom options) (#732) · 1b51de89
      Shu Fujita authored
      * Structuralize RSpec test cases of AnnotateModels.get_schema_info (with custom options)
      
      * Replace expression expansion to plain text
      
      * Refactor RSpec test cases of AnnotateModels.get_schema_info (with custom options)
      
      * Change position of test cases
    • Fix typo in RSpec of AnnotateModels (#731) · fd663b96
      Shu Fujita authored
    • 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.
  17. 19 Jan, 2020 1 commit
    • Refactor RSpec for AnnotateModels (1) (#726) · 87b51c24
      Shu Fujita authored
      I refactored and structuralized RSpec test cases of AnnotateModels for readability and scalability because it was too complex to read.
      
      cf. #718 
      In this PR, I refactored test cases of some methods in `AnnotateModels`.
      I will refactor test cases of other methods in another PR.
  18. 18 Jan, 2020 1 commit
    • 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
  19. 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.
  20. 18 Dec, 2019 2 commits
    • [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)
      ```
  21. 09 Nov, 2019 4 commits
  22. 28 Sep, 2019 1 commit
  23. 26 Sep, 2019 1 commit
  24. 03 Sep, 2019 1 commit
    • Make it possible to annotate models and routes together (#647) · 846c7f8e
      Andrew W. Lee authored
      Prior to this change, `Annotate.include_models?` returned the inverse of `Annotate.include_routes?`. This made it so annotating models and routes was not possible to do together.
      
      This PR adds an explicit `--models` flag and also adds it the option to `lib/generators/annotate/templates/auto_annotate_models.rake` with the default being set to `false`. 
      
      Fixes #563 and undoes the bug introduced in #485.
  25. 02 Sep, 2019 1 commit
    • Tidy spec directory (#646) · 2775001d
      Andrew W. Lee authored
      In looking into #563, I realized there are gaps in test coverage. For example, `bin/annotate` doesn't have any tests. 
      
      Tidying the spec directory to make it easier to add tests in future work.