quality_extensions 1.1.3 → 1.1.4
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.
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Tyler Rick
|
3
|
+
# Copyright:: Copyright (c) 2009, Tyler Rick
|
4
|
+
# License:: Ruby License
|
5
|
+
# Submit to Facets?::
|
6
|
+
# Developer notes::
|
7
|
+
# Changes::
|
8
|
+
#++
|
9
|
+
|
10
|
+
class String
|
11
|
+
|
12
|
+
def prefix_lines(prefix)
|
13
|
+
gsub(/^/, prefix)
|
14
|
+
end
|
15
|
+
|
16
|
+
def unprefix_lines(prefix)
|
17
|
+
gsub(/^#{Regexp.escape(prefix)}/, "")
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO:
|
21
|
+
#def suffix_lines(suffix)
|
22
|
+
#def unsuffix_lines(suffix)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# _____ _
|
28
|
+
# |_ _|__ ___| |_
|
29
|
+
# | |/ _ \/ __| __|
|
30
|
+
# | | __/\__ \ |_
|
31
|
+
# |_|\___||___/\__|
|
32
|
+
#
|
33
|
+
=begin test
|
34
|
+
require 'spec'
|
35
|
+
|
36
|
+
describe "String#prefix_lines" do
|
37
|
+
|
38
|
+
it "lets you indent lines, similar to Facets' String#indent(n)" do
|
39
|
+
"abc". prefix_lines(' ').should == ' abc'
|
40
|
+
" abc".prefix_lines(' '). should == ' abc'
|
41
|
+
|
42
|
+
("abc\n" +
|
43
|
+
"xyz" ).prefix_lines(' ').should ==
|
44
|
+
(" abc\n" +
|
45
|
+
" xyz")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lets you comment lines" do
|
49
|
+
"abc". prefix_lines('# ').should == '# abc'
|
50
|
+
" abc".prefix_lines('# ').should == '# abc'
|
51
|
+
|
52
|
+
("line 1\n" +
|
53
|
+
"line 2" ).prefix_lines('# ').should ==
|
54
|
+
("# line 1\n" +
|
55
|
+
"# line 2")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "lets you uncomment lines" do
|
59
|
+
"# abc". unprefix_lines('# ').should == 'abc'
|
60
|
+
"# abc".unprefix_lines('# ').should == ' abc'
|
61
|
+
|
62
|
+
("# line 1\n" +
|
63
|
+
"# line 2" ).unprefix_lines('# ').should ==
|
64
|
+
("line 1\n" +
|
65
|
+
"line 2")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
=end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quality_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick and others
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-12 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/quality_extensions/console/command.rb
|
62
62
|
- lib/quality_extensions/string/to_underscored_label.rb
|
63
63
|
- lib/quality_extensions/string/md5.rb
|
64
|
+
- lib/quality_extensions/string/prefix_lines.rb
|
64
65
|
- lib/quality_extensions/string/all.rb
|
65
66
|
- lib/quality_extensions/string/constantize.rb
|
66
67
|
- lib/quality_extensions/string/with_knowledge_of_color.rb
|