tosspayments2-rails 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: fd88d1af83f21b3f11746c4825425fd7c9bfee9aa793bd0c6adfde623b25a8c2
4
- data.tar.gz: 780b41fdccead7e7b6e26beb5f0ad701f756cc19036c7a713aa1b6c978cbbe19
3
+ metadata.gz: eb64e6c73df51a171c0ba0d31f2093fcc1ba34b672ad3b5e5bd02da8a1f3c5b3
4
+ data.tar.gz: aa0089e54ec709f14814943949fd897133a15a19fd3c6db38801d22912929bd8
5
5
  SHA512:
6
- metadata.gz: 8804a4ec3d7f980fca6cdba867592f73a763ec933bf963c90bb52e30837be9b59fc4e0cabf320e4915da4eaa9e8fc475e52419620db1565a52d0a714e85eafac
7
- data.tar.gz: fe9a02353d00025acb304f67ff7b6e90d2b5bedd6e69760921be3352eb9e06608ce2f073cf24934191550d123561f0102a754f0de0e169dd73a576f06c7d97c2
6
+ metadata.gz: 53d0d4d3a04dee7af35cb1309c87239b104026bb7e1bac7555897266fa74c19687cd1c3e3a31a423ebfcb146f2ac5945fd79b5d9ae23a4cd30328264751db53c
7
+ data.tar.gz: 8eb8411a7feb2b176498014061755ad8f0274429c313077d8994edaa407c289ddba0676cbf4004b5b817c3ccbdd0a6e7dc40f61d5fa35006c46b61cd5d55c9f1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  _No changes yet._
4
4
 
5
+ ## [0.4.0] - 2025-08-20
6
+ ### Changed
7
+ - Add frozen_string_literal magic comments to generator templates
8
+ - Update .gitignore to ignore built gem artifacts (*.gem)
9
+ - RuboCop clean; RSpec green
10
+
5
11
  ## [0.3.0] - 2025-08-21
6
12
  ### Changed
7
13
  - General maintenance and improvements for release process
@@ -5,7 +5,10 @@ module Tosspayments2
5
5
  module Generators
6
6
  class InstallGenerator < ::Rails::Generators::Base
7
7
  source_root File.expand_path('templates', __dir__)
8
+
8
9
  class_option :controller, type: :boolean, default: false, desc: 'Generate example payments controller'
10
+ class_option :with_model, type: :boolean, default: true,
11
+ desc: 'Generate Payment model, migration, and views'
9
12
 
10
13
  def create_initializer
11
14
  template 'initializer.rb', 'config/initializers/tosspayments2.rb'
@@ -16,6 +19,38 @@ module Tosspayments2
16
19
 
17
20
  template 'payments_controller.rb', 'app/controllers/payments_controller.rb'
18
21
  end
22
+
23
+ def create_payment_model_and_migration
24
+ return unless options[:with_model]
25
+
26
+ # Payment 모델 생성
27
+ template 'payment.rb', 'app/models/payment.rb'
28
+
29
+ # 마이그레이션 파일명에 타임스탬프 추가
30
+ timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
31
+ migration_file = "db/migrate/#{timestamp}_create_payments.rb"
32
+ template 'migration.rb', migration_file
33
+
34
+ # 뷰 파일 생성
35
+ empty_directory 'app/views/payments'
36
+ template 'index.html.erb', 'app/views/payments/index.html.erb'
37
+ template 'show.html.erb', 'app/views/payments/show.html.erb'
38
+ end
39
+
40
+ def add_payments_route
41
+ route 'resources :payments'
42
+ end
43
+
44
+ # 제너레이터 실행 시 자동으로 모델/마이그레이션/뷰 생성
45
+ def install
46
+ create_payment_model_and_migration
47
+ add_payments_route
48
+ end
49
+
50
+ # Thor의 hook으로 install 메서드가 자동 실행되도록 설정
51
+ def self.default_task
52
+ :install
53
+ end
19
54
  end
20
55
  end
21
56
  end
@@ -0,0 +1,25 @@
1
+ <h1>결제 내역</h1>
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th>주문번호</th>
6
+ <th>금액</th>
7
+ <th>상태</th>
8
+ <th>거래ID</th>
9
+ <th>생성일</th>
10
+ <th></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% @payments.each do |payment| %>
15
+ <tr>
16
+ <td><%= payment.order_id %></td>
17
+ <td><%= payment.amount %></td>
18
+ <td><%= payment.status %></td>
19
+ <td><%= payment.transaction_id %></td>
20
+ <td><%= payment.created_at.strftime('%Y-%m-%d %H:%M') %></td>
21
+ <td><%= link_to '상세', payment_path(payment) %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreatePayments < ActiveRecord::Migration[6.0]
4
+ def change
5
+ create_table :payments do |t|
6
+ t.string :order_id, null: false
7
+ t.integer :amount, null: false
8
+ t.string :status, null: false
9
+ t.string :transaction_id
10
+ t.timestamps
11
+ end
12
+ add_index :payments, :order_id, unique: true
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 결제 정보를 저장하는 Payment 모델
4
+ class Payment < ApplicationRecord
5
+ # TODO: 필요에 따라 연관관계 및 유효성 검증 추가
6
+ # 예시 컬럼: amount, order_id, status, transaction_id 등
7
+ end
@@ -0,0 +1,9 @@
1
+ <h1>결제 상세</h1>
2
+ <ul>
3
+ <li>주문번호: <%= @payment.order_id %></li>
4
+ <li>금액: <%= @payment.amount %></li>
5
+ <li>상태: <%= @payment.status %></li>
6
+ <li>거래ID: <%= @payment.transaction_id %></li>
7
+ <li>생성일: <%= @payment.created_at.strftime('%Y-%m-%d %H:%M') %></li>
8
+ </ul>
9
+ <%= link_to '목록으로', payments_path %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tosspayments2
4
4
  module Rails
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tosspayments2-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucius Choi
@@ -57,8 +57,12 @@ files:
57
57
  - RELEASE_NOTES_v0.2.0.md
58
58
  - Rakefile
59
59
  - lib/generators/tosspayments2/install/install_generator.rb
60
+ - lib/generators/tosspayments2/install/templates/index.html.erb
60
61
  - lib/generators/tosspayments2/install/templates/initializer.rb
62
+ - lib/generators/tosspayments2/install/templates/migration.rb
63
+ - lib/generators/tosspayments2/install/templates/payment.rb
61
64
  - lib/generators/tosspayments2/install/templates/payments_controller.rb
65
+ - lib/generators/tosspayments2/install/templates/show.html.erb
62
66
  - lib/tosspayments2/rails.rb
63
67
  - lib/tosspayments2/rails/callback_verifier.rb
64
68
  - lib/tosspayments2/rails/client.rb