bancos_brasileiros 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a94008e2224172585906defd9ea32701115421c4ed642c2f83544c9fa45400c0
4
- data.tar.gz: 361a1b62a8226f51bbcb4856a83bcec30d9e3f9856c2ca60f190ad91751a33b8
3
+ metadata.gz: 30339bda5226f9da5f97b9cd634a9ed180b48d71db984bdd6bd46ec0c622de94
4
+ data.tar.gz: 2a3b8d73de7b39b5b659df47ec2f233fe548943e074ef6e2759c27aca8d555e2
5
5
  SHA512:
6
- metadata.gz: 8adec4a93cce14226e8c0b7520ec6ac106bdb9ffa8cfd2b3af729527924371db1fa2940de1c1dcba0b15f1e9dd7537ae6dc1194f68e29e88b149ac7a39282cdb
7
- data.tar.gz: 91e18688b8e73762fb3fc07489da7a57ce0d21981f8aea5e995b335ff7ba704dd2712bf506396a19ae0784793c100ddea70aa865bb8a9eb0d9fb4ddcc77174f6
6
+ metadata.gz: a67bdd5d7beb2442e97f674ac4dd80cf385dfd6d12d147dafdc4ced7b34dafe36ec97b5148ef80a79474dc36556b389d28bafc1ef34095e80266658d861ae863
7
+ data.tar.gz: 31123aa9e416a513544f672d2e65fa3ef7b3eacb4065cd5896fe74745c3544605082585d7577d7e50c23897ee582caa666325a811b73d43282b9c41b588cc3ea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.1.3
2
+
3
+ - Change README
4
+ - Add view example
5
+
6
+ ## 0.1.2
7
+
8
+ - Change README
9
+
1
10
  ## 0.1.1
2
11
 
3
12
  - Add json with all banks (updated until Jul 13, 2024)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Bancos Brasileiros
2
2
 
3
- 🇧🇷 🏦 📋 Brazilian commercial banks list
3
+ 🇧🇷 🏦 📋 Brazilian commercial banks list.
4
+
5
+ This gem was created to meet a need in the [Brazilian Banks Project](https://guibranco.github.io/BancosBrasileiros/), developed by [Guilherme Branco](https://github.com/guibranco). The project keeps an up-to-date list of banks in various programming languages, and I realized the need to provide support for Rails as well.
4
6
 
5
7
  ## Installation
6
8
 
@@ -11,6 +13,137 @@ gem 'bancos_brasileiros'
11
13
  ```
12
14
  and run **bundle install**
13
15
 
16
+ ## Usage
17
+
18
+ Example of how to use the `bancos_brasileiros` in a rails project:
19
+
20
+ Create a controller:
21
+
22
+ ```ruby
23
+ # app/controllers/banks_controller.rb
24
+ class BanksController < ApplicationController
25
+
26
+ def index
27
+ @banks = BancosBrasileiros.all_banks
28
+ respond_to do |format|
29
+ format.html
30
+ format.json { render json: @banks }
31
+ end
32
+ end
33
+
34
+ def show
35
+ @bank = BancosBrasileiros.find_bank_by_compe(params[:id])
36
+ respond_to do |format|
37
+ if @bank
38
+ format.html
39
+ format.json { render json: @bank }
40
+ else
41
+ format.html { render plain: 'Bank not found.', status: :not_found }
42
+ format.json { render json: { error: 'Bank not found.' }, status: :not_found }
43
+ end
44
+ end
45
+ end
46
+
47
+ def by_ispb
48
+ @bank = BancosBrasileiros.find_bank_by_ispb(params[:ispb])
49
+ respond_to do |format|
50
+ if @bank
51
+ format.html { render :show }
52
+ format.json { render json: @bank }
53
+ else
54
+ format.html { render plain: 'Bank not found.', status: :not_found }
55
+ format.json { render json: { error: 'Bank not found.' }, status: :not_found }
56
+ end
57
+ end
58
+ end
59
+
60
+ def by_network
61
+ @banks = BancosBrasileiros.find_banks_by_network(params[:network])
62
+ respond_to do |format|
63
+ format.html { render :index }
64
+ format.json { render json: @banks }
65
+ end
66
+ end
67
+
68
+ def by_type
69
+ @banks = BancosBrasileiros.find_banks_by_type(params[:type])
70
+ respond_to do |format|
71
+ format.html { render :index }
72
+ format.json { render json: @banks }
73
+ end
74
+ end
75
+
76
+ def by_pix_type
77
+ @banks = BancosBrasileiros.find_banks_by_pix_type(params[:pix_type])
78
+ respond_to do |format|
79
+ format.html { render :index }
80
+ format.json { render json: @banks }
81
+ end
82
+ end
83
+ end
84
+ ```
85
+ Create routes:
86
+
87
+ ```ruby
88
+ # config/routes.rb
89
+ Rails.application.routes.draw do
90
+ resources :banks, only: [:index, :show] do
91
+ collection do
92
+ get 'by_ispb/:ispb', to: 'banks#by_ispb'
93
+ get 'by_network/:network', to: 'banks#by_network'
94
+ get 'by_type/:type', to: 'banks#by_type'
95
+ get 'by_pix_type/:pix_type', to: 'banks#by_pix_type'
96
+ end
97
+ end
98
+ end
99
+ ```
100
+ Create a example of view:
101
+
102
+ ```html
103
+ <!-- app/views/banks/index.html.erb -->
104
+ <h1>Lista de Bancos Brasileiros</h1>
105
+ <table>
106
+ <thead>
107
+ <tr>
108
+ <th>COMPE</th>
109
+ <th>Nome</th>
110
+ <th>Tipo</th>
111
+ <th>Network</th>
112
+ <th>Ações</th>
113
+ </tr>
114
+ </thead>
115
+ <tbody>
116
+ <% @banks.each do |bank| %>
117
+ <tr>
118
+ <td><%= bank['COMPE'] %></td>
119
+ <td><%= bank['LongName'] %></td>
120
+ <td><%= bank['Type'] %></td>
121
+ <td><%= bank['Network'] %></td>
122
+ <td><%= link_to 'Ver detalhes', bank_path(bank['COMPE']) %></td>
123
+ </tr>
124
+ <% end %>
125
+ </tbody>
126
+ </table>
127
+
128
+ <!-- app/views/banks/show.html.erb -->
129
+ <h1>Detalhes do Banco</h1>
130
+ <p><strong>COMPE:</strong> <%= @bank['COMPE'] %></p>
131
+ <p><strong>ISPB:</strong> <%= @bank['ISPB'] %></p>
132
+ <p><strong>Nome:</strong> <%= @bank['LongName'] %></p>
133
+ <p><strong>Nome Curto:</strong> <%= @bank['ShortName'] %></p>
134
+ <p><strong>Tipo:</strong> <%= @bank['Type'] %></p>
135
+ <p><strong>Network:</strong> <%= @bank['Network'] %></p>
136
+ <p><strong>Pix Type:</strong> <%= @bank['PixType'] %></p>
137
+ <p><strong>Produtos:</strong> <%= @bank['Products'].join(', ') %></p>
138
+ <p><strong>URL:</strong> <%= link_to @bank['Url'], @bank['Url'] %></p>
139
+ <p><strong>Data de Início de Operação:</strong> <%= @bank['DateOperationStarted'] %></p>
140
+ <p><strong>Data de Início do Pix:</strong> <%= @bank['DatePixStarted'] %></p>
141
+ <p><strong>Data de Registro:</strong> <%= @bank['DateRegistered'] %></p>
142
+ <p><strong>Data de Atualização:</strong> <%= @bank['DateUpdated'] %></p>
143
+
144
+ <%= link_to 'Voltar', banks_path %>
145
+ ```
146
+
14
147
  ## Requirements
15
148
 
16
149
  - Ruby >= 2.6.0 (recommended 2.7+)
Binary file
Binary file
@@ -19,8 +19,6 @@ Gem::Specification.new do |spec|
19
19
  "changelog_uri" => "https://github.com/eltonsantos/bancos_brasileiros/blob/master/CHANGELOG.md",
20
20
  }
21
21
 
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
22
  spec.files = Dir.chdir(__dir__) do
25
23
  `git ls-files -z`.split("\x0").reject do |f|
26
24
  (File.expand_path(f) == __FILE__) ||
@@ -30,10 +28,4 @@ Gem::Specification.new do |spec|
30
28
  spec.bindir = "exe"
31
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
30
  spec.require_paths = ["lib"]
33
-
34
- # Uncomment to register a new dependency of your gem
35
- # spec.add_dependency "example-gem", "~> 1.0"
36
-
37
- # For more information and examples about making a new gem, check out our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BancosBrasileiros
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bancos_brasileiros
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elton Santos
@@ -23,6 +23,8 @@ files:
23
23
  - README.md
24
24
  - Rakefile
25
25
  - bancos_brasileiros-0.1.0.gem
26
+ - bancos_brasileiros-0.1.1.gem
27
+ - bancos_brasileiros-0.1.2.gem
26
28
  - bancos_brasileiros.gemspec
27
29
  - data/bancos.json
28
30
  - lib/bancos_brasileiros.rb