tc_validator 0.1.2

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b438408da4a46192c144e4a63728cb36446095e
4
+ data.tar.gz: a636fdbf04348d09007cf83d14cd75549163e786
5
+ SHA512:
6
+ metadata.gz: 55c2c6dabd99cf904ac5a45b82a1b247d34db9f7ee74cc8561e37492230e4a761bc371b044134b26d4788316acc0b725da734bdefd3f3239dfc8e9b8ad159af7
7
+ data.tar.gz: 4f88e9e5a839990eb13a2770ff62d3920225c32f8f070fca609dedc56f1af03567f99478c38cc53ae58d090c78d853d02da99872eab0a5b981deaeadd673cfc7
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tc_validator.gemspec
4
+ gemspec
@@ -0,0 +1,72 @@
1
+ ## TcValidator
2
+
3
+ Ruby library to validate Turkish Republic ID (TC Kimlik NO).
4
+ TcValidator can validate TC ID from formal website [tckimlik.nvi.gov.tr](https://tckimlik.nvi.gov.tr).
5
+
6
+ It needs Turkish Republic ID (TC Kimlik No), first name, last name and birth year to try the validation.
7
+
8
+ TcValidator also using [Savon](https://github.com/savonrb/savon) gem as runtime dependency
9
+ for SOAP client.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'tc_validator'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install tc_validator
26
+
27
+ ## Usage
28
+ Pass TC ID, first name, last name and birth year as string parameters to validator.
29
+ ```ruby
30
+ TcValidator.check_tc_id(tc_id, name, last_name, birth_year)
31
+ ```
32
+ More detailed examples:
33
+
34
+ If TC ID square with TC Kimlik No Algorithm TcValidator returns ``` true or false ```
35
+ ```ruby
36
+ # if 'xxxxxxxxxxx' square with TC Kimlik No Algorithm and not Sadık's ID
37
+ # The below command returns false
38
+ TcValidator.check_tc_id('xxxxxxxxxxx', 'Sadık', 'Ay', '19xx')
39
+ => false
40
+ ```
41
+
42
+ ```ruby
43
+ # if 'xxxxxxxxxxx' square with TC Kimlik No Algorithm and other parameters square with Faruk's infos
44
+ # The below command returns true
45
+ TcValidator.check_tc_id('xxxxxxxxxxx', 'Kerim Rıza', 'Karalı', '19xx')
46
+ => true
47
+ ```
48
+
49
+ ```ruby
50
+ # If TC ID doesn't square with TC Kimlik No Algorithm
51
+ # The above command returns 'Invalid TC ID'
52
+ TcValidator.check_tc_id('11111111111', 'Ekin', 'Kara', '19xx')
53
+ => Invalid TC ID
54
+ ```
55
+
56
+ ## Development
57
+
58
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt
59
+ that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
62
+ version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git
63
+ commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/sadikay/tc_validator/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
72
+ 6.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tc_validator"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ require 'tc_validator/version'
2
+ require 'savon'
3
+ require 'active_support/dependencies'
4
+
5
+ class String
6
+ def replace_and_upcase
7
+ gsub(/ı|i/, 'ı' => 'I', 'i' => 'İ').mb_chars.upcase
8
+ end
9
+ end
10
+
11
+ module TcValidator
12
+ def self.check_tc_id(tc_id, name, surname, year)
13
+ client = Savon.client(wsdl: 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL')
14
+ begin
15
+ response = client.call(:tc_kimlik_no_dogrula, message: {
16
+ 'TCKimlikNo' => tc_id,
17
+ 'Ad' => name.replace_and_upcase,
18
+ 'Soyad' => surname.replace_and_upcase,
19
+ 'DogumYili' => year.to_s
20
+ })
21
+ response.body[:tc_kimlik_no_dogrula_response][:tc_kimlik_no_dogrula_result]
22
+ rescue Savon::SOAPFault
23
+ return false
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module TcValidator
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tc_validator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tc_validator"
8
+ spec.version = TcValidator::VERSION
9
+ spec.authors = ["sadikay"]
10
+ spec.email = ["sadikay91@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby library to validate Turkis Repuplic ID (TC Kimlik NO)}
13
+ spec.description = %q{TcValidator can validate TR ID from https://tckimlik.nvi.gov.tr.}
14
+ spec.homepage = "https://github.com/sadikay/tcvalidator"
15
+
16
+ # spec.rubyforge_project = "tc_validator"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "activesupport"
26
+ spec.add_development_dependency "rspec"
27
+
28
+ spec.add_runtime_dependency 'savon'
29
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tc_validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - sadikay
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-03 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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: activesupport
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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: savon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: TcValidator can validate TR ID from https://tckimlik.nvi.gov.tr.
84
+ email:
85
+ - sadikay91@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/tc_validator.rb
99
+ - lib/tc_validator/version.rb
100
+ - tc_validator.gemspec
101
+ homepage: https://github.com/sadikay/tcvalidator
102
+ licenses: []
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.4.6
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Ruby library to validate Turkis Repuplic ID (TC Kimlik NO)
124
+ test_files: []