erb2haml 项目使用教程
1. 项目的目录结构及介绍
erb2haml/
├── lib/
│ └── erb2haml/
│ ├── converter.rb
│ ├── railtie.rb
│ └── version.rb
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── Rakefile
├── erb2haml.gemspec
- lib/: 包含项目的主要逻辑文件。
- converter.rb: 负责ERB到Haml的转换逻辑。
- railtie.rb: 集成Rails的初始化文件。
- version.rb: 定义项目的版本号。
- Gemfile: 定义项目的依赖。
- LICENSE: 项目的许可证。
- README.md: 项目的说明文档。
- Rakefile: 定义Rake任务。
- erb2haml.gemspec: 项目的gemspec文件。
2. 项目的启动文件介绍
项目的启动文件主要是 lib/erb2haml/railtie.rb
,它负责在Rails应用启动时加载erb2haml的相关功能。
require 'erb2haml/railtie'
3. 项目的配置文件介绍
项目的配置文件主要是 erb2haml.gemspec
,它定义了项目的元数据和依赖。
Gem::Specification.new do |spec|
spec.name = "erb2haml"
spec.version = Erb2Haml::VERSION
spec.authors = ["David Leung"]
spec.email = ["david@example.com"]
spec.summary = %q{Simple script to bulk convert ERB files in a Rails app to Haml.}
spec.description = %q{erb2haml gives your Rails app rake tasks to convert or replace all ERB view templates to Haml.}
spec.homepage = "https://github.com/dhl/erb2haml"
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.add_dependency "html2haml", ">= 0"
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
end
这个文件定义了项目的名称、版本、作者、描述、主页、许可证以及依赖项。