mightystring 0.1.4 → 0.1.5.b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +10 -10
- data/{README → README.md} +30 -20
- data/bin/ms-striphtml +36 -36
- data/lib/mightystring.rb +57 -30
- data/lib/mightystring/string_at.rb +26 -16
- data/lib/mightystring/string_del.rb +51 -51
- data/lib/mightystring/string_each.rb +24 -0
- data/lib/mightystring/string_fetch.rb +13 -0
- data/lib/mightystring/string_find.rb +19 -0
- data/lib/mightystring/string_first.rb +13 -0
- data/lib/mightystring/string_index_all.rb +27 -27
- data/lib/mightystring/string_join.rb +13 -0
- data/lib/mightystring/string_last.rb +13 -0
- data/lib/mightystring/string_map.rb +19 -0
- data/lib/mightystring/string_match_pci.rb +16 -0
- data/lib/mightystring/string_method_missing.rb +25 -0
- data/lib/mightystring/string_pop.rb +15 -0
- data/lib/mightystring/string_push.rb +13 -0
- data/lib/mightystring/string_shift.rb +15 -0
- data/lib/mightystring/string_sort.rb +17 -0
- data/lib/mightystring/{string_stripbyac.rb → string_strip_byac.rb} +28 -28
- data/lib/mightystring/string_unshift.rb +13 -0
- data/lib/mightystring/strip_html.rb +143 -149
- data/lib/mightystring/version.rb +3 -3
- data/test/test_ms.rb +53 -50
- metadata +32 -21
- data/lib/mightystring/string_matchpci.rb +0 -16
data/lib/mightystring/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module MightyString
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
module MightyString
|
2
|
+
VERSION = "0.1.5.b"
|
3
|
+
end
|
data/test/test_ms.rb
CHANGED
@@ -1,50 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert "
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
assert "
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assert MightyString::HTML.strip_first_seq("
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
assert MightyString::HTML.strip_html("<
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/mightystring'
|
3
|
+
|
4
|
+
class TestMightyString < Test::Unit::TestCase
|
5
|
+
def test_at
|
6
|
+
assert "abc".at(0) == "a"
|
7
|
+
assert "0123456789".at(-1) == "9"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_del
|
11
|
+
assert "abc".del(1) == "ac"
|
12
|
+
assert "0123456789".del(0..2) == "3456789"
|
13
|
+
assert "iudsfbv\nui4adv\nvw7revg".del("\n") == "iudsfbvui4advvw7revg"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_each
|
17
|
+
assert "12345".each.all?{|i| i.to_i < 10}
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def test_index_all
|
22
|
+
assert "012324507654301243".index_all 0 == [0,7,13]
|
23
|
+
assert "the apple is the best fruit in the world".index_all "the" == [0, 13, 31]
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_match_pci
|
27
|
+
assert "<TD>".match_pci("td")
|
28
|
+
assert "<TD>".match_pci("><") == false
|
29
|
+
assert "Principle".match_pci("rINCi")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_strip_byac
|
33
|
+
assert "qa2ws3ed4rf5tg6yh7uj8ik9ol".strip_byac( Range.new( "0", "9" ).to_a ) == "23456789"
|
34
|
+
|
35
|
+
custRange = (Range.new('a','z').to_a + Range.new('A','Z').to_a + [" "]).flatten
|
36
|
+
assert "<html><body> Content </body></html>".strip_byac(custRange) == "htmlbody Content bodyhtml"
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_strip_first_seq
|
40
|
+
assert MightyString::HTML.strip_first_seq("APPLES n APPLES ARE Yummy!","APPLES",{"APPLES" => "COWS"}) == "COWS n APPLES ARE Yummy!"
|
41
|
+
assert MightyString::HTML.strip_first_seq("Cows Cows and more Cows!","Cows", {"Cows" => "Winner"}) == "Winner Cows and more Cows!"
|
42
|
+
assert MightyString::HTML.strip_first_seq(" ---- APPLES &nbps;", " " ) == " ---- APPLES &nbps;"
|
43
|
+
assert MightyString::HTML.strip_first_seq("™ ---- ™ TradeMark ™", "™" ) == "(TM) ---- ™ TradeMark ™"
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_strip_html
|
47
|
+
assert MightyString::HTML.strip_html("<html>") == ""
|
48
|
+
assert MightyString::HTML.strip_html("<table><tr><td>Piped sides.</td></tr></table>") == " | Piped sides. | "
|
49
|
+
assert MightyString::HTML.strip_html("Hello<br>World!") == "Hello\nWorld!"
|
50
|
+
assert MightyString::HTML.strip_html("<p>"Quoted" Copyright © TradeMark ™</p>") == "'Quoted' Copyright (c) TradeMark (TM)"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mightystring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5.b
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Daniel P. Clark / 6ftDan(TM)
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Array functionality in Strings as well as Matching, Indexing, Substitution,
|
15
14
|
Deletion, and more.
|
@@ -19,43 +18,55 @@ executables:
|
|
19
18
|
extensions: []
|
20
19
|
extra_rdoc_files: []
|
21
20
|
files:
|
22
|
-
-
|
23
|
-
-
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- bin/ms-striphtml
|
24
|
+
- lib/mightystring.rb
|
25
|
+
- lib/mightystring/string_at.rb
|
24
26
|
- lib/mightystring/string_del.rb
|
27
|
+
- lib/mightystring/string_each.rb
|
28
|
+
- lib/mightystring/string_fetch.rb
|
29
|
+
- lib/mightystring/string_find.rb
|
30
|
+
- lib/mightystring/string_first.rb
|
25
31
|
- lib/mightystring/string_index_all.rb
|
26
|
-
- lib/mightystring/
|
32
|
+
- lib/mightystring/string_join.rb
|
33
|
+
- lib/mightystring/string_last.rb
|
34
|
+
- lib/mightystring/string_map.rb
|
35
|
+
- lib/mightystring/string_match_pci.rb
|
36
|
+
- lib/mightystring/string_method_missing.rb
|
37
|
+
- lib/mightystring/string_pop.rb
|
38
|
+
- lib/mightystring/string_push.rb
|
39
|
+
- lib/mightystring/string_shift.rb
|
40
|
+
- lib/mightystring/string_sort.rb
|
41
|
+
- lib/mightystring/string_strip_byac.rb
|
42
|
+
- lib/mightystring/string_unshift.rb
|
27
43
|
- lib/mightystring/strip_html.rb
|
28
|
-
- lib/mightystring/
|
29
|
-
- lib/mightystring.rb
|
44
|
+
- lib/mightystring/version.rb
|
30
45
|
- test/test_ms.rb
|
31
|
-
- README
|
32
|
-
- LICENSE
|
33
|
-
- bin/ms-striphtml
|
34
46
|
homepage: http://www.github.com/danielpclark/mightystring
|
35
47
|
licenses:
|
36
48
|
- The MIT License (MIT)
|
37
|
-
|
38
|
-
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
39
51
|
rdoc_options: []
|
40
52
|
require_paths:
|
41
53
|
- lib
|
42
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
55
|
requirements:
|
45
|
-
- -
|
56
|
+
- - ">="
|
46
57
|
- !ruby/object:Gem::Version
|
47
58
|
version: '0'
|
48
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
60
|
requirements:
|
51
|
-
- -
|
61
|
+
- - ">"
|
52
62
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
63
|
+
version: 1.3.1
|
54
64
|
requirements: []
|
55
65
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
66
|
+
rubygems_version: 2.3.0
|
57
67
|
signing_key:
|
58
|
-
specification_version:
|
59
|
-
summary: Strings (are) Arrays
|
68
|
+
specification_version: 4
|
69
|
+
summary: Strings (are) Arrays with Matching, Indexing, Substitution, Deletion, and
|
70
|
+
more.
|
60
71
|
test_files:
|
61
72
|
- test/test_ms.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# Part of MightyString
|
2
|
-
# by Daniel P. Clark
|
3
|
-
# webmaster@6ftdan.com
|
4
|
-
|
5
|
-
# Match Partial Case-Insensitive
|
6
|
-
module Match_PCI
|
7
|
-
module String
|
8
|
-
# Match Partial Case-Insensitive: Usage: "My string has this?".matchpci('RinG') => true
|
9
|
-
def match_pci(in_srch = "")
|
10
|
-
if not in_srch.empty?
|
11
|
-
return !!self.downcase[in_srch.downcase]
|
12
|
-
end
|
13
|
-
return false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|