Created
August 3, 2013 06:32
-
-
Save shu0115/6145461 to your computer and use it in GitHub Desktop.
Create New Gem - webpay-scaffold ref: http://qiita.com/shu_0115/items/1d1ca307171820283e1a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/labo | |
bundle gem webpay-scaffold | |
---------- | |
create webpay-scaffold/Gemfile | |
create webpay-scaffold/Rakefile | |
create webpay-scaffold/LICENSE.txt | |
create webpay-scaffold/README.md | |
create webpay-scaffold/.gitignore | |
create webpay-scaffold/webpay-scaffold.gemspec | |
create webpay-scaffold/lib/webpay/scaffold.rb | |
create webpay-scaffold/lib/webpay/scaffold/version.rb | |
Initializating git repo in /Users/shu/labo/webpay-scaffold | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd webpay-scaffold |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake install | |
---------- | |
minimum-omniauth-scaffold 0.0.1 built to pkg/minimum-omniauth-scaffold-0.0.1.gem. | |
minimum-omniauth-scaffold (0.0.1) installed. | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/labo | |
rails new webpay_scaffold_sample | |
cd webpay_scaffold_sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vi Gemfile | |
---------- | |
# WebPay | |
gem 'webpay-scaffold', path: "~/labo/webpay-scaffold" | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem uninstall webpay-scaffold | |
gem uninstall webpay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install | |
---------- | |
Installing webpay (2.0.2) | |
Using webpay-scaffold (0.0.1) from source at ~/labo/webpay-scaffold | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem list webpay | |
---------- | |
*** LOCAL GEMS *** | |
webpay (2.0.2) | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails g -h | |
---------- | |
Webpay: | |
webpay:scaffold | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails g webpay:scaffold | |
---------- | |
create config/initializers/web_pay.rb | |
create db/migrate/20010101000000_create_payments.rb | |
create db/migrate/20010102000000_create_cards.rb | |
create app/models/card.rb | |
create app/models/payment.rb | |
create app/models/web_pay_connect.rb | |
create config/settings.yml | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails destroy webpay:scaffold | |
---------- | |
remove config/initializers/web_pay.rb | |
remove db/migrate/20010101000000_create_payments.rb | |
remove db/migrate/20010102000000_create_cards.rb | |
remove app/models/card.rb | |
remove app/models/payment.rb | |
remove app/models/web_pay_connect.rb | |
remove config/settings.yml | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WebPay | |
gem 'webpay-scaffold', path: "~/labo/webpay-scaffold" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git add . && git commit -m "First commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails g webpay:scaffold | |
---------- | |
create config/initializers/web_pay.rb | |
create db/migrate/20010101000000_create_payments.rb | |
create db/migrate/20010102000000_create_cards.rb | |
create app/models/card.rb | |
create app/models/payment.rb | |
create app/models/web_pay_connect.rb | |
append config/settings.yml | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake db:migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TopController < ApplicationController | |
# トップ | |
def index | |
# 新しい課金の作成 | |
card = { | |
number: "4242424242424242", | |
exp_month: "11", | |
exp_year: "2014", | |
cvc: "123", | |
name: "SHUN MATSUMOTO", | |
} | |
response, card = WebPayConnect.charge_create(100, card, 'プレミアム料') | |
payment = Payment.create(response.merge(user_id: current_user.try(:id))) | |
card = Card.create(card.merge(user_id: current_user.try(:id))) | |
# 課金情報の取得 | |
response = WebPayConnect.charge_retrieve('ch_gNP3TE4GB0bC6eX') | |
# 課金リストの取得 | |
response = WebPayConnect.charge_list(5, 10) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vi lib/webpay/scaffold/version.rb | |
---------- | |
module Webpay | |
module Scaffold | |
VERSION = "0.0.1" | |
end | |
end | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git add . && git commit -m "Release 0.0.1" | |
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake release | |
---------- | |
webpay-scaffold 0.0.1 built to pkg/webpay-scaffold-0.0.1.gem. | |
Tagged v0.0.1. | |
Pushed git commits and tags. | |
Pushed webpay-scaffold 0.0.1 to rubygems.org. | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem uninstall webpay-scaffold | |
---------- | |
Successfully uninstalled webpay-scaffold-0.0.1 | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install webpay-scaffold | |
---------- | |
Fetching: webpay-scaffold-0.0.1.gem (100%) | |
Successfully installed webpay-scaffold-0.0.1 | |
1 gem installed | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----- | |
Project Name | |
[ webpay-scaffold ] | |
Description (optional) | |
[ Scaffold for WebPay API. ] | |
=> Create repository | |
----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote add origin git@github.com:shu0115/webpay-scaffold.git | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vi webpay-scaffold.gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spec.description = %q{Scaffold for WebPay API.} | |
spec.summary = %q{WebPay Scaffold} | |
spec.homepage = "https://github.com/shu0115/webpay-scaffold" | |
# 〜 | |
spec.add_dependency "webpay" | |
spec.add_dependency "rails_config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git add . && git commit -m "Update gemspec" | |
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "webpay/scaffold/version" | |
require 'rails/generators' | |
require 'webpay' | |
require 'rails_config' | |
module Webpay | |
class ScaffoldGenerator < Rails::Generators::Base | |
@@template_path = source_root File.expand_path( "../scaffold/templates", __FILE__ ) | |
def generate_scaffold | |
## config/initializers | |
copy_file( "#{@@template_path}/initializers/web_pay.rb", "config/initializers/web_pay.rb" ) | |
## db/migrate | |
copy_file( "#{@@template_path}/migrate/create_payments.rb", "db/migrate/20010101000000_create_payments.rb" ) | |
copy_file( "#{@@template_path}/migrate/create_cards.rb", "db/migrate/20010102000000_create_cards.rb" ) | |
## models | |
copy_file( "#{@@template_path}/models/card.rb", "app/models/card.rb" ) | |
copy_file( "#{@@template_path}/models/payment.rb", "app/models/payment.rb" ) | |
copy_file( "#{@@template_path}/models/web_pay_connect.rb", "app/models/web_pay_connect.rb" ) | |
## settings | |
if File.exist?("config/settings.yml") | |
content = "\n# WebPay API Key\n" | |
content += "web_pay_api_key: 'test_secret_5ete0yfRC3g67ndfMm0kC1S9'\n" | |
content += "web_pay_currency: 'jpy'\n" | |
append_file( "config/settings.yml", content.force_encoding('ASCII-8BIT') ) | |
else | |
copy_file( "#{@@template_path}/config/settings.yml", "config/settings.yml" ) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git add . && git commit -m "Update" | |
git push origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment