commonthread-rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/commonthread-rails.gemspec +2 -2
- data/lib/commonthread/monkey_patches.rb +1 -1
- data/test/test_monkey_patches.rb +28 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/commonthread-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{commonthread-rails}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["CommonThread"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.description = %q{commonthread-rails is a collection of things that make rails development better for us. It includes date formats, monkey patches to String, Array and NilClass to make things nicer. An Encrypter using blowfish. Also, some rails filters}
|
14
14
|
s.email = %q{hello@commonthread.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class String
|
2
2
|
def convert(pattern, template)
|
3
3
|
output = String.new(template)
|
4
|
-
self.match(pattern).to_a.each_with_index{|group, index| output.gsub!("$#{index}", group)}
|
4
|
+
self.match(pattern).to_a.each_with_index{|group, index| output.gsub!("$#{index}", group.to_s)}
|
5
5
|
output
|
6
6
|
end
|
7
7
|
|
data/test/test_monkey_patches.rb
CHANGED
@@ -40,6 +40,30 @@ class TestMonkeyPatches < Test::Unit::TestCase
|
|
40
40
|
assert_equal "commonthread-rails".to_pretty_url, "commonthread-rails"
|
41
41
|
assert_equal "commonthread-rails v0.1.1".to_pretty_url, "commonthread-rails_v011"
|
42
42
|
end
|
43
|
+
|
44
|
+
should "make random strings" do
|
45
|
+
assert String.rand =~ /^[a-z0-9]{8}$/
|
46
|
+
assert String.rand(5) =~ /^[a-z0-9]{5}$/
|
47
|
+
end
|
48
|
+
|
49
|
+
should "check if string is an email" do
|
50
|
+
assert "ben@commonthread.com".email?
|
51
|
+
assert ! "ben.commonthread.com".email?
|
52
|
+
end
|
53
|
+
|
54
|
+
should "check if string is a phone number" do
|
55
|
+
assert "800.555.1212".phone?
|
56
|
+
assert "800-555-1212".phone?
|
57
|
+
assert "(800) 555-1212".phone?
|
58
|
+
assert ! "800.555.121".phone?
|
59
|
+
end
|
60
|
+
|
61
|
+
should "check if string is a date" do
|
62
|
+
assert "08/02/1980".date?
|
63
|
+
assert "08-02-1980".date?
|
64
|
+
assert "Aug 2, 1980".date?
|
65
|
+
assert ! "08021980".date?
|
66
|
+
end
|
43
67
|
end
|
44
68
|
|
45
69
|
context "Array patches" do
|
@@ -85,6 +109,10 @@ class TestMonkeyPatches < Test::Unit::TestCase
|
|
85
109
|
assert_equal nil.to_s(:standard), ""
|
86
110
|
end
|
87
111
|
|
112
|
+
should "not fail on to_xs" do
|
113
|
+
assert_equal nil.to_xs, ""
|
114
|
+
end
|
115
|
+
|
88
116
|
should "not fail on empty?" do
|
89
117
|
assert nil.empty?
|
90
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonthread-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CommonThread
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-26 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|