odyssey 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +31 -0
- data/README.md +1 -1
- data/changelog.md +3 -0
- data/lib/odyssey.rb +10 -25
- data/lib/odyssey/error.rb +4 -0
- data/lib/odyssey/version.rb +1 -1
- data/spec/odyssey_spec.rb +8 -1
- metadata +6 -4
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6a284fce2d0aae3b4cbba40c7a44212b318146525c8b68044d5f8293c6d39f
|
4
|
+
data.tar.gz: 74e76ecbec621570651e6c89d043355d4adc6773e5e6996efe6864cce1e2d670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96f23450e57618982d81b2b79aa1e33f22486fd69cbcbe9caf23197b96611e33a678408b7d3aada5d90a0b395337d691655a7dd0de51c8f6f58e1277884be93
|
7
|
+
data.tar.gz: b605033fd23d562e6d2d3676b85911d13b1b3b0ab3d7899b0b46124d4001d0e6b724a37d0b5ab8baa9a22fe9bd1ae2c0e2633990ff234a94db517a934bdca451
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ruby:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: ['2.4.x', '2.5.x', '2.6.x', '2.7.x']
|
11
|
+
env:
|
12
|
+
CI: true
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v1
|
16
|
+
with:
|
17
|
+
submodules: true
|
18
|
+
|
19
|
+
- name: set up ruby
|
20
|
+
uses: actions/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
|
24
|
+
- name: setup bundler, gems
|
25
|
+
run: |
|
26
|
+
gem install bundler
|
27
|
+
bundle install
|
28
|
+
|
29
|
+
- name: run specs
|
30
|
+
run: |
|
31
|
+
bundle exec rake spec
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Odyssey
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/odyssey.svg)](https://badge.fury.io/rb/odyssey)
|
4
|
-
|
4
|
+
![](https://github.com/cameronsutter/odyssey/workflows/ci/badge.svg)
|
5
5
|
|
6
6
|
Odyssey is an extendible text analyzing gem that outputs the readability score of text. It has several of the common readability formulas available, but defaults to the Flesch-Kincaid Reading Ease score.
|
7
7
|
|
data/changelog.md
ADDED
data/lib/odyssey.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "odyssey/
|
1
|
+
require "odyssey/error"
|
2
2
|
|
3
3
|
module Odyssey
|
4
|
-
|
4
|
+
FORMULAS = %w[Ari ColemanLiau FleschKincaidGl FleschKincaidRe GunningFog Smog]
|
5
5
|
DEFAULT_FORMULA = 'FleschKincaidRe'
|
6
6
|
|
7
7
|
#main method
|
@@ -11,18 +11,13 @@ module Odyssey
|
|
11
11
|
@engine = Odyssey::Engine.new(formula_name)
|
12
12
|
score = @engine.score(text)
|
13
13
|
|
14
|
-
|
15
|
-
if all_stats
|
16
|
-
output = @engine.get_stats
|
17
|
-
else
|
18
|
-
output = score
|
19
|
-
end
|
14
|
+
return @engine.get_stats if all_stats
|
20
15
|
|
21
|
-
|
16
|
+
score
|
22
17
|
end
|
23
18
|
|
24
19
|
def self.analyze_multi(text, formula_names, all_stats = false)
|
25
|
-
raise ArgumentError, "You must supply at least one formula" if formula_names.empty?
|
20
|
+
raise Odyssey::ArgumentError, "You must supply at least one formula" if formula_names.empty?
|
26
21
|
|
27
22
|
scores = {}
|
28
23
|
@engine = Odyssey::Engine.new(formula_names[0])
|
@@ -33,20 +28,15 @@ module Odyssey
|
|
33
28
|
scores[formula_name] = @engine.score("", false)
|
34
29
|
end
|
35
30
|
|
36
|
-
|
37
|
-
all_stats = @engine.get_stats(false)
|
38
|
-
all_stats['scores'] = scores
|
39
|
-
output = all_stats
|
40
|
-
else
|
41
|
-
output = scores
|
42
|
-
end
|
31
|
+
return scores unless all_stats
|
43
32
|
|
44
|
-
|
33
|
+
all_stats = @engine.get_stats(false)
|
34
|
+
all_stats['scores'] = scores
|
35
|
+
all_stats
|
45
36
|
end
|
46
37
|
|
47
38
|
def self.analyze_all(text)
|
48
|
-
|
49
|
-
analyze_multi text, formulas, true
|
39
|
+
analyze_multi text, FORMULAS, true
|
50
40
|
end
|
51
41
|
|
52
42
|
#run whatever method was given as if it were a shortcut to a formula
|
@@ -56,11 +46,6 @@ module Odyssey
|
|
56
46
|
super unless Object.const_defined? formula_class
|
57
47
|
analyze(args[0], formula_class, args[1] || false)
|
58
48
|
end
|
59
|
-
|
60
|
-
#define this here, so it doesn't get sent to method_missing()
|
61
|
-
def self.to_ary
|
62
|
-
[]
|
63
|
-
end
|
64
49
|
end
|
65
50
|
|
66
51
|
require 'odyssey/engine'
|
data/lib/odyssey/version.rb
CHANGED
data/spec/odyssey_spec.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Odyssey do
|
4
|
+
describe '.analyze_multi' do
|
5
|
+
it 'raises an error if no formulas are supplied' do
|
6
|
+
expect do
|
7
|
+
Odyssey.analyze_multi(one_simple_sentence, [])
|
8
|
+
end.to raise_error(Odyssey::ArgumentError)
|
9
|
+
end
|
10
|
+
end
|
4
11
|
|
5
12
|
context 'default formula' do
|
6
13
|
it 'should return something' do
|
@@ -117,7 +124,7 @@ describe Odyssey do
|
|
117
124
|
end
|
118
125
|
|
119
126
|
it 'should raise an error for empty formula list' do
|
120
|
-
expect { Odyssey.analyze_multi one_simple_sentence, [] }.to raise_error(ArgumentError)
|
127
|
+
expect { Odyssey.analyze_multi one_simple_sentence, [] }.to raise_error(Odyssey::ArgumentError)
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odyssey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Sutter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,14 +75,16 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".github/workflows/ci.yml"
|
78
79
|
- ".gitignore"
|
79
|
-
- ".travis.yml"
|
80
80
|
- Gemfile
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- changelog.md
|
84
85
|
- lib/odyssey.rb
|
85
86
|
- lib/odyssey/engine.rb
|
87
|
+
- lib/odyssey/error.rb
|
86
88
|
- lib/odyssey/formulas/ari.rb
|
87
89
|
- lib/odyssey/formulas/coleman_liau.rb
|
88
90
|
- lib/odyssey/formulas/fake_formula.rb
|
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
125
|
- !ruby/object:Gem::Version
|
124
126
|
version: '0'
|
125
127
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.1.2
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: Text readability analyzer using Flesch-Kincaid and others
|
data/.travis.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
dist: bionic # Ubuntu 18.04
|
4
|
-
|
5
|
-
# Test against all Ruby-supported versions
|
6
|
-
#
|
7
|
-
# See https://www.ruby-lang.org/en/downloads/branches/
|
8
|
-
rvm:
|
9
|
-
- 2.4
|
10
|
-
- 2.5
|
11
|
-
- 2.6
|
12
|
-
|
13
|
-
script: |
|
14
|
-
bundle exec rake spec
|
15
|
-
|
16
|
-
notifications:
|
17
|
-
email: false
|