Giter Club home page Giter Club logo

rsgem's Introduction

rsgem - Rootstrap's gem generator

Gem Version ci Maintainability Test Coverage

rsgem is a tool to help you start developing gems with the defaults we use at Rootstrap.

Installation

$ gem install rsgem

We highly suggest to not include rsgem in your Gemfile. rsgem is not a library, and should not affect the dependency tree of your project.

Usage

rsgem new NAME

RSGem will solve the following tasks for you:

  1. Create a folder for your gem leveraging bundler's defaults. (You need bundler in your system)
  2. Add the following dependencies:
  3. Add configuration files for Reek and Rubocop with default Rootstrap's configuration.
  4. Add a rake task to run Rubocop and Reek by calling rake code_analysis.
  5. Clean the Gemfile.
  6. Git ignore the Gemfile.lock
  7. Add a CI provider configuration. GitHub Actions and Travis are available providers. Travis is the default.
  8. Set the bundled files to be a short list of files. By default the gem will bundle:
    • LICENSE.txt
    • README.md
    • lib/**/* (everything inside lib)
  9. Apply Rubocop style fixes

Examples

rsgem new foo

Creates a new gem called foo.

rsgem new bar --ci=github_actions

Creates a new gem called bar that uses Github Actions as the CI provider.

rsgem new foo_bar --bundler=--ext

Creates a new gem called foo_bar and passes the --ext flag to bundler.

rsgem new bar_foo --bundler='--several --flags'

Creates a new gem passing several flags to bundler.

Help

rsgem -h

Displays global help.

rsgem new -h

Displays help for the new command.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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 tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rootstrap/rsgem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rootstrap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

rsgem's People

Contributors

diegous avatar fedeagripa avatar horacio avatar jpascual1994 avatar juan-apa avatar juanmanuelramallo avatar juannferrari avatar mrubi-rootstrap avatar santib avatar testing11223344 avatar vitogit avatar yez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsgem's Issues

Generation process is frozen in macOS

Steps to reproduce

  1. rvm use 2.6.5
  2. gem install bundler
  3. gem install rsgem
  4. cd Documents/rootsrap
  5. rsgem new foo

Expected

foo gem folder is created correctly

Actual

Process is frozen without any output

Add code coverage configuration

Why

We want to generate the gem with the default configuration for code coverage in the spec helper file.

What

Add the code coverage call in the main spec helper file, so that running the tests also generate the coverage.

Add option to add FactoryBot

Why

We want to allow new gems to use Factory Bot when requested

What

Add the FactoryBot dependency to the Rootstrap::Gem#create method. Make sure it's only added when specified by the user

Return an error if bundler is not present in the system

Why

We want to let the user know that bundler was not found in the system when trying to create the gem.

What

Add the exception: true option to the Kernel#system call and rescue the error to display a message to the end user.

Add new rubocop cop defaults

What

Add the following configurations to the default rubocop file:

  • Layout/SpaceAroundMethodCallOperator
  • Lint/RaiseException
  • Lint/StructNewOverride
  • Style/ExponentialNotation

Add a verbosity configuration to the context

Why

We want to provide a clean output to the final user but allow him to see the steps if he desires so

What

Create a configuration attribute in the context object. That attribute should be used to check whether to print something into the standard output or not

Configure CI

Why

We want to provide CI configuration out of the box

What

Update the CI configuration file to provide the basic structure needed.

Notes

Make sure to leave a comment in the file to update with the correct Code Climate ID

Remove gems from Gemfile

Why

We want to follow the tech guides regarding gem development

What

Remove the gems specified in the Gemfile after the project is created

Create CLI

Why

We want users to be able to call this gem's functionality via a command line interface app

What

Create the CLI app to use this gem.

Notes

The gem Thor looks promising

Run bundle install before running rubocop in new project

Steps to reproduce

  1. Using a ruby version without any gems installed in the system
  2. Install bundler
  3. Run gem install rsgem
  4. Run rsgem new testing

Expected

testing gem is created successfully

Actual

An error appears:

Could not find gem 'reek' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)

Notes

Install local dependencies before running rubocop in the new project

Add rake task for code analysis

Why

We want to build top quality projects with static code analysis tools in place by default

What

Add the rake task to run both Reek and Rubocop

Improve CLI output

Why

All CLI gems have a proper CLI output to allow users know what's going on while executing a command.

What

Update the output of the new command to better display information of what's going on.
Nice to have, some colors.

Add cache config for Github Actions

Why

We want to leverage from Github Actions configurations and cache all dependencies.

What

Update both this project GH Actions config and the one delivered in the support folder so that Github Actions can cache the dependencies when running the tests.

Update the files bundled by default

Why

We don't want final users to have all the files from the project

What

Update the gemspec file to have a minimal config like:

  s.files         = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
  s.require_paths = ["lib"]

Update license to use Rootstrap instead of system user name

Why

We want to have Rootstrap legal name by default in license files, as we do in every other OSS project.

What

Update the license file to have Rootstrap name in the copyright section.

Example

The MIT License (MIT)

Copyright (c) 2020 Rootstrap

Permission is hereby granted, ...

Error when working with system's ruby

Steps to reproduce

  1. Linux
  2. No ruby version manager
  3. gem install bundler
  4. gem install rsgem
  5. rsgem new some_name

Expected

Works correctly

Actual

Traceback (most recent call last):
	9: from /usr/local/bin/rsgem:23:in `<main>'
	8: from /usr/local/bin/rsgem:23:in `load'
	7: from /var/lib/gems/2.7.0/gems/rsgem-0.1.2/exe/rsgem:7:in `<top (required)>'
	6: from /var/lib/gems/2.7.0/gems/dry-cli-0.6.0/lib/dry/cli.rb:67:in `call'
	5: from /var/lib/gems/2.7.0/gems/dry-cli-0.6.0/lib/dry/cli.rb:114:in `perform_registry'
	4: from /var/lib/gems/2.7.0/gems/rsgem-0.1.2/lib/rsgem/cli/commands/new.rb:29:in `call'
	3: from /var/lib/gems/2.7.0/gems/rsgem-0.1.2/lib/rsgem/gem.rb:12:in `create'
	2: from /var/lib/gems/2.7.0/gems/rsgem-0.1.2/lib/rsgem/gem.rb:59:in `create_gem'
	1: from /var/lib/gems/2.7.0/gems/rsgem-0.1.2/lib/rsgem/tasks/create_gem.rb:13:in `create'
/var/lib/gems/2.7.0/gems/rsgem-0.1.2/lib/rsgem/tasks/create_gem.rb:13:in ``': No such file or directory - bundle (Errno::ENOENT)

Raise a warning if user does not have a git user set

Why

Gemspec authors config will be empty if the user has not set their git config user.name (or email) , hence making executables (like rubocop) to fail at runtime

What

Raise a warning when the user does not have a git user name, and update the gemspec with a temporary author name, so that the tasks can continue to work properly

Add an option to create gem for Rails

Why

Given we want to ease the start of the development of a gem, we also want to provide the more appropriate defaults for gems that target Rails applications.

What

Investigate the basic structure of a gem targeting a Rails application.
Add the option to the CLI and the tasks needed to fulfil this.
You can also include a link in the readme if there's a good guide to develop gems for Rails apps.

Notes

https://guides.rubyonrails.org/plugins.html

Rename gem to be RSGem

Why

We want to have a real and rememberable name for the gem. It's usage would be:

$ rsgem new NAME

What

Update the gem's name to be RSGem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.