atm_program 1.4.1.pre → 1.5.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 +4 -4
 - data/lib/account.rb +1 -3
 - data/lib/atm.rb +3 -3
 - data/lib/atm_program.rb +2 -1
 - data/lib/transaction.rb +4 -4
 - data/lib/validation.rb +2 -2
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5b3f4bdef07fcdca735e2e456c22b9d53907ce2e54d325fe949e4106471124e2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7a9b496594fb7e256f2c9004c3d63e36c039149ad21e0d2c335047d1af892728
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 357db845bc92ecc75cc7d064b081444eba2debf0fd1f3c7d16fb2d325a085f8c58df37e003e1eb5a9e9169cfa67fa3b92c3efd68b167e665b4800e9d3709f93a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: af50c89f0c5ecec35be4ec8533de736ad5e0ccea706372fe3b03ccadc7ca3540d90a4ec06b239a20e7deee28f325dbfcaeabd91f42d0b42f7839c6c05a1b2533
         
     | 
    
        data/lib/account.rb
    CHANGED
    
    | 
         @@ -1,7 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
2 
     | 
    
         
             
            require 'csv'
         
     | 
| 
       4 
     | 
    
         
            -
            # class Account
         
     | 
| 
       5 
3 
     | 
    
         
             
            class Account
         
     | 
| 
       6 
4 
     | 
    
         
             
              attr_accessor :name, :card_number, :pin, :balance, :transactions, :card_blocked
         
     | 
| 
       7 
5 
     | 
    
         | 
| 
         @@ -14,7 +12,7 @@ class Account 
     | 
|
| 
       14 
12 
     | 
    
         
             
              end
         
     | 
| 
       15 
13 
     | 
    
         | 
| 
       16 
14 
     | 
    
         
             
              def self.find_by_card_number(card_number)
         
     | 
| 
       17 
     | 
    
         
            -
                CSV.table( 
     | 
| 
      
 15 
     | 
    
         
            +
                CSV.table(ACCOUNT_PATH).each do |entry|
         
     | 
| 
       18 
16 
     | 
    
         
             
                  if entry[:card_number] == card_number
         
     | 
| 
       19 
17 
     | 
    
         
             
                    return new(entry[:name], entry[:card_number], entry[:pin], entry[:balance], entry[:card_blocked])
         
     | 
| 
       20 
18 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/atm.rb
    CHANGED
    
    | 
         @@ -17,12 +17,12 @@ class Atm 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              def thank_you
         
     | 
| 
       19 
19 
     | 
    
         
             
                puts "\nThank You for using the ATM"
         
     | 
| 
       20 
     | 
    
         
            -
                sleep( 
     | 
| 
      
 20 
     | 
    
         
            +
                sleep(1.5)
         
     | 
| 
       21 
21 
     | 
    
         
             
                welcome_screen
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              def clear
         
     | 
| 
       25 
     | 
    
         
            -
                sleep( 
     | 
| 
      
 25 
     | 
    
         
            +
                sleep(1.5)
         
     | 
| 
       26 
26 
     | 
    
         
             
                puts `clear`
         
     | 
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
         @@ -116,7 +116,7 @@ class Atm 
     | 
|
| 
       116 
116 
     | 
    
         
             
                return unless valid_pin?
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
118 
     | 
    
         
             
                transactions = []
         
     | 
| 
       119 
     | 
    
         
            -
                CSV.table( 
     | 
| 
      
 119 
     | 
    
         
            +
                CSV.table(TRANSACTION_PATH).each do |row|
         
     | 
| 
       120 
120 
     | 
    
         
             
                  next unless row[:card_number] == @current_account.card_number && row[:status] == 'Success'
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
122 
     | 
    
         
             
                  transaction_number = row[:transaction_number].to_s.rjust(4, '0')
         
     | 
    
        data/lib/atm_program.rb
    CHANGED
    
    | 
         @@ -3,7 +3,8 @@ require 'base64' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require_relative 'atm'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'highline/import'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'colorize'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
            ACCOUNT_PATH = File.join(File.dirname(__FILE__), 'account.csv')
         
     | 
| 
      
 7 
     | 
    
         
            +
            TRANSACTION_PATH = File.join(File.dirname(__FILE__), 'transaction.csv')
         
     | 
| 
       7 
8 
     | 
    
         
             
            module ATM
         
     | 
| 
       8 
9 
     | 
    
         
             
              def self.start
         
     | 
| 
       9 
10 
     | 
    
         
             
                Atm.new
         
     | 
    
        data/lib/transaction.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ class Transaction 
     | 
|
| 
       11 
11 
     | 
    
         
             
                @current_account = current_account
         
     | 
| 
       12 
12 
     | 
    
         
             
                @type = type
         
     | 
| 
       13 
13 
     | 
    
         
             
                @amount = amount
         
     | 
| 
       14 
     | 
    
         
            -
                @transaction_number = File.readlines( 
     | 
| 
      
 14 
     | 
    
         
            +
                @transaction_number = File.readlines(TRANSACTION_PATH).length
         
     | 
| 
       15 
15 
     | 
    
         
             
                @row = "#{@transaction_number},#{@current_account.card_number},#{@type},#{Time.now.strftime('%d/%m/%Y %I:%M:%S:%P')},#{@amount},"
         
     | 
| 
       16 
16 
     | 
    
         
             
                validate_type if valid_pin?
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
         @@ -104,7 +104,7 @@ class Transaction 
     | 
|
| 
       104 
104 
     | 
    
         
             
              end
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
              def update_account_file(transaction_type, amount: nil, pin: nil)
         
     | 
| 
       107 
     | 
    
         
            -
                data = CSV.table( 
     | 
| 
      
 107 
     | 
    
         
            +
                data = CSV.table(ACCOUNT_PATH)
         
     | 
| 
       108 
108 
     | 
    
         
             
                data.each do |entry|
         
     | 
| 
       109 
109 
     | 
    
         
             
                  next unless entry[:card_number] == @current_account.card_number
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
         @@ -113,13 +113,13 @@ class Transaction 
     | 
|
| 
       113 
113 
     | 
    
         
             
                  when :Deposit then entry[:balance] += amount
         
     | 
| 
       114 
114 
     | 
    
         
             
                  when :'Change Pin' then entry[:pin] = pin
         
     | 
| 
       115 
115 
     | 
    
         
             
                  end
         
     | 
| 
       116 
     | 
    
         
            -
                  File.write( 
     | 
| 
      
 116 
     | 
    
         
            +
                  File.write(ACCOUNT_PATH, data)
         
     | 
| 
       117 
117 
     | 
    
         
             
                  break
         
     | 
| 
       118 
118 
     | 
    
         
             
                end
         
     | 
| 
       119 
119 
     | 
    
         
             
              end
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
              def update_transaction_file(data)
         
     | 
| 
       122 
     | 
    
         
            -
                File.open( 
     | 
| 
      
 122 
     | 
    
         
            +
                File.open(TRANSACTION_PATH, 'a') do |row|
         
     | 
| 
       123 
123 
     | 
    
         
             
                  row << data
         
     | 
| 
       124 
124 
     | 
    
         
             
                end
         
     | 
| 
       125 
125 
     | 
    
         
             
              end
         
     | 
    
        data/lib/validation.rb
    CHANGED
    
    | 
         @@ -21,13 +21,13 @@ module Validation 
     | 
|
| 
       21 
21 
     | 
    
         
             
                  puts "Incorrect Pin\n\n"
         
     | 
| 
       22 
22 
     | 
    
         
             
                  next unless n == 2
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                  @accounts_table = CSV.table( 
     | 
| 
      
 24 
     | 
    
         
            +
                  @accounts_table = CSV.table(ACCOUNT_PATH).each do |account|
         
     | 
| 
       25 
25 
     | 
    
         
             
                    if account[:card_number] == @current_account.card_number
         
     | 
| 
       26 
26 
     | 
    
         
             
                      account[:card_blocked] = 'true'
         
     | 
| 
       27 
27 
     | 
    
         
             
                      break
         
     | 
| 
       28 
28 
     | 
    
         
             
                    end
         
     | 
| 
       29 
29 
     | 
    
         
             
                  end
         
     | 
| 
       30 
     | 
    
         
            -
                  File.write( 
     | 
| 
      
 30 
     | 
    
         
            +
                  File.write(ACCOUNT_PATH, @accounts_table)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  puts "You have entered wrong pin 3 times\nnow your card is blocked contact your bank for more details.."
         
     | 
| 
       32 
32 
     | 
    
         
             
                  return false
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: atm_program
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.5.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Zaid Shaikh
         
     | 
| 
         @@ -67,9 +67,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  version: 2.7.0
         
     | 
| 
       68 
68 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       69 
69 
     | 
    
         
             
              requirements:
         
     | 
| 
       70 
     | 
    
         
            -
              - - " 
     | 
| 
      
 70 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       71 
71 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       72 
     | 
    
         
            -
                  version:  
     | 
| 
      
 72 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       73 
73 
     | 
    
         
             
            requirements: []
         
     | 
| 
       74 
74 
     | 
    
         
             
            rubygems_version: 3.3.3
         
     | 
| 
       75 
75 
     | 
    
         
             
            signing_key: 
         
     |