Module: SmartRspec::Support::Regexes
- Included in:
- Matchers
- Defined in:
- lib/smart_rspec/support/regexes.rb
Constant Summary collapse
- @@uri_regexes =
{ protocol: /((ht|f)tp[s]?)/i, uri: %r{^( (((ht|f)tp[s]?://)|([a-z0-9]+\.))+ (?<!@) ([a-z0-9\_\-]+) (\.[a-z]+)+ ([\?/\:][a-z0-9_=%&@\?\./\-\:\#\(\)]+)? /? )$}ix }
Instance Method Summary collapse
Instance Method Details
#build_img_regex(exts = []) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/smart_rspec/support/regexes.rb', line 25 def build_img_regex(exts = []) exts = [exts].flatten if exts.nil? || exts.empty? exts = %w(jpg jpeg png gif) elsif exts.include?(:jpg) && !exts.include?(:jpeg) exts.push :jpeg end %r{(^http{1}[s]?://([w]{3}\.)?.+\.(#{exts.join('|')})(\?.+)?$)}i end |
#build_regex(type, *args) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/smart_rspec/support/regexes.rb', line 15 def build_regex(type, *args) case type.to_sym when :email then /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i when :image then build_img_regex(args) else @@uri_regexes[type] end end |