textstat 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: b2c0ed4e6cb91a3c7ed173cb3c165660bd20f621430b8fb19f3258b5e9689a85
4
- data.tar.gz: 4e566915224c921e827809619b7dca5df7abfb6d5fcce4b6d188abf224cb9776
3
+ metadata.gz: acc0d4631073c696b6a8b819c5aeea999ba98f0be16c1d3c34d347b2ccdf7260
4
+ data.tar.gz: ce4bd16bcaa4edcc22080657a6f28d9e5f439ed56398e268bf4dc50165922840
5
5
  SHA512:
6
- metadata.gz: d7d2d84eae2bd350746a074565e0070ac912a62caa156e1140176c5d586817215df677a043081ba829142a191bd8401d1729be76ab7e280e8f16b8450b5e54ff
7
- data.tar.gz: 4ac752bba6250fe0e75a3e7b5398deedcd7248cf900e0af11f89c49effa368e403b5d2e8b0e8cc6772cd2000c7764f6556537dc1818b4af2d2190e6a9404eb6c
6
+ metadata.gz: be0dac8aa46ebd1ffa7a1ced5e2931cea7f270c9369791a4749c39b5403bed6f8dca90e52e3858afccebd1962a8fb3ad3d2b1c5532034478ddaf5d53a183ddf1
7
+ data.tar.gz: 7da4fb8249f0b8ed2dd2be25aa764e1333152014147b8ea1545916bbd39823b83b6a4546690a575f343b7876930445689c93a7b16c31150bd49827a342bfda43
data/lib/counter.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/textstat.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'text-hyphen'
2
2
 
3
3
  class TextStat
4
+ GEM_PATH = File.dirname(File.dirname(__FILE__))
5
+
4
6
  def self.char_count(text, ignore_spaces = true)
5
7
  text = text.delete(' ') if ignore_spaces
6
8
  text.length
@@ -152,7 +154,7 @@ class TextStat
152
154
  def self.difficult_words(text, language = 'en_us')
153
155
  require 'set'
154
156
  easy_words = Set.new
155
- File.read("lib/dictionaries/#{language}.txt").each_line do |line|
157
+ File.read(File.join(dictionary_path, "#{language}.txt")).each_line do |line|
156
158
  easy_words << line.chop
157
159
  end
158
160
 
@@ -290,4 +292,12 @@ class TextStat
290
292
  return "#{score.to_i - 1}th and #{score.to_i}th grade"
291
293
  end
292
294
  end
293
- end
295
+
296
+ def self.dictionary_path=(path)
297
+ @dictionary_path = path
298
+ end
299
+
300
+ def self.dictionary_path
301
+ @dictionary_path ||= File.join(TextStat::GEM_PATH, 'lib', 'dictionaries')
302
+ end
303
+ end
@@ -1,3 +1,3 @@
1
1
  class TextStat
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -158,5 +158,20 @@ describe TextStat do
158
158
  standard = TextStat.text_standard(@long_test)
159
159
  expect(standard).to eql '10th and 11th grade'
160
160
  end
161
+
162
+ describe '.dictionary_path' do
163
+ subject(:dictionary_path) { described_class.dictionary_path }
164
+
165
+ it 'returns the Gem dictionary path by default' do
166
+ gem_root = File.dirname(File.dirname(__FILE__))
167
+ default_path = File.join(gem_root, 'lib', 'dictionaries')
168
+ expect(dictionary_path).to eq default_path
169
+ end
170
+
171
+ it 'allows dictionary path to be overridden' do
172
+ described_class.dictionary_path = '/some/other/path'
173
+ expect(dictionary_path).to eq '/some/other/path'
174
+ end
175
+ end
161
176
  end
162
177
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textstat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Polak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-hyphen
@@ -108,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.7.8
111
+ rubygems_version: 3.1.0.pre1
113
112
  signing_key:
114
113
  specification_version: 4
115
114
  summary: Ruby gem to calculate readability statistics of a text object - paragraphs,