capitalize 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +7 -0
- data/capitalize.gemspec +24 -0
- data/lib/capitalize.rb +10 -0
- data/lib/capitalize/version.rb +3 -0
- data/lib/countries.rb +3 -0
- data/spec/capitalize_spec.rb +25 -0
- data/spec/spec_helper.rb +1 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7457ba508f7c3b70e8ccef7c316c6abc8c736365
|
4
|
+
data.tar.gz: e7af34f200b79101b6dafd253620a9770727cd68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7577e6ad860845e74dffbfb054e9a1bee9695913b4e1c5b171f9cfdcf12e6d5379d43a983ef469fc5a6b5cc0bbb9c80fbad4543412d34beb9fb5a85a010385fe
|
7
|
+
data.tar.gz: 79b16c695f991c6b756dc16f9e4f8fddd0e00e7f30609fe4153faba538cdb6977117118d64322502bd5f1d05eb73b9e73cab1c9bb04ae30b62dd4c994b7bd015
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ten Mutunhire
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Capitalize
|
2
|
+
|
3
|
+
Gem to capitalize a given country.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capitalize'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capitalize
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In the controller or module where you need to print a capital city, simply require the gem
|
24
|
+
|
25
|
+
e.g.
|
26
|
+
|
27
|
+
```require 'capitalize'
|
28
|
+
|
29
|
+
class GameController < ApplicationController
|
30
|
+
end
|
31
|
+
```
|
32
|
+
Then to capitalize a given country e.g. Ghana, run:
|
33
|
+
|
34
|
+
```my_capital = Capitalize.new.capitalize("Ghana")```
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/tranc99/capitalize/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/capitalize.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capitalize/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capitalize"
|
8
|
+
spec.version = Capitalize::VERSION
|
9
|
+
spec.authors = ["Ten Mutunhire"]
|
10
|
+
spec.email = ["tmutunhire@gmail.com"]
|
11
|
+
spec.summary = %q{Gem to give the capital of a specified nation}
|
12
|
+
spec.description = %q{First, require Capitalize. Then call like this: my_capital = Capitalize::capitalize("Ghana") , for instance}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
end
|
data/lib/capitalize.rb
ADDED
data/lib/countries.rb
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
module Countries
|
2
|
+
COUNTRIES = {" "=>nil, "A "=>nil, "Afghanistan"=>"Kabul ", "Albania"=>"Tirana ", "Algeria"=>"Algiers ", "Andorra"=>"Andorra la Vella ", "Angola"=>"Luanda ", "Antigua & Barbuda"=>"Saint John's ", "Argentina"=>"Buenos Aires ", "Armenia"=>"Yerevan ", "Australia"=>"Canberra ", "Austria"=>"Vienna ", "Azerbaijan"=>"Baku ", "B "=>nil, "Bahamas"=>"Nassau ", "Bahrain"=>"Al-Manamah ", "Bangladesh"=>"Dhaka ", "Barbados"=>"Bridgetown ", "Belarus"=>"Minsk ", "Belgium"=>"Brussels ", "Belize"=>"Belmopan ", "Benin"=>"Porto-Novo ", "Bhutan"=>"Thimphu ", "Bolivia"=>"La Paz (administrative); Sucre (judicial) ", "Bosnia & Herzegovina"=>"Sarajevo ", "Botswana"=>"Gaborone ", "Brazil"=>"Brasilia ", "Brunei"=>"Bandar Seri Begawan ", "Bulgaria"=>"Sofia ", "Burkina Faso"=>"Ouagadougou ", "Burundi"=>"Bujumbura ", "C "=>nil, "Cambodia"=>"Phnom Penh ", "Cameroon"=>"Yaounde ", "Canada"=>"Ottawa ", "Cape Verde"=>"Praia ", "Central African Republic"=>"Bangui ", "Chad"=>"N'Djamena ", "Chile"=>"Santiago ", "China"=>"Beijing ", "Colombia"=>"Bogota ", "Comoros"=>"Moroni ", "Congo"=>"Brazzaville ", "Congo Democratic Republic of the"=>"Kinshasa ", "Costa Rica"=>"San Jose ", "Cote d'Ivoire"=>"Abidjan", "Croatia"=>"Zagreb ", "Cuba"=>"Havana ", "Cyprus"=>"Nicosia ", "Czech Republic"=>"Prague ", "D "=>nil, "Denmark"=>"Copenhagen ", "Djibouti"=>"Djibouti City ", "Dominica"=>"Roseau ", "Dominican Republic"=>"Santo Domingo ", "E "=>nil, "East Timor"=>"Dili ", "Ecuador"=>"Quito ", "Egypt"=>"Cairo ", "El Salvador"=>"San Salvador ", "Equatorial Guinea"=>"Malabo ", "Eritrea"=>"Asmara ", "Estonia"=>"Tallinn ", "Ethiopia"=>"Addis Ababa ", "F "=>nil, "Fiji"=>"Suva ", "Finland"=>"Helsinki ", "France"=>"Paris ", "G "=>nil, "Gabon"=>"Libreville ", "Gambia"=>"Banjul ", "Georgia"=>"Tbilisi ", "Germany"=>"Berlin ", "Ghana"=>"Accra ", "Greece"=>"Athens ", "Grenada"=>"Saint George's ", "Guatemala"=>"Guatemala City ", "Guinea"=>"Conakry ", "Guinea-Bissau"=>"Bissau ", "Guyana"=>"Georgetown ", "H "=>nil, "Haiti"=>"Port-au-Prince ", "Honduras"=>"Tegucigalpa ", "Hungary"=>"Budapest ", "I "=>nil, "Iceland"=>"Reykjavik ", "India"=>"New Delhi ", "Indonesia"=>"Jakarta ", "Iran"=>"Tehran ", "Iraq"=>"Baghdad ", "Ireland"=>"Dublin ", "Israel"=>"Jerusalem ", "Italy"=>"Rome ", "J "=>nil, "Jamaica"=>"Kingston ", "Japan"=>"Tokyo ", "Jordan"=>"Amman ", "K "=>nil, "Kazakhstan"=>"Astana ", "Kenya"=>"Nairobi ", "Kiribati"=>"Tarawa Atoll ", "Korea North"=>"Pyongyang ", "Korea South"=>"Seoul ", "Kosovo"=>"Pristina ", "Kuwait"=>"Kuwait City ", "Kyrgyzstan"=>"Bishkek ", "L "=>nil, "Laos"=>"Vientiane ", "Latvia"=>"Riga ", "Lebanon"=>"Beirut ", "Lesotho"=>"Maseru ", "Liberia"=>"Monrovia ", "Libya"=>"Tripoli ", "Liechtenstein"=>"Vaduz ", "Lithuania"=>"Vilnius ", "Luxembourg"=>"Luxembourg ", "M "=>nil, "Macedonia"=>"Skopje ", "Madagascar"=>"Antananarivo ", "Malawi"=>"Lilongwe ", "Malaysia"=>"Kuala Lumpur ", "Maldives"=>"Male ", "Mali"=>"Bamako ", "Malta"=>"Valletta ", "Marshall Islands"=>"Majuro ", "Mauritania"=>"Nouakchott ", "Mauritius"=>"Port Louis ", "Mexico"=>"Mexico City ", "Micronesia"=>"Palikir ", "Moldova"=>"Chisinau ", "Monaco"=>"Monaco ", "Mongolia"=>"Ulaanbaatar ", "Montenegro"=>"Podgorica ", "Morocco"=>"Rabat ", "Mozambique"=>"Maputo ", "Myanmar (Burma)"=>"Rangoon (Yangon); Nay Pyi Taw (administrative) ", "N "=>nil, "Namibia"=>"Windhoek ", "Nauru"=>"no official capital; government offices in Yaren District ", "Nepal"=>"Kathmandu ", "Netherlands"=>"Amsterdam ", "New Zealand"=>"Wellington ", "Nicaragua"=>"Managua ", "Niger"=>"Niamey ", "Nigeria"=>"Abuja ", "Norway"=>"Oslo ", "O "=>nil, "Oman"=>"Muscat ", "P "=>nil, "Pakistan"=>"Islamabad ", "Palau"=>"Melekeok ", "Palestinian State* "=>nil, "Panama"=>"Panama City ", "Papua New Guinea"=>"Port Moresby ", "Paraguay"=>"Asuncion ", "Peru"=>"Lima ", "Philippines"=>"Manila ", "Poland"=>"Warsaw ", "Portugal"=>"Lisbon ", "Q "=>nil, "Qatar"=>"Doha ", "R "=>nil, "Romania"=>"Bucharest ", "Russia"=>"Moscow ", "Rwanda"=>"Kigali ", "S "=>nil, "Saint Kitts and Nevis"=>"Basseterre ", "Saint Lucia"=>"Castries ", "Saint Vincent and the Grenadines"=>"Kingstown ", "Samoa"=>"Apia ", "San Marino"=>"San Marino ", "Sao Tome and Principe"=>"Sao Tome ", "Saudi Arabia"=>"Riyadh ", "Senegal"=>"Dakar ", "Serbia"=>"Belgrade ", "Seychelles"=>"Victoria ", "Sierra Leone"=>"Freetown ", "Singapore"=>"Singapore ", "Slovakia"=>"Bratislava ", "Slovenia"=>"Ljubljana ", "Solomon Islands"=>"Honiara ", "Somalia"=>"Mogadishu ", "South Africa"=>"Pretoria (executive); Cape Town (legislative); Bloemfontein (judicial) ", "South Sudan"=>"Juba ", "Spain"=>"Madrid ", "Sri Lanka"=>"Colombo; Sri Jayewardenepura Kotte (legislative) ", "Sudan"=>"Khartoum ", "Suriname"=>"Paramaribo ", "Swaziland"=>"Mbabane ", "Sweden"=>"Stockholm ", "Switzerland"=>"Bernd ", "Syria"=>"Damascus ", "T "=>nil, "Taiwan"=>"Taipei ", "Tajikistan"=>"Dushanbe ", "Tanzania"=>"Dar es Salaam; Dodoma (legislative) ", "Thailand"=>"Bangkok ", "Togo"=>"Lome ", "Tonga"=>"Nuku'alofa ", "Trinidad and Tobago"=>"Port-of-Spain ", "Tunisia"=>"Tunis ", "Turkey"=>"Ankara ", "Turkmenistan"=>"Ashgabat ", "Tuvalu"=>"Vaiaku village, Funafuti province ", "U "=>nil, "Uganda"=>"Kampala ", "Ukraine"=>"Kyiv ", "United Arab Emirates"=>"Abu Dhabi ", "United Kingdom"=>"London ", "United States of America"=>"Washington D.C. ", "Uruguay"=>"Montevideo ", "Uzbekistan"=>"Tashkent ", "V "=>nil, "Vanuatu"=>"Port-Vila ", "Vatican City (Holy See)"=>"Vatican City ", "Venezuela"=>"Caracas ", "Vietnam"=>"Hanoi ", "Y "=>nil, "Yemen"=>"Sanaa ", "Z "=>nil, "Zambia"=>"Lusaka ", "Zimbabwe"=>"Harare"}
|
3
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Capitalize do
|
4
|
+
subject { Capitalize.new }
|
5
|
+
|
6
|
+
describe '#process' do
|
7
|
+
let(:input) { 'Ten' }
|
8
|
+
let(:output) { subject.process(input) }
|
9
|
+
|
10
|
+
it 'handles exceptions well' do
|
11
|
+
expect(output).to eq 'Sorry, the Boss is sleeping.'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "successful case" do
|
17
|
+
let(:input) { 'Ghana' }
|
18
|
+
let(:output) { subject.process(input) }
|
19
|
+
|
20
|
+
it 'handles exceptions well' do
|
21
|
+
expect(output.strip).to eq 'Accra'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'capitalize'
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capitalize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ten Mutunhire
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: 'First, require Capitalize. Then call like this: my_capital = Capitalize::capitalize("Ghana")
|
56
|
+
, for instance'
|
57
|
+
email:
|
58
|
+
- tmutunhire@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- capitalize.gemspec
|
69
|
+
- lib/capitalize.rb
|
70
|
+
- lib/capitalize/version.rb
|
71
|
+
- lib/countries.rb
|
72
|
+
- spec/capitalize_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Gem to give the capital of a specified nation
|
98
|
+
test_files:
|
99
|
+
- spec/capitalize_spec.rb
|
100
|
+
- spec/spec_helper.rb
|