country_state_select 3.0.5 → 3.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +15 -0
- data/.travis.yml +4 -1
- data/Gemfile +2 -0
- data/README.md +6 -1
- data/Rakefile +2 -0
- data/app/controllers/country_state_select/cscs_controller.rb +2 -0
- data/config/routes.rb +2 -0
- data/country_state_select.gemspec +6 -6
- data/lib/country_state_select.rb +6 -2
- data/lib/country_state_select/engine.rb +2 -0
- data/lib/country_state_select/engine3.rb +2 -0
- data/lib/country_state_select/railtie.rb +2 -0
- data/lib/country_state_select/version.rb +3 -1
- data/spec/country_state_select_spec.rb +6 -2
- data/spec/spec_helper.rb +2 -1
- metadata +15 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e19a1973258042a873d741682f8b4fa4eadfe1191cc988bc4bb8efa1785fd108
|
4
|
+
data.tar.gz: e68fdf8aa8c862cc844337862e00646bc71727c607ec38fcc27d947246a9ffc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4807a8138b62e598471aa6edc0f32e78a8c84fa47b9f79fbcc551af5a755fad6347e1cead2a0d201f60c766c54b16a7c827f4f0c5fe118d08f52204052697a0a
|
7
|
+
data.tar.gz: 1ea10b63f82e6f4f94de47fffceaed21934a6ca01c78efbdc110a43e4c36d45a34f2dc2dfefcf828dbe9be19b2b8ccd7355ba557f80b73555e09bf2d9d7d6dca
|
@@ -0,0 +1,15 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
9
|
+
executor: ruby/default
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Which bundler?
|
14
|
+
command: bundle -v
|
15
|
+
- ruby/bundle-install
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
## Country State Select
|
2
|
-
[![Build Status](https://travis-ci.org/arvindvyas/Country-State-Select.svg?branch=master)](https://travis-ci.org/arvindvyas/Country-State-Select)
|
2
|
+
[![Build Status](https://travis-ci.org/arvindvyas/Country-State-Select.svg?branch=master)](https://travis-ci.org/arvindvyas/Country-State-Select)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/arvindvyas/Country-State-Select/badges/gpa.svg)](https://codeclimate.com/github/arvindvyas/Country-State-Select)
|
4
|
+
|
5
|
+
|
3
6
|
|
4
7
|
Country State Select is a library that provides an easy API to generate Country , State / Province and City dropdowns for use in forms.
|
5
8
|
|
@@ -24,6 +27,8 @@ Then run
|
|
24
27
|
|
25
28
|
bundle install
|
26
29
|
|
30
|
+
# NOTE
|
31
|
+
In the latest version we have removed all the dependencies of js and you are feel free to use any js you can use predefine method to populate data
|
27
32
|
|
28
33
|
Don't forget to restart your server after you install it.
|
29
34
|
## Setup Gem
|
data/Rakefile
CHANGED
data/config/routes.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'country_state_select/version'
|
5
6
|
|
@@ -18,11 +19,10 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.add_development_dependency 'bundler'
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
22
|
+
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
23
24
|
spec.add_development_dependency 'rspec'
|
24
|
-
spec.add_development_dependency 'pry'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency 'rails'
|
27
26
|
spec.add_runtime_dependency 'city-state'
|
27
|
+
spec.add_runtime_dependency 'rails'
|
28
28
|
end
|
data/lib/country_state_select.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'country_state_select/version'
|
2
4
|
require 'city-state'
|
3
5
|
require 'rails'
|
@@ -17,6 +19,7 @@ module CountryStateSelect
|
|
17
19
|
def self.states_collection(f, options)
|
18
20
|
states = collect_states(f.object.send(options[:country]))
|
19
21
|
return f.object.send(options[:state]) if states.empty?
|
22
|
+
|
20
23
|
states
|
21
24
|
end
|
22
25
|
|
@@ -33,6 +36,7 @@ module CountryStateSelect
|
|
33
36
|
# Return the cities of given state and country
|
34
37
|
def self.collect_cities(state_id = '', country_id = '')
|
35
38
|
return [] if state_id.nil? || country_id.nil?
|
39
|
+
|
36
40
|
CS.cities(state_id.to_sym, country_id.to_sym)
|
37
41
|
end
|
38
42
|
|
@@ -51,7 +55,7 @@ module CountryStateSelect
|
|
51
55
|
# Create hash to use in the simple_form
|
52
56
|
def self.merge_hash(options, collections)
|
53
57
|
options = options.merge(collection: collections)
|
54
|
-
options = options.merge(as: :string) if collections.
|
58
|
+
options = options.merge(as: :string) if collections.instance_of?(String)
|
55
59
|
options
|
56
60
|
end
|
57
61
|
end
|
@@ -61,7 +65,7 @@ when /[4-6]/
|
|
61
65
|
require 'country_state_select/engine'
|
62
66
|
when /^3\.[12]/
|
63
67
|
require 'country_state_select/engine3'
|
64
|
-
when /^3\.
|
68
|
+
when /^3\.0/
|
65
69
|
require 'country_state_select/railtie'
|
66
70
|
else
|
67
71
|
raise 'Unsupported rails version'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe CountryStateSelect do
|
@@ -75,7 +77,9 @@ describe CountryStateSelect do
|
|
75
77
|
|
76
78
|
describe '#states_options' do
|
77
79
|
let(:f) { double(object: {}) }
|
78
|
-
let(:options)
|
80
|
+
let(:options) do
|
81
|
+
{ form: f, label: 'State / Province', field_names: { country: :country_field_name, state: :state_field_name } }
|
82
|
+
end
|
79
83
|
|
80
84
|
it 'should return a Hash' do
|
81
85
|
expect(f.object).to receive(:country_field_name).and_return('US')
|
@@ -162,7 +166,7 @@ describe CountryStateSelect do
|
|
162
166
|
|
163
167
|
it 'returns an empty array if there are no states in that Country' do
|
164
168
|
method_call = CountryStateSelect.collect_cities('', '')
|
165
|
-
expect(method_call).to eq(
|
169
|
+
expect(method_call).to eq(nil)
|
166
170
|
end
|
167
171
|
end
|
168
172
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country_state_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arvind Vyas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,21 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rails
|
56
|
+
name: city-state
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: rails
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -102,6 +88,7 @@ executables: []
|
|
102
88
|
extensions: []
|
103
89
|
extra_rdoc_files: []
|
104
90
|
files:
|
91
|
+
- ".circleci/config.yml"
|
105
92
|
- ".gitignore"
|
106
93
|
- ".travis.yml"
|
107
94
|
- Gemfile
|
@@ -123,7 +110,7 @@ homepage: https://github.com/arvindvyas/Country-State-Select
|
|
123
110
|
licenses:
|
124
111
|
- MIT
|
125
112
|
metadata: {}
|
126
|
-
post_install_message:
|
113
|
+
post_install_message:
|
127
114
|
rdoc_options: []
|
128
115
|
require_paths:
|
129
116
|
- lib
|
@@ -138,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
125
|
- !ruby/object:Gem::Version
|
139
126
|
version: '0'
|
140
127
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
128
|
+
rubygems_version: 3.1.2
|
129
|
+
signing_key:
|
144
130
|
specification_version: 4
|
145
131
|
summary: Dynamically select Country and State.
|
146
132
|
test_files:
|