app/models/detour/feature.rb in detour-0.0.3 vs app/models/detour/feature.rb in detour-0.0.5
- old
+ new
@@ -1,24 +1,25 @@
# Represents an individual feature that may be rolled out to a set of records
# via individual flags, percentages, or defined groups.
class Detour::Feature < ActiveRecord::Base
include Detour::Concerns::Matchers
- include Detour::Concerns::FlagActions
self.table_name = :detour_features
serialize :flag_in_counts, JSON
serialize :opt_out_counts, JSON
has_many :flag_in_flags
- has_many :group_flags
+ has_many :defined_group_flags
+ has_many :database_group_flags
has_many :percentage_flags
has_many :opt_out_flags
has_many :flags, dependent: :destroy
validates_presence_of :name
validates_uniqueness_of :name
+ validates_format_of :name, with: /\A[\w-]+\Z/
attr_accessible :name
# Returns an instance variable intended to hold an array of the lines of code
# that this feature appears on.
@@ -67,10 +68,10 @@
Dir[*Detour.config.grep_dirs].each do |path|
next unless File.file? path
File.open path do |file|
file.each_line.with_index(1) do |line, i|
- line.scan(/\.has_feature\?\s*\(*:(\w+)/).each do |match, _|
+ line.scan(/\.has_feature\?\s*\(?[:"]([\w-]+)/).each do |match, _|
(hash[match] ||= new(name: match)).lines << "#{path}#L#{i}"
end
end
end
end