royw-roys_extensions 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 2
3
+ :patch: 3
4
4
  :major: 0
@@ -7,7 +7,7 @@ require 'module_extensions'
7
7
  class File
8
8
  class << self
9
9
  my_extension("mkdirs") do
10
- ##
10
+ # == Synopsis
11
11
  # make directories including any missing in the path
12
12
  #
13
13
  # @param [String] dirspec the path to make sure exists
@@ -18,5 +18,16 @@ class File
18
18
  end
19
19
  end
20
20
  end
21
+
22
+ my_extension("touch") do
23
+ # == Synopsis
24
+ # Sets the last modification time of the given filespec
25
+ # to the current time. Create the given file if it doesn't
26
+ # exist
27
+ require 'fileutils'
28
+ def File.touch(filespec)
29
+ FileUtils.touch(filespec)
30
+ end
31
+ end
21
32
  end
22
33
  end
@@ -24,6 +24,14 @@ class String
24
24
  end
25
25
  end
26
26
 
27
+ my_extension("remove_punctuation") do
28
+ # == Synopsis
29
+ # remove punctuation the shouldn't be in file names
30
+ def remove_punctuation
31
+ self.gsub(/([\?\:\!\"\'\,\.\-\/\*\~\;\@\#\$\%\^])/, ' ').gsub(/\s+/, ' ').strip
32
+ end
33
+ end
34
+
27
35
  my_extension("strip_tags") do
28
36
  # == Synopsis
29
37
  # remove angle bracket tags from the string
@@ -27,4 +27,8 @@ describe "StringExtensions" do
27
27
  s.ext('d').should == 'a/b/c.d'
28
28
  end
29
29
 
30
+ it "should remove punctuation for a file name" do
31
+ s = '*abc?:!",.-/~;@#$%^def' + "\'ghi"
32
+ s.remove_punctuation.should == 'abc def ghi'
33
+ end
30
34
  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.2
4
+ version: 0.0.3
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-21 00:00:00 -07:00
12
+ date: 2009-04-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15