lib/rollout.rb in rollout-2.2.4 vs lib/rollout.rb in rollout-2.3.0
- old
+ new
@@ -11,11 +11,11 @@
@options = opts
@name = name
if string
raw_percentage,raw_users,raw_groups = string.split("|")
- @percentage = raw_percentage.to_i
+ @percentage = raw_percentage.to_f
@users = (raw_users || "").split(",").map(&:to_s).to_set
@groups = (raw_groups || "").split(",").map(&:to_sym).to_set
else
clear
end
@@ -83,10 +83,10 @@
def id_user_by
@options[:id_user_by] || :id
end
def user_in_percentage?(user)
- Zlib.crc32(user_id_for_percentage(user)) % 100 < @percentage
+ Zlib.crc32(user_id_for_percentage(user)) % 100_000 < @percentage * 1_000
end
def user_id_for_percentage(user)
if @options[:randomize_percentage]
user_id(user).to_s + @name.to_s