url_formatter 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in url_formatter.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ module UrlFormatter
2
+ VERSION = "0.0.1.alpha"
3
+ end
@@ -0,0 +1,17 @@
1
+ require "url_formatter/version"
2
+ require "url_formatter/model_additions"
3
+ require "url_formatter/railtie" if defined? Rails
4
+
5
+ module UrlFormatter
6
+ def self.format_url(url)
7
+ if url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp
8
+ "http://#{url}"
9
+ else
10
+ url
11
+ end
12
+ end
13
+
14
+ def self.url_regexp
15
+ /^https?:\/\/([^\s:@]+:[^\s:@]*@)?[-[[:alnum:]]]+(\.[-[[:alnum:]]]+)+\.?(:\d{1,5})?([\/?]\S*)?$/iux
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "url_formatter/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "url_formatter"
7
+ s.version = UrlFormatter::VERSION
8
+ s.authors = ["Ryan Bates"]
9
+ s.email = ["ryan@railscasts.com"]
10
+ s.homepage = "https://github.com/ryanb/url_formatter"
11
+ s.summary = %q{Format and validate a URL in Active Record}
12
+ s.description = %q{Example of creating a Ruby Gem for RailsCasts episode #301}
13
+
14
+ s.rubyforge_project = "url_formatter"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_development_dependency "supermodel"
23
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: url_formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Bates
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70221063413020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70221063413020
25
+ - !ruby/object:Gem::Dependency
26
+ name: supermodel
27
+ requirement: &70221063412600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70221063412600
36
+ description: ! 'Example of creating a Ruby Gem for RailsCasts episode #301'
37
+ email:
38
+ - ryan@railscasts.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - Rakefile
46
+ - lib/url_formatter.rb
47
+ - lib/url_formatter/version.rb
48
+ - url_formatter.gemspec
49
+ homepage: https://github.com/ryanb/url_formatter
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>'
65
+ - !ruby/object:Gem::Version
66
+ version: 1.3.1
67
+ requirements: []
68
+ rubyforge_project: url_formatter
69
+ rubygems_version: 1.8.11
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Format and validate a URL in Active Record
73
+ test_files: []