orthographer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/orthographer.rb +11 -0
- data/lib/orthographer/checker.rb +41 -0
- data/lib/orthographer/miss_result.rb +25 -0
- data/lib/orthographer/none_result.rb +17 -0
- data/lib/orthographer/result.rb +26 -0
- data/lib/orthographer/version.rb +3 -0
- data/orthographer.gemspec +27 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6514446b528bd79d07cb3af8e84722efc7adfb23
|
4
|
+
data.tar.gz: f8fd8ebf72a1c6912ad88a2f864e524d990d20ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc1e46352dfc23ccfb194896df1086b288328cf0fd56da75d4bc2cbd0f5fc7a9d1d6fc0589ffd19e4b334f01393f312ab2fd6c34c8a06093fe4dc02a1d27f84d
|
7
|
+
data.tar.gz: 784d84c5ecf9884ebee53cf58334734b2b687c16af34afe38cd14f85ebcfc0d1fcbf4e9f39ab357ddf11002624772b213b21cd90f9943af189024f760bce1e1f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1
|
4
|
+
- 2.2
|
5
|
+
- 2.3.1
|
6
|
+
before_install:
|
7
|
+
- sudo apt-get -qq update
|
8
|
+
- sudo apt-get install -y hunspell
|
9
|
+
- gem install bundler -v 1.13.5
|
10
|
+
notifications:
|
11
|
+
email: false
|
12
|
+
webhooks:
|
13
|
+
urls:
|
14
|
+
- https://uplink-app.herokuapp.com/travis_hooks
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jon Allured
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Orthographer
|
2
|
+
|
3
|
+
[![Build Status][status]][travis]
|
4
|
+
|
5
|
+
[status]: https://travis-ci.org/jonallured/orthographer.svg?branch=master
|
6
|
+
[travis]: https://travis-ci.org/jonallured/orthographer
|
7
|
+
|
8
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/orthographer`. To experiment with that code, run `bin/console` for an interactive prompt.
|
9
|
+
|
10
|
+
TODO: Delete this and the text above, and describe your gem
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'orthographer'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install orthographer
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
TODO: Write usage instructions here
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/orthographer.
|
41
|
+
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
46
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "orthographer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/orthographer.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Orthographer
|
2
|
+
class Checker
|
3
|
+
def self.check(text)
|
4
|
+
new(text).check
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(text)
|
8
|
+
@text = text
|
9
|
+
end
|
10
|
+
|
11
|
+
def check
|
12
|
+
misspellings.flatten.compact
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def output
|
18
|
+
@output ||= `echo "#{@text}" | hunspell -a`
|
19
|
+
end
|
20
|
+
|
21
|
+
def line_feedback
|
22
|
+
without_version_info = output.sub /.*\n/, ''
|
23
|
+
# remove trailing newlines when they are followed by another newline
|
24
|
+
without_trailing_newlines = without_version_info.gsub /(\w)\n(\n)/, '\1\2'
|
25
|
+
without_trailing_newlines.split "\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
def misspellings
|
29
|
+
line_feedback.map.with_index do |feedback, index|
|
30
|
+
word_feedback = feedback.split("\n")
|
31
|
+
word_feedback.map do |word|
|
32
|
+
if word[0] == "&"
|
33
|
+
MissResult.new(word, index + 1)
|
34
|
+
elsif word[0] == "#"
|
35
|
+
NoneResult.new(word, index + 1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Orthographer
|
2
|
+
class MissResult < Result
|
3
|
+
def to_s
|
4
|
+
"#{super.to_s}: #{suggestions}"
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def splitted_feedback
|
10
|
+
@splitted_feedback ||= @feedback.gsub(/:/, '').split ' '
|
11
|
+
end
|
12
|
+
|
13
|
+
def offset
|
14
|
+
splitted_feedback[3]
|
15
|
+
end
|
16
|
+
|
17
|
+
def original
|
18
|
+
splitted_feedback[1]
|
19
|
+
end
|
20
|
+
|
21
|
+
def suggestions
|
22
|
+
@feedback.split(': ').last
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Orthographer
|
2
|
+
class Result
|
3
|
+
def initialize(feedback, line)
|
4
|
+
@feedback = feedback
|
5
|
+
@line = line
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"#{coordinates} #{original}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def coordinates
|
13
|
+
"(#{@line}, #{offset})"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def offset
|
19
|
+
raise 'Implement in subclass'
|
20
|
+
end
|
21
|
+
|
22
|
+
def original
|
23
|
+
raise 'Implement in subclass'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'orthographer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "orthographer"
|
8
|
+
spec.version = Orthographer::VERSION
|
9
|
+
spec.authors = ["Jon Allured"]
|
10
|
+
spec.email = ["jon.allured@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Check your spelling."
|
13
|
+
spec.description = "This gem wraps hunspell and checks your spelling."
|
14
|
+
spec.homepage = "https://github.com/jonallured/orthographer"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orthographer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon Allured
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: This gem wraps hunspell and checks your spelling.
|
56
|
+
email:
|
57
|
+
- jon.allured@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/orthographer.rb
|
72
|
+
- lib/orthographer/checker.rb
|
73
|
+
- lib/orthographer/miss_result.rb
|
74
|
+
- lib/orthographer/none_result.rb
|
75
|
+
- lib/orthographer/result.rb
|
76
|
+
- lib/orthographer/version.rb
|
77
|
+
- orthographer.gemspec
|
78
|
+
homepage: https://github.com/jonallured/orthographer
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.5.1
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Check your spelling.
|
102
|
+
test_files: []
|