Skip to content

Commit

Permalink
fix return type and edit readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hamitturkukaya committed Jul 4, 2014
1 parent ce45674 commit 2bbdf51
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
60 changes: 53 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BinChecker

TODO: Write a gem description
Bin checker identifies Turkish banks with bin numbers, It bases on [berkayunal](https://github.com/berkayunal)'s bin [list](https://gist.github.com/berkayunal/1595676).

## Installation

Expand All @@ -16,14 +16,60 @@ Or install it yourself as:

$ gem install bin_checker

After installation you should run

$ rails g bin_checker:migration
$ rake db:migrate
$ rake bin_numbers:insert

for seeding datas.

## Usage
When you want to get bank infos just run like

card = BinNumber.get_bank('454894')
card.bank_name
=> "T.C. ZİRAAT BANKASI A.Ş."
card.card_type
=> "VISA"
card.sub_type
=> "CLASSIC"
card.virtual
=> false
card.prepaid
=> false

## Bugs and Feedback

TODO: Write usage instructions here
If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.

http://github.com/lab2023/bin_checker

## Contributing

1. Fork it ( https://github.com/[my-github-username]/bin_checker/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
BinChecker uses [TomDoc](http://tomdoc.org/), [rDoc](http://rubydoc.info/gems/kangal) and [SemVer](http://semver.org/), and takes it seriously.

Once you've made your great commits:

1. Fork Template
2. Create a topic branch - `git checkout -b my_branch`
3. Push to your branch - `git push origin my_branch`
4. Create a Pull Request from your branch
5. That's it!

## Credits

![lab2023](http://lab2023.com/assets/images/named-logo.png)

- BinChecker is maintained and funded by [lab2023 - information technologies](http://lab2023.com/)
- Thank you to all the [contributors!](https://github.com/kebab-project/kangal/graphs/contributors)
- The names and logos for lab2023 are trademarks of lab2023, inc.

## License

Copyright 2014 lab2023 - information technologies
14 changes: 1 addition & 13 deletions lib/models/bin_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@
class BinNumber < ActiveRecord::Base
self.table_name = 'bin_checker_bin_numbers'

def as_json(options={})
{
bin_number: bin_number,
bank_number: bank_number,
bank_name: bank_name,
card_type: card_type,
sub_type: sub_type,
virtual: virtual,
prepaid: prepaid
}
end

def self.get_bank(bin_id)
bin_number = BinNumber.where(bin_number: bin_id.to_s).try(:first)
if bin_number.present?
bin_number.as_json
bin_number
else
nil
end
Expand Down
14 changes: 7 additions & 7 deletions lib/tasks/initialize_bin_numbers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace :bin_numbers do
puts 'Start'
bins.each do |bin|
number = BinNumber.new
number.bin_number = bin[0] if bin[0]
number.bank_number = bin[1] if bin[0]
number.bank_name = bin[2] if bin[0]
number.card_type = bin[3] if bin[0]
number.sub_type = bin[4] if bin[0]
number.virtual = true if bin[0]
number.prepaid = true if bin[0]
number.bin_number = bin[0].strip if bin[0]
number.bank_number = bin[1].strip if bin[1]
number.bank_name = bin[2].strip if bin[2]
number.card_type = bin[3].strip if bin[3]
number.sub_type = bin[4].strip if bin[4]
number.virtual = true if bin[5]
number.prepaid = true if bin[6]
number.save
end
puts 'Finish'
Expand Down

0 comments on commit 2bbdf51

Please sign in to comment.