Skip to content

Commit

Permalink
Allow annotating models and routes using sorbet's static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wteuber committed Sep 3, 2024
1 parent 5d01c41 commit 00e4b9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module AnnotateModels
}
}.freeze

MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*(?:\n|r\n))|(^# coding:.*(?:\n|\r\n))|(^# -\*- coding:.*(?:\n|\r\n))|(^# -\*- encoding\s?:.*(?:\n|\r\n))|(^#\s*frozen_string_literal:.+(?:\n|\r\n))|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))/).freeze
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*(?:\n|r\n))|(^# coding:.*(?:\n|\r\n))|(^# -\*- coding:.*(?:\n|\r\n))|(^# -\*- encoding\s?:.*(?:\n|\r\n))|(^#\s*frozen_string_literal:.+(?:\n|\r\n))|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))|(^#\s*typed:.+(?:\n|\r\n))/).freeze

class << self
def annotate_pattern(options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/annotate_routes/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module AnnotateRoutes
module Helpers
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)/).freeze
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)|(^#\s*typed:.*)/).freeze

class << self
# TODO: write the method doc using ruby rdoc formats
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"# frozen_string_literal: true\n# encoding: utf-8",
'# frozen_string_literal: true',
'#frozen_string_literal: false',
'# -*- frozen_string_literal : true -*-'
'# -*- frozen_string_literal : true -*-',
'#typed: false',
'# typed: true'
].freeze unless const_defined?(:MAGIC_COMMENTS)

def mock_index(name, params = {})
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/annotate/annotate_routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"# frozen_string_literal: true\n# encoding: utf-8",
'# frozen_string_literal: true',
'#frozen_string_literal: false',
'# -*- frozen_string_literal : true -*-'
'# -*- frozen_string_literal : true -*-',
'#typed: false',
'# typed: true'
].freeze unless const_defined?(:MAGIC_COMMENTS)

let :stubs do
Expand Down

0 comments on commit 00e4b9a

Please sign in to comment.