lib/lookbook/support/utils/utils.rb in lookbook-1.5.5 vs lib/lookbook/support/utils/utils.rb in lookbook-2.0.0.beta.0

- old
+ new

@@ -5,11 +5,19 @@ parts = args.map { |arg| arg.to_s } id_str = parts.join("-").force_encoding("UTF-8").parameterize.dasherize PathUtils.strip_slashes(id_str).tr("/", "-").gsub("--", "-") end + def temp_id(prefix: nil) + [prefix, (Time.now.to_f * 1000).to_i + rand(0..100)].compact.join("-") + end + def name(str) str.to_s.parameterize.tr("-", "_") + end + + def symbolize_name(str) + name(str).to_sym end def value_or_fallback(value, fallback = nil, &block) if value.nil? fallback_block = block || proc { fallback }