word_count_analyzer 0.0.10 → 0.0.11
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1aca10a5014f22128759d78ac94e1344dde8056
|
4
|
+
data.tar.gz: 83ef54c2fb432cab8246aecda21cefdce01f0c82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da0391470b4bffa94c4830e0aa52066ee9ab8b1792b06c5e14049e08527a7c7321ee7f658e4ee6c90b6b9ce1aa63b080d76b2161b244c6870b3814cc803b062c
|
7
|
+
data.tar.gz: cb77e8ceda65956f77c9d3aabd33e8e39ec4d682e6cc215ac0ac48cb4ada8e9e55afc0bbed8d6f830a9d6e8e37635148f7fd3d4ce08d735dc9050ed9b80f9630
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module WordCountAnalyzer
|
2
2
|
class Counter
|
3
|
-
attr_reader :text, :ellipsis, :hyperlink, :contraction, :hyphenated_word, :date, :number, :numbered_list, :xhtml, :forward_slash, :backslash, :dotted_line, :dashed_line, :underscore, :stray_punctuation, :tgr
|
3
|
+
attr_reader :text, :ellipsis, :hyperlink, :contraction, :hyphenated_word, :date, :number, :numbered_list, :xhtml, :forward_slash, :backslash, :dotted_line, :dashed_line, :underscore, :stray_punctuation, :equal_sign, :tgr
|
4
4
|
def initialize(text:, **args)
|
5
5
|
@text = text
|
6
6
|
@ellipsis = args[:ellipsis] || 'ignore'
|
@@ -17,6 +17,7 @@ module WordCountAnalyzer
|
|
17
17
|
@dashed_line = args[:dashed_line] || 'ignore'
|
18
18
|
@underscore = args[:underscore] || 'ignore'
|
19
19
|
@stray_punctuation = args[:stray_punctuation] || 'ignore'
|
20
|
+
@equal_sign = 'ignore'
|
20
21
|
@tgr = EngTagger.new
|
21
22
|
end
|
22
23
|
|
@@ -39,6 +40,7 @@ module WordCountAnalyzer
|
|
39
40
|
@dashed_line = 'ignore'
|
40
41
|
@underscore = 'ignore'
|
41
42
|
@stray_punctuation = 'ignore'
|
43
|
+
@equal_sign = 'break'
|
42
44
|
word_count
|
43
45
|
end
|
44
46
|
|
@@ -77,6 +79,7 @@ module WordCountAnalyzer
|
|
77
79
|
processed_text = process_dashed_line(processed_text)
|
78
80
|
processed_text = process_underscore(processed_text)
|
79
81
|
processed_text = process_stray_punctuation(processed_text)
|
82
|
+
processed_text = process_equal_sign(processed_text) if @equal_sign.eql?('break')
|
80
83
|
processed_text.split(/\s+/).reject(&:empty?).size
|
81
84
|
end
|
82
85
|
|
@@ -226,5 +229,9 @@ module WordCountAnalyzer
|
|
226
229
|
raise 'The value you specified for stray_punctuation is not a valid option. Please use either `ignore` or `count`. The default option is `ignore`'
|
227
230
|
end
|
228
231
|
end
|
232
|
+
|
233
|
+
def process_equal_sign(txt)
|
234
|
+
txt.split('=').join(' ').split(/>(?=[a-zA-z]+)/).join(' ')
|
235
|
+
end
|
229
236
|
end
|
230
237
|
end
|
@@ -599,6 +599,12 @@ RSpec.describe WordCountAnalyzer::Counter do
|
|
599
599
|
ws = WordCountAnalyzer::Counter.new(text: text)
|
600
600
|
expect(ws.pages_count).to eq(9)
|
601
601
|
end
|
602
|
+
|
603
|
+
it 'reverse engineers Pages word count #005' do
|
604
|
+
text = "<span class=\"large-text\">Hello world</span> <new-tag>Hello</new-tag>"
|
605
|
+
ws = WordCountAnalyzer::Counter.new(text: text)
|
606
|
+
expect(ws.pages_count).to eq(12)
|
607
|
+
end
|
602
608
|
end
|
603
609
|
|
604
610
|
context 'Microsoft Word Count' do
|