spellr 0.4.1 → 0.5.0

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.
@@ -34,6 +34,8 @@ in
34
34
  instanceof
35
35
  int
36
36
  interface
37
+ java
38
+ javascript
37
39
  let
38
40
  long
39
41
  native
@@ -44,6 +46,7 @@ private
44
46
  protected
45
47
  public
46
48
  return
49
+ script
47
50
  short
48
51
  static
49
52
  super
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spellr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
@@ -163,8 +163,6 @@ files:
163
163
  - Gemfile.lock
164
164
  - LICENSE.txt
165
165
  - README.md
166
- - bin/fetch_wordlist/english
167
- - bin/fetch_wordlist/ruby
168
166
  - exe/spellr
169
167
  - lib/.spellr.yml
170
168
  - lib/spellr.rb
@@ -193,6 +191,19 @@ files:
193
191
  - lib/spellr/wordlist_reporter.rb
194
192
  - spellr.gemspec
195
193
  - wordlists/dockerfile.txt
194
+ - wordlists/english.LICENSE.txt
195
+ - wordlists/english.txt
196
+ - wordlists/english/AU.LICENSE.txt
197
+ - wordlists/english/AU.txt
198
+ - wordlists/english/CA.LICENSE.txt
199
+ - wordlists/english/CA.txt
200
+ - wordlists/english/GB.txt
201
+ - wordlists/english/GBs.LICENSE.txt
202
+ - wordlists/english/GBs.txt
203
+ - wordlists/english/GBz.LICENSE.txt
204
+ - wordlists/english/GBz.txt
205
+ - wordlists/english/US.LICENSE.txt
206
+ - wordlists/english/US.txt
196
207
  - wordlists/html.txt
197
208
  - wordlists/javascript.txt
198
209
  - wordlists/ruby.txt
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'net/http'
5
- require 'optparse'
6
-
7
- class SCOWLDownloader
8
- SIZE_OPTIONS = %w{10 20 35 40 50 55 60 70 80 95}.freeze
9
- VARIANT_OPTIONS = %w{none common acceptable seldom-used}.freeze
10
- DIACRITIC_OPTIONS = %w{strip keep both}.freeze
11
- SPELLING_LANGUAGE_OPTIONS = %w{US GBs GBz CA AU}.freeze
12
-
13
- def initialize
14
- set_default_options
15
- parse_options
16
- puts Net::HTTP.get_response(uri).body
17
- end
18
-
19
- private
20
-
21
- def set_default_options
22
- @options = {
23
- max_size: 50,
24
- spelling: :US,
25
- max_variant: 0,
26
- diacritic: :both,
27
- hacker: true
28
- }
29
- end
30
-
31
- def parse_options # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
32
- # rubocop:disable Metrics/LineLength
33
- OptionParser.new do |opts|
34
- opts.banner = 'Usage: spellr [options] fetch english [wordlist options]'
35
- opts.on('-s', '--max-size', '=SIZE', String, SIZE_OPTIONS, 'Wordlist size. Options: 10 (~5,000 words), 20, 35, 40, 50 (default), 60, 70 (~170,000 words)') { |i| @options[:max_size] = i }
36
- opts.on('-v', '--max-variants', '=VARIANTS', String, VARIANT_OPTIONS, 'Spelling variants. Options: none (default), common, acceptable, seldom-used') { |i| @options[:max_variant] = VARIANT_OPTIONS.index(i) }
37
- opts.on('-d', '--diacritic', '=DIACRITIC', String, DIACRITIC_OPTIONS, 'Include diacritics in words. Options: strip (café becomes cafe), keep, both (default. cafe & café)') { |s| @options[:diacritic] = s }
38
- opts.on('-l', '--language=x,y,z', Array, 'Comma separated list of English variations. Options: US (default), GBs (GB with -ise), GBz (GB with -ize), CA, AU') do |a|
39
- raise ArgumentError unless (a - SPELLING_LANGUAGE_OPTIONS).empty?
40
-
41
- @options[:spelling] = a
42
- end
43
- opts.on('-p', '--[no-]programming', 'include common programming terms like grep (default true)') do |h|
44
- @options[:special] = :hacker if h
45
- end
46
- opts.on_tail('-h', '--help') do
47
- warn opts.to_s
48
- exit 1
49
- end
50
- end.parse!
51
- # rubocop:enable Metrics/LineLength
52
- end
53
-
54
- attr_reader :options
55
-
56
- def uri
57
- query = URI.encode_www_form(
58
- **options,
59
- download: :wordlist,
60
- encoding: :'utf-8',
61
- format: :inline
62
- )
63
- URI.parse("http://app.aspell.net/create?#{query}")
64
- end
65
- end
66
-
67
- SCOWLDownloader.new
@@ -1,150 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'optparse'
5
- class RubyWords # rubocop:disable Metrics/ClassLength
6
- def initialize
7
- @strings = []
8
- prepare_excluded_classes
9
-
10
- parse_options
11
-
12
- prepare_post_excluded_classes
13
-
14
- puts generate_words
15
- end
16
-
17
- private
18
-
19
- def prepare_excluded_classes
20
- @looked_at = []
21
- @looked_at << RubyWords.__id__
22
- @looked_at << OptionParser.__id__ # because we're including it here
23
- end
24
-
25
- def generate_words
26
- $VERBOSE = nil
27
- @strings = []
28
- generate_words_for(Module)
29
- generate_keywords
30
- generate_convention_words
31
- end
32
-
33
- def generate_words_for(constant)
34
- return if @looked_at.include?(constant.__id__) # to prevent endless loops
35
-
36
- @looked_at << constant.__id__
37
-
38
- generate_methods_for(constant)
39
- generate_child_constants_for(constant)
40
- end
41
-
42
- def generate_methods_for(constant)
43
- @strings |= constant.public_instance_methods(false) if constant.respond_to?(:public_instance_methods)
44
- @strings |= constant.public_methods(false) if constant.respond_to?(:public_methods)
45
- end
46
-
47
- def generate_child_constants_for(constant) # rubocop:disable Metrics/MethodLength
48
- return unless constant.respond_to?(:constants)
49
-
50
- constant.constants.each do |child|
51
- if autoload?(child)
52
- warn "Skipping autoload constant #{constant}::#{child}"
53
- next
54
- end
55
-
56
- @strings |= [child]
57
- child = constant.const_get(child)
58
- generate_words_for(child)
59
- rescue StandardError, LoadError => e
60
- warn "Error loading #{constant}::#{child} => #{e.message}"
61
- end
62
- end
63
-
64
- def generate_keywords
65
- @strings |= %w{
66
- __ENCODING__ __LINE__ __FILE__ BEGIN END alias and begin break case class def
67
- defined? do else elsif end ensure false for if in module next nil not or redo
68
- rescue retry return self super then true undef unless until when while yield
69
- }
70
- end
71
-
72
- def generate_convention_words
73
- @strings |= %w{
74
- klass
75
- }
76
- end
77
-
78
- # badly behaved classes that I'll always have to exclude
79
- # TODO: use the full class name rather than __id__ so i don't have to load anything
80
- def prepare_post_excluded_classes
81
- %w{RSpec::Core::Runner I18n::Tests}.each do |exclude|
82
- @looked_at << Module.const_get(exclude).__id__
83
- rescue StandardError, LoadError # rubocop:disable Lint/HandleExceptions
84
- end
85
- end
86
-
87
- def exclude_option(excludes, quiet: false)
88
- excludes.each do |exclude|
89
- @looked_at << Module.const_get(exclude).__id__
90
- rescue StandardError, LoadError => e
91
- warn "Error excluding #{exclude} => #{e.message}" unless quiet
92
- end
93
- end
94
-
95
- def bundler_option(_)
96
- require 'bundler/setup'
97
- require_each Bundler.setup.requires.values.flatten(1)
98
- end
99
-
100
- def require_each(requirables)
101
- requirables.each(&method(:soft_require))
102
- end
103
-
104
- def soft_require(requireable)
105
- require requireable
106
- rescue LoadError => e
107
- warn "Error requiring #{requireable} => #{e.message}"
108
- end
109
-
110
- def require_option(gems)
111
- soft_require 'bundler/setup'
112
- require_each(gems)
113
- end
114
-
115
- def available_stdlibs
116
- %w{
117
- abbrev base64 benchmark bigdecimal cgi cmath coverage csv date delegate digest
118
- drb/drb e2mmap English erb etc expect fcntl fiddle fileutils find forwardable
119
- getoptlong io/console io/nonblock io/wait ipaddr irb json logger matrix mkmf
120
- monitor mutex_m net/ftp net/http net/imap net/pop net/smtp net/telnet nkf
121
- objspace observer open-uri open3 openssl optionparser optparse ostruct pathname
122
- pp prettyprint prime pstore psych pty racc/parser readline resolv ripper rss scanf
123
- sdbm securerandom set shell shellwords singleton socket stringio strscan sync syslog
124
- tempfile thwait time timeout tmpdir tracer tsort uri weakref webrick yaml zlib
125
- }
126
- end
127
-
128
- def stdlib_option(stdlibs)
129
- stdlibs &= available_stdlibs
130
- stdlibs.each { |p| require p }
131
- @strings += stdlibs
132
- @looked_at -= [OptionParser.__id__] if stdlibs.include?('optparse') # because they might want it too
133
- end
134
-
135
- def parse_options # rubocop:disable Metrics/MethodLength
136
- OptionParser.new do |opts|
137
- opts.set_program_name 'spellr --fetch ruby'
138
- opts.on('-r', '--require=x,y,z', Array, 'requires the specified gems', &method(:require_option))
139
- opts.on('-s', '--stdlib=x,y,z', Array, 'requires the specified stdlib packages', &method(:stdlib_option))
140
- opts.on('-b', '--bundler', 'includes methods and constants required by emfile', &method(:bundler_option))
141
- opts.on('-x', '--exclude=x,y,z', Array, 'exclude listing these constants and their methods', &method(:exclude_option)) # rubocop:disable Metrics/LineLength
142
- opts.on_tail('-h', '--help', 'Shows this message') do
143
- warn opts
144
- exit 1
145
- end
146
- end.parse!
147
- end
148
- end
149
-
150
- RubyWords.new