Module: MacSpec::TestingFramework::Functions
- Defined in:
- lib/mac_spec/testing_framework/core/functions.rb
Overview
Temporary
A temporary module that holds functionality that awaits to be refactored to the right place.
Class Method Summary collapse
-
.determine_class_name(name) ⇒ Object
:nodoc:.
- .make_constantizeable(string) ⇒ Object
- .string?(string) ⇒ Boolean
Class Method Details
.determine_class_name(name) ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/mac_spec/testing_framework/core/functions.rb', line 12 def self.determine_class_name(name) #:nodoc: name.to_s.split(/\W+/).map { |s| s[0..0].upcase + s[1..-1] }.join end |
.make_constantizeable(string) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mac_spec/testing_framework/core/functions.rb', line 16 def self.make_constantizeable(string) return string unless self.string?(string) string = string.gsub(/[^\w\s]/,"").gsub(/^[\d\s]*/,"") raise ArgumentError.new( "Invalid argument: #{string}. Must not be empty after removing '\W'-class chars." ) if string.gsub(/\s/,"").empty? string end |
.string?(string) ⇒ Boolean
8 9 10 |
# File 'lib/mac_spec/testing_framework/core/functions.rb', line 8 def self.string?(string) string.is_a?(String) ? true : false end |