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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ace660f0424c63de5937d950c7442f706976f18d
4
- data.tar.gz: e26dc771b958b344a201e30a11dc862ee22b277e
3
+ metadata.gz: 480cc88d0cb89226200c6b51d78cd942ffe5912c
4
+ data.tar.gz: cbf6278af0d3a18fc3eac8b2690fc60ccc241781
5
5
  SHA512:
6
- metadata.gz: d9942342c95d151c76717f0163230cf9159a6ce969280d4948b4c8e7c041bb876be50ec5d32ef0b7eeeaa62c5c0da96959e4854faa3461628b80e29191349fa4
7
- data.tar.gz: 840c0a06b942238fb1016a33ed0d25e7b49862bc7ccb78ee2e8b53e00b39309274f146d56369d835cf8bdc3967b29913900cf77175c18ff8e5dac82f8c90c79b
6
+ metadata.gz: 60b631d1ac2fb82ab19b8348181cd1826f616d03fdc06d4e4c8d11e89cfaeda331d9b8dca3e6ea2951afc3dcc4220a415f1f5a6057dc42f97d68489e2d5564e3
7
+ data.tar.gz: ddcdf43c06c6ce3b04601900c5b87f41011500305891c3b276d373a20b54a7cfbd0a16f4991c9b81ab66a066782b9f39dc5796200bbcdf9d20d91710d6aad8cd
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in noble_names.gemspec
4
+ gemspec
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
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ desc 'Run tests'
4
+ task default: :test
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = 'test/**/*_test.rb'
7
+ end
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -0,0 +1,11 @@
1
+ require_relative 'core_ext/string.rb'
2
+
3
+ module NobleNames
4
+ # This is wrapped in a method so it isn't immediatly
5
+ # evaluated when its loaded
6
+ def self.initialize
7
+ String.class_eval do
8
+ include NobleNames::CoreExt::String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module NobleNames
2
+ VERSION = '0.1.1'.freeze
3
+ 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.0
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