Class: Ruboty::Gen::Readme

Inherits:
Object
  • Object
show all
Defined in:
lib/ruboty/gen/readme.rb

Overview

ReadmeGen Core

Constant Summary collapse

README =
'README.md'
RUBOTY_MEGEN_FILE =
'Rubotyme'
RUBOTY_MEGEN_TEMPLATE =
<<-EOS
# encoding: utf-8

# user_name(github user name)
# user_name is required
# user_name allow only String
# user_name's default value => "user_name"
user_name "user_name"

# gem_class_name
# gem_class_name is required
# gem_class_name allow only String
# gem_class_name's default value => "your_gem_class_name"
# ex: SampleGem (Ruboty::SampleGem)
gem_class_name "your_gem_class_name"

# gem_name
# gem_name is required
# gem_name allow only String
# gem_name's default value => "your_gem_name"
# ex: sample_gem (not ruboty-sample_gem)
gem_name "your_gem_name"

# title
# title is required
# title allow only String
# title's default value => "title"
# ex: output N line messages.
title "title"

# you can set multiple ENV variables
env do |e|
  # name
  # name allow only String
  # name's default value => ""
  e.name "environment variable name"

  # description
  # description allow only String
  # description's default value => ""
  e.description ""
end

# you can set multiple dependencies
dependency do |d|
  # name
  # name allow only String
  # name's default value => ""
  d.name ""

  # description
  # description allow only String
  # description's default value => ""
  d.description ""
end

# you can set multiple commands
command do |c|
  # name
  # name allow only String
  # name's default value => ""
  c.name ""

  # pattern
  # pattern allow only String
  # pattern's default value => ""
  c.pattern ""

  # description
  # description allow only String
  # description's default value => ""
  c.description ""

  # example
  # example allow only String
  # example's default value => ""
  c.example ""
end
EOS
RUBOTY_README_TEMPLATE =
<<-EOS
# Ruboty::<%=gem_class_name%>

A Ruboty Handler + Actions to <%=title%>.

[Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'ruboty-<%=gem_name%>'
```

And then execute:

    $ bundle

## Commands

|Command|Pattern|Description|
|:--|:--|:--|
<%=command_table%>

## Usage
<%=usages%>

## ENV

|Name|Description|
|:--|:--|
<%=env_table%>

## Dependency

|Name|Description|
|:--|:--|
<%=dependency_table%>

## Contributing

1. Fork it ( https://github.com/<%=user_name%>/ruboty-<%=gem_name%>/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
EOS
RUBOTY_README_EMOJI_TEMPLATE =
<<-EOS
# Ruboty::<%=gem_class_name%>

A Ruboty Handler + Actions to <%=title%>.

[Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty

## :arrow_down: Installation

Add this line to your application's Gemfile:

```ruby
gem 'ruboty-<%=gem_name%>'
```

And then execute:

    $ bundle

## :cl: Commands

|Command|Pattern|Description|
|:--|:--|:--|
<%=command_table%>

## :scroll: Usage
<%=usages%>

## :earth_asia: ENV

|Name|Description|
|:--|:--|
<%=env_table%>

## :couple: Dependency

|Name|Description|
|:--|:--|
<%=dependency_table%>

## :two_men_holding_hands: Contributing :two_women_holding_hands:

1. Fork it ( https://github.com/<%=user_name%>/ruboty-<%=gem_name%>/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
EOS

Class Method Summary collapse

Class Method Details

.generate(options = {}) ⇒ Object

generate ruboty README.md template.



197
198
199
200
201
202
203
# File 'lib/ruboty/gen/readme.rb', line 197

def self.generate(options = {})
  src = read_dsl
  dsl = Ruboty::Dsl.new
  dsl.instance_eval src
  src = apply(dsl.ruboty_megen, options)
  File.open(README, 'w:utf-8') { |file|file.puts src }
end

.initObject

generate Rubotymegenfile to current directory.



190
191
192
193
194
# File 'lib/ruboty/gen/readme.rb', line 190

def self.init
  File.open(RUBOTY_MEGEN_FILE, 'w') do |f|
    f.puts RUBOTY_MEGEN_TEMPLATE
  end
end