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 +4 -4
- data/lib/counter.rb +0 -0
- data/lib/dictionaries/ca.txt +0 -0
- data/lib/dictionaries/cs.txt +0 -0
- data/lib/dictionaries/nl.txt +0 -0
- data/lib/textstat.rb +12 -2
- data/lib/textstat/version.rb +1 -1
- data/spec/textstat_spec.rb +15 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acc0d4631073c696b6a8b819c5aeea999ba98f0be16c1d3c34d347b2ccdf7260
|
4
|
+
data.tar.gz: ce4bd16bcaa4edcc22080657a6f28d9e5f439ed56398e268bf4dc50165922840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0dac8aa46ebd1ffa7a1ced5e2931cea7f270c9369791a4749c39b5403bed6f8dca90e52e3858afccebd1962a8fb3ad3d2b1c5532034478ddaf5d53a183ddf1
|
7
|
+
data.tar.gz: 7da4fb8249f0b8ed2dd2be25aa764e1333152014147b8ea1545916bbd39823b83b6a4546690a575f343b7876930445689c93a7b16c31150bd49827a342bfda43
|
data/lib/counter.rb
CHANGED
File without changes
|
data/lib/dictionaries/ca.txt
CHANGED
File without changes
|
data/lib/dictionaries/cs.txt
CHANGED
File without changes
|
data/lib/dictionaries/nl.txt
CHANGED
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("
|
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
|
-
|
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
|
data/lib/textstat/version.rb
CHANGED
data/spec/textstat_spec.rb
CHANGED
@@ -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.
|
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:
|
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
|
-
|
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,
|