开源项目 offsite_payments
使用教程
1. 项目的目录结构及介绍
offsite_payments
项目的目录结构如下:
offsite_payments/
├── bin/
├── gemfiles/
├── generators/
├── lib/
│ ├── offsite_payments/
│ │ ├── version.rb
│ │ └── ...
│ └── offsite_payments.rb
├── script/
├── test/
├── .gitignore
├── .yardopts
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Gemfile
├── Gemfile.lock
├── MIT-LICENSE
├── README.md
├── Rakefile
├── offsite_payments.gemspec
├── repo.db.yml
└── shipit_rubygems.yml
目录介绍
bin/
: 包含可执行文件。gemfiles/
: 包含不同环境的 Gemfile。generators/
: 包含代码生成器。lib/
: 包含项目的主要代码。offsite_payments/
: 包含offsite_payments
的核心代码。version.rb
: 定义项目的版本号。
script/
: 包含脚本文件。test/
: 包含测试文件。.gitignore
: Git 忽略文件配置。.yardopts
: YARD 文档生成器配置。CHANGELOG.md
: 项目更新日志。CONTRIBUTING.md
: 贡献指南。Gemfile
: 依赖管理文件。Gemfile.lock
: 依赖锁定文件。MIT-LICENSE
: 项目许可证。README.md
: 项目说明文档。Rakefile
: Rake 任务配置文件。offsite_payments.gemspec
: 项目 gem 配置文件。repo.db.yml
: 仓库数据库配置文件。shipit_rubygems.yml
: 发布配置文件。
2. 项目的启动文件介绍
项目的启动文件是 lib/offsite_payments.rb
,它负责加载项目的核心功能和依赖。
# lib/offsite_payments.rb
require 'offsite_payments/version'
require 'offsite_payments/helper'
require 'offsite_payments/notification'
require 'offsite_payments/return'
require 'offsite_payments/bogus'
require 'offsite_payments/integrations'
require 'offsite_payments/billing_response'
require 'offsite_payments/country'
require 'offsite_payments/currency'
require 'offsite_payments/requires_parameters'
require 'offsite_payments/string_extensions'
require 'offsite_payments/validation'
require 'offsite_payments/action_view_helper'
3. 项目的配置文件介绍
项目的配置文件是 offsite_payments.gemspec
,它定义了项目的元数据和依赖。
# offsite_payments.gemspec
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'offsite_payments'
s.version = OffsitePayments::VERSION
s.summary = 'Framework and tools for dealing with offsite (hosted) payment pages'
s.description = 'Offsite Payments is a simple abstraction library used in ' +
'and sponsored by Shopify. It is written by Tobias Luetke ' +
'Cody Fauser and contributors. The aim of the project is ' +
'to put as simple an abstraction as possible on top of ' +
'offsite (often called hosted) payment pages and allow ' +
'contributors to easily help services such as Shopify ' +
'extend the number of offsite payment services they support.'
s.authors = ['Tobias Luetke', 'Cody Fauser']
s.email = 'tobi@shopify.com'
s.homepage = 'https://github.com/activemerchant/offsite_payments'
s.files = Dir['CHANGELOG.md', 'README.md', 'MIT-LICENSE', 'lib/**/*']
s.require_path = 'lib'
s.metadata['allowed_push_host'] = 'https://rubygems.org'
s.post_install_message = %q[
In order to use `offsite_payments` gem, you need to either install or add to your Gemfile one of the two options for Money gem:
- `gem 'money'`
- `gem 'shopify-money', require: 'money'`
Regardless of which gem you choose, please add them *before* `offsite_payments`.
For more info, go to https://github.com/activemerchant/offsite_payments#money-gem-dependency
]
end
这个配置文件定义了项目的名称、版本、描述、作者、依赖等信息,并且包含了安装后的提示信息。