Sha256: 55c15719eed171292c9f56db5f099d6763fc5bd3dd1bf300a53011f0d59408fa
Contents?: true
Size: 617 Bytes
Versions: 17
Compression:
Stored size: 617 Bytes
Contents
# frozen_string_literal: true def read_json_file(file) JSON.parse(File.read(file)) rescue StandardError => e raise "JSON parsing error in #{file} #{e}" end # Sanitize and classify a slug # @note As a class can not start with a digit or underscore, a D_ is # put as a prefix in such case. Ugly but well :x # Not only used to classify slugs though, but Dynamic Finder names as well # # @return [ Symbol ] def classify_slug(slug) classified = slug.to_s.gsub(/[^a-z\d\-]/i, '-').gsub(/\-{1,}/, '_').camelize.to_s classified = "D_#{classified}" if /\d/.match?(classified[0]) classified.to_sym end
Version data entries
17 entries across 17 versions & 1 rubygems