mightystring 0.1.5.b → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f81d10d6170f550308207e1db2ff1250969c1649
4
- data.tar.gz: e38c7eefd1a4ef0c3e9d39c055d9a666c8df8a5e
3
+ metadata.gz: c1dc9af7333c929b1b42ace68f82c7b090f0ead9
4
+ data.tar.gz: 30145612c2b45d9bce6d734212dd0f3468f579c8
5
5
  SHA512:
6
- metadata.gz: c75de5c7c086b57a3e40ea2ce1d6c2d9138a7279ee4a02c5fe31d4311f2264dd1ff9cb6e380f7bd8062362cd2e50e9cdb58892de92106d30498e1de2ce6e6bf2
7
- data.tar.gz: 6d46ef97a9ce7836f160dea1934fb914b0ddf214ed42ec2f25eb4b38cf5fabf95fbbec0c192b5516a1a81de616c30bd8ab61151e21e0b0905a3a01f700ef7f2e
6
+ metadata.gz: ba8d2e06a9af2b34cd54b469f7609dae61e9bcbab4e479f6d943598efbb4d07f6e6d89d6d333c2c3b7d04168dd2b113a33c4f1390aa6bff32049db8f71719bc0
7
+ data.tar.gz: 0918a55c46ef10645a6950e3399dbc1c0d0e0c55f25c1a03260e4ab394062e6730cc141e943fb5baec81ffd75ca62ae056827404c071c8b0dbd36f8f973bf9e5
data/README.md CHANGED
@@ -1,30 +1,38 @@
1
1
  # MightyString
2
2
  by Daniel P. Clark
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/mightystring.svg)](http://badge.fury.io/rb/mightystring)
5
+ [![Epic Winning](https://img.shields.io/badge/Epic-Winning-brightgreen.svg?style=flat)](https://rubygems.org/gems/mightystring)
6
+
7
+ [![Ruby Version Support](https://img.shields.io/badge/Ruby%20Version%20Support-1.8.7-red.svg?style=flat)](https://www.ruby-lang.org)
8
+
9
+
4
10
  *Description:* Add Array functionality to Strings and other tools for Strings: Matching, Indexing, Substitution, Deletion, and more.
5
11
 
12
+ Install: `gem install mightystring`
13
+
6
14
  *Pain points this solves.*
7
15
  * After working with Python, it's obvious Ruby strings are lacking... so lets spiff them up.
8
16
  * Strings are Arrays... I mean really, think about it. This works toward making Strings function as Arrays.
9
- * Also this provides additional string tools under MightyString... like strip_html.
17
+ * Also this provides additional string tools under MightyString... like parsing HTML into text.
10
18
 
11
19
  *My method.*
12
20
  * I believe code should be beautiful, simple, and well rounded. I've come to expect strings to be handled easily like arrays. There's no reason why not. So I've brought that reality to Ruby.
13
21
 
14
22
  *Some tools to consider here.*
15
- * MightyString::HTML.strip_html provides a more ideal HTML to ASCII formatting output. This is an advanced block "filtering" module. It works very well with, currently, extremely rare cases that fall through it's fingers. Regardless it's beautiful, and will strive to be more so.
23
+ * MightyString::HTML.text provides a more ideal HTML to ASCII formatting output. This is an advanced block "filtering" module. It works very well with, currently, extremely rare cases that fall through it's fingers. Regardless it's beautiful, and will strive to be more so.
16
24
 
17
25
  *Advanced detail.*
18
26
  * Look at the test/test_ms.rb for case usages of each feature.
19
27
 
28
+ > As a general rule I've avoided regex for this library. But due to regex's nature of design I will use it for
29
+ parsing string data within **MightyString::HTML** . I plan to keep parsing syntax as the only exception for using regex in this library.
30
+
20
31
  Follow this project and contribute via github http://www.github.com/danielpclark/mightystring
21
32
  <br />
22
33
  <br />
23
- # Goal for 0.2.0
34
+ # Goal for 0.3.0
24
35
  *Have Array and String interchangable. Same errors, same results.*
25
- <br />
26
- <br />
27
- Version <strong>0.1.4</strong><br />
28
- * Added string input acceptance to del<br />
29
- Example:<br />
30
- <code>"12#34#56#78".del("#") # => "12345678"</code></p>
36
+
37
+ > NOTES: Implementing the flatten and join methods on String breaks functionality within Rails and Rubygems. Future
38
+ additions will be separated into the MightyString module itself. Although a brilliant idea may indeed resolve this.
data/bin/ms-striphtml CHANGED
@@ -30,7 +30,7 @@ end
30
30
  if ARGV.any? { |s| s.downcase.include?('.htm') } then
31
31
  ARGV.each do |s|
32
32
  if s.downcase.include?('.htm') and File.exists?(s)
33
- puts HTML.strip_html( File.open(s, "rb").read )
33
+ puts HTML.text( File.open(s, "rb").read )
34
34
  end
35
35
  end
36
36
  end
data/lib/mightystring.rb CHANGED
@@ -1,33 +1,33 @@
1
- require_relative 'mightystring/string_at'
2
- require_relative 'mightystring/string_del'
3
- require_relative 'mightystring/string_each'
4
- require_relative 'mightystring/string_fetch'
5
- require_relative 'mightystring/string_find'
6
- require_relative 'mightystring/string_first'
7
- require_relative 'mightystring/string_index_all'
8
- require_relative 'mightystring/string_join'
9
- require_relative 'mightystring/string_last'
10
- require_relative 'mightystring/string_map'
11
- require_relative 'mightystring/string_match_pci'
12
- require_relative 'mightystring/string_pop'
13
- require_relative 'mightystring/string_push'
14
- require_relative 'mightystring/string_shift'
15
- require_relative 'mightystring/string_sort'
16
- require_relative 'mightystring/string_strip_byac'
17
- require_relative 'mightystring/string_unshift'
18
- require_relative 'mightystring/strip_html'
19
- require_relative 'mightystring/version'
20
- require_relative 'mightystring/string_method_missing'
1
+ require 'mightystring/string_at'
2
+ require 'mightystring/string_del'
3
+ # require 'mightystring/string_each'
4
+ require 'mightystring/string_fetch'
5
+ # require 'mightystring/string_find'
6
+ require 'mightystring/string_first'
7
+ require 'mightystring/string_index_all'
8
+ # require 'mightystring/string_join'
9
+ require 'mightystring/string_last'
10
+ require 'mightystring/string_map'
11
+ require 'mightystring/string_match_pci'
12
+ require 'mightystring/string_pop'
13
+ require 'mightystring/string_push'
14
+ require 'mightystring/string_shift'
15
+ require 'mightystring/string_sort'
16
+ require 'mightystring/string_strip_byac'
17
+ require 'mightystring/string_unshift'
18
+ require 'mightystring/strip_html'
19
+ require 'mightystring/version'
20
+ # require 'mightystring/string_method_missing'
21
21
 
22
22
  class String
23
23
  include At::String
24
24
  include Del::String
25
- include Each::String
25
+ # include Each::String
26
26
  include Fetch::String
27
- include Find::String
27
+ # include Find::String
28
28
  include First::String
29
29
  include Index_All::String
30
- include Join::String
30
+ # include Join::String
31
31
  include Last::String
32
32
  include Map::String
33
33
  include Match_PCI::String
@@ -37,21 +37,5 @@ class String
37
37
  include Sort::String
38
38
  include Strip_byAC::String
39
39
  include UnShift::String
40
- include MethodMissing::String
41
- end
42
-
43
-
44
- class Array
45
- # To fix a bug that our method_missing creates
46
- # we need to set a MAXIMUM for FLATTEN
47
- alias_method :_old_flatten, :flatten
48
- alias_method :_old_flatten!, :flatten!
49
-
50
- def flatten(level = 99)
51
- _old_flatten(level)
52
- end
53
-
54
- def flatten!(level = 99)
55
- _old_flatten!(level)
56
- end
40
+ #include MethodMissing::String
57
41
  end
@@ -1,16 +1,10 @@
1
1
  # Part of MightyString
2
2
  # by Daniel P. Clark
3
3
  # webmaster@6ftdan.com
4
- require 'forwardable'
5
4
 
6
5
  # At
7
6
  module At
8
7
  module String
9
- extend Forwardable
10
-
11
- def self.included(base)
12
- base.send :extend, Forwardable
13
- end
14
8
 
15
9
  # At : Returns string instead of char number.
16
10
  def at(in_srch = nil)
@@ -20,7 +14,12 @@ module At
20
14
  return nil
21
15
  end
22
16
 
23
- delegate values_at: :chars
24
- delegate delete_at: :chars
17
+ def values_at(*args)
18
+ self.chars.values_at(*args).join
19
+ end
20
+
21
+ def delete_at(arg)
22
+ self.replace self[0...arg] + self[arg+1..-1]
23
+ end
25
24
  end
26
25
  end
@@ -1,24 +1,23 @@
1
- # Part of MightyString
2
- # by Daniel P. Clark
3
- # webmaster@6ftdan.com
4
- require 'forwardable'
5
-
6
- module Each
7
- module String
8
- extend Forwardable
9
-
10
- def self.included(base)
11
- base.send :extend, Forwardable
12
- end
13
-
14
- # Enumerator for String
15
- delegate each: :chars
16
- delegate each_index: :chars
17
- delegate each_with_index: :chars
18
- delegate each_entry: :chars
19
- delegate each_slice: :chars
20
- delegate each_cons: :chars
21
- delegate each_with_object: :chars
22
- delegate reverse_each: :chars
23
- end
24
- end
1
+ # Won't be using forwardable
2
+ #
3
+ # require 'forwardable'
4
+ #
5
+ # module Each
6
+ # module String
7
+ # extend Forwardable
8
+ #
9
+ # def self.included(base)
10
+ # base.send :extend, Forwardable
11
+ # end
12
+ #
13
+ # # Enumerator for String
14
+ # delegate :each => :chars
15
+ # delegate :each_index => :chars
16
+ # delegate :each_with_index => :chars
17
+ # delegate :each_entry => :chars
18
+ # delegate :each_slice => :chars
19
+ # delegate :each_cons => :chars
20
+ # delegate :each_with_object => :chars
21
+ # delegate :reverse_each => :chars
22
+ # end
23
+ # end
@@ -1,19 +1,18 @@
1
- # Part of MightyString
2
- # by Daniel P. Clark
3
- # webmaster@6ftdan.com
4
- require 'forwardable'
5
-
6
- module Find
7
- module String
8
- extend Forwardable
9
-
10
- def self.included(base)
11
- base.send :extend, Forwardable
12
- end
13
-
14
- # Enumerator for String
15
- delegate find: :chars
16
- delegate find_index: :chars
17
- delegate find_all: :chars
18
- end
19
- end
1
+ # Won't be using forwardable
2
+ #
3
+ # require 'forwardable'
4
+ #
5
+ # module Find
6
+ # module String
7
+ # extend Forwardable
8
+ #
9
+ # def self.included(base)
10
+ # base.send :extend, Forwardable
11
+ # end
12
+ #
13
+ # # Enumerator for String
14
+ # delegate :find => :chars
15
+ # delegate :find_index => :chars
16
+ # delegate :find_all => :chars
17
+ # end
18
+ # end
@@ -1,13 +1,10 @@
1
- # Part of MightyString
2
- # by Daniel P. Clark
3
- # webmaster@6ftdan.com
4
-
5
-
6
- module Join
7
- module String
8
- # Returns String
9
- def join
10
- return self
11
- end
12
- end
13
- end
1
+ # Breaks Rails as is with cookies feature
2
+ #
3
+ # module Join
4
+ # module String
5
+ # # Returns String
6
+ # def join
7
+ # return self
8
+ # end
9
+ # end
10
+ # end
@@ -1,19 +1,33 @@
1
1
  # Part of MightyString
2
2
  # by Daniel P. Clark
3
3
  # webmaster@6ftdan.com
4
- require 'forwardable'
4
+ #require 'forwardable'
5
5
 
6
6
  module Map
7
7
  module String
8
- extend Forwardable
8
+
9
+ def map(*args, &block)
10
+ if (!args.compact.empty? || !block.nil?)
11
+ self.chars.map(*args,&block).join
12
+ else
13
+ self.chars.map(*args,&block)
14
+ end
15
+ end
9
16
 
10
- def self.included(base)
11
- base.send :extend, Forwardable
17
+ def map!(*args, &block)
18
+ if (!args.compact.empty? || !block.nil?)
19
+ self.replace self.chars.map(*args,&block).join
20
+ else
21
+ self.chars.map(*args,&block)
22
+ end
12
23
  end
13
24
 
14
- # Map for String
15
- delegate map: :chars
16
- delegate map!: :chars
17
- delegate flat_map: :chars
25
+ def flat_map(*args, &block)
26
+ if (!args.compact.empty? || !block.nil?)
27
+ self.chars.flat_map(*args,&block).join
28
+ else
29
+ self.chars.flat_map(*args,&block)
30
+ end
31
+ end
18
32
  end
19
33
  end
@@ -10,7 +10,7 @@ module Match_PCI
10
10
  if not in_srch.empty?
11
11
  return !!self.downcase[in_srch.downcase]
12
12
  end
13
- return false
13
+ return false
14
14
  end
15
15
  end
16
16
  end
@@ -2,24 +2,39 @@
2
2
  # by Daniel P. Clark
3
3
  # webmaster@6ftdan.com
4
4
 
5
- module MethodMissing
6
- module String
5
+ #module MethodMissing
6
+ # module String
7
+ #
8
+ # def method_missing(meth,*args, &block)
9
+ # if self.chars.respond_to? meth
10
+ # self.chars.send meth, *args, &block
11
+ # else
12
+ # super
13
+ # end
14
+ # end
15
+ #
16
+ # def respond_to?(meth)
17
+ # if self.chars.respond_to? meth
18
+ # true
19
+ # else
20
+ # super
21
+ # end
22
+ # end
23
+ #
24
+ # end
25
+ #end
7
26
 
8
- def method_missing(meth,*args, &block)
9
- if self.chars.respond_to? meth
10
- self.chars.send meth, *args, &block
11
- else
12
- super
13
- end
14
- end
15
-
16
- def respond_to?(meth)
17
- if self.chars.respond_to? meth
18
- true
19
- else
20
- super
21
- end
22
- end
23
-
24
- end
25
- end
27
+ #class Array
28
+ # To fix a bug that our method_missing creates
29
+ # we need to set a MAXIMUM for FLATTEN
30
+ # alias_method :_old_flatten, :flatten
31
+ # alias_method :_old_flatten!, :flatten!
32
+ #
33
+ # def flatten(level = 42)
34
+ # _old_flatten(level)
35
+ # end
36
+ #
37
+ # def flatten!(level = 42)
38
+ # _old_flatten!(level)
39
+ # end
40
+ #end
@@ -1,9 +1,7 @@
1
- # APP_VERSION = '0.1 11-27-2012'
2
-
3
- # Mighty String - Strip HTML
4
- # Ruby should be easy to read, regex is not. I believe string block handling can be done better than rough regex'ing.
1
+ # Mighty String - HTML to text parser
5
2
  #
6
3
  # TODO *FIXME* A rare href exception gets by, as well as some comment cases, only if math_by_space is enabled. 0.1 11-27-2012 "Release Version"
4
+ # TODO FEATURE: Split all lines in document and make sure only one blank new-line is permitted.
7
5
  #
8
6
  # Ver 0.1 11-27-2012 "Release Version"
9
7
  # - Modularized and Gemified
@@ -24,21 +22,8 @@
24
22
  # Ver Pre_0.1
25
23
  # - HTML tag stripper with ASCII output
26
24
 
27
- Strip_HTML_License = "
28
-
29
- MightyString is licensed under 'The MIT License (MIT)'
30
-
31
- Copyright (c) 2012 Daniel P. Clark & 6ft Dan(TM)
32
-
33
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34
-
35
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36
-
37
- THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
38
- # REQUIRE #
39
-
40
- require_relative 'string_match_pci' unless defined? Match_PCI
41
- require_relative 'string_index_all' unless defined? Index_All
25
+ require 'string_match_pci' unless defined? Match_PCI
26
+ require 'string_index_all' unless defined? Index_All
42
27
 
43
28
  # END REQUIRE #
44
29
  class String
@@ -48,18 +33,39 @@ end
48
33
 
49
34
  module MightyString
50
35
  module HTML
51
- # Define some generic rules here ***
52
- # ---- COOL note: you can insert ASCII color escape code rules here... like for href then blue and for /a then plain
53
- def self.html_to_text_codes
54
- {"&quot;"=>"'","br"=>"\n","&#39;" => "'", "td" => " | ", "&nbsp;" => " ", "&trade;" => "(TM)", "&copy;" => "(c)"} # replace html segment and insert plan text equivalent
55
- end
36
+ def self.text(htmlstr, options = {})
37
+ options[:mappings] = default_options[:mappings].
38
+ merge(options.delete(:mappings)) if options.has_key?(:mappings)
39
+ options = default_options.merge(options)
40
+ options[:tag_markers].each { |g|
41
+ sh_endpoints = htmlstr.index_all(g[1])
42
+ if sh_endpoints.nil?
43
+ break
44
+ end
45
+ sh_end = htmlstr.rindex(g[1])
46
+ sh_start = htmlstr.rindex(g[0])
47
+ while !!sh_end and !!sh_start do
48
+ if sh_end > sh_start
49
+ sh_seq = htmlstr[sh_start,sh_end - sh_start + 1]
50
+ until sh_seq.count(g[1]) == 1 do # until we've selected only the inner block
51
+ sh_end = htmlstr[0,sh_end-1].rindex(g[1])
52
+ sh_seq = htmlstr[sh_start,sh_end - sh_start + 1]
53
+ end
54
+ if not (options[:math_by_space] and not html_math_exceptions(htmlstr[sh_start,sh_end - sh_start + 1]) == 0)
55
+ htmlstr = strip_first_seq( htmlstr, htmlstr[sh_start,sh_end - sh_start + 1], options[:mappings])
56
+ else
57
+ sh_end = sh_end - 1
58
+ end
59
+ else
60
+ sh_start = sh_start - 1
61
+ end
62
+ sh_end = htmlstr[0..sh_end].rindex(g[1])
63
+ sh_start = htmlstr[0..sh_start].rindex(g[0])
64
+ end
65
+ }
66
+ return htmlstr
67
+ end
56
68
 
57
- def self.math_by_space
58
- false # TODO FIXME exceptions get past a href 12-12-12
59
- end
60
-
61
- # End define generic rules ***
62
-
63
69
  def self.html_math_exceptions(in_str = "")
64
70
  if in_str["< "] or in_str["& "]
65
71
  return 1 # Execption found at beginning
@@ -72,7 +78,7 @@ module MightyString
72
78
  end
73
79
 
74
80
  # strip sequence out ( master string, sequence to remove, any characters to swap inplace this for that )
75
- def self.strip_first_seq( mstr = "", mseq = "", cmpchar = self.html_to_text_codes )
81
+ def self.strip_first_seq( mstr = "", mseq = "", cmpchar = default_options[:mappings] )
76
82
  if not cmpchar.empty? and cmpchar.keys.any? {|mkey| mseq.match_pci(mkey) } # keys exist and one of the keys match
77
83
  cmpchar.each_key { |mkey|
78
84
  if mseq.match_pci(mkey)
@@ -85,59 +91,28 @@ module MightyString
85
91
  return mstr
86
92
  end
87
93
 
88
- # Pick tags/blocks of string to remove (ex: "&", ";" like in "&quot;" can become "" or "'" if rules set))
89
- def self.strip_html( htmlstr = "", xarg = [["<",">"],["&",";"]] ) # xarg start, end
90
- xarg.each { |g|
91
- sh_endpoints = htmlstr.index_all(g[1])
92
- if sh_endpoints.nil?
93
- break
94
- end
95
- sh_end = htmlstr.rindex(g[1])
96
- sh_start = htmlstr.rindex(g[0])
97
- while !!sh_end and !!sh_start do
98
- if sh_end > sh_start
99
- sh_seq = htmlstr[sh_start,sh_end - sh_start + 1]
100
- until sh_seq.count(g[1]) == 1 do # until we've selected only the inner block
101
- sh_end = htmlstr[0,sh_end-1].rindex(g[1])
102
- sh_seq = htmlstr[sh_start,sh_end - sh_start + 1]
103
- end
104
- if not (math_by_space and not html_math_exceptions(htmlstr[sh_start,sh_end - sh_start + 1]) == 0)
105
- htmlstr = strip_first_seq( htmlstr, htmlstr[sh_start,sh_end - sh_start + 1])
106
- else
107
- sh_end = sh_end - 1
108
- end
109
- else
110
- sh_start = sh_start - 1
111
- end
112
- sh_end = htmlstr[0..sh_end].rindex(g[1])
113
- sh_start = htmlstr[0..sh_start].rindex(g[0])
114
- end
115
- }
116
- return htmlstr
117
- end
118
94
 
119
- def self.testCase
120
- pagesample = "<html><body>This code primarily removes (less than)tags(greater than) and (amperstand)code(semicolon).<br>This default behavior can be modified to fit your needs.<br>4>3 doesn't pair up, so it's visible.<br>As well as this with a space 4 > 3.<br>The opposite is 3 < 4. Can you see me?<br>These following punctions don't get removed because they are out of matching order. ';and&'.<br>< This is visible because of the first space before the less than symbol. ><br>&This shows because it's longer then characters in length and has a space in it.;<br><br><table><tr><td>My Box Table</td></tr></table> <!-- <div>Old HTML commented out. This is a unique case.<br>The code finds the innermost blocks and removes them outwards. So something like '< !-- < tag >' or '< /tag > -- >' won't raise an error.<br>(I added the spaces so you can still see the ouput print.)</div> --><br><br><h1>Ruby is quite nice!</h1><br><a href='_blank'>http://www.6ftdan.com</a></body></html>"
121
- puts pagesample
122
- puts
123
- puts " * - * - * - Before test is above. - * - * - after striphtml follows - * - * - *"
124
- puts
125
- puts strip_html(pagesample)
95
+ # <b>DEPRECATED:</b> Please use <tt>MightyString::HTML.text</tt> instead.
96
+ # Pick tags/blocks of string to remove (ex: "&", ";" like in "&quot;" can become "" or "'" if rules set))
97
+ def self.strip_html( htmlstr = "", xarg = default_options[:tag_markers] ) # xarg start, end
98
+ warn "#{Kernel.caller.first} [DEPRECATED] `MightyString::HTML.strip_html` is depreciated. Please use MightyString::HTML.text instead."
99
+ text(htmlstr, :tag_markers => xarg)
126
100
  end
127
-
128
- def self.license
129
- license = "Mighty_String::Strip_HTML is licensed under 'The MIT License (MIT)'
130
-
131
- Copyright (c) 2012 Daniel P. Clark & 6ft Dan(TM)
132
101
 
133
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
102
+ def self.default_options
103
+ {
104
+ :tag_markers => [["<",">"],["&",";"]],
105
+ :mappings => {
106
+ "&quot;"=>"'","br"=>"\n","&#39;" => "'", "&nbsp;" => " ", "&trade;" => "(TM)", "&copy;" => "(c)"
107
+ },
108
+ :math_by_space => false,
109
+ :drop_styles => true, # TODO Add this feature
110
+ :drop_scripts => true, # TODO Add this feature
111
+ :drop_iframes => false, # TODO Add this feature
112
+ :permitted_blank_line_rows => 1, # TODO Add this feature
113
+ :images_to_alt_text => false # TODO Add this feature
114
+ }
115
+ end
134
116
 
135
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
136
-
137
- THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
138
- puts
139
- puts license
140
- puts
141
- end
142
117
  end # module Strip_HTML
143
118
  end # MightyString
@@ -1,3 +1,3 @@
1
1
  module MightyString
2
- VERSION = "0.1.5.b"
2
+ VERSION = "0.2.0"
3
3
  end
data/test/test_ms.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'test/unit'
2
- require_relative '../lib/mightystring'
2
+ $: << 'lib/'
3
+ require 'mightystring'
3
4
 
4
5
  class TestMightyString < Test::Unit::TestCase
5
6
  def test_at
@@ -13,11 +14,10 @@ class TestMightyString < Test::Unit::TestCase
13
14
  assert "iudsfbv\nui4adv\nvw7revg".del("\n") == "iudsfbvui4advvw7revg"
14
15
  end
15
16
 
16
- def test_each
17
- assert "12345".each.all?{|i| i.to_i < 10}
18
- end
17
+ # def test_each
18
+ # assert "12345".each.all?{|i| i.to_i < 10}
19
+ # end
19
20
 
20
-
21
21
  def test_index_all
22
22
  assert "012324507654301243".index_all 0 == [0,7,13]
23
23
  assert "the apple is the best fruit in the world".index_all "the" == [0, 13, 31]
@@ -44,10 +44,10 @@ class TestMightyString < Test::Unit::TestCase
44
44
  end
45
45
 
46
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>&quot;Quoted&quot; Copyright &copy; TradeMark &trade;</p>") == "'Quoted' Copyright (c) TradeMark (TM)"
47
+ assert MightyString::HTML.text("<html>") == ""
48
+ assert MightyString::HTML.text("<table><tr><td>Piped sides.</td></tr></table>", :mappings => {"td" => ' | '}) == " | Piped sides. | "
49
+ assert MightyString::HTML.text("Hello<br>World!") == "Hello\nWorld!"
50
+ assert MightyString::HTML.text("<p>&quot;Quoted&quot; Copyright &copy; TradeMark &trade;</p>") == "'Quoted' Copyright (c) TradeMark (TM)"
51
51
  end
52
52
  end
53
53
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mightystring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.b
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark / 6ftDan(TM)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Array functionality in Strings as well as Matching, Indexing, Substitution,
14
14
  Deletion, and more.
@@ -55,15 +55,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: '0'
58
+ version: '1.8'
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">"
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 1.3.1
63
+ version: '0'
64
64
  requirements: []
65
65
  rubyforge_project:
66
- rubygems_version: 2.3.0
66
+ rubygems_version: 2.4.5
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: Strings (are) Arrays with Matching, Indexing, Substitution, Deletion, and