babosa 0.3.11 → 1.0.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.
@@ -13,6 +13,6 @@ describe Babosa::Transliterator::Vietnamese do
13
13
  "thật" => "that",
14
14
  "khổ" => "kho"
15
15
  }
16
- examples.each {|k, v| t.transliterate(k).should eql(v)}
16
+ examples.each {|k, v| expect(t.transliterate(k)).to eql(v)}
17
17
  end
18
18
  end
@@ -1,22 +1,9 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path("../spec_helper", __FILE__)
3
3
 
4
- PROXIES = [Babosa::UTF8::DumbProxy]
5
-
4
+ PROXIES = [Babosa::UTF8::DumbProxy, Babosa::UTF8::ActiveSupportProxy, Babosa::UTF8::UnicodeProxy]
6
5
  PROXIES << Babosa::UTF8::JavaProxy if Babosa.jruby15?
7
6
 
8
- begin
9
- require "unicode"
10
- PROXIES << Babosa::UTF8::UnicodeProxy
11
- rescue LoadError
12
- end
13
-
14
- begin
15
- require "activesupport"
16
- PROXIES << Babosa::UTF8::ActiveSupportProxy
17
- rescue LoadError
18
- end
19
-
20
7
  PROXIES.each do |proxy|
21
8
 
22
9
  describe proxy do
@@ -27,20 +14,25 @@ PROXIES.each do |proxy|
27
14
  uncomposed_bytes = [65, 204, 138, 69, 204, 129, 73, 204, 130, 195, 152, 85, 204, 136]
28
15
  composed_bytes = [195, 133, 195, 137, 195, 142, 195, 152, 195, 156]
29
16
  uncomposed_string = uncomposed_bytes.pack("C*").unpack("U*").pack("U*")
30
- composed_string = composed_bytes.pack("C*").unpack("U*").pack("U*")
31
- proxy.normalize_utf8(uncomposed_string).unpack("C*").should eql(composed_bytes)
17
+ expect(proxy.normalize_utf8(uncomposed_string).unpack("C*")).to eql(composed_bytes)
32
18
  end
33
19
  end
34
20
 
35
21
  describe "#upcase" do
36
22
  it "should upcase the string" do
37
- proxy.upcase("åéîøü").should eql("ÅÉÎØÜ")
23
+ expect(proxy.upcase("åéîøü")).to eql("ÅÉÎØÜ")
38
24
  end
39
25
  end
40
26
 
41
27
  describe "#downcase" do
42
28
  it "should downcase the string" do
43
- proxy.downcase("ÅÉÎØÜ").should eql("åéîøü")
29
+ expect(proxy.downcase("ÅÉÎØÜ")).to eql("åéîøü")
30
+ end
31
+ end
32
+
33
+ describe 'tidy_bytes' do
34
+ it 'should fix invalid UTF-8 strings' do
35
+ expect(proxy.tidy_bytes("\x93abc")).to eq('“abc')
44
36
  end
45
37
  end
46
38
 
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babosa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-08 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 3.2.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.0
26
+ version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.11.0
33
+ version: 3.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.11.0
40
+ version: 3.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: unicode
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  description: |2
@@ -75,8 +89,12 @@ executables: []
75
89
  extensions: []
76
90
  extra_rdoc_files: []
77
91
  files:
78
- - lib/babosa/candidates.rb
79
- - lib/babosa/generator.rb
92
+ - ".gemtest"
93
+ - Changelog.md
94
+ - MIT-LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - lib/babosa.rb
80
98
  - lib/babosa/identifier.rb
81
99
  - lib/babosa/transliterator/base.rb
82
100
  - lib/babosa/transliterator/bulgarian.rb
@@ -101,12 +119,6 @@ files:
101
119
  - lib/babosa/utf8/proxy.rb
102
120
  - lib/babosa/utf8/unicode_proxy.rb
103
121
  - lib/babosa/version.rb
104
- - lib/babosa.rb
105
- - Changelog.md
106
- - README.md
107
- - MIT-LICENSE
108
- - Rakefile
109
- - init.rb
110
122
  - spec/babosa_spec.rb
111
123
  - spec/spec_helper.rb
112
124
  - spec/transliterators/base_spec.rb
@@ -114,8 +126,10 @@ files:
114
126
  - spec/transliterators/danish_spec.rb
115
127
  - spec/transliterators/german_spec.rb
116
128
  - spec/transliterators/greek_spec.rb
129
+ - spec/transliterators/latin_spec.rb
117
130
  - spec/transliterators/macedonian_spec.rb
118
131
  - spec/transliterators/norwegian_spec.rb
132
+ - spec/transliterators/polish_spec.rb
119
133
  - spec/transliterators/romanian_spec.rb
120
134
  - spec/transliterators/russian_spec.rb
121
135
  - spec/transliterators/serbian_spec.rb
@@ -124,8 +138,7 @@ files:
124
138
  - spec/transliterators/ukrainian_spec.rb
125
139
  - spec/transliterators/vietnamese_spec.rb
126
140
  - spec/utf8_proxy_spec.rb
127
- - .gemtest
128
- homepage: http://norman.github.com/babosa
141
+ homepage: http://github.com/norman/babosa
129
142
  licenses: []
130
143
  metadata: {}
131
144
  post_install_message:
@@ -134,17 +147,17 @@ require_paths:
134
147
  - lib
135
148
  required_ruby_version: !ruby/object:Gem::Requirement
136
149
  requirements:
137
- - - '>='
150
+ - - ">="
138
151
  - !ruby/object:Gem::Version
139
- version: '0'
152
+ version: 2.0.0
140
153
  required_rubygems_version: !ruby/object:Gem::Requirement
141
154
  requirements:
142
- - - '>='
155
+ - - ">="
143
156
  - !ruby/object:Gem::Version
144
157
  version: '0'
145
158
  requirements: []
146
- rubyforge_project: '[none]'
147
- rubygems_version: 2.0.3
159
+ rubyforge_project:
160
+ rubygems_version: 2.4.5
148
161
  signing_key:
149
162
  specification_version: 4
150
163
  summary: A library for creating slugs.
data/init.rb DELETED
@@ -1,3 +0,0 @@
1
- require "rubygems"
2
- require "bundler/setup"
3
- require "babosa"
@@ -1,45 +0,0 @@
1
- require 'securerandom'
2
-
3
- module Babosa
4
-
5
- # This iterates through slug candidates and generates them lazily. In other
6
- # words, if the first candidate succeeds, the remaning ones are not
7
- # evaluated. It also appends a fallback candidate which uses the final
8
- # candidate's slug plus a GUID.
9
- class Candidates
10
-
11
- include Enumerable
12
-
13
- def initialize(object, *array)
14
- @candidates = to_candidate_array(object, array.flatten(1))
15
- @candidates << (@candidates.last.dup << -> {SecureRandom.uuid})
16
- end
17
-
18
- def each(*args, &block)
19
- @candidates.each(*args) do |candidate|
20
- yield candidate.map(&:call).join(' ').to_slug.normalize!
21
- end
22
- end
23
-
24
- private
25
-
26
- def to_candidate_array(object, array)
27
- array.map do |candidate|
28
- case candidate
29
- when String
30
- [->{candidate}]
31
- when Array
32
- to_candidate_array(object, candidate).flatten
33
- when Symbol
34
- [object.method(candidate)]
35
- else
36
- if candidate.respond_to?(:call)
37
- [candidate]
38
- else
39
- [->{candidate.to_s}]
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,24 +0,0 @@
1
- require 'set'
2
-
3
- module Babosa
4
- # A simple slug generator using a Set as a backend. Obviously this is silly
5
- # and potentially a great way to leak memory, but it demonstrates the
6
- # funcionality.
7
- class Generator
8
- def initialize
9
- @set = Set.new
10
- end
11
-
12
- def available?(slug)
13
- !@set.member?(slug)
14
- end
15
-
16
- def add(slug)
17
- @set.add slug; slug
18
- end
19
-
20
- def generate(candidates)
21
- candidates.each {|c| return add c if available?(c)}
22
- end
23
- end
24
- end