Skip to content

Commit

Permalink
bin_checker İnitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
hamitturkukaya committed Jul 4, 2014
1 parent 06f2b94 commit 268259f
Show file tree
Hide file tree
Showing 13 changed files with 570 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.gem
*.rbc
.idea/
.bundle
.config
.yardoc
Expand All @@ -8,6 +9,7 @@ InstalledFiles
_yardoc
coverage
doc/
bin/
lib/bundler/man
pkg
rdoc
Expand Down
35 changes: 17 additions & 18 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Copyright (c) 2014 hamitturkukaya
The MIT License (MIT)

MIT License
Copyright (c) 2014 lab2023

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 13 additions & 10 deletions bin_checker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bin_checker/version'

Gem::Specification.new do |spec|
spec.name = "bin_checker"
spec.name = 'bin_checker'
spec.version = BinChecker::VERSION
spec.authors = ["hamitturkukaya"]
spec.email = ["[email protected]"]
spec.summary = %q{TODO: Write a short summary. Required.}
spec.description = %q{TODO: Write a longer description. Optional.}
spec.homepage = ""
spec.license = "MIT"
spec.authors = ['lab2023', 'Hamit Türkü Kaya']
spec.email = ['lab2023', '[email protected]']
spec.summary = %q{Bin checker identifies Turkish banks with bin numbers.}
spec.description = %q{Bin checker identifies Turkish banks with bin numbers.}
spec.homepage = 'https://github.com/lab2023/bin_checker'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency 'bundler', '~> 1.6'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
spec.add_runtime_dependency 'activemodel', '>= 0'
spec.add_runtime_dependency 'activerecord', '>= 0'
end
5 changes: 3 additions & 2 deletions lib/bin_checker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "bin_checker/version"
require 'bin_checker/version'
require 'models/bin_number'

module BinChecker
# Your code goes here...
require 'bin_checker/railtie' if defined?(Rails)
end
12 changes: 12 additions & 0 deletions lib/bin_checker/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'bin_checker'
require 'rails'

module BinChecker
class Railtie < Rails::Railtie
railtie_name :bin_checker

rake_tasks do
load 'tasks/initialize_bin_numbers.rake'
end
end
end
2 changes: 1 addition & 1 deletion lib/bin_checker/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BinChecker
VERSION = "0.0.1"
VERSION = '0.0.1'
end
20 changes: 20 additions & 0 deletions lib/generators/bin_checker/migration/migration_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'rails/generators/migration'
require 'rails/generators/active_record'

module BinChecker
class MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration

namespace 'bin_checker:migration'

source_root File.join(File.dirname(__FILE__), 'templates')

def self.next_migration_number(dirname)
ActiveRecord::Generators::Base.next_migration_number(dirname)
end

def create_migration_file
migration_template 'migration.rb', 'db/migrate/create_bin_numbers_table.rb' rescue nil
end
end
end
17 changes: 17 additions & 0 deletions lib/generators/bin_checker/migration/templates/migration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CreateBinNumbersTable < ActiveRecord::Migration
def self.up
create_table :bin_checker_bin_numbers do |t|
t.string :bin_number, index: true
t.string :bank_number
t.string :bank_name
t.string :card_type
t.string :sub_type
t.boolean :virtual, null: false, default: false
t.boolean :prepaid, null: false, default: false
end
end

def self.down
drop_table :bin_checker_bin_numbers
end
end
27 changes: 27 additions & 0 deletions lib/models/bin_number.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'active_model'
require 'active_model/validations'

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?

This comment has been minimized.

bin_number.as_json
else
nil
end
end
end
Loading

0 comments on commit 268259f

Please sign in to comment.