Real World Rails

真实世界的 Rails 应用及其开源代码库,供开发者学习借鉴。「Real World Rails applications and their open source codebases for developers to learn from」

Github stars Tracking Chart

Real World Rails

真实世界(Real World Rails)的 Rails 应用及其开源代码库,供开发者学习借鉴。

这个项目将100多个(并在不断增加)活跃的、开源的 Rails 应用和引擎集中在一个资源库中,使开发者更容易下载收集到的代码库,并从经验丰富的开发者编写的 Rails 应用中学习。阅读开源代码可以成为宝贵的学习辅助工具。你可以在 apps/engines/ 子目录中找到源代码。

Real World Rails 的成立是为了帮助新手开发者学习,并研究和撰写 Rails 开发实践。

  • 找到你不确定的方法的使用示例。
  • 了解其他开发者如何使用你想使用的 gem。
  • 了解如何编写测试。
  • 查看 Rails 引擎是如何构建的
  • ......还有很多很多。

如果你有一个有趣或好玩的想法,想了解这些真实世界的 Rails 应用,请在问题跟踪器上贡献你的想法 -- Eliot Sykes

如何在电脑上安装

# Clone this git repo:
git clone git@github.com:eliotsykes/real-world-rails.git
cd real-world-rails/
# The Rails apps are linked to as git submodules.
# This will take some time...(see comment below for possible speedup)
git submodule update --init
# OR If you've got git 2.9+ installed try to run updates in parallel:
# git submodule update --init --jobs 4
# To run the `bin/rwr` inspectors, install gems:
bundle install
echo "All done! Why not run some inspections? Run bin/rwr"

其他真实世界的代码基集合

如何分析真实世界中的 Rails 应用程序

查找工作子类

这将找到大多数,但不是所有的工作子类(需要ag)。

# Outputs jobs source in terminal
ag --ruby '< [A-Za-z]+Job\b'
# Open each job in your editor (e.g. atom)
ag --ruby -l '< [A-Za-z]+Job\b' | xargs atom

(用于研究 Real World Rails 后台Jobs

列出每个 Real World Rails 应用的模型

有兴趣看看各位开发者朋友是如何为自己的模型命名的吗?运行:

bin/rwr models | sort -f | uniq -c | sort -k 1nr -k 2f

显示每个 Real World Rails 应用的常量

bin/rwr constants

(这对研究 Ruby 中的的魔法数字以及如何让它们消失?有帮助)

显示查看规格

查看每个应用程序中每个视图规格的文件路径和来源。

bin/rwr view-specs

(这将显示 250 多个视图规格,请参见《视图规格大清单》

显示模型方法

只查看模型方法名和文件路径:

bin/rwr model-method-name

参见模型方法源和文件路径:

bin/rwr model-methods

使用 gem 查找项目:

find apps/ -name Gemfile.lock | xargs grep GEM_NAME_GOES_HERE
# e.g. Find all projects using doorkeeper gem
find apps/ -name Gemfile.lock | xargs grep doorkeeper

分析视图命名实践

bin/rwr shared-view-dirs
bin/rwr view-naming

寻找如何配置领班流程(foreman processes)的思路

# Outputs contents from all Procfiles
find apps/ -name 'Procfile*' | xargs cat

Settings

分析 apps/ 之外的目录

在 bin/rwr 命令前面加上 FILES_PATTERN 环境变量:

FILES_PATTERN=~/dev/my-rails-app/**/*.rb bin/rwr

将源输出格式更改为 markdown

在 SOURCE_OUTPUT_FORMAT 环境变量前加上 bin/rwr 前缀:

SOURCE_OUTPUT_FORMAT=markdown bin/rwr view-specs

贡献信息

如何添加一个真实世界的 Rails 应用程序

给定一个 Rails 应用 githubuser/foo 的 GitHub repo:

# Inside real-world-rails root:
git submodule add -b master git@github.com:githubuser/foo.git apps/foo

重新生成 repos.md

# Requires valid GITHUB_ACCESS_TOKEN
bin/get_project_data > repos.md
# OR, if GitHub GraphQL API v4 schema has changed, update cached copy of schema:
FETCH_LATEST_SCHEMA=true bin/get_project_data > repos.md

更新 Rails 应用程序子模块到最新

apps/ 中的 Rails 应用是 git 子模块。Git 子模块被锁定在一个版本上,不会与最新版本保持同步。

要更新修订版,请运行:

# This will take some time:
git submodule foreach git pull

如何删除一个 git 子模块

只有当之前的公共库被删除时,才能使用此功能。

# Remove the submodule from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule from .git/modules
rm -rf .git/modules/path/to/submodule
# Remove from .gitmodules and remove the submodule directory
git rm -f path/to/submodule

编写一个 Inspector?一些文档可以帮助理解 AST,Parser...

Inspector 负责对 Rails 应用进行分析。

如果您正在寻找如何编写新的检查器的信息,请查看现有的检查器,并查看这些 API 文档。

贡献

  • Eliot Sykes https://eliotsykes.com/
  • 欢迎贡献,请将GitHub repo分叉,进行修改,然后提交你的pull请求!如果你想帮忙,请联系我们。如果你想得到一些帮助,请联系我们。


Overview

Name With Ownereliotsykes/real-world-rails
Primary LanguageRuby
Program languageRuby (Language Count: 1)
PlatformLinux, Mac, Windows
License:MIT License
Release Count0
Created At2015-05-02 11:28:52
Pushed At2024-04-13 12:37:51
Last Commit At
Stargazers Count1.7k
Watchers Count33
Fork Count136
Commits Count15.5k
Has Issues Enabled
Issues Count178
Issue Open Count30
Pull Requests Count7582
Pull Requests Open Count19
Pull Requests Close Count211
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Real World Rails

Real World Rails applications and their open source codebases for developers to learn from

This project brings 100+ (and growing) active, open source Rails apps and engines together in one repository, making it easier for developers to download the collected codebases and learn from Rails apps written by experienced developers. Reading open source code can be an invaluable learning aid. You’ll find the source code in the apps/ and engines/ subdirectories.

Real World Rails was begun to help teach newer developers and to research and write about Rails development practices:

  • Find example usage of a method you’re unsure of
  • Learn how other developers use a gem you’d like to use
  • Discover how to write tests
  • See how Rails engines are built
  • …and much, much more.

If you've got an idea for something that'd be interesting or fun to find out about these Real World Rails apps, contribute your idea on the issue trackerEliot Sykes

How to install on your computer

# Clone this git repo:
git clone git@github.com:eliotsykes/real-world-rails.git

cd real-world-rails/

# The Rails apps are linked to as git submodules.
# This will take some time...(see comment below for possible speedup)
git submodule update --init

# OR If you've got git 2.9+ installed try to run updates in parallel:
# git submodule update --init --jobs 4

# To run the `bin/rwr` inspectors, install gems:
bundle install

echo "All done! Why not run some inspections? Run bin/rwr"

Other Real World Codebase Collections

How you can analyze Real World Rails apps

Find job subclasses

This will find most, but not all job subclasses (requires ag):

# Outputs jobs source in terminal
ag --ruby '< [A-Za-z]+Job\b'

# Open each job in your editor (e.g. atom)
ag --ruby -l '< [A-Za-z]+Job\b'
To the top