luzvimin 0.1.0

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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in luzvimin.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Karren Javier
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.
@@ -0,0 +1,29 @@
1
+ # Luzvimin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'luzvimin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install luzvimin
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ ---
2
+ BASILAN:
3
+ name: Basilan
4
+ position: 1
5
+ LANAO_DEL_SUR:
6
+ name: Lanao del Sur
7
+ position: 2
8
+ MAGUINDANAO:
9
+ name: Maguindanao
10
+ position: 3
11
+ SHARIF_KABUNSUAN:
12
+ name: Sharif Kabunsuan
13
+ position: 4
14
+ SULU:
15
+ name: Sulu
16
+ position: 5
17
+ TAWI_TAWI:
18
+ name: Tawi-Tawi
19
+ position: 6
20
+
@@ -0,0 +1,19 @@
1
+ ---
2
+ ALBAY:
3
+ name: Albay
4
+ position: 1
5
+ CAMARINES_NORTE:
6
+ name: Camarines Norte
7
+ position: 2
8
+ CAMARINES_SUR:
9
+ name: Camarines Sur
10
+ position: 3
11
+ NAGA:
12
+ name: Naga
13
+ position: 4
14
+ MASBATE:
15
+ name: Masbate
16
+ position: 5
17
+ SORSOGON:
18
+ name: Sorsogon
19
+ position: 6
@@ -0,0 +1,16 @@
1
+ ---
2
+ BATANES:
3
+ name: Batanes
4
+ position: 1
5
+ CAGAYAN_VALLEY:
6
+ name: Cagayan Valley
7
+ position: 2
8
+ ISABELA:
9
+ name: Isabela
10
+ position: 3
11
+ NUEVA_VISCAYA:
12
+ name: Nueva Viscaya
13
+ position: 4
14
+ QUIRINO:
15
+ name: Quirino
16
+ position: 5
@@ -0,0 +1,25 @@
1
+ ---
2
+ CAVITE:
3
+ name: Cavite
4
+ position: 1
5
+ TAGAYTAY:
6
+ name: Tagaytay
7
+ position: 2
8
+ LAGUNA:
9
+ name: Laguna
10
+ position: 3
11
+ BATANGAS:
12
+ name: Batangas
13
+ position: 4
14
+ RIZAL:
15
+ name: Rizal
16
+ position: 5
17
+ ANTIPOLO:
18
+ name: Antipolo
19
+ position: 6
20
+ QUEZON:
21
+ name: Quezon
22
+ position: 7
23
+ LUCENA:
24
+ name: Lucena
25
+ position: 8
@@ -0,0 +1,22 @@
1
+ ---
2
+ ABRA:
3
+ name: Abra
4
+ position: 1
5
+ APAYAO:
6
+ name: Apayao
7
+ position: 2
8
+ BAGUIO:
9
+ name: Baguio
10
+ position: 3
11
+ BENGUET:
12
+ name: Benguet
13
+ position: 4
14
+ IFUGAO:
15
+ name: Ifugao
16
+ position: 5
17
+ KALINGA:
18
+ name: Kalinga
19
+ position: 6
20
+ MOUNTAIN_PROVINCE:
21
+ name: Mountain Province
22
+ position: 7
@@ -0,0 +1,16 @@
1
+ ---
2
+ BUTUAN_CITY:
3
+ name: Butuan City
4
+ position: 1
5
+ AGUSAN_DEL_SUR:
6
+ name: Agusan del Sur
7
+ position: 2
8
+ DINAGAY:
9
+ name: Dinagay
10
+ position: 3
11
+ SURIGAO_DEL_NORTE:
12
+ name: Surigao del Norte
13
+ position: 4
14
+ SURIGAO_DEL_SUR:
15
+ name: Surigao del Sur
16
+ position: 5
@@ -0,0 +1,28 @@
1
+ ---
2
+ AURORA:
3
+ name: Aurora
4
+ position: 1
5
+ BATAAN:
6
+ name: Bataan
7
+ position: 2
8
+ BULACAN:
9
+ name: Bulacan
10
+ position: 3
11
+ NUEVA_ECIJA:
12
+ name: Nueva Ecija
13
+ position: 4
14
+ PAMPANGA:
15
+ name: Pampanga
16
+ position: 5
17
+ TARLAC:
18
+ name: Tarlac
19
+ position: 6
20
+ ZAMBALES:
21
+ name: Zambales
22
+ position: 7
23
+ ANGELES:
24
+ name: Angeles
25
+ position: 8
26
+ OLONGAPO:
27
+ name: Olongapo
28
+ position: 9
@@ -0,0 +1,22 @@
1
+ ---
2
+ CEBU:
3
+ name: Cebu
4
+ position: 1
5
+ CEBU_CITY:
6
+ name: Cebu City
7
+ position: 2
8
+ LAPU_LAPU_CITY:
9
+ name: Lapu-Lapu City
10
+ position: 3
11
+ MANDAUE_CITY:
12
+ name: Mandaue City
13
+ position: 4
14
+ BOHOL:
15
+ name: Bohol
16
+ position: 5
17
+ NEGROS_ORIENTAL:
18
+ name: Negros Oriental
19
+ position: 6
20
+ SIQUIJOR:
21
+ name: Siquijor
22
+ position: 7
@@ -0,0 +1,17 @@
1
+ ---
2
+ COMPOSTELA_VALLEY:
3
+ name: COMPOSTELA Valley
4
+ position: 1
5
+ DAVAO_DEL_NORTE:
6
+ name: Davao del Norte
7
+ position: 2
8
+ DAVAO_DEL_SUR:
9
+ name: Davao del Sur
10
+ position: 3
11
+ DAVAO_ORIENTAL:
12
+ name: Davao Oriental
13
+ position: 4
14
+ DAVAO_CITY:
15
+ name: Davao City
16
+ position: 5
17
+
@@ -0,0 +1,19 @@
1
+ ---
2
+ SAMAR:
3
+ name: Samar
4
+ position: 1
5
+ EASTERN_SAMAR:
6
+ name: Eastern Samar
7
+ position: 2
8
+ NORTHERN_SAMAR:
9
+ name: Northern Samar
10
+ position: 3
11
+ LEYTE:
12
+ name: Leyte
13
+ position: 4
14
+ SOUTHERN_LEYTE:
15
+ name: Sourthern Leyte
16
+ position: 5
17
+ BILIRAN:
18
+ name: Biliran
19
+ position: 6
@@ -0,0 +1,13 @@
1
+ ---
2
+ ILOCOS_NORTE:
3
+ name: Ilocos Norte
4
+ position: 1
5
+ ILOCOS_SUR:
6
+ name: Ilocos Sur
7
+ position: 2
8
+ LA_UNION:
9
+ name: La Union
10
+ position: 3
11
+ PANGASINAN:
12
+ name: Pangasinan
13
+ position: 4
@@ -0,0 +1,16 @@
1
+ ---
2
+ MARINDUQUE:
3
+ name: Marinduque
4
+ position: 1
5
+ OCCIDENTAL_MINDORO:
6
+ name: Occidental Mindoro
7
+ position: 2
8
+ ORIENTAL_MINDORO:
9
+ name: Oriental Mindoro
10
+ position: 3
11
+ PALAWAN:
12
+ name: Palawan
13
+ position: 4
14
+ ROMBLON:
15
+ name: Romblon
16
+ position: 5
@@ -0,0 +1,4 @@
1
+ ---
2
+ METRO_MANILA:
3
+ name: Metro Manila
4
+ position: 1
@@ -0,0 +1,19 @@
1
+ ---
2
+ BUKIDNON:
3
+ name: Bukidnon
4
+ position: 1
5
+ MISAMIS_ORIENTAL:
6
+ name: Misamis Oriental
7
+ position: 2
8
+ MISAMIS_OCCIDENTAL:
9
+ name: Misamis Occidental
10
+ position: 3
11
+ CAMIGUIN:
12
+ name: Camiguin
13
+ position: 4
14
+ LANAO_DEL_NORTE:
15
+ name: Lanao del Norte
16
+ position: 5
17
+ CAGAYAN_DE_ORO:
18
+ name: Cagayan de Oro
19
+ position: 6
@@ -0,0 +1,19 @@
1
+ ---
2
+ COTABATO:
3
+ name: COTABATO
4
+ position: 1
5
+ SARANGANI:
6
+ name: Sarangani
7
+ position: 2
8
+ SOUTH_COTABATO:
9
+ name: South Cotabato
10
+ position: 3
11
+ SULTAN_KUDARAT:
12
+ name: Sultan Kudarat
13
+ position: 4
14
+ GEN_SANTOS_CITY:
15
+ name: Gen. Santos City
16
+ position: 5
17
+ COTABATO_CITY:
18
+ name: Cotabato City
19
+ position: 6
@@ -0,0 +1,25 @@
1
+ ---
2
+ AKLAN:
3
+ name: Aklan
4
+ position: 1
5
+ ANTIQUE:
6
+ name: Antique
7
+ position: 2
8
+ CAPIZ:
9
+ name: Capiz
10
+ position: 3
11
+ GUIMARAS:
12
+ name: Guimaras
13
+ position: 4
14
+ ILOILO:
15
+ name: Iloilo
16
+ position: 5
17
+ ILOILO_CITY:
18
+ name: Iloilo City
19
+ position: 6
20
+ NEGROS_OCCIDENTAL:
21
+ name: Negros Occidental
22
+ position: 7
23
+ BACOLOD_CITY:
24
+ name: Bacolod City
25
+ position: 8
@@ -0,0 +1,13 @@
1
+ ---
2
+ ZAMBOANGA_DEL_NORTE:
3
+ name: Zamboanga del Norte
4
+ position: 1
5
+ ZAMBOANGA_DEL_SUR:
6
+ name: Zamboanga del Sur
7
+ position: 2
8
+ ZAMBOANGA_SIBUGAY:
9
+ name: Zamboanga Sibugay
10
+ position: 3
11
+ ZAMBOANGA_CITY:
12
+ name: Zamboanga City
13
+ position: 4
@@ -0,0 +1,69 @@
1
+ ---
2
+ NCR:
3
+ code: NCR
4
+ name: National Capital Region
5
+ position: 1
6
+ CAR:
7
+ code: CAR
8
+ name: Cordillera Autonomous Region
9
+ position: 2
10
+ ILOCOS:
11
+ code: Region I
12
+ name: Ilocos Region
13
+ position: 3
14
+ CAGAYAN:
15
+ code: REGION II
16
+ name: Cagayan Region
17
+ position: 4
18
+ CENTRAL_LUZON:
19
+ code: REGION III
20
+ name: Central Luzon
21
+ position: 5
22
+ CALABARZON:
23
+ code: CALABARZON
24
+ name: CALABARZON
25
+ position: 6
26
+ MIMAROPA:
27
+ code: MIMAROPA
28
+ name: MIMAROPA
29
+ position: 7
30
+ BICOL:
31
+ code: REGION V
32
+ name: Bicol
33
+ position: 8
34
+ WESTERN_VISAYAS:
35
+ code: REGION VI
36
+ name: Western Visayas
37
+ position: 9
38
+ CENTRAL_VISAYAS:
39
+ code: REGION VII
40
+ name: Central Visayas
41
+ position: 10
42
+ EASTERN_VISAYAS:
43
+ code: REGION VIII
44
+ name: Eastern Visayas
45
+ position: 11
46
+ ZAMBOANGA_PENINSULA:
47
+ code: REGION IX
48
+ name: Zamboanga Peninsula
49
+ position: 12
50
+ NORTHERN_MINDANAO:
51
+ code: REGION X
52
+ name: Northern Mindanao
53
+ position: 13
54
+ DAVAO:
55
+ code: REGION XI
56
+ name: Davao Region
57
+ position: 14
58
+ SOCSARGEN:
59
+ code: SOCSARGEN
60
+ name: SOCSARGEN
61
+ position: 15
62
+ ARMM:
63
+ code: ARMM
64
+ name: ARMM
65
+ position: 17
66
+ CARAGA:
67
+ code: CARAGA
68
+ name: CARAGA
69
+ position: 16
@@ -0,0 +1,46 @@
1
+ require 'yaml'
2
+ require 'luzvimin/version'
3
+
4
+ module Luzvimin
5
+ PHILIPPINES = YAML.load_file(File.join(File.dirname(__FILE__), 'data', 'regions.yml')) || {}
6
+ REGIONS = PHILIPPINES.map { |k, v| [k, v] }.sort_by{ |k, v| v['position'] }
7
+ METHODS = ['code', 'name', 'position', 'id']
8
+
9
+ attr_reader :data
10
+
11
+ class Region
12
+ METHODS.each do |method|
13
+ define_method(method) do
14
+ @data[method] if @data
15
+ end
16
+ end
17
+
18
+ def initialize(region)
19
+ @data = PHILIPPINES[region] if region.is_a?(String)
20
+ @data['id'] = region if @data
21
+ end
22
+
23
+ def provinces
24
+ provinces = YAML.load_file(File.join(File.dirname(__FILE__), 'data/provinces', "#{self.id}.yml")) || {}
25
+ provinces.map { |k, v| [k, v] }.sort_by{ |k, v| v['position'] }
26
+ end
27
+
28
+ def select_provinces
29
+ provinces.map {|s| [s[1]['name'],s[0]]}
30
+ end
31
+ end
32
+
33
+ class << self
34
+ def region(region)
35
+ Region.new(region)
36
+ end
37
+
38
+ def regions
39
+ REGIONS
40
+ end
41
+
42
+ def select_regions
43
+ REGIONS.map {|s| [s[1]['name'],s[0]]}
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Luzvimin
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'luzvimin/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "luzvimin"
8
+ gem.version = Luzvimin::VERSION
9
+ gem.authors = ["Karren Javier"]
10
+ gem.email = ["karrenjavier@yahoo.com"]
11
+ gem.description = %q{Philippine geography gem listing all regions and provinces}
12
+ gem.summary = %q{Philippine geography gem listing all regions and provinces}
13
+ gem.homepage = "http://kjavier.github.com/luzvimin"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec", "~> 2.6"
21
+ end
@@ -0,0 +1,47 @@
1
+ require 'luzvimin'
2
+
3
+ describe Luzvimin::Region do
4
+ let(:region) { Luzvimin::Region.new('NCR') }
5
+ let(:invalid_region) { Luzvimin::Region.new('NONE') }
6
+
7
+ describe 'specific region' do
8
+ context 'when valid' do
9
+ it { region.id.should == 'NCR' }
10
+ it { region.code.should == 'NCR' }
11
+ it { region.name.should == 'National Capital Region' }
12
+ it { region.position.should == 1 }
13
+ end
14
+
15
+ context 'when invalid' do
16
+ it { invalid_region.id.should == nil }
17
+ it { invalid_region.code.should == nil }
18
+ it { invalid_region.name.should == nil }
19
+ it { invalid_region.position.should == nil }
20
+ end
21
+ end
22
+
23
+ describe 'provinces' do
24
+ context 'when valid' do
25
+ subject { region.provinces }
26
+ it { should be_an(Array) }
27
+ it { should have(1).provinces }
28
+
29
+ it { region.provinces.first.should be_an(Array) }
30
+ end
31
+ end
32
+
33
+ describe 'select_provinces' do
34
+ context 'all' do
35
+ subject { region.select_provinces }
36
+ it { should be_an(Array) }
37
+ it { should have(1).items }
38
+ end
39
+
40
+ context 'first province' do
41
+ subject { region.select_provinces.first }
42
+ it { should be_an(Array) }
43
+ it { should_not be_empty }
44
+ it { should have(2).items }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,42 @@
1
+ require 'luzvimin'
2
+
3
+ describe Luzvimin do
4
+ describe 'region' do
5
+ context 'when valid' do
6
+ region = Luzvimin.region('NCR')
7
+ it { region.code.should == 'NCR' }
8
+ it { region.name.should == 'National Capital Region' }
9
+ it { region.position.should == 1 }
10
+ end
11
+
12
+ context 'when invalid' do
13
+ region = Luzvimin.region('NONE')
14
+ it { region.code.should == nil }
15
+ it { region.name.should == nil }
16
+ it { region.position.should == nil }
17
+ end
18
+ end
19
+
20
+ describe 'regions' do
21
+ subject { Luzvimin.regions }
22
+ it { should be_an(Array) }
23
+ it { should have(17).regions }
24
+
25
+ it { Luzvimin.regions.first.should be_an(Array) }
26
+ end
27
+
28
+ describe 'select_regions' do
29
+ context 'all' do
30
+ subject { Luzvimin.select_regions }
31
+ it { should be_an(Array) }
32
+ it { should have(17).items }
33
+ end
34
+
35
+ context 'first region' do
36
+ subject { Luzvimin.select_regions.first }
37
+ it { should be_an(Array) }
38
+ it { should_not be_empty }
39
+ it { should have(2).items }
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: luzvimin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Karren Javier
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.6'
30
+ description: Philippine geography gem listing all regions and provinces
31
+ email:
32
+ - karrenjavier@yahoo.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - lib/data/provinces/ARMM.yml
43
+ - lib/data/provinces/BICOL.yml
44
+ - lib/data/provinces/CAGAYAN.yml
45
+ - lib/data/provinces/CALABARZON.yml
46
+ - lib/data/provinces/CAR.yml
47
+ - lib/data/provinces/CARAGA.yml
48
+ - lib/data/provinces/CENTRAL_LUZON.yml
49
+ - lib/data/provinces/CENTRAL_VISAYAS.yml
50
+ - lib/data/provinces/DAVAO.yml
51
+ - lib/data/provinces/EASTERN_VISAYAS.yml
52
+ - lib/data/provinces/ILOCOS.yml
53
+ - lib/data/provinces/MIMAROPA.yml
54
+ - lib/data/provinces/NCR.yml
55
+ - lib/data/provinces/NORTHERN_MINDANAO.yml
56
+ - lib/data/provinces/SOCSARGEN.yml
57
+ - lib/data/provinces/WESTERN_VISAYAS.yml
58
+ - lib/data/provinces/ZAMBOANGA_PENINSULA.yml
59
+ - lib/data/regions.yml
60
+ - lib/luzvimin.rb
61
+ - lib/luzvimin/version.rb
62
+ - luzvimin.gemspec
63
+ - spec/luzvimin_region_spec.rb
64
+ - spec/luzvimin_spec.rb
65
+ homepage: http://kjavier.github.com/luzvimin
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.24
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Philippine geography gem listing all regions and provinces
89
+ test_files:
90
+ - spec/luzvimin_region_spec.rb
91
+ - spec/luzvimin_spec.rb
92
+ has_rdoc: