Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
516ed58
Fix: RuntimeError - Don't know how to build task 'db:migrate' (#844)
onk Jan 3, 2021
206d970
Update codeql-analysis.yml
ctran Jan 3, 2021
7d211dd
Create release-drafter.yml (#846)
ctran Jan 3, 2021
7b4bcde
Enable bundler caching for travis (#853)
Taher-Ghaleb Mar 24, 2021
83ff912
Fix typo invlaid -> invalid (#835)
olleolleolle Mar 24, 2021
70aba78
Use ruby/setup-ruby since actions/ruby is deprecated (#855)
ctran Mar 24, 2021
18e9e28
Bump puma from 4.3.3 to 4.3.5 in /spec/integration/rails_6.0.2.1 (#808)
dependabot[bot] Apr 26, 2021
4c41913
Bump puma from 4.3.3 to 4.3.5 in /spec/integration/rails_5.2.4.1 (#809)
dependabot[bot] Apr 26, 2021
4ddc7f1
Bump websocket-extensions in /spec/integration/rails_5.2.4.1 (#812)
dependabot[bot] Apr 26, 2021
de1e962
Bump websocket-extensions in /spec/integration/rails_6.0.2.1 (#813)
dependabot[bot] Apr 26, 2021
f665895
Bump rack from 2.1.2 to 2.2.3 in /spec/integration/rails_6.0.2.1 (#819)
dependabot[bot] Apr 26, 2021
a867eb0
Bump rack from 2.1.2 to 2.2.3 in /spec/integration/rails_5.2.4.1 (#820)
dependabot[bot] Apr 26, 2021
e075a21
Allow `get_loaded_model` to succeed when `$LOAD_PATH` contains non-st…
Hamms May 10, 2021
80fbfa5
fix ci: conflicts with removed gems (#865)
ocarta-l Jun 12, 2021
3aa43ea
Remove support for Ruby < 2.4 (#884)
ctran Jun 14, 2021
e4f761c
`get_loaded_model_by_path` is supposed to be nil-safe (#883)
sato11 Jun 14, 2021
ea3c309
Bump puma from 4.3.7 to 5.3.2 in /spec/integration/rails_5.2.4.1 (#887)
dependabot[bot] Jun 14, 2021
7863949
Bump nokogiri from 1.11.2 to 1.11.7 in /spec/integration/rails_6.0.2.…
dependabot[bot] Jun 14, 2021
69ab184
Fix: use klass.table_name instead of guessing from associated models …
ocarta-l Jan 31, 2022
ecf70d8
Fix undefined method error when geometric columns have no `srid` (#920)
oieioi Feb 1, 2022
eaacc0b
Loosen activerecord restriction to work with rails 7 (#912)
dabit Feb 3, 2022
bbb79eb
Bump puma from 5.3.2 to 5.6.1 in /spec/integration/rails_5.2.4.1 (#925)
dependabot[bot] Feb 3, 2022
77b8cac
Bump addressable from 2.7.0 to 2.8.0 in /spec/integration/rails_6.0.2…
dependabot[bot] Feb 8, 2022
d3a135d
bump: version to 3.2.0
ctran Feb 10, 2022
43e1185
Merge branch 'release/3.2.0'
ctran Feb 10, 2022
4319ec8
Bump version to 3.2.0
ctran Feb 10, 2022
3d2711a
Merge branch 'release/3.2.0'
ctran Feb 10, 2022
94f499d
Bump to v3.2.0
ctran Feb 10, 2022
a7cc62b
Merge branch 'release/v3.2.0'
ctran Feb 10, 2022
09d4723
Put Comments on New Line for Bare Formatting
deiden26 Sep 23, 2020
6620b6e
feat: add the ability to annotate nested namespaced models
Jul 24, 2021
658760b
chore: update setup ruby ci step
Aug 2, 2021
77f3d29
fix rubocop errors
Aug 2, 2021
2e3d977
chore: add rails 7 support
Sep 19, 2022
e657593
Merge branch 'master' into tborg.rebase-upstream
tborg Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,22 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7.4']
ruby: ['2.4', '2.5', '2.6']

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Ruby
uses: ruby/setup-ruby@v1.79.0
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Install sqlite
run: |
sudo apt-get install libsqlite3-dev

- name: Update System
run: |
gem update --system --no-document

- name: Bundle install for Annotate models
run: |
bundle install --jobs=4 --retry=3

- name: Run Tests
run: INTEGRATION_TESTS=1 bundle exec rspec

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: "Code scanning - action"

on:
push:
branches-ignore:
- pr/*
- scratch/*
pull_request:
schedule:
- cron: '0 6 * * 4'
- cron: '0 20 * * 7'

jobs:
CodeQL-Build:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Drafter

on:
push:
branches:
- develop

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "develop"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 2.6.7
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rvm:
env:
- RAILS_ENV=development RACK_ENV=development INTEGRATION_TESTS=1

cache: bundler

addons:
apt_packages:
- libsqlite3-dev
Expand Down
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note: The cmd option is now required due to the increasing number of ways
# NOTE: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def exit_exception(e)
exit e.status_code
end

# Note : this causes annoying psych warnings under Ruby 1.9.2-p180; to fix, upgrade to 1.9.3
# NOTE: this causes annoying psych warnings under Ruby 1.9.2-p180; to fix, upgrade to 1.9.3
begin
require 'bundler'
Bundler.setup(:default, :development)
Expand Down Expand Up @@ -162,7 +162,7 @@ namespace :integration do
fixtures[Digest::MD5.hexdigest(File.read(fname))] = File.expand_path(fname)
end

candidates.keys.each do |digest|
candidates.each_key do |digest|
next unless fixtures.key?(digest)
candidates[digest].each do |fname|
# Double-check contents in case of hash collision...
Expand Down
2 changes: 1 addition & 1 deletion annotate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|

s.specification_version = 4 if s.respond_to? :specification_version
s.add_runtime_dependency(%q<rake>, '>= 10.4', '< 14.0')
s.add_runtime_dependency(%q<activerecord>, ['>= 6.1', '< 7.1'])
s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 8.0'])

s.metadata = {
"bug_tracker_uri" => "https://github.com/ctran/annotate_models/issues/",
Expand Down
15 changes: 6 additions & 9 deletions lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ def get_loaded_model(model_path, file)
# auto_load/eager_load paths. Try all possible model paths one by one.
absolute_file = File.expand_path(file)
model_paths =
$LOAD_PATH.select { |path| absolute_file.include?(path) }
$LOAD_PATH.map(&:to_s)
.select { |path| absolute_file.include?(path) }
.map { |path| absolute_file.sub(path, '').sub(/\.rb$/, '').sub(/^\//, '') }
model_paths
.map { |path| get_loaded_model_by_path(path) }
Expand All @@ -660,9 +661,7 @@ def get_loaded_model(model_path, file)

# Retrieve loaded model class by path to the file where it's supposed to be defined.
def get_loaded_model_by_path(model_path)
klass = ActiveSupport::Inflector.constantize(ActiveSupport::Inflector.camelize(model_path))

klass if klass.is_a?(Class) && klass < ActiveRecord::Base
ActiveSupport::Inflector.constantize(ActiveSupport::Inflector.camelize(model_path))
rescue StandardError, LoadError
# Revert to the old way but it is not really robust
ObjectSpace.each_object(::Class)
Expand Down Expand Up @@ -905,9 +904,7 @@ def ignored_translation_table_colums(klass)
# Construct the foreign column name in the translations table
# eg. Model: Car, foreign column name: car_id
foreign_column_name = [
klass.translation_class.to_s
.gsub('::Translation', '').gsub('::', '_')
.downcase,
klass.table_name.to_s.singularize,
'_id'
].join.to_sym

Expand Down Expand Up @@ -948,9 +945,9 @@ def get_attributes(column, column_type, klass, options)
# Check out if we got a geometric column
# and print the type and SRID
if column.respond_to?(:geometry_type)
attrs << "#{column.geometry_type}, #{column.srid}"
attrs << [column.geometry_type, column.try(:srid)].compact.join(', ')
elsif column.respond_to?(:geometric_type) && column.geometric_type.present?
attrs << "#{column.geometric_type.to_s.downcase}, #{column.srid}"
attrs << [column.geometric_type.to_s.downcase, column.try(:srid)].compact.join(', ')
end

# Check if the column has indices and print "indexed" if true
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Annotate
def self.version
'3.1.1'
'3.2.0'
end
end
2 changes: 2 additions & 0 deletions lib/tasks/annotate_models_migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if defined?(Rails::Application) && Rails.version.split('.').first.to_i >= 6
end

migration_tasks.each do |task|
next unless Rake::Task.task_defined?(task)

Rake::Task[task].enhance do
Rake::Task[Rake.application.top_level_tasks.last].enhance do
annotation_options_task = if Rake::Task.task_defined?('app:set_annotation_options')
Expand Down
13 changes: 12 additions & 1 deletion spec/integration/rails_6.1.7/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ gem 'rails', '6.1.7'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.3.8'
gem 'puma', '~> 5.6'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/rails_7.0.4/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem 'rails', '7.0.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.3.8'
gem 'puma', '~> 5.6.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
Expand Down
12 changes: 8 additions & 4 deletions spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def mock_column(name, type, options = {})

context 'with Globalize gem' do
let :translation_klass do
double('Post::Translation',
to_s: 'Post::Translation',
double('Folder::Post::Translation',
to_s: 'Folder::Post::Translation',
columns: [
mock_column(:id, :integer, limit: 8),
mock_column(:post_id, :integer, limit: 8),
Expand Down Expand Up @@ -1181,7 +1181,10 @@ def mock_column(name, type, options = {})
limit: { srid: 4326, type: 'geometry' }),
mock_column(:location, :geography,
geometric_type: 'Point', srid: 0,
limit: { srid: 0, type: 'geometry' })
limit: { srid: 0, type: 'geometry' }),
mock_column(:non_srid, :geography,
geometric_type: 'Point',
limit: { type: 'geometry' })
]
end

Expand All @@ -1195,6 +1198,7 @@ def mock_column(name, type, options = {})
# active :boolean default(FALSE), not null
# geometry :geometry not null, geometry, 4326
# location :geography not null, point, 0
# non_srid :geography not null, point
#
EOS
end
Expand Down Expand Up @@ -1984,7 +1988,7 @@ class FooWithKnownMacro < ActiveRecord::Base
end
end

context 'when the file includes invlaid multibyte chars (USASCII)' do
context 'when the file includes invalid multibyte chars (USASCII)' do
context 'when class FooWithUtf8 is defined in "foo_with_utf8.rb"' do
let :filename do
'foo_with_utf8.rb'
Expand Down