Created
February 14, 2024 06:33
-
-
Save synth/8c9eee23aa9df535aa42a30f7cff9ba9 to your computer and use it in GitHub Desktop.
Revisions
-
synth created this gist
Feb 14, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ module Flipper module FlagRegistration # These functions are all memoized because they should be static for the # lifetime of a deployment (albeit they are really static to a Ruby process) def self.registered_flags @registered_flags ||= YAML.load_file("config/feature_flags.yml") end def self.flags_in_code @flags_in_code ||= begin search_regex = 'Flipper.enabled\?\(.*\)' command = "grep -rohE --exclude-dir='.//.*' --include='*rb' '#{search_regex}' ./" results = `#{command}` lines = results.split("\n") lines.map do |line| ast = Parser::CurrentRuby.parse(line) ast.children[2].children[0] end end end def self.registered_flags_not_found @registered_flags_not_found ||= flags_in_code - registered_flags.keys.map(&:to_sym) end def self.flags_not_registered @flags_not_registered ||= flags_in_code - registered_flags.keys.map(&:to_sym) end end end