Giter Site home page Giter Site logo

hexx-cli's Introduction

Hexx::CLI

Gem Version Build Status Dependency Status Code Climate Coverage

The module contains:

  • Hexx::CLI::Base - the Thor::Group-based generator, extended by additional helper methods
  • Hexx::CLI::Name - the parser for the generator argument or option.

Installation

Add this line to your application's Gemfile:

# Gemfile
group :development do
  gem "hexx-cli", require: false
end

Then execute:

bundle

Or add it manually:

gem install hexx-cli

Usage

Hexx::CLI::Base

Create custom generator class, inherited from the Hexx::CLI::Base:

class CLI < Hexx::CLI::Base
end

The generator includes Thor::Actions as well as private helper methods:

  • source_path
  • copy_folder
  • from_template

#source_path

The method returns the source path setting for the class.

#copy_folder

The method recursively copies files from the source folder to the desinaton.

copy_folder "source", "target", skip: true

Its behaviour differs from the Thor::Actions directory in two aspects:

  • The leading underscore is authomatically removed from the filename. This makes it possible to copy dotfiles:
source/_.coveralls.yml --> target/.coveralls.yml
  • If the source file has .erb extension, it is treated as the template. Such files are preprocessed by the ruby ERB parser and copied to the destination without .erb extension:
source/spec_helper.rb.erb --> target/spec_helper.rb

#from_template

The method returns the content of ERB-preprocessed template.

from_template "template.erb"

It can be used to append, prepend or inject the content from template to existing files:

append_to_file "filename", from_template("template.erb")

Hexx::CLI::Name

The parser takes the string and decorates it with methods for naming conventions:

name = Hexx::CLI::Name "mammals/carnivores-cats::wildcats.purr"

name.item
# => "wildcat"
name.items
# => "wildcats"
name.file
# => "mammals-carnivores-cats-wildcats.purr"
name.path
# => "mammals/carnivores/cats/wildcats.purr"
name.type
# => "Mammals::Carnivores::Cats::Wildcats.purr"
name.const
# => "Wildcats.purr"
name.namespaces
# => %w(Mammals Carnivores Cats)

Compatibility

Tested under rubies, compatible with MRI 2.0+:

  • MRI 2.0+
  • Rubinius 2+ (2.0 mode only)
  • JRuby-head (2.0 mode only)

Uses RSpec 3.0+ and [hexx-rspec] settings for the test environment.

License

See the MIT LICENSE.

hexx-cli's People

Contributors

nepalez avatar

Watchers

James Cloos avatar Tyler Rollins avatar

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.