masterdata 0.2.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c1878ec040ed832d9e36afb1b7a8a10c2b0bddec1c70143301cbeee1dde62f8
4
+ data.tar.gz: e2562cb53beb1dde10752c2f3ab50988df9fcab4db56f5e403dfe621f89787ae
5
+ SHA512:
6
+ metadata.gz: 736944550221fb7468d3f9a2c9f275e585dcfe3bc39178ec564e9faebdff5f6f2c1b4101cdc997723c80a1d800126c32efc95d2777c79856ec03f7138edde4fb
7
+ data.tar.gz: 9533cbe9e12fa05e73066a499c5b32e9080a33cc6e63dda994fc7e9b592ef060315a0325ef406525745887b46f2e4c50a8917f5a08488d59b02c1c1d498d9174
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-01-16
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sairam160305@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in masterdata.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ masterdata (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ parallel (1.21.0)
11
+ parser (3.1.0.0)
12
+ ast (~> 2.4.1)
13
+ rainbow (3.1.1)
14
+ rake (13.0.6)
15
+ regexp_parser (2.2.0)
16
+ rexml (3.2.5)
17
+ rubocop (1.24.1)
18
+ parallel (~> 1.10)
19
+ parser (>= 3.0.0.0)
20
+ rainbow (>= 2.2.2, < 4.0)
21
+ regexp_parser (>= 1.8, < 3.0)
22
+ rexml
23
+ rubocop-ast (>= 1.15.1, < 2.0)
24
+ ruby-progressbar (~> 1.7)
25
+ unicode-display_width (>= 1.4.0, < 3.0)
26
+ rubocop-ast (1.15.1)
27
+ parser (>= 3.0.1.1)
28
+ ruby-progressbar (1.11.0)
29
+ unicode-display_width (2.1.0)
30
+
31
+ PLATFORMS
32
+ x64-mingw32
33
+
34
+ DEPENDENCIES
35
+ masterdata!
36
+ rake (~> 13.0)
37
+ rubocop (~> 1.7)
38
+
39
+ BUNDLED WITH
40
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 sairam6267
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,43 @@
1
+ # Masterdata
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/masterdata`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'masterdata'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install masterdata
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/masterdata. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/masterdata/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Masterdata project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/masterdata/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "masterdata"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
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,8 @@
1
+ module Masterdata
2
+ class Error < StandardError; end
3
+ class << self
4
+ def dialcode_country
5
+ dialcode_country={"+93"=>"Afghanistan", "+355"=>"Albania", "+213"=>"Algeria", "+1"=>"United States", "+376"=>"Andorra", "+244"=>"Angola", "+54"=>"Argentina", "+374"=>"Armenia", "+297"=>"Aruba", "+61"=>"Australia", "+672"=>"Australian External Territories", "+43"=>"Austria", "+994"=>"Azerbaijan", "+973"=>"Bahrain", "+880"=>"Bangladesh", "+375"=>"Belarus", "+32"=>"Belgium", "+501"=>"Belize", "+229"=>"Benin", "+975"=>"Bhutan", "+591"=>"Bolivia ", "+599"=>"Curaçao", "+387"=>"Bosnia and Herzegovina", "+267"=>"Botswana", "+55"=>"Brazil", "+673"=>"Brunei Darussalam", "+359"=>"Bulgaria", "+226"=>"Burkina Faso", "+257"=>"Burundi", "+855"=>"Cambodia", "+237"=>"Cameroon", "+238"=>"Cape Verde", "+236"=>"Central African Republic", "+235"=>"Chad", "+56"=>"Chile", "+86"=>"China", "+57"=>"Colombia", "+269"=>"Comoros", "+242"=>"Congo", "+682"=>"Cook Islands", "+506"=>"Costa Rica", "+225"=>"Côte d'Ivoire", "+385"=>"Croatia", "+53"=>"Cuba", "+357"=>"Cyprus", "+420"=>"Czech Republic", "+850"=>"North Korea", "+243"=>"Democratic Republic of the Congo", "+45"=>"Denmark", "+246"=>"Diego Garcia", "+253"=>"Djibouti", "+593"=>"Ecuador", "+20"=>"Egypt", "+503"=>"El Salvador", "+240"=>"Equatorial Guinea", "+291"=>"Eritrea", "+372"=>"Estonia", "+251"=>"Ethiopia", "+500"=>"Falkland Islands ", "+298"=>"Faroe Islands", "+679"=>"Fiji", "+358"=>"Finland", "+33"=>"France", "+262"=>"Mayotte", "+594"=>"French Guiana", "+689"=>"French Polynesia", "+241"=>"Gabon", "+220"=>"Gambia", "+995"=>"Georgia", "+49"=>"Germany", "+233"=>"Ghana", "+350"=>"Gibraltar", "+881"=>"Global Mobile Satellite System , shared", "+30"=>"Greece", "+299"=>"Greenland", "+388"=>"Group of countries, shared code", "+590"=>"Guadeloupe", "+502"=>"Guatemala", "+224"=>"Guinea", "+245"=>"Guinea-Bissau", "+592"=>"Guyana", "+509"=>"Haiti", "+504"=>"Honduras", "+852"=>"Hong Kong", "+36"=>"Hungary", "+354"=>"Iceland", "+91"=>"India", "+62"=>"Indonesia", "+870"=>"Inmarsat SNAC", "+800"=>"International Freephone Service", "+882"=>"International Networks, shared code", "+883"=>"International Networks, shared code", "+979"=>"International Premium Rate Service ", "+808"=>"International Shared Cost Service ", "+98"=>"Iran ", "+964"=>"Iraq", "+353"=>"Ireland", "+972"=>"Israel", "+39"=>"Vatican", "+81"=>"Japan", "+962"=>"Jordan", "+7"=>"Russian Federation", "+254"=>"Kenya", "+686"=>"Kiribati", "+82"=>"Korea ", "+965"=>"Kuwait", "+996"=>"Kyrgyzstan", "+856"=>"Lao P.D.R.", "+371"=>"Latvia", "+961"=>"Lebanon", "+266"=>"Lesotho", "+231"=>"Liberia", "+218"=>"Libya", "+423"=>"Liechtenstein", "+370"=>"Lithuania", "+352"=>"Luxembourg", "+853"=>"Macao", "+261"=>"Madagascar", "+265"=>"Malawi", "+60"=>"Malaysia", "+960"=>"Maldives", "+223"=>"Mali", "+356"=>"Malta", "+692"=>"Marshall Islands", "+596"=>"Martinique", "+222"=>"Mauritania", "+230"=>"Mauritius", "+52"=>"Mexico", "+691"=>"Micronesia", "+373"=>"Moldova ", "+377"=>"Monaco", "+976"=>"Mongolia", "+382"=>"Montenegro", "+212"=>"Morocco", "+258"=>"Mozambique", "+95"=>"Myanmar", "+264"=>"Namibia", "+674"=>"Nauru", "+977"=>"Nepal", "+31"=>"Netherlands", "+687"=>"New Caledonia", "+64"=>"New Zealand", "+505"=>"Nicaragua", "+227"=>"Niger", "+234"=>"Nigeria", "+683"=>"Niue", "+47"=>"Norway", "+968"=>"Oman", "+92"=>"Pakistan", "+680"=>"Palau", "+507"=>"Panama", "+675"=>"Papua New Guinea", "+595"=>"Paraguay", "+51"=>"Peru", "+63"=>"Philippines", "+48"=>"Poland", "+351"=>"Portugal", "+974"=>"Qatar", "+40"=>"Romania", "+250"=>"Rwanda", "+247"=>"Saint Helena, Ascension and Tristan da Cunha", "+290"=>"Saint Helena, Ascension and Tristan da Cunha", "+508"=>"Saint Pierre and Miquelon", "+685"=>"Samoa", "+378"=>"San Marino", "+239"=>"Sao Tome and Principe", "+966"=>"Saudi Arabia", "+221"=>"Senegal", "+381"=>"Serbia", "+248"=>"Seychelles", "+232"=>"Sierra Leone", "+65"=>"Singapore", "+421"=>"Slovakia", "+386"=>"Slovenia", "+677"=>"Solomon Islands", "+252"=>"Somalia", "+27"=>"South Africa", "+211"=>"South Sudan", "+34"=>"Spain", "+94"=>"Sri Lanka", "+249"=>"Sudan", "+597"=>"Suriname", "+268"=>"Swaziland", "+46"=>"Sweden", "+41"=>"Switzerland", "+963"=>"Syrian Arab Republic", "+886"=>"Taiwan, China", "+992"=>"Tajikistan", "+255"=>"Tanzania", "+888"=>"Telecommunications for Disaster Relief ", "+66"=>"Thailand", "+389"=>"The Former Yugoslav Republic of Macedonia", "+670"=>"Timor-Leste", "+228"=>"Togo", "+690"=>"Tokelau", "+676"=>"Tonga", "+991"=>"Trial of a proposed new international service", "+216"=>"Tunisia", "+90"=>"Turkey", "+993"=>"Turkmenistan", "+688"=>"Tuvalu", "+256"=>"Uganda", "+380"=>"Ukraine", "+971"=>"United Arab Emirates", "+44"=>"United Kingdom", "+878"=>"Universal Personal Telecommunication ", "+598"=>"Uruguay", "+998"=>"Uzbekistan", "+678"=>"Vanuatu", "+379"=>"Vatican", "+58"=>"Venezuela ", "+84"=>"Viet Nam", "+681"=>"Wallis and Futuna", "+967"=>"Yemen", "+260"=>"Zambia", "+263"=>"Zimbabwe", "+970"=>"Reserved"}
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Masterdata
4
+ VERSION = "0.2.0"
5
+ end
data/lib/masterdata.rb ADDED
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "masterdata/version"
4
+ require_relative "masterdata/dialcode"
5
+ require 'i18n_data'
6
+ require 'csv'
7
+ require "normalize_country"
8
+ require 'city-state'
9
+ require 'iso_country_codes'
10
+ require 'validates_zipcode'
11
+ require 'phonelib'
12
+ require 'email_address'
13
+ require 'geocoder'
14
+
15
+ module Masterdata
16
+ class Error < StandardError; end
17
+ # Your code goes here...
18
+ class << self
19
+
20
+ def read_csv(path)
21
+ data = {}
22
+ df = CSV.table(path)
23
+ df.headers.each do |column|
24
+ data.merge!(column=>df[column].map{|values| values.class==NilClass ? "N" : values}.map(&:to_s))
25
+ end
26
+ return data
27
+ end
28
+ @@country_codes = I18nData.countries.keys().map(&:downcase)
29
+ @@country_names = I18nData.countries.values().map(&:downcase)
30
+ @@dialcode = Masterdata::dialcode_country
31
+ def validate_abbrevate_countrycodes(csv_data,countrycodecol)
32
+ alpha_country_codes = []
33
+ abbre_country_codes = []
34
+ csv_data[countrycodecol.to_sym].map(&:downcase).each do |alpha2|
35
+ if @@country_codes.include?(alpha2[0,2])
36
+ alpha_country_codes << alpha2[0,2] # validating country codes
37
+ abbre_country_codes << NormalizeCountry(alpha2[0,2].upcase, :to => :short) #abbrevating CountryCodes after validation
38
+ elsif alpha2=="N"
39
+ alpha_country_codes << alpha2
40
+ abbre_country_codes << alpha2
41
+ else
42
+ alpha_country_codes << "I" # invalid
43
+ abbre_country_codes << "N" # null value
44
+ end
45
+ end
46
+ return alpha_country_codes , abbre_country_codes
47
+ end
48
+
49
+ def val_country_state_names(csv_data,col,countrycol)
50
+ col = col.map{|e| e.to_sym}
51
+ state_names = []
52
+ csv_data[countrycol.to_sym].map{|code| if code.size==2 then state_names << CS.states(code.downcase.to_sym).values() end} #states names getting
53
+ country_state_names= (@@country_names << state_names.compact().flatten.map(&:downcase)).flatten #collecting all country and state names
54
+ # val_country_state_names = [:state,:country]
55
+ col.each do |ele|
56
+ csv_data[ele].each_with_index do |data,index|
57
+ if data !="N"
58
+ if country_state_names.include?(data.downcase)
59
+ csv_data[ele][index] = data #validating states and country names
60
+ else
61
+ csv_data[ele][index] = "I"
62
+ end
63
+ elsif data == "N"
64
+ csv_data[ele][index] = "N"
65
+ else
66
+ csv_data[ele][index]
67
+ end
68
+ end
69
+ end
70
+ return col.map{|e| csv_data[e]}
71
+ end
72
+
73
+ def val_dial_code(csv_data,dialcol)
74
+ country_dail_codes = @@country_codes.map(&:upcase).map{|codes| IsoCountryCodes.find(codes).calling[1..-1]} # collecting all country dial codes from countries
75
+ val_country_dail_codes = []
76
+ csv_data[dialcol.to_sym].each do |i|
77
+ if country_dail_codes.include?(i)
78
+ val_country_dail_codes << "+#{i}" # validating column dial codes
79
+ elsif i == "N"
80
+ val_country_dail_codes << "N"
81
+ else
82
+ val_country_dail_codes << "I"
83
+ end
84
+ end
85
+ return val_country_dail_codes
86
+ end
87
+
88
+ def infogain_countrycode(csv_data,column)
89
+ infogaincc = []
90
+ csv_data[column.to_sym].each do |codes|
91
+ # p codes
92
+ if (codes =="I" || codes == "N") #countrycodes
93
+ infogaincc << ["NO INFO",codes,"NO INFO"]
94
+ else
95
+ infogaincc << [NormalizeCountry(IsoCountryCodes.find(codes).name , :to => :short) , IsoCountryCodes.find(codes).calling]
96
+ end
97
+ end
98
+ return infogaincc
99
+ end
100
+
101
+ def infogain_country(csv_data,column)
102
+ infogainc = []
103
+ csv_data[column.to_sym].each do |codes|
104
+ # p codes
105
+ if (codes =="I" || codes == "N") #country
106
+ infogainc << ["NO INFO","NO INFO"]
107
+ else
108
+ infogainc << [I18nData.country_code(codes),IsoCountryCodes.find(I18nData.country_code(codes)).calling]
109
+ end
110
+ end
111
+ return infogainc
112
+ end
113
+
114
+ def infogain_countrydialcode(csv_data,column)
115
+ infogaincdc = []
116
+ csv_data[column.to_sym].each do |codes|
117
+ # p codes
118
+ if (codes =="I" || codes == "N") #countrydialcodes
119
+ infogaincdc << ["NO INFO","NO INFO"]
120
+ else
121
+ infogaincdc << [@@dialcode[codes],I18nData.country_code(@@dialcode[codes])]
122
+ end
123
+ end
124
+ return infogaincdc
125
+ end
126
+
127
+ def update_columns(csv_data,headers,header_values)
128
+ headers = headers.map{|x| x.to_sym}
129
+ headers.each_with_index do |data,index|
130
+ csv_data[headers[index]].replace(header_values[index])
131
+ end
132
+ return csv_data
133
+ end
134
+
135
+ def val_pincode(pincode_col,countrycode_col)
136
+ pincodes = []
137
+ pincode_col.each_with_index do |data,index|
138
+ if data != "N"
139
+ if ValidatesZipcode.valid?(data,countrycode_col[index])
140
+ pincodes << data
141
+ else
142
+ pincodes << "I"
143
+ end
144
+ else
145
+ pincodes << "N"
146
+ end
147
+ end
148
+ return pincodes
149
+ end
150
+
151
+ def val_contactnumber(contact_col,countrycode_col)
152
+ valcontactnumber = []
153
+ contact_col.each_with_index do |data,index|
154
+ if Phonelib.valid_for_country?(data,countrycode_col[index])
155
+ valcontactnumber << data
156
+ else
157
+ valcontactnumber << "I"
158
+ end
159
+ end
160
+ return valcontactnumber
161
+ end
162
+
163
+ def val_emailaddress(emailcol)
164
+ valemailcol = []
165
+ emailcol.each do |val|
166
+ # p val
167
+ if val != "N"
168
+ if EmailAddress.valid?(val)
169
+ valemailcol << val
170
+ else
171
+ valemailcol << "I"
172
+ end
173
+ else
174
+ valemailcol << "N"
175
+ end
176
+ end
177
+ return valemailcol
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/masterdata/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "masterdata"
7
+ spec.version = Masterdata::VERSION
8
+ spec.authors = ["sairam6267"]
9
+ spec.email = ["sairam160305@gmail.com"]
10
+
11
+ spec.summary = "https://github.com/sairam6267/masterdata"
12
+ spec.description = "This gem is under development"
13
+ spec.homepage = "https://github.com/sairam6267/masterdata"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/sairam6267/masterdata"
21
+ spec.metadata["changelog_uri"] = "https://github.com/sairam6267/masterdata"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: masterdata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - sairam6267
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem is under development
14
+ email:
15
+ - sairam160305@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rubocop.yml"
22
+ - CHANGELOG.md
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/masterdata.rb
32
+ - lib/masterdata/dialcode.rb
33
+ - lib/masterdata/version.rb
34
+ - masterdata.gemspec
35
+ homepage: https://github.com/sairam6267/masterdata
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ homepage_uri: https://github.com/sairam6267/masterdata
40
+ source_code_uri: https://github.com/sairam6267/masterdata
41
+ changelog_uri: https://github.com/sairam6267/masterdata
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.4.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.2.22
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: https://github.com/sairam6267/masterdata
61
+ test_files: []