turkish_id 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac00acf5d67426d22aec34b35e3c5115ee54cc39
4
- data.tar.gz: 10f764a1bc0a2fed3dbda9716a89ce517211527c
3
+ metadata.gz: d96231198d925643a7631ec1d6c349b2a0e9ecb0
4
+ data.tar.gz: 486a165f4ec17935636c3533e5271a3282d75dc3
5
5
  SHA512:
6
- metadata.gz: 88991714f712feba40571e886f33d52165711a783cdc8c13f427e1deb38307bc6d55a467327327bb3537d77d7cd711276608404fa8437506ffb3b939dfd4bf25
7
- data.tar.gz: 2f20697b59ad19e97394e35b695aa55f77fd39cb351771859383ff960433e3165866740d888caa7bf922801436ac40923adb971a01ad2f5df53e58f6fe971521
6
+ metadata.gz: bef5b54e4efac51b1812196c4d60fc5a6d963223453022c598622921cfcddff79310725ed8b8fe18647a39a407aa693a34e8f13b8e49dccadde5853a3783eedb
7
+ data.tar.gz: 491c4e22eac5b642f3a7cc52088814cae870d8c3dec666993000d57e6734518ab54a56422252624bf7f8b3af94891a53eb6fb20ddf0fe09ca43e04902aa594fc
data/README.md CHANGED
@@ -7,7 +7,7 @@ This gem provides methods to validate Turkish Identification Numbers.
7
7
 
8
8
  Add this line to your application's Gemfile:
9
9
 
10
- ```ruby
10
+ ```rb
11
11
  gem 'turkish_id'
12
12
  ```
13
13
 
@@ -22,9 +22,11 @@ Or install it yourself as:
22
22
  ## Usage
23
23
 
24
24
  Create a new instance:
25
+
25
26
  ```rb
26
27
  identity_number = TurkishId.new('10000000146')
27
28
  ```
29
+
28
30
  Use ```is_valid?``` method to check validity:
29
31
 
30
32
  ```rb
@@ -32,6 +34,13 @@ identity_number.is_valid?
32
34
  => true
33
35
  ```
34
36
 
37
+ Or use the command line executable:
38
+
39
+ ```sh
40
+ $ turkish_id 10000000078
41
+ Your identification number is valid.
42
+ ```
43
+
35
44
  ## Anatomy of the Turkish ID Number
36
45
 
37
46
  The Turkish Identification Number consists of ```11``` digits.
data/bin/turkish_id CHANGED
@@ -6,13 +6,31 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
6
6
 
7
7
  require 'turkish_id'
8
8
 
9
- print "Enter your 11 digit id number to validate: "
9
+ @help = '
10
+ Usage
11
+ turkish_id QUERY
10
12
 
11
- begin
12
- identity_number = TurkishId.new(gets.chomp)
13
- valid = identity_number.is_valid?
14
- rescue
15
- puts "Your identification number is invalid."
13
+ Examples
14
+ turkish_id 10000000078
15
+ turkish_id 10000000146
16
+
17
+ '
18
+
19
+ def parse_input
20
+ ARGV[0] ? validate_id(ARGV[0]) : print_help
21
+ end
22
+
23
+ def validate_id(id_number)
24
+ identity_number = TurkishId.new(id_number)
25
+ print_result(identity_number.is_valid?)
26
+ end
27
+
28
+ def print_result(result)
29
+ STDOUT.puts "Your identification number is #{ result ? 'valid' : 'invalid' }."
30
+ end
31
+
32
+ def print_help
33
+ STDOUT.puts @help
16
34
  end
17
35
 
18
- puts "Your identification number is valid." if valid
36
+ parse_input
@@ -1,3 +1,3 @@
1
1
  class TurkishId
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turkish_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerem Bozdas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler