rails_country_select 1.0.0 → 1.0.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f4daa65a3cd6a3bdbbd49ae7e10d340c09977202
4
+ data.tar.gz: 7660e92d3e92dc97bd4128a25fb5ef6140a31e93
5
+ SHA512:
6
+ metadata.gz: b6c9fb9f159062295da92e149aaf2c306a49907dad0b6afe6908f696c8de36b82f1ccc671c67b9f0fcfea2c193175a8030af24dc61b5f1e23afe03c50598802f
7
+ data.tar.gz: aa46531ed9f2f8dbe50fe68f9bbbe86d204fde8d8841515a49ee2ce429a59aa6b4a85c1c6faa904c944b1c653164754336704ad83bd29c4daeadf1bada12ed17
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler
4
+ - gem --version
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ V1.0.0
2
+ ========
3
+ * First stable version
4
+ * Find specific country info helpers
5
+
6
+
1
7
  V0.2.2
2
8
  ========
3
9
  * Country Name Locales
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+
2
+ #### [Current]
3
+ * [1ef9c11](../../commit/1ef9c11) test __(Ruben Espinosa)__
4
+ * [bf39215](../../commit/bf39215) test __(Ruben Espinosa)__
5
+ * [139a339](../../commit/139a339) test __(Ruben Espinosa)__
6
+ * [8fc462a](../../commit/8fc462a) test __(Ruben Espinosa)__
7
+ * [94c0d65](../../commit/94c0d65) test __(Ruben Espinosa)__
8
+ * [ee6f577](../../commit/ee6f577) complex method __(Ruben Espinosa)__
9
+ * [3d7da08](../../commit/3d7da08) Bump to 1.0.1 __(Ruben Espinosa)__
10
+ * [d8438d9](../../commit/d8438d9) Update README.md __(Ruben Espinosa)__
11
+ * [87c07f7](../../commit/87c07f7) Update README.md __(Ruben Espinosa)__
12
+ * [8ecacac](../../commit/8ecacac) rspec __(Ruben Espinosa)__
13
+ * [9108006](../../commit/9108006) Update README.md __(Ruben Espinosa)__
14
+ * [9f000cc](../../commit/9f000cc) Update README.md __(Ruben Espinosa)__
15
+ * [34d73d2](../../commit/34d73d2) Update README.md __(Ruben Espinosa)__
16
+ * [0080f24](../../commit/0080f24) Update README.md __(Ruben Espinosa)__
17
+ * [798daca](../../commit/798daca) readme __(Ruben Espinosa)__
18
+ * [b205976](../../commit/b205976) readme __(Ruben Espinosa)__
19
+
20
+ #### v1.0.0
21
+ * [5888b2d](../../commit/5888b2d) Bump to 1.0.0 __(Ruben Espinosa)__
22
+ * [1670624](../../commit/1670624) first stable version __(Ruben Espinosa)__
23
+ * [201d146](../../commit/201d146) Bump to 0.2.3 __(Ruben Espinosa)__
24
+
25
+ #### v0.2.2
26
+ * [73c78b8](../../commit/73c78b8) I18N support __(Ruben Espinosa)__
27
+ * [2e52efc](../../commit/2e52efc) Bump to 0.2.2 __(Ruben Espinosa)__
28
+ * [6792be7](../../commit/6792be7) Update README.md __(Ruben Espinosa)__
29
+ * [a161a7e](../../commit/a161a7e) Update README.md __(Ruben Espinosa)__
30
+ * [3abb9a8](../../commit/3abb9a8) Update README.md __(Ruben Espinosa)__
31
+
32
+ #### v0.2.1
33
+ * [38104c7](../../commit/38104c7) Bump to 0.2.1 __(Ruben Espinosa)__
34
+
35
+ #### v0.2.0
36
+ * [4b792cf](../../commit/4b792cf) readme __(Ruben Espinosa)__
37
+ * [2f5387e](../../commit/2f5387e) version 0.0.2 __(Ruben Espinosa)__
38
+ * [8ac988b](../../commit/8ac988b) Bump to 0.2.0 __(Ruben Espinosa)__
39
+ * [c55cda8](../../commit/c55cda8) Update README.md __(Ruben Espinosa)__
40
+ * [8da5bf1](../../commit/8da5bf1) Update README.md __(Ruben Espinosa)__
41
+
42
+ #### v0.1.0
43
+ * [4140cea](../../commit/4140cea) Bump to 0.1.0 __(Ruben Espinosa)__
44
+
45
+ #### v0.0.1
46
+ * [d1fe0eb](../../commit/d1fe0eb) first commit __(Ruben Espinosa)__
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rails_country_select.gemspec
4
4
  gemspec
5
+ gem 'rspec'
6
+ gem 'coveralls', :require => false
7
+ gem 'rails'
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # RailsCountrySelect [![Gem Version](https://badge.fury.io/rb/rails_country_select.png)](http://badge.fury.io/rb/rails_country_select) [![Code Climate](https://codeclimate.com/github/rderoldan1/rails_country_select.png)](https://codeclimate.com/github/rderoldan1/rails_country_select)
1
+ # RailsCountrySelect
2
+ [![Gem Version](https://badge.fury.io/rb/rails_country_select.png)](http://badge.fury.io/rb/rails_country_select) [![Code Climate](https://codeclimate.com/github/rderoldan1/rails_country_select.png)](https://codeclimate.com/github/rderoldan1/rails_country_select) [![Build Status](https://travis-ci.org/rderoldan1/rails_country_select.png?branch=master)](https://travis-ci.org/rderoldan1/rails_country_select) [![Coverage Status](https://coveralls.io/repos/rderoldan1/rails_country_select/badge.png?branch=master)](https://coveralls.io/r/rderoldan1/rails_country_select?branch=master)
2
3
 
3
4
  Rails 3 gem for Select tag in order to choose a country in your forms, provides 4 options.
4
5
 
@@ -28,8 +29,9 @@ Or install it yourself as:
28
29
  ## Usage
29
30
 
30
31
  ### Basic
31
- value : country cod number
32
- text : country name
32
+ * value : country cod number
33
+ * text : country name
34
+
33
35
  ```rails
34
36
  <%= form_for @user do |f| %>
35
37
  <%= f.country_select :country %>
@@ -38,7 +40,7 @@ text : country name
38
40
 
39
41
  HTML generated
40
42
  ```html
41
- <select id="cliente_nacionalidad" name="user[country]">
43
+ <select id="user_country" name="user[country]">
42
44
  <option value="4">Afghanistan</option>
43
45
  <option value="248">Albania</option>
44
46
  <option value="8">Åland Islands</option>
@@ -59,7 +61,7 @@ HTML generated
59
61
  HTML generated
60
62
 
61
63
  ```html
62
- <select id="cliente_nacionalidad" name="user[country]" prompt="Choose a country" value="CO">
64
+ <select id="user_country" name="user[country]" prompt="Choose a country" value="CO">
63
65
  <option value="AF">Afghanistan</option>
64
66
  <option value="AL">Albania</option>
65
67
  <option value="AX">Åland Islands</option>
@@ -67,7 +69,7 @@ HTML generated
67
69
  ```
68
70
 
69
71
 
70
- ### Show country info
72
+ ### Show country info in array
71
73
  A helper method is available to get all the country info in the views, it return an array, the usage is.
72
74
 
73
75
  Find by name
@@ -100,6 +102,21 @@ country(:alpha3s => "USA", :alpha2s => "US", :num => 840, :name => "United State
100
102
  [840, "United States", "US", "USA"]
101
103
  ```
102
104
 
105
+ #### Show specific country info
106
+ All the methods receive a hash options :name, :cod, :alpha2s, :alpha3s
107
+ ```ruby
108
+ country_name :num => "170"
109
+ => "Colombia"
110
+
111
+ country_cod :name => "Colombia"
112
+ => 170
113
+ country_alpha2s :num => "170"
114
+ => "CO"
115
+
116
+ country_alpha3s :num => "170"
117
+ => "COL"
118
+ ```
119
+
103
120
  #### Usage in views
104
121
 
105
122
  Assuming that your User model store country cod.
@@ -108,6 +125,12 @@ Assuming that your User model store country cod.
108
125
  <p>Country Name: <%= country(:num => @user.country_num)[1] %><p>
109
126
  <p>Country Apha2s: <%= country(:num => @user.country_num)[2] %><p>
110
127
  <p>Country Apha3s: <%= country(:num => @user.country_num)[3] %><p>
128
+
129
+ <p>Country Cod: <%= country_cod(:num => @user.country_num) %><p>
130
+ <p>Country Name: <%= country_name(:num => @user.country_num) %><p>
131
+ <p>Country Apha2s: <%= country_alpha2s(:num => @user.country_num) %><p>
132
+ <p>Country Apha3s: <%= country_alpha3s(:num => @user.country_num) %><p>
133
+
111
134
  ```
112
135
 
113
136
  ### Locales
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -1,3 +1,3 @@
1
1
  module RailsCountrySelect
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  require "rails_country_select/version"
3
3
  require File.expand_path('../country_definitions', __FILE__)
4
4
 
5
- if defined?(Rails) && defined?(ActionView)
5
+ #if defined?(Rails) && defined?(ActionView)
6
6
  module ActionView
7
7
  module Helpers
8
8
  autoload :CountryHelper, 'rails_country_select/helpers/rails_country_select'
@@ -19,7 +19,7 @@ if defined?(Rails) && defined?(ActionView)
19
19
  }
20
20
 
21
21
  select_options = potential[options[:keys]].zip(potential[options[:values]])
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_select_tag(select_options, options, html_options)
22
+ ActiveModelInstanceTag.new(object, method, self, options.delete(:object)).to_select_tag(select_options, options, html_options)
23
23
  end
24
24
  end
25
25
 
@@ -33,7 +33,7 @@ if defined?(Rails) && defined?(ActionView)
33
33
  def country(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
34
34
  result = []
35
35
  COUNTRY_NUMS.zip(translate_countries, COUNTRY_ALPHA2S, COUNTRY_ALPHA3S).each do |country|
36
- if options[:num].to_i.eql?(country[0]) || options[:name].eql?(country[1]) || options[:alpha2s].eql?(country[2]) || options[:alpha3s].eql?(country[3])
36
+ if find_country(options, country)
37
37
  result = country
38
38
  end
39
39
  end
@@ -66,7 +66,11 @@ if defined?(Rails) && defined?(ActionView)
66
66
  I18n.t(code, :scope => :countries, :default => name)
67
67
  end
68
68
  end
69
+
70
+ def find_country(options, country)
71
+ options[:num].to_i.eql?(country[0]) || options[:name].eql?(country[1]) || options[:alpha2s].eql?(country[2]) || options[:alpha3s].eql?(country[3])
72
+ end
69
73
  end
70
74
  end
71
- end
75
+ #end
72
76
 
@@ -0,0 +1,35 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+
5
+ describe 'helper methods' do
6
+
7
+ it 'should include countries names' do
8
+ names = COUNTRY_NAMES
9
+ names.class.should be Array
10
+ names.include?("Colombia").should eq true
11
+ names.should_not be nil
12
+ end
13
+
14
+ it 'should include countries nums' do
15
+ names = COUNTRY_NUMS
16
+ names.class.should be Array
17
+ names.include?(170).should eq true
18
+ names.should_not be nil
19
+ end
20
+
21
+ it 'should include countries alpha 2' do
22
+ names = COUNTRY_ALPHA2S
23
+ names.class.should be Array
24
+ names.include?("CO").should eq true
25
+ names.should_not be nil
26
+ end
27
+
28
+ it 'should include countries alpha 3' do
29
+ names = COUNTRY_ALPHA3S
30
+ names.class.should be Array
31
+ names.include?("COL").should eq true
32
+ names.should_not be nil
33
+ end
34
+
35
+ end
@@ -0,0 +1,15 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ describe 'ActionView' do
5
+ it 'should include helper tag methods' do
6
+ ActionView::Helpers::FormOptionsHelper.instance_methods.include?(:country_select).should be true
7
+ ActionView::Helpers::FormBuilder.instance_methods.include?(:country_select).should be true
8
+ end
9
+
10
+ it 'fail test' do
11
+ user = double("user")
12
+ expect { country_select(user, :name)}.to raise_error
13
+ end
14
+ end
15
+
@@ -0,0 +1,42 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ describe 'Helper methods' do
5
+
6
+ it 'should find country name' do
7
+ a = country_name(:num => "170")
8
+ a.class.should be String
9
+ a.should eq "Colombia"
10
+ a.should_not be_nil
11
+ end
12
+
13
+ it 'should find country alpha2s' do
14
+ a = country_alpha2s(:num => "170")
15
+ a.class.should be String
16
+ a.should eq "CO"
17
+ a.should_not be_nil
18
+ end
19
+
20
+ it 'should find country alpha3s' do
21
+ a = country_alpha3s(:num => "170")
22
+ a.class.should be String
23
+ a.should eq "COL"
24
+ a.should_not be_nil
25
+ end
26
+
27
+ it 'should find country number' do
28
+ a = country_cod(:name => "Colombia")
29
+ a.class.should be Fixnum
30
+ a.should eq 170
31
+ a.should_not be_nil
32
+ end
33
+
34
+ it 'should find country info' do
35
+ a = country(:name => "Colombia")
36
+ a.class.should be Array
37
+ a.count.should eq 4
38
+ a[0].should eq 170
39
+ a[0].class.should eq Fixnum
40
+ a.should_not be_nil
41
+ end
42
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'coveralls'
4
+
5
+ Coveralls.wear! 'rails'
6
+
7
+ require File.expand_path('../../lib/rails_country_select', __FILE__)
8
+ require File.expand_path('../../lib/country_definitions', __FILE__)
9
+
10
+ require 'action_view'
11
+ require 'action_view/helpers'
12
+ require 'i18n'
13
+
14
+ include ActionView::Helpers
15
+ include ActionView::Helpers::FormOptionsHelper
16
+ include ActionView::Helpers::FormHelper
17
+ include ActionView::Helpers::TagHelper
18
+ RSpec.configure do |config|
19
+ end
@@ -0,0 +1,10 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ describe 'Version' do
5
+ it 'should be the version number' do
6
+ a = RailsCountrySelect::VERSION
7
+ a.class.should be(String)
8
+ a.should_not be_nil
9
+ end
10
+ end
metadata CHANGED
@@ -1,49 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_country_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ruben Espinosa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-06 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
- description: ! 'Select tag for countries in rails form, based in LukeCarrier rails
41
+ description: 'Select tag for countries in rails form, based in LukeCarrier rails
47
42
  2 plugin '
48
43
  email:
49
44
  - rderoldan1@gmail.com
@@ -51,8 +46,11 @@ executables: []
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
54
- - .gitignore
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".travis.yml"
55
52
  - CHANGELOG
53
+ - CHANGELOG.md
56
54
  - Gemfile
57
55
  - LICENSE.txt
58
56
  - README.md
@@ -61,35 +59,38 @@ files:
61
59
  - lib/rails_country_select.rb
62
60
  - lib/rails_country_select/version.rb
63
61
  - rails_country_select.gemspec
62
+ - spec/form_helper_spec.rb
63
+ - spec/form_tag_spec.rb
64
+ - spec/helper_spec.rb
65
+ - spec/spec_helper.rb
66
+ - spec/version_spec.rb
64
67
  homepage: https://github.com/rderoldan1/rails_country_select
65
68
  licenses:
66
69
  - MIT
70
+ metadata: {}
67
71
  post_install_message:
68
72
  rdoc_options: []
69
73
  require_paths:
70
74
  - lib
71
75
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
76
  requirements:
74
- - - ! '>='
77
+ - - ">="
75
78
  - !ruby/object:Gem::Version
76
79
  version: '0'
77
- segments:
78
- - 0
79
- hash: -1361916533450864319
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
81
  requirements:
83
- - - ! '>='
82
+ - - ">="
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
- segments:
87
- - 0
88
- hash: -1361916533450864319
89
85
  requirements: []
90
86
  rubyforge_project:
91
- rubygems_version: 1.8.25
87
+ rubygems_version: 2.2.2
92
88
  signing_key:
93
- specification_version: 3
89
+ specification_version: 4
94
90
  summary: Select tag for countries in rails form
95
- test_files: []
91
+ test_files:
92
+ - spec/form_helper_spec.rb
93
+ - spec/form_tag_spec.rb
94
+ - spec/helper_spec.rb
95
+ - spec/spec_helper.rb
96
+ - spec/version_spec.rb