word_count_analyzer 0.0.10 → 0.0.11

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: 9100a7be1a916cb3872aa74e9e76ddfb83744d62
4
- data.tar.gz: 99b5f6ddb28101de71f97d3b44e179d485f7ab84
3
+ metadata.gz: f1aca10a5014f22128759d78ac94e1344dde8056
4
+ data.tar.gz: 83ef54c2fb432cab8246aecda21cefdce01f0c82
5
5
  SHA512:
6
- metadata.gz: e0727cd58ddf83c23ac0dde9f9c713d7cad4f5c21fd572bc0bd21064266f57e5ff3d2489326d951ec5b7e3a7d38370a36f98596bd725d08092ad9fdabea43480
7
- data.tar.gz: decc5f7b4256f0884b61bf23191ae638509a68f948a2515333ddbef2a9e6d3d6c9004ebb1e5db1352a11a1212399497cd798bb559d1f91bb14b778342ec123c0
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
@@ -1,3 +1,3 @@
1
1
  module WordCountAnalyzer
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word_count_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias