wp_validators 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in wp_validators.gemspec
4
+ gemspec
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wp_validators (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ rspec (1.3.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (>= 1.0.0.rc.6)
16
+ rspec (~> 1.3.0)
17
+ wp_validators!
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'bundler/setup'
5
+ require 'spec/rake/spectask'
6
+ Spec::Rake::SpecTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ require 'uri'
2
+
3
+ module WpValidators
4
+ def self.is_valid_url?(string)
5
+ uri = begin
6
+ URI::parse(string)
7
+ rescue URI::InvalidURIError, URI::BadURIError
8
+ return false
9
+ end
10
+
11
+ %w[http https].include?(uri.scheme)
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module WpValidators
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'wp_validators'
5
+
6
+ require 'spec'
7
+ require 'spec/autorun'
8
+
9
+ Spec::Runner.configure do |config|
10
+ # future configuration can go here
11
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe WpValidators do
4
+ describe '.is_valid_url?' do
5
+ def be_valid_url
6
+ simple_matcher("a valid url") do |str|
7
+ WpValidators.is_valid_url?(str)
8
+ end
9
+ end
10
+
11
+ it 'returns true for a valid http URL' do
12
+ 'http://example.com/'.should be_valid_url
13
+ end
14
+
15
+ it 'returns true for a valid https URL' do
16
+ 'https://example.com/'.should be_valid_url
17
+ end
18
+
19
+ it 'returns false for a string that is not a URL' do
20
+ 'some string'.should_not be_valid_url
21
+ end
22
+
23
+ it 'returns false for an ftp URL' do
24
+ 'ftp://example.com/'.should_not be_valid_url
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/wp_validators/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "wp_validators"
6
+ s.version = WpValidators::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Myron Marston']
9
+ s.email = ['myron.marston@gmail.com']
10
+ s.homepage = "http://rubygems.org/gems/wp_validators"
11
+ s.summary = "Some validators used at whitepages.com."
12
+ s.description = "Currently includes a URL validator."
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "wp_validators"
16
+
17
+ s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
18
+ s.add_development_dependency "rspec", "~> 1.3.0"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
22
+ s.require_path = 'lib'
23
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wp_validators
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Myron Marston
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-25 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 1
27
+ - 0
28
+ - 0
29
+ - rc
30
+ - 6
31
+ version: 1.0.0.rc.6
32
+ prerelease: false
33
+ name: bundler
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 3
44
+ - 0
45
+ version: 1.3.0
46
+ prerelease: false
47
+ name: rspec
48
+ type: :development
49
+ version_requirements: *id002
50
+ description: Currently includes a URL validator.
51
+ email:
52
+ - myron.marston@gmail.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
60
+ - .gitignore
61
+ - Gemfile
62
+ - Gemfile.lock
63
+ - Rakefile
64
+ - lib/wp_validators.rb
65
+ - lib/wp_validators/version.rb
66
+ - spec/spec_helper.rb
67
+ - spec/wp_validators_spec.rb
68
+ - wp_validators.gemspec
69
+ has_rdoc: true
70
+ homepage: http://rubygems.org/gems/wp_validators
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 1
91
+ - 3
92
+ - 6
93
+ version: 1.3.6
94
+ requirements: []
95
+
96
+ rubyforge_project: wp_validators
97
+ rubygems_version: 1.3.6
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Some validators used at whitepages.com.
101
+ test_files: []
102
+