midwire_common 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG +4 -0
- data/README.md +1 -1
- data/lib/midwire_common/rake_helper.rb +2 -0
- data/lib/midwire_common/time.rb +1 -1
- data/lib/midwire_common/version.rb +1 -1
- data/spec/lib/midwire_common/string_spec.rb +67 -67
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5da67bc5fb2262d2499c04aa0f873cb27ac6b2f4
|
4
|
+
data.tar.gz: 34b348ccd6c0026a7574ed73687199b98d392d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b6f1d4ba80fb18e2c5c0e90a9106b22b27a880bef6bc922e04cfa6562c239617b10e6e08022e1be514004e962dda7c1493c8855194ea5ba308be5369dad7506
|
7
|
+
data.tar.gz: e748deb30355bab169231a6ef3a461691086c787d4772f17f4eb608f100173006698be066fa9f10147ab8cd24aafe0f167485dd4d875e6aa9ec2beef4bd21d03
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
data/lib/midwire_common/time.rb
CHANGED
@@ -50,12 +50,12 @@ describe String do
|
|
50
50
|
it "'trim!' removes whitespace from both sides of the string" do
|
51
51
|
mystring = " \t \t a test is coming \t \t "
|
52
52
|
mystring.trim!
|
53
|
-
mystring.should ==
|
53
|
+
mystring.should == 'a test is coming'
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
context
|
58
|
-
it
|
57
|
+
context 'formatting and manipulation' do
|
58
|
+
it 'here_with_pipe - without linefeeds' do
|
59
59
|
html = <<-STOP.here_with_pipe
|
60
60
|
|<!-- Begin: comment -->
|
61
61
|
|<script type="text/javascript">
|
@@ -64,7 +64,7 @@ describe String do
|
|
64
64
|
html.should == "<!-- Begin: comment --> <script type=\"text/javascript\"> </script>"
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it 'here_with_pipe - with linefeeds' do
|
68
68
|
html = <<-STOP.here_with_pipe("\n")
|
69
69
|
|<!-- Begin: comment -->
|
70
70
|
|<script type="text/javascript">
|
@@ -73,7 +73,7 @@ describe String do
|
|
73
73
|
html.should == "<!-- Begin: comment -->\n<script type=\"text/javascript\">\n</script>"
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'here_with_pipe - with no space delimeter' do
|
77
77
|
html = <<-STOP.here_with_pipe("")
|
78
78
|
|<!-- Begin: comment -->
|
79
79
|
|<script type="text/javascript">
|
@@ -82,91 +82,91 @@ describe String do
|
|
82
82
|
html.should == "<!-- Begin: comment --><script type=\"text/javascript\"></script>"
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
it 'format_phone returns a formatted phone number string' do
|
86
|
+
'9132329999'.format_phone.should == '(913)232-9999'
|
87
|
+
'913.232.9999'.format_phone.should == '(913)232-9999'
|
88
|
+
'913 232 9999'.format_phone.should == '(913)232-9999'
|
89
|
+
'913-232-9999'.format_phone.should == '(913)232-9999'
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
s =
|
92
|
+
it 'sanitizes itself' do
|
93
|
+
'|bogus|'.sanitize.should == 'bogus'
|
94
|
+
'|∫|ß'.sanitize.should == ''
|
95
|
+
'ßogus'.sanitize.should == 'ogus'
|
96
|
+
'<tag>bogus</tag>'.sanitize.should == 'tagbogustag'
|
97
|
+
'<tag>.bogus.</tag>'.sanitize.should == 'tag.bogus.tag'
|
98
|
+
s = '|∫|ß'
|
99
99
|
s.sanitize!
|
100
|
-
s.should ==
|
100
|
+
s.should == ''
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
s =
|
103
|
+
it 'shortens itself with elipses at the end' do
|
104
|
+
s = 'this is my very long string which I will eventually shorten with the enhanced String class that we are now testing.'
|
105
105
|
short = s.shorten
|
106
|
-
short.should ==
|
106
|
+
short.should == 'this is my very long string...'
|
107
107
|
short.length.should == 30
|
108
108
|
|
109
|
-
s =
|
109
|
+
s = '1234567890123456789012345678901234567890'
|
110
110
|
short = s.shorten
|
111
|
-
short.should ==
|
111
|
+
short.should == '123456789012345678901234567...'
|
112
112
|
short.length.should == 30
|
113
113
|
|
114
|
-
s =
|
114
|
+
s = '12345678901234567890'
|
115
115
|
short = s.shorten
|
116
|
-
short.should ==
|
116
|
+
short.should == '12345678901234567890'
|
117
117
|
short.length.should == 20
|
118
118
|
end
|
119
119
|
|
120
|
-
context
|
121
|
-
it
|
120
|
+
context 'quotes' do
|
121
|
+
it 'escapes single quotes' do
|
122
122
|
"this is a 'test'".escape_single_quotes.should == "this is a \\'test\\'"
|
123
123
|
end
|
124
124
|
|
125
|
-
it
|
125
|
+
it 'escapes double quotes' do
|
126
126
|
'this is a "test"'.escape_double_quotes.should == "this is a \\\\\"test\\\\\""
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
context
|
132
|
-
it
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
it
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
it
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
it
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
131
|
+
context 'characterization' do
|
132
|
+
it 'knows if it is alpha-numeric or not' do
|
133
|
+
'abcd-9191'.is_alpha_numeric?.should be_false
|
134
|
+
'abcd.9191'.is_alpha_numeric?.should be_false
|
135
|
+
'abcd91910'.is_alpha_numeric?.should be_true
|
136
|
+
'abcd_9191'.is_alpha_numeric?.should be_false
|
137
|
+
'abcd 9191'.is_alpha_numeric?.should be_false
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'knows if it is an email address or not' do
|
141
|
+
'abcd_9191'.is_email_address?.should be_false
|
142
|
+
'abcd@9191'.is_email_address?.should be_false
|
143
|
+
'abcd@9191.poop'.is_email_address?.should be_false
|
144
|
+
'abcd@9191.info'.is_email_address?.should be_true
|
145
|
+
'abcd-asdf@9191.com'.is_email_address?.should be_true
|
146
|
+
'abcd_asdf@9191.com'.is_email_address?.should be_true
|
147
|
+
'abcd.asdf@9191.com'.is_email_address?.should be_true
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'knows if it is a zipcode or not' do
|
151
|
+
'13922-2356'.is_zipcode?.should be_true
|
152
|
+
'13922.2343'.is_zipcode?.should be_false
|
153
|
+
'13922 2342'.is_zipcode?.should be_false
|
154
|
+
'ABSSD'.is_zipcode?.should be_false
|
155
|
+
'i3323'.is_zipcode?.should be_false
|
156
|
+
'13922'.is_zipcode?.should be_true
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'knows if it is numeric or not' do
|
160
|
+
'12341'.is_numeric?.should be_true
|
161
|
+
'12341.23'.is_numeric?.should be_true
|
162
|
+
'12341.00000000000000023'.is_numeric?.should be_true
|
163
|
+
'0.12341'.is_numeric?.should be_true
|
164
|
+
'0x2E'.is_numeric?.should be_true
|
165
|
+
' 0.12341'.is_numeric?.should be_true
|
166
|
+
' 0.12341 '.is_numeric?.should be_true
|
167
|
+
'.12341'.is_numeric?.should be_true
|
168
|
+
' 12341.'.is_numeric?.should be_false
|
169
|
+
' 12341. '.is_numeric?.should be_false
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midwire_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Blackburn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rspec"
|
134
|
+
- ".ruby-version"
|
134
135
|
- CHANGELOG
|
135
136
|
- Gemfile
|
136
137
|
- Guardfile
|