ffi-hunspell 0.3.0 → 0.3.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1f146caea929efea0b2d0ea4853410c9693a271
4
+ data.tar.gz: 7f29da7a3b1a6e272a1f17aed2ff75b771128f56
5
+ SHA512:
6
+ metadata.gz: 65c59a19ade6f500cfe8782699432efc0a28c573cd81a760982b8335db1d78fe740c521f8a5c526ae66d0fb7a2b94950f32a59d6fc347b9e6411ec14b5b342c8
7
+ data.tar.gz: 645580d8d22a25966345a86d5303130a801e6236120c02ca8314280f2b79e038ebb3ce68e21864685ca2e24d50807715e34bc6e45a7fcaedae30d8d6ef89c9b7
@@ -4,11 +4,10 @@ before_install:
4
4
  - gem install ffi rubygems-tasks rspec yard
5
5
  rvm:
6
6
  - 1.9.3
7
- - 2.0.0
8
- - jruby-19mode
9
- - rbx-19mode
7
+ - 2.3.0
8
+ - jruby
9
+ - rbx
10
10
  matrix:
11
11
  allow_failures:
12
- - rvm: rbx-18mode
13
- - rvm: rbx-19mode
14
- script: rake test
12
+ - rvm: rbx
13
+ script: rake spec
@@ -1,9 +1,14 @@
1
+ ### 0.3.1 / 2016-01-14
2
+
3
+ * Prefer loading hunspell-1.3 over hunspell-1.2, if both are installed.
4
+ * Support auto-detection of hunspell installed by homebrew (@forward3d).
5
+
1
6
  ### 0.3.0 / 2013-05-01
2
7
 
3
8
  * Detect Ubuntu's hunspell directory (`/usr/share/hunspell`).
4
9
  * {FFI::Hunspell::Dictionary#encoding} now returns an `Encoding` object.
5
10
  * Encode Strings returned from {FFI::Hunspell::Dictionary#stem} and
6
- {FFI::Hunspell::Dictionary#suggestions} to match the dictionary's native
11
+ {FFI::Hunspell::Dictionary#suggest} to match the dictionary's native
7
12
  encoding.
8
13
 
9
14
  ### 0.2.6 / 2013-02-05
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2013 Hal Brodigan
1
+ Copyright (c) 2010-2016 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -58,7 +58,7 @@ Suggest alternate spellings for a word:
58
58
 
59
59
  ## License
60
60
 
61
- Copyright (c) 2010-2013 Hal Brodigan
61
+ Copyright (c) 2010-2016 Hal Brodigan
62
62
 
63
63
  See {file:LICENSE.txt} for license information.
64
64
 
data/Rakefile CHANGED
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'rubygems-tasks', '~> 0.1'
6
5
  require 'rubygems/tasks'
7
6
 
8
7
  Gem::Tasks.new
@@ -12,7 +11,6 @@ rescue LoadError => e
12
11
  end
13
12
 
14
13
  begin
15
- gem 'rspec', '~> 2.4'
16
14
  require 'rspec/core/rake_task'
17
15
 
18
16
  RSpec::Core::RakeTask.new
@@ -25,7 +23,6 @@ task :test => :spec
25
23
  task :default => :spec
26
24
 
27
25
  begin
28
- gem 'yard', '~> 0.7'
29
26
  require 'yard'
30
27
 
31
28
  YARD::Rake::YardocTask.new
@@ -1,5 +1,5 @@
1
1
  name: ffi-hunspell
2
- version: 0.3.0
2
+ version: 0.3.1
3
3
  summary: FFI bindings for Hunspell
4
4
  description: Ruby FFI bindings for the Hunspell spell checker.
5
5
  license: MIT
@@ -17,5 +17,5 @@ dependencies:
17
17
 
18
18
  development_dependencies:
19
19
  rubygems-tasks: ~> 0.1
20
- rspec: ~> 2.4
20
+ rspec: ~> 3.0
21
21
  yard: ~> 0.7
@@ -4,8 +4,11 @@ module FFI
4
4
  module Hunspell
5
5
  extend FFI::Library
6
6
 
7
- ffi_lib ['hunspell-1.2', 'libhunspell-1.2.so.0',
8
- 'hunspell-1.3', 'libhunspell-1.3.so.0']
7
+ ffi_lib [
8
+ 'hunspell-1.3', 'libhunspell-1.3.so.0',
9
+ 'hunspell-1.2', 'libhunspell-1.2.so.0'
10
+ ]
11
+
9
12
 
10
13
  attach_function :Hunspell_create, [:string, :string], :pointer
11
14
  attach_function :Hunspell_create_key, [:string, :string, :string], :pointer
@@ -39,7 +42,7 @@ module FFI
39
42
  #
40
43
  # @since 0.2.0
41
44
  #
42
- def Hunspell.lang
45
+ def self.lang
43
46
  @lang ||= DEFAULT_LANG
44
47
  end
45
48
 
@@ -54,7 +57,7 @@ module FFI
54
57
  #
55
58
  # @since 0.2.0
56
59
  #
57
- def Hunspell.lang=(new_lang)
60
+ def self.lang=(new_lang)
58
61
  @lang = new_lang.to_s
59
62
  end
60
63
 
@@ -65,6 +68,9 @@ module FFI
65
68
  KNOWN_DIRECTORIES = [
66
69
  # User
67
70
  File.join(Gem.user_home,USER_DIR),
71
+ # OS X brew-instlled hunspell
72
+ File.join(Gem.user_home,'Library/Spelling'),
73
+ '/Library/Spelling',
68
74
  # Debian
69
75
  '/usr/local/share/myspell/dicts',
70
76
  '/usr/share/myspell/dicts',
@@ -86,12 +92,16 @@ module FFI
86
92
  #
87
93
  # @since 0.2.0
88
94
  #
89
- def Hunspell.directories
95
+ def self.directories
90
96
  @directories ||= KNOWN_DIRECTORIES.select do |path|
91
97
  File.directory?(path)
92
98
  end
93
99
  end
94
100
 
101
+ def self.directories=(dirs)
102
+ @directories = dirs
103
+ end
104
+
95
105
  #
96
106
  # Opens a Hunspell dictionary.
97
107
  #
@@ -106,7 +116,7 @@ module FFI
106
116
  #
107
117
  # @return [nil]
108
118
  #
109
- def Hunspell.dict(name=Hunspell.lang,&block)
119
+ def self.dict(name=Hunspell.lang,&block)
110
120
  Dictionary.open(name,&block)
111
121
  end
112
122
  end
@@ -2,30 +2,28 @@ require 'spec_helper'
2
2
  require 'ffi/hunspell/dictionary'
3
3
 
4
4
  describe Hunspell::Dictionary do
5
- subject { Hunspell::Dictionary }
5
+ subject { described_class }
6
6
 
7
7
  let(:lang) { 'en_US' }
8
-
9
8
  let(:affix_path) { File.join(Hunspell.directories.last,"#{lang}.aff") }
10
- let(:dic_path) { File.join(Hunspell.directories.last,"#{lang}.dic") }
9
+ let(:dic_path) { File.join(Hunspell.directories.last,"#{lang}.dic") }
11
10
 
12
11
  describe "#initialize" do
13
- subject { described_class }
12
+ subject { described_class.new(affix_path,dic_path) }
14
13
 
15
14
  it "should create a dictionary from '.aff' and '.dic' files" do
16
- dict = subject.new(affix_path,dic_path)
17
- dict.should_not be_nil
18
-
19
- dict.close
15
+ expect(subject.to_ptr).to_not be_nil
20
16
  end
17
+
18
+ after { subject.close }
21
19
  end
22
20
 
23
- describe "open" do
21
+ describe ".open" do
24
22
  subject { described_class }
25
23
 
26
24
  it "should find and open a dictionary file for a given language" do
27
25
  subject.open(lang) do |dict|
28
- dict.should_not be_nil
26
+ expect(dict).to_not be_nil
29
27
  end
30
28
  end
31
29
 
@@ -33,69 +31,71 @@ describe Hunspell::Dictionary do
33
31
  dict = subject.open(lang)
34
32
  dict.close
35
33
 
36
- dict.should be_closed
34
+ expect(dict).to be_closed
37
35
  end
38
36
 
39
37
  context "when given an unknown dictionary name" do
40
38
  it "should raise an ArgumentError" do
41
- lambda {
39
+ expect {
42
40
  subject.open('foo')
43
- }.should raise_error(ArgumentError)
41
+ }.to raise_error(ArgumentError)
44
42
  end
45
43
  end
46
44
  end
47
45
 
48
- subject { described_class.new(affix_path,dic_path) }
46
+ context "when opened" do
47
+ subject { described_class.new(affix_path,dic_path) }
49
48
 
50
- after(:all) { subject.close }
51
-
52
- it "should provide the encoding of the dictionary files" do
53
- subject.encoding.should == Encoding::ISO_8859_1
54
- end
55
-
56
- it "should check if a word is valid" do
57
- subject.should be_valid('dog')
58
- subject.should_not be_valid('dxg')
59
- end
49
+ after { subject.close }
60
50
 
61
- describe "#stem" do
62
- it "should find the stems of a word" do
63
- subject.stem('fishing').should == %w[fishing fish]
51
+ it "should provide the encoding of the dictionary files" do
52
+ expect(subject.encoding).to be Encoding::ISO_8859_1
64
53
  end
65
54
 
66
- it "should force_encode all strings" do
67
- subject.suggest('fishing').all? { |string|
68
- string.encoding == subject.encoding
69
- }.should be_true
55
+ it "should check if a word is valid" do
56
+ expect(subject.valid?('dog')).to be true
57
+ expect(subject.valid?('dxg')).to be false
70
58
  end
71
59
 
72
- context "when there are no stems" do
73
- it "should return []" do
74
- subject.stem("zzzzzzz").should == []
60
+ describe "#stem" do
61
+ it "should find the stems of a word" do
62
+ expect(subject.stem('fishing')).to be == %w[fishing fish]
75
63
  end
76
- end
77
- end
78
64
 
79
- describe "#suggest" do
80
- it "should suggest alternate spellings for words" do
81
- subject.suggest('arbitrage').should include(*[
82
- 'arbitrage',
83
- 'arbitrages',
84
- 'arbitrager',
85
- 'arbitraged',
86
- 'arbitrate'
87
- ])
88
- end
65
+ it "should force_encode all strings" do
66
+ expect(subject.suggest('fishing')).to all satisfy { |string|
67
+ string.encoding == subject.encoding
68
+ }
69
+ end
89
70
 
90
- it "should force_encode all strings" do
91
- subject.suggest('arbitrage').all? { |string|
92
- string.encoding == subject.encoding
93
- }.should be_true
71
+ context "when there are no stems" do
72
+ it "should return []" do
73
+ expect(subject.stem("zzzzzzz")).to be == []
74
+ end
75
+ end
94
76
  end
95
77
 
96
- context "when there are no suggestions" do
97
- it "should return []" do
98
- subject.suggest("________").should == []
78
+ describe "#suggest" do
79
+ it "should suggest alternate spellings for words" do
80
+ expect(subject.suggest('arbitrage')).to include(
81
+ 'arbitrage',
82
+ 'arbitrages',
83
+ 'arbitrager',
84
+ 'arbitraged',
85
+ 'arbitrate'
86
+ )
87
+ end
88
+
89
+ it "should force_encode all strings" do
90
+ expect(subject.suggest('arbitrage')).to all satisfy { |string|
91
+ string.encoding == subject.encoding
92
+ }
93
+ end
94
+
95
+ context "when there are no suggestions" do
96
+ it "should return []" do
97
+ expect(subject.suggest("________")).to be == []
98
+ end
99
99
  end
100
100
  end
101
101
  end
@@ -2,24 +2,34 @@ require 'spec_helper'
2
2
  require 'ffi/hunspell/hunspell'
3
3
 
4
4
  describe Hunspell do
5
- it "should have a default language" do
6
- subject.lang.should_not be_nil
7
- subject.lang.should_not be_empty
8
- end
5
+ describe ".lang" do
6
+ subject { super().lang }
9
7
 
10
- it "should have directories to search within" do
11
- subject.directories.should_not be_empty
8
+ it "should have a default language" do
9
+ expect(subject).to_not be_nil
10
+ expect(subject).to_not be_empty
11
+ end
12
12
  end
13
13
 
14
- it "should open a dictionary file" do
15
- subject.dict('en_US') do |dict|
16
- dict.should_not be_nil
14
+ describe ".directories" do
15
+ subject { super().directories }
16
+
17
+ it "should have directories to search within" do
18
+ expect(subject).to_not be_empty
17
19
  end
18
20
  end
19
21
 
20
- it "should open the dictionary file for the default language" do
21
- subject.dict do |dict|
22
- dict.should_not be_nil
22
+ describe ".dict" do
23
+ it "should open a dictionary file" do
24
+ subject.dict('en_US') do |dict|
25
+ expect(dict).to_not be_nil
26
+ end
27
+ end
28
+
29
+ it "should open the dictionary file for the default language" do
30
+ subject.dict do |dict|
31
+ expect(dict).to_not be_nil
32
+ end
23
33
  end
24
34
  end
25
35
  end
@@ -1,6 +1,4 @@
1
- gem 'rspec', '~> 2.4'
2
1
  require 'rspec'
3
-
4
2
  require 'ffi/hunspell'
5
3
 
6
4
  include FFI
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-hunspell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Postmodern
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-02 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffi
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rubygems-tasks
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.1'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.1'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '2.4'
47
+ version: '3.0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '2.4'
54
+ version: '3.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: yard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0.7'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0.7'
78
69
  description: Ruby FFI bindings for the Hunspell spell checker.
@@ -84,11 +75,11 @@ extra_rdoc_files:
84
75
  - LICENSE.txt
85
76
  - README.md
86
77
  files:
87
- - .gemtest
88
- - .gitignore
89
- - .rspec
90
- - .travis.yml
91
- - .yardopts
78
+ - ".gemtest"
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - ".travis.yml"
82
+ - ".yardopts"
92
83
  - ChangeLog.md
93
84
  - LICENSE.txt
94
85
  - README.md
@@ -104,27 +95,26 @@ files:
104
95
  homepage: https://github.com/postmodern/ffi-hunspell#readme
105
96
  licenses:
106
97
  - MIT
98
+ metadata: {}
107
99
  post_install_message:
108
100
  rdoc_options: []
109
101
  require_paths:
110
102
  - lib
111
103
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
104
  requirements:
114
- - - ! '>='
105
+ - - ">="
115
106
  - !ruby/object:Gem::Version
116
107
  version: 1.9.1
117
108
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
109
  requirements:
120
- - - ! '>='
110
+ - - ">="
121
111
  - !ruby/object:Gem::Version
122
112
  version: '0'
123
113
  requirements:
124
114
  - libhunspell >= 1.2.0
125
115
  rubyforge_project:
126
- rubygems_version: 1.8.25
116
+ rubygems_version: 2.4.7
127
117
  signing_key:
128
- specification_version: 3
118
+ specification_version: 4
129
119
  summary: FFI bindings for Hunspell
130
120
  test_files: []