noble_names 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/data/particles.yml +26 -0
- data/lib/noble_names/config.rb +27 -0
- data/lib/noble_names/core_ext/string.rb +19 -0
- data/lib/noble_names/initializer.rb +11 -0
- data/lib/noble_names/version.rb +3 -0
- metadata +14 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 480cc88d0cb89226200c6b51d78cd942ffe5912c
|
4
|
+
data.tar.gz: cbf6278af0d3a18fc3eac8b2690fc60ccc241781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b631d1ac2fb82ab19b8348181cd1826f616d03fdc06d4e4c8d11e89cfaeda331d9b8dca3e6ea2951afc3dcc4220a415f1f5a6057dc42f97d68489e2d5564e3
|
7
|
+
data.tar.gz: ddcdf43c06c6ce3b04601900c5b87f41011500305891c3b276d373a20b54a7cfbd0a16f4991c9b81ab66a066782b9f39dc5796200bbcdf9d20d91710d6aad8cd
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Paul Martensen
|
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,69 @@
|
|
1
|
+
# NobleNames
|
2
|
+
|
3
|
+
A small Gem to capitalize names with regard to nobility particles.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'noble_names'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install noble_names
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Just
|
24
|
+
```ruby
|
25
|
+
require 'noble_names'
|
26
|
+
```
|
27
|
+
and use `String#to_title` to correctly format your names.
|
28
|
+
```ruby
|
29
|
+
"james of windsor".to_title #=> "James of Windsor"
|
30
|
+
"joseph von und zu reinbeck".to_title #=> "Joseph von und zu Reinbeck"
|
31
|
+
```
|
32
|
+
you can also use the bang method:
|
33
|
+
```ruby
|
34
|
+
my_string = "joseph von und zu reinbeck"
|
35
|
+
my_string.to_title!
|
36
|
+
my_string #=> "Joseph von und zu Reinbeck"
|
37
|
+
```
|
38
|
+
|
39
|
+
### Languages
|
40
|
+
So far only English and German are supported.
|
41
|
+
By default all available languages are used. If you want to configure which one
|
42
|
+
to use for your application, you can do it like so:
|
43
|
+
```ruby
|
44
|
+
NobleNames.configure do |config|
|
45
|
+
config.languages = [:english,:spanish]
|
46
|
+
end
|
47
|
+
```
|
48
|
+
This way other language particles will be ignored.
|
49
|
+
```ruby
|
50
|
+
"joseph von und zu reinbeck".to_title #=> "Joseph Von Und Zu Reinbeck"
|
51
|
+
```
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
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).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
To add more particles from other languages, just add them to the
|
62
|
+
`data/particles.yml` file.
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Haniyya/noble_names.
|
64
|
+
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
69
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'noble_names'
|
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/data/particles.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
particles:
|
2
|
+
german:
|
3
|
+
- 'von'
|
4
|
+
- 'und'
|
5
|
+
- 'zu'
|
6
|
+
- 'v.'
|
7
|
+
- 'vom'
|
8
|
+
- 'zum'
|
9
|
+
- 'der'
|
10
|
+
- 'dem'
|
11
|
+
english:
|
12
|
+
- 'of'
|
13
|
+
- 'de'
|
14
|
+
french:
|
15
|
+
- 'de'
|
16
|
+
- 'le'
|
17
|
+
- 'la'
|
18
|
+
spanish:
|
19
|
+
- 'de'
|
20
|
+
- 'da'
|
21
|
+
portuguese:
|
22
|
+
- 'de'
|
23
|
+
- 'da'
|
24
|
+
- 'du'
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NobleNames
|
2
|
+
class << self
|
3
|
+
attr_writer :configuration
|
4
|
+
|
5
|
+
def configuration
|
6
|
+
@configuration ||= Configuration.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
yield(configuration)
|
12
|
+
end
|
13
|
+
|
14
|
+
class Configuration
|
15
|
+
def initialize
|
16
|
+
@languages = [:all]
|
17
|
+
end
|
18
|
+
|
19
|
+
def languages=(languages)
|
20
|
+
@languages = Array(languages)
|
21
|
+
end
|
22
|
+
|
23
|
+
def languages
|
24
|
+
@languages == [:all] ? SUPPORTED_LANGUAGES : @languages
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module NobleNames
|
2
|
+
module CoreExt
|
3
|
+
module String
|
4
|
+
# Capitalizes each Word in a name
|
5
|
+
# except for those which are nobility particles
|
6
|
+
# 'jamie jones'.to_title # => 'Jamie Jones'
|
7
|
+
# 'jamie of windsor'.to_title # => 'Jamie of Windsor'
|
8
|
+
def to_title
|
9
|
+
dup.to_title!
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_title!
|
13
|
+
words = split(/\s+/)
|
14
|
+
words.map! { |w| NobleNames.noble_capitalize(w) }
|
15
|
+
replace(words * ' ')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noble_names
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Martensen
|
@@ -60,7 +60,20 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- data/particles.yml
|
63
72
|
- lib/noble_names.rb
|
73
|
+
- lib/noble_names/config.rb
|
74
|
+
- lib/noble_names/core_ext/string.rb
|
75
|
+
- lib/noble_names/initializer.rb
|
76
|
+
- lib/noble_names/version.rb
|
64
77
|
homepage: https://github.com/Haniyya/noble_names
|
65
78
|
licenses:
|
66
79
|
- MIT
|