Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 61 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,84 @@
# Foobara::EmptyRubyProjectGenerator

TODO: Delete this and the text below, and describe your gem
Generates an empty Ruby project with RuboCop, RSpec, and GitHub Actions already wired up, so you can focus on writing your gem's code rather than setting up boilerplate code.

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
into a gem. Put your Ruby code in the file `lib/foobara/empty_ruby_project_generator`. To experiment with that code,
run `bin/console` for an interactive prompt.
The generated project is ideally meant to be used with Foobara however, it can also be used for non-Foobara projects by deleting Foobara-specific parts after generation.

## Installation

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it
to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with
instructions to install your gem from git if you don't plan to release to RubyGems.org.
The `foobara-empty-ruby-project-generator` is part of the `foob` family of code generators. Installing the `foob` gem will therefore automatically bring in this generator along with all other foobara generators eliminating the need to install the `foobara-empty-ruby-project-generator` gem separately.

Install the gem and add to the application's Gemfile by executing:
Install the gem directly in the terminal:

$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
`$ gem install foob`

If bundler is not being used to manage dependencies, install the gem by executing:
Or add it to your Gemfile:

$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
`$ bundle add foob`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I don't think I've ever used bundle add


## Usage

TODO: Write usage instructions here
Run the generator to create a new project:

## Development
`$ foob g ruby-project -n NAME [options]`

```bash
bundle config --global local.foobara /path/to/foobara
bundle config set disable_local_branch_check true
```
The `-n` flag represents the name of the project to be generated and is required. It accepts either a plain project name or a name in the
`org/project` format:

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
also run `bin/console` for an interactive prompt that will allow you to experiment.
- **Individual account:** `-n my-gem` — creates a project with a single
module e.g. `MyGem`
- **Organization:** `-n my-org/my-gem` — creates a project with a nested
module e.g. `MyOrg::MyGem` and uses `my-org` as the GitHub organization

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
For a full list of available options run:

`$ foob g ruby-project --help`

or

`$ foob help ruby-project`

**Commonly used options:**

| Flag | Description |
|------|-------------|
| `-n, --name` | Project name or org/project (required) |
| `-d, --description` | Project description. Defaults to `"No description. Add one."` |
| `-a, --author-names` | Author name(s) |
| `--author-emails` | Author email(s) |
| `-l, --license` | One of: `MIT`, `Apache-2.0`, `MPL-2.0`, `Apache-2.0 OR MIT` |
| `-u, --use-git` | Initialize a git repository |
| `--push-to-github` | Create a private GitHub repo and push to it |
| `-o, --output-directory` | Where to generate the project. Defaults to the project name |
Comment thread
zhephyn marked this conversation as resolved.

**Example:**

`$ foob g ruby-project -n my-org/my-gem -d "Does something useful" -l MIT --use-git`

The above generator example when run will put the project in the `my-org/my-gem` folder.

Upon running the generator, all projects will have the following structure:

- `lib/` - Contains all files that are loaded via `require` and based on the name you provided when generating the project, this folder will be structured as either `lib/my_org/my_gem.rb` for an organisation project name OR `lib/my_gem.rb` for a plain project name.

- `src/` - Contains your ruby gem code. This is a Foobara-specific convention whereby instead of putting all your code in the `lib/` folder, the actual implementation code lives in `src/` folder while the `lib/` folder is reserved for code that can be required.

If you used the `foobara-empty-ruby-project-generator` gem to generate a non-Foobara Ruby project, you can delete the `src/` folder and place all your code in the `lib/` folder as well as delete any associated Foobara-specific parts.

## Contributing

Bug reports and pull requests are welcome on GitHub
at https://github.com/[USERNAME]/foobara-empty_ruby_project_generator.
Contributions in the form of PRs and issues are always welcome.

To work on an existing issue or submit a PR:

1. Fork the repo and clone it to your local machine
2. Run `bundle install` to install dependencies
3. Run `rake` to ensure that everything works as expected before making any changes.
4. Implement your changes and add tests where applicable
5. Re-run `rake` to make sure that all tests and rubocop pass.
6. Commit, push to GitHub and open a PR for review

## License

This project is licensed under your choice of the Apache-2.0 license or the MIT license.
See [LICENSE.txt](LICENSE.txt) for more info about licensing.
This project is licensed under your choice of the Apache-2.0 license or
the MIT license. See [LICENSE.txt](LICENSE.txt) for more info.
Loading