trick_bag 0.32.0 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.33.0
2
+
3
+ * Added dos2unix and dos2unix! to Formatters.
4
+
5
+
1
6
  ## v0.32.0
2
7
 
3
8
  * Added timestamp, replace_with_timestamp in Formatters.
@@ -60,9 +60,25 @@ module Formatters
60
60
 
61
61
  # Replaces all occurrences of marker with the current date/time in
62
62
  # YYYYMMDD-HHMMSS format.
63
- def replace_with_timestamp(string, marker = '*', datetime = DateTime.now)
63
+ def replace_with_timestamp(string, marker = '{dt}', datetime = DateTime.now)
64
64
  string.gsub(marker, timestamp(datetime))
65
65
  end
66
+
67
+
68
+ # Like the Unix dos2unix command, but on strings rather than files, strips CR characters.
69
+ # Note: The 'os' gem can be used to determine os.
70
+ def dos2unix(string)
71
+ string ? string.gsub("\r", '') : string
72
+ end
73
+
74
+
75
+ # Like the Unix dos2unix command, but on strings rather than files, strips CR characters.
76
+ # Modifies the original string.
77
+ # Note: The 'os' gem can be used to determine os.
78
+ def dos2unix!(string)
79
+ string ? string.gsub!("\r", '') : string
80
+ end
81
+
66
82
  end
67
83
  end
68
84
 
@@ -1,3 +1,3 @@
1
1
  module TrickBag
2
- VERSION = "0.32.0"
2
+ VERSION = "0.33.0"
3
3
  end
@@ -74,5 +74,34 @@ describe Formatters do
74
74
  #
75
75
  end
76
76
  end
77
+
78
+
79
+ context ".dos2unix" do
80
+
81
+ specify "strings not containing line endings remain unchanged" do
82
+ strings = ['', 'abc', ' ']
83
+ expect(strings.map { |s| Formatters.dos2unix(s) }).to eq(strings)
84
+ end
85
+
86
+ specify "CR characters are stripped" do
87
+ expect(Formatters.dos2unix("foo\r\nbar\r\n")).to eq("foo\nbar\n")
88
+ end
89
+ end
90
+
91
+ context ".dos2unix!" do
92
+
93
+ specify "strings not containing line endings remain unchanged" do
94
+ expect(Formatters.dos2unix('')).to eq('')
95
+ expect(Formatters.dos2unix(' ')).to eq(' ')
96
+ expect(Formatters.dos2unix('abc')).to eq('abc')
97
+ end
98
+
99
+ specify "CR characters are stripped" do
100
+ s = "foo\r\nbar\r\n"
101
+ Formatters.dos2unix!(s)
102
+ expect(s).to eq("foo\nbar\n")
103
+ end
104
+ end
105
+
77
106
  end
78
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trick_bag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.0
4
+ version: 0.33.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-13 00:00:00.000000000 Z
12
+ date: 2014-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vrsn-ie-dnsruby