Skip to content

Commit 00e4b9a

Browse files
committed
Allow annotating models and routes using sorbet's static checks
See https://sorbet.org/docs/static
1 parent 5d01c41 commit 00e4b9a

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

lib/annotate/annotate_models.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module AnnotateModels
3939
}
4040
}.freeze
4141

42-
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
42+
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
4343

4444
class << self
4545
def annotate_pattern(options = {})

lib/annotate/annotate_routes/helpers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module AnnotateRoutes
22
module Helpers
3-
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)/).freeze
3+
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)|(^#\s*typed:.*)/).freeze
44

55
class << self
66
# TODO: write the method doc using ruby rdoc formats

spec/lib/annotate/annotate_models_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"# frozen_string_literal: true\n# encoding: utf-8",
1919
'# frozen_string_literal: true',
2020
'#frozen_string_literal: false',
21-
'# -*- frozen_string_literal : true -*-'
21+
'# -*- frozen_string_literal : true -*-',
22+
'#typed: false',
23+
'# typed: true'
2224
].freeze unless const_defined?(:MAGIC_COMMENTS)
2325

2426
def mock_index(name, params = {})

spec/lib/annotate/annotate_routes_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"# frozen_string_literal: true\n# encoding: utf-8",
2121
'# frozen_string_literal: true',
2222
'#frozen_string_literal: false',
23-
'# -*- frozen_string_literal : true -*-'
23+
'# -*- frozen_string_literal : true -*-',
24+
'#typed: false',
25+
'# typed: true'
2426
].freeze unless const_defined?(:MAGIC_COMMENTS)
2527

2628
let :stubs do

0 commit comments

Comments
 (0)