royw-roys_extensions 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ require 'spec/rake/spectask'
20
20
  Spec::Rake::SpecTask.new(:spec) do |spec|
21
21
  spec.libs << 'lib' << 'spec'
22
22
  spec.spec_files = FileList['spec/**/*_spec.rb']
23
- spec.spec_opts = ["--color"]
23
+ spec.spec_opts = ["--color", "--format nested"]
24
24
  end
25
25
 
26
26
  Spec::Rake::SpecTask.new(:rcov) do |spec|
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 0
@@ -5,7 +5,7 @@ include FileUtils
5
5
 
6
6
  TMPDIR = File.join(File.dirname(__FILE__), '../tmp')
7
7
 
8
- describe "FileExtensions" do
8
+ describe "file_extensions" do
9
9
  before(:all) do
10
10
  Dir.mkdir(TMPDIR) unless File.exist?(TMPDIR)
11
11
  end
@@ -14,26 +14,32 @@ describe "FileExtensions" do
14
14
  rm_rf(Dir.glob(File.join(TMPDIR,'file_extensions_spec*')))
15
15
  end
16
16
 
17
- it "should make a single directory when it does not exist" do
18
- dirspec = get_temp_filename
19
- File.mkdirs(dirspec)
20
- (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
17
+ describe("File.mkdirs") do
18
+ it "should make a single directory when it does not exist" do
19
+ dirspec = get_temp_filename
20
+ File.mkdirs(dirspec)
21
+ (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
22
+ end
23
+
24
+ it "should make a multiple directories when they do not exist" do
25
+ dirspec = File.join(get_temp_filename, 'foo', 'bar')
26
+ File.mkdirs(dirspec)
27
+ (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
28
+ end
29
+
30
+ it "should not make any directories when they already exist" do
31
+ dirspec = File.join(get_temp_filename, 'foo', 'bar')
32
+ File.mkdirs(dirspec)
33
+ File.mkdirs(dirspec)
34
+ (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
35
+ end
21
36
  end
22
37
 
23
- it "should make a multiple directories when they do not exist" do
24
- dirspec = File.join(get_temp_filename, 'foo', 'bar')
25
- File.mkdirs(dirspec)
26
- (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
38
+ describe("File.touch") do
39
+ it "should create new file if none exists"
40
+ it "should change the modification time to the current time for pre-existing file"
27
41
  end
28
42
 
29
- it "should not make any directories when they already exist" do
30
- dirspec = File.join(get_temp_filename, 'foo', 'bar')
31
- File.mkdirs(dirspec)
32
- File.mkdirs(dirspec)
33
- (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
34
- end
35
-
36
-
37
43
  def get_temp_filename
38
44
  outfile = Tempfile.new('file_extensions_spec', TMPDIR)
39
45
  filespec = outfile.path
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "KernelExtensions" do
4
- it "should time a block of code" do
5
- elapse = timer { sleep 1.1 }
6
- (elapse.should > 1) && (elapse.should < 2)
3
+ describe "kernel_extensions" do
4
+ describe "timer" do
5
+ it "should time a block of code" do
6
+ elapse = timer { sleep 1.1 }
7
+ (elapse.should > 1) && (elapse.should < 2)
8
+ end
7
9
  end
8
-
9
10
  end
@@ -1,34 +1,35 @@
1
1
  require 'spec_helper'
2
2
  require 'ruby-debug'
3
3
 
4
- describe "ModuleExtensions" do
5
- it "should allow a method to be added to a class when the method does not already exists" do
6
- class A
7
- my_extension("foo") do
8
- def foo
9
- 'foo'
4
+ describe "module_extensions" do
5
+ describe "my_extension" do
6
+ it "should allow a method to be added to a class when the method does not already exists" do
7
+ class A
8
+ my_extension("foo") do
9
+ def foo
10
+ 'foo'
11
+ end
10
12
  end
11
13
  end
14
+ A.instance_methods.include?('foo').should be_true
12
15
  end
13
- A.instance_methods.include?('foo').should be_true
14
- end
15
16
 
16
- it "should not allow adding a method to a class if the method already exists" do
17
- class A
18
- def foo
19
- 'bar'
17
+ it "should not allow adding a method to a class if the method already exists" do
18
+ class A
19
+ def foo
20
+ 'bar'
21
+ end
20
22
  end
21
- end
22
23
 
23
- class A
24
- my_extension("foo") do
25
- def foo
26
- 'foo'
24
+ class A
25
+ my_extension("foo") do
26
+ def foo
27
+ 'foo'
28
+ end
27
29
  end
28
30
  end
31
+ a = A.new
32
+ a.foo.should == 'bar'
29
33
  end
30
- a = A.new
31
- a.foo.should == 'bar'
32
34
  end
33
-
34
35
  end
@@ -1,41 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "NumericExtensions" do
4
- it "should convert 0 seconds to '00:00:00'" do
5
- 0.elapsed_time_s.should == '00:00:00'
6
- end
3
+ describe "numeric_extensions" do
4
+ describe "elapsed_time" do
5
+ it "should convert 0 seconds to '00:00:00'" do
6
+ 0.elapsed_time_s.should == '00:00:00'
7
+ end
7
8
 
8
- it "should convert 59 seconds to '00:00:59'" do
9
- 59.elapsed_time_s.should == '00:00:59'
10
- end
9
+ it "should convert 59 seconds to '00:00:59'" do
10
+ 59.elapsed_time_s.should == '00:00:59'
11
+ end
11
12
 
12
- it "should convert 60 seconds to '00:01:00'" do
13
- 60.elapsed_time_s.should == '00:01:00'
14
- end
13
+ it "should convert 60 seconds to '00:01:00'" do
14
+ 60.elapsed_time_s.should == '00:01:00'
15
+ end
15
16
 
16
- it "should convert 3599 seconds to '00:59:59'" do
17
- 3599.elapsed_time_s.should == '00:59:59'
18
- end
17
+ it "should convert 3599 seconds to '00:59:59'" do
18
+ 3599.elapsed_time_s.should == '00:59:59'
19
+ end
19
20
 
20
- it "should convert 3600 seconds to '01:00:00'" do
21
- 3600.elapsed_time_s.should == '01:00:00'
22
- end
21
+ it "should convert 3600 seconds to '01:00:00'" do
22
+ 3600.elapsed_time_s.should == '01:00:00'
23
+ end
23
24
 
24
- it "should convert 86399 seconds to '23:59:59'" do
25
- 86399.elapsed_time_s.should == '23:59:59'
26
- end
25
+ it "should convert 86399 seconds to '23:59:59'" do
26
+ 86399.elapsed_time_s.should == '23:59:59'
27
+ end
27
28
 
28
- it "should convert 86400 seconds to '24:00:00'" do
29
- 86400.elapsed_time_s.should == '24:00:00'
30
- end
29
+ it "should convert 86400 seconds to '24:00:00'" do
30
+ 86400.elapsed_time_s.should == '24:00:00'
31
+ end
31
32
 
32
- it "should convert 359999 seconds to '99:59:59'" do
33
- 359999.elapsed_time_s.should == '99:59:59'
34
- end
33
+ it "should convert 359999 seconds to '99:59:59'" do
34
+ 359999.elapsed_time_s.should == '99:59:59'
35
+ end
35
36
 
36
- it "should convert 360000 seconds to '100:00:00'" do
37
- 360000.elapsed_time_s.should == '100:00:00'
37
+ it "should convert 360000 seconds to '100:00:00'" do
38
+ 360000.elapsed_time_s.should == '100:00:00'
39
+ end
38
40
  end
39
41
 
40
-
41
42
  end
@@ -1,44 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "ObjectExtensions" do
4
- it "should be blank for nil" do
5
- nil.blank?.should be_true
6
- end
3
+ describe "object_extensions" do
4
+ describe "blank?" do
5
+ it "should be blank for nil" do
6
+ nil.blank?.should be_true
7
+ end
7
8
 
8
- it "should be blank for empty String" do
9
- ''.blank?.should be_true
10
- end
9
+ it "should be blank for empty String" do
10
+ ''.blank?.should be_true
11
+ end
11
12
 
12
- it "should be blank for pure white space String" do
13
- ' '.blank?.should be_true
14
- end
13
+ it "should be blank for pure white space String" do
14
+ ' '.blank?.should be_true
15
+ end
15
16
 
16
- it "should be blank for empty Array" do
17
- [].blank?.should be_true
18
- end
17
+ it "should be blank for empty Array" do
18
+ [].blank?.should be_true
19
+ end
19
20
 
20
- it "should be blank for Array of nils" do
21
- [nil, nil].blank?.should be_true
22
- end
21
+ it "should be blank for Array of nils" do
22
+ [nil, nil].blank?.should be_true
23
+ end
23
24
 
24
- it "should be blank for empty Hash" do
25
- {}.blank?.should be_true
26
- end
25
+ it "should be blank for empty Hash" do
26
+ {}.blank?.should be_true
27
+ end
27
28
 
28
- it "should not be blank for non-empty String" do
29
- ' foo '.blank?.should be_false
30
- end
29
+ it "should not be blank for non-empty String" do
30
+ ' foo '.blank?.should be_false
31
+ end
31
32
 
32
- it "should not be blank for non-empty Array" do
33
- [1].blank?.should be_false
34
- end
33
+ it "should not be blank for non-empty Array" do
34
+ [1].blank?.should be_false
35
+ end
35
36
 
36
- it "should not be blank for empty embedded Arrays" do
37
- [[]].blank?.should be_false
38
- end
37
+ it "should not be blank for empty embedded Arrays" do
38
+ [[]].blank?.should be_false
39
+ end
39
40
 
40
- it "should not be blank for non-empty Hash" do
41
- {:a => nil}.blank?.should be_false
41
+ it "should not be blank for non-empty Hash" do
42
+ {:a => nil}.blank?.should be_false
43
+ end
42
44
  end
43
-
44
45
  end
@@ -1,34 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
- puts "string_extensions"
4
- describe "StringExtensions" do
5
- it "should escape unicode binary in URL strings to %xx notation" do
6
- s = "http://www.themoviedb.org/image/backdrops/23357/W\303\244hrend_Du_schliefst.jpg"
7
- s.escape_unicode.should == "http://www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst.jpg"
8
- end
3
+ describe "string_extensions" do
9
4
 
10
- it "should strip angle bracket tags" do
11
- s = 'Now is the <b>time</b> for all <i>good</i> Aggies'
12
- s.strip_tags.should == 'Now is the time for all good Aggies'
5
+ describe "escape_unicode" do
6
+ it "should escape unicode binary in URL strings to %xx notation" do
7
+ s = "http://www.themoviedb.org/image/backdrops/23357/W\303\244hrend_Du_schliefst.jpg"
8
+ s.escape_unicode.should == "http://www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst.jpg"
9
+ end
13
10
  end
14
11
 
15
- it "should replace file extension" do
16
- s = 'a/b.c'
17
- s.ext('d').should == 'a/b.d'
12
+ describe "strip_tags" do
13
+ it "should strip angle bracket tags" do
14
+ s = 'Now is the <b>time</b> for all <i>good</i> Aggies'
15
+ s.strip_tags.should == 'Now is the time for all good Aggies'
16
+ end
18
17
  end
19
18
 
20
- it "should replace only the last file extension in the string" do
21
- s = 'a.b.c'
22
- s.ext('d').should == 'a.b.d'
19
+ describe "ext" do
20
+ it "should replace file extension" do
21
+ s = 'a/b.c'
22
+ s.ext('d').should == 'a/b.d'
23
+ end
24
+
25
+ it "should replace only the last file extension in the string" do
26
+ s = 'a.b.c'
27
+ s.ext('d').should == 'a.b.d'
28
+ end
29
+
30
+ it "should append file extension when there is not one" do
31
+ s = 'a/b/c'
32
+ s.ext('d').should == 'a/b/c.d'
33
+ end
23
34
  end
24
35
 
25
- it "should append file extension when there is not one" do
26
- s = 'a/b/c'
27
- s.ext('d').should == 'a/b/c.d'
36
+ describe "remove_punctuation" do
37
+ it "should remove punctuation for a file name" do
38
+ s = '*abc?:!",.-/~;@#$%^def' + "\'ghi"
39
+ s.remove_punctuation.should == 'abc def ghi'
40
+ end
28
41
  end
29
42
 
30
- it "should remove punctuation for a file name" do
31
- s = '*abc?:!",.-/~;@#$%^def' + "\'ghi"
32
- s.remove_punctuation.should == 'abc def ghi'
43
+ describe "unescape_html" do
44
+ it "should convert &amp; to &" do
45
+ "M&amp;M".unescape_html.should == 'M&M'
46
+ end
47
+
48
+ it "should convert &#243; to ó" do
49
+ "&#243;smosis".unescape_html.should == 'ósmosis'
50
+ end
33
51
  end
52
+
34
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-roys_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-22 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15