ruboty-megen 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cce9c8d9074416d20af2fa26b36156b1d7bfd976
4
+ data.tar.gz: 2f839d0ed5cb39ba486cb1a94dfc95b869f86947
5
+ SHA512:
6
+ metadata.gz: 522f3da3c97bde0bc7abb643bf159adc696c1fe905e99c2083400d20bdb86321079c645f18a4fec36f27afe055a95f1a5d1545e98cf5e775ec70ceca58729ef9
7
+ data.tar.gz: c4c9034dfb91d1924630da4824ed61a91e84502d263693581bf973f3396e7e09383f6b8ee3c3e1bea85bc03c2ca846e7d89baa150a2348183c0bc8ffa49a363d
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ ClassLength:
2
+ Enabled: false
3
+ Style/FileName:
4
+ Enabled: false
5
+ Style/TrivialAccessors:
6
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system 2.1.11
4
+ - gem --version
5
+ rvm:
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rspec', '~> 2.14.1'
5
+ gem 'thor', '~> 0.18.1'
6
+ gem 'simplecov', '~> 0.8.2'
7
+ group :test do
8
+ gem 'coveralls', require: false
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tbpgr
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # Ruboty::Gen::Readme
2
+
3
+ Generate README.md for Ruboty Handler + Actions plugin.
4
+
5
+ [![Build Status](https://travis-ci.org/tbpgr/ruboty-megen.png?branch=master)](https://travis-ci.org/tbpgr/ruboty-megen)
6
+ [![Coverage Status](https://coveralls.io/repos/tbpgr/ruboty-megen/badge.png)](https://coveralls.io/r/tbpgr/ruboty-megen)
7
+
8
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'ruboty-megen'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install ruboty-megen
25
+
26
+ ## Rubotyme
27
+ ### Setting File Parameters
28
+
29
+ |key|value|example|
30
+ |:--|:--|:--|
31
+ |user_name|github user name|tbpgr|
32
+ |gem_class_name|gem class name|Ume|
33
+ |gem_name|gem name|ume|
34
+ |title|title|An Ruboty Handler + Actions to output N line messages.|
35
+ |env/name|ENV variable name|DEFAULT_UME_TEXT|
36
+ |env/description|ENV description|default ume text|
37
+ |dependencies/name|dependency name|Ume API|
38
+ |dependencies/description|dependency description|this plugin depend on XXX API ver 1.2.3|
39
+ |commands/command name|Ruboty::Handler.on name|ume|
40
+ |commands/command pattern|Ruboty::Handler.on pattern|/ume (?<count>.*?)\z/ |
41
+ |commands/command description|Ruboty::Handler.on description|output empty message N lines (<count> times)|
42
+
43
+ ## Usage
44
+ ### init
45
+ generate Rubotyme template file.
46
+
47
+ ~~~
48
+ $ ruboty-megen init
49
+ ~~~
50
+
51
+ ### generate
52
+ generate Ruboty Handler + Action README.md template
53
+
54
+ * edit Rubotyme file
55
+
56
+ ~~~ruby
57
+ # encoding: utf-8
58
+ user_name "tbpgr"
59
+
60
+ gem_class_name "Ume"
61
+ gem_name "ume"
62
+
63
+ title "An Ruboty Handler + Actions to output N line messages."
64
+
65
+ env do |e|
66
+ e.name "ENV1"
67
+ e.description "ENV1 desc"
68
+ end
69
+
70
+ env do |e|
71
+ e.name "ENV2"
72
+ e.description "ENV2 desc"
73
+ end
74
+
75
+ dependency do |d|
76
+ d.name "dependency2"
77
+ d.description "dependency2 description"
78
+ end
79
+
80
+ command do |c|
81
+ c.name "ume"
82
+ c.pattern "/ume (?<count>.*?)\z/"
83
+ c.description "output empty message N lines (<count> times)"
84
+ end
85
+
86
+ command do |c|
87
+ c.name "umec"
88
+ c.pattern "/umec (?<text>.+?) (?<count>.*?)\z/"
89
+ c.description "output <text> message N lines (<count> times)"
90
+ end
91
+ ~~~
92
+
93
+ * generate README
94
+
95
+ ~~~
96
+ $ ruboty-megen generate
97
+ ~~~
98
+
99
+ * output
100
+
101
+ [sample output ruboty-ume README](./sample/README.md)
102
+
103
+ ## Contributing
104
+
105
+ 1. Fork it ( https://github.com/tbpgr/ruboty_megen/fork )
106
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
107
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
108
+ 4. Push to the branch (`git push origin my-new-feature`)
109
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+ task default: [:spec]
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ end
data/bin/ruboty-megen ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'ruboty/gen'
5
+ require 'ruboty/gen/version'
6
+ require 'thor'
7
+
8
+ module Ruboty
9
+ # = RubotyMegen CLI
10
+ class CLI < Thor
11
+ class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
12
+ class_option :version, type: :boolean, desc: 'version'
13
+
14
+ desc 'generate', 'Generate README.md template'
15
+ def generate
16
+ Ruboty::Gen::Readme.generate
17
+ end
18
+
19
+ desc 'init', 'generate Rubotyme template'
20
+ def init
21
+ Ruboty::Gen::Readme.init
22
+ end
23
+
24
+ desc 'version', 'version'
25
+ def version
26
+ p Ruboty::VERSION
27
+ end
28
+ end
29
+ end
30
+
31
+ Ruboty::CLI.start(ARGV)
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module RubotyMegen
4
+ # Command
5
+ class Command
6
+ def initialize
7
+ @name, @pattern, @description = ''
8
+ end
9
+
10
+ def name(name)
11
+ @name = name
12
+ end
13
+
14
+ def pattern(pattern)
15
+ @pattern = pattern
16
+ end
17
+
18
+ def description(description)
19
+ @description = description
20
+ end
21
+
22
+ [:name, :pattern, :description].each do |m|
23
+ define_method :"read_#{m}" do
24
+ instance_variable_get("@#{m}")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ module RubotyMegen
4
+ # Dependency
5
+ class Dependency
6
+ def initialize
7
+ @name, @description = ''
8
+ end
9
+
10
+ def name(name)
11
+ @name = name
12
+ end
13
+
14
+ def description(description)
15
+ @description = description
16
+ end
17
+
18
+ [:name, :description].each do |m|
19
+ define_method :"read_#{m}" do
20
+ instance_variable_get("@#{m}")
21
+ end
22
+ end
23
+ end
24
+ end
data/lib/models/env.rb ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module RubotyMegen
4
+ module Models
5
+ # Env
6
+ class Env
7
+ def initialize
8
+ @name, @description = ''
9
+ end
10
+
11
+ def name(name)
12
+ @name = name
13
+ end
14
+
15
+ def description(description)
16
+ @description = description
17
+ end
18
+
19
+ [:name, :description].each do |m|
20
+ define_method :"read_#{m}" do
21
+ instance_variable_get("@#{m}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require 'ruboty/dsl/dsl_model'
3
+ require 'ruboty/models/env'
4
+ require 'ruboty/models/dependency'
5
+ require 'ruboty/models/command'
6
+
7
+ module Ruboty
8
+ # Dsl
9
+ class Dsl
10
+ attr_accessor :ruboty_megen
11
+
12
+ [:user_name, :gem_class_name, :gem_name, :title].each do |f|
13
+ define_method f do |value|
14
+ @ruboty_megen.send("#{f}=", value)
15
+ end
16
+ end
17
+
18
+ def env
19
+ e = Ruboty::Models::Env.new
20
+ yield(e)
21
+ @ruboty_megen.env << e
22
+ end
23
+
24
+ def dependency
25
+ d = Ruboty::Models::Dependency.new
26
+ yield(d)
27
+ @ruboty_megen.dependencies << d
28
+ end
29
+
30
+ def command
31
+ c = Ruboty::Models::Command.new
32
+ yield(c)
33
+ @ruboty_megen.commands << c
34
+ end
35
+
36
+ def initialize
37
+ @ruboty_megen = Ruboty::DslModel.new
38
+ @ruboty_megen.user_name = 'your githbu username'
39
+ @ruboty_megen.gem_class_name = 'your_gem_class_name'
40
+ @ruboty_megen.gem_name = 'your_gem_name'
41
+ @ruboty_megen.title = 'title'
42
+ @ruboty_megen.env = []
43
+ @ruboty_megen.dependencies = []
44
+ @ruboty_megen.commands = []
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ # rubocop:disable LineLength
4
+ module Ruboty
5
+ # DslModel
6
+ class DslModel
7
+ # user_name
8
+ attr_accessor :user_name
9
+
10
+ # gem_class_name
11
+ attr_accessor :gem_class_name
12
+
13
+ # title
14
+ attr_accessor :title
15
+
16
+ # gem_name
17
+ attr_accessor :gem_name
18
+
19
+ # env
20
+ attr_accessor :env
21
+
22
+ # dependencies
23
+ attr_accessor :dependencies
24
+
25
+ # commands
26
+ attr_accessor :commands
27
+ end
28
+ end
29
+ # rubocop:enable LineLength
data/lib/ruboty/dsl.rb ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'ruboty/dsl/dsl'
3
+ require 'ruboty/dsl/dsl_model'
@@ -0,0 +1,226 @@
1
+ # encoding: utf-8
2
+ require 'erb'
3
+
4
+ module Ruboty
5
+ module Gen
6
+ # ReadmeGen Core
7
+ class Readme
8
+ # rubocop:disable LineLength
9
+ README = 'README.md'
10
+ RUBOTY_MEGEN_FILE = 'Rubotyme'
11
+ RUBOTY_MEGEN_TEMPLATE = <<-EOS
12
+ # encoding: utf-8
13
+
14
+ # user_name(github user name)
15
+ # user_name is required
16
+ # user_name allow only String
17
+ # user_name's default value => "user_name"
18
+ user_name "user_name"
19
+
20
+ # gem_class_name
21
+ # gem_class_name is required
22
+ # gem_class_name allow only String
23
+ # gem_class_name's default value => "your_gem_class_name"
24
+ # ex: SampleGem (Ruboty::SampleGem)
25
+ gem_class_name "your_gem_class_name"
26
+
27
+ # gem_name
28
+ # gem_name is required
29
+ # gem_name allow only String
30
+ # gem_name's default value => "your_gem_name"
31
+ # ex: sample_gem (not ruboty-sample_gem)
32
+ gem_name "your_gem_name"
33
+
34
+ # title
35
+ # title is required
36
+ # title allow only String
37
+ # title's default value => "title"
38
+ # ex: output N line messages.
39
+ title "title"
40
+
41
+ # you can set multiple ENV variables
42
+ env do |e|
43
+ # name
44
+ # name allow only String
45
+ # name's default value => ""
46
+ e.name "environment variable name"
47
+
48
+ # description
49
+ # description allow only String
50
+ # description's default value => ""
51
+ e.description ""
52
+ end
53
+
54
+ # you can set multiple dependencies
55
+ dependency do |d|
56
+ # name
57
+ # name allow only String
58
+ # name's default value => ""
59
+ d.name ""
60
+
61
+ # description
62
+ # description allow only String
63
+ # description's default value => ""
64
+ d.description ""
65
+ end
66
+
67
+ # you can set multiple commands
68
+ command do |c|
69
+ # name
70
+ # name allow only String
71
+ # name's default value => ""
72
+ c.name ""
73
+
74
+ # pattern
75
+ # pattern allow only String
76
+ # pattern's default value => ""
77
+ c.pattern ""
78
+
79
+ # description
80
+ # description allow only String
81
+ # description's default value => ""
82
+ c.description ""
83
+ end
84
+ EOS
85
+
86
+ RUBOTY_README_TEMPLATE = <<-EOS
87
+ # Ruboty::<%=gem_class_name%>
88
+
89
+ An Ruboty Handler + Actions to <%=title%>.
90
+
91
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
92
+
93
+ ## Installation
94
+
95
+ Add this line to your application's Gemfile:
96
+
97
+ ```ruby
98
+ gem 'ruboty-<%=gem_name%>'
99
+ ```
100
+
101
+ And then execute:
102
+
103
+ $ bundle
104
+
105
+ Or install it yourself as:
106
+
107
+ $ gem install ruboty-<%=gem_name%>
108
+
109
+
110
+ ## Commands
111
+
112
+ |Command|Pattern|Description|
113
+ |:--|:--|:--|
114
+ <%=command_table%>
115
+
116
+ ## Usage
117
+ <%=usages%>
118
+
119
+ ## ENV
120
+
121
+ |Name|Description|
122
+ |:--|:--|
123
+ <%=env_table%>
124
+
125
+ ## Dependency
126
+
127
+ |Name|Description|
128
+ |:--|:--|
129
+ <%=dependency_table%>
130
+
131
+ ## Contributing
132
+
133
+ 1. Fork it ( https://github.com/<%=user_name%>/ruboty-<%=gem_name%>/fork )
134
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
135
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
136
+ 4. Push to the branch (`git push origin my-new-feature`)
137
+ 5. Create a new Pull Request
138
+ EOS
139
+ # rubocop:enable LineLength
140
+
141
+ # generate Rubotymegenfile to current directory.
142
+ def self.init
143
+ File.open(RUBOTY_MEGEN_FILE, 'w') do |f|
144
+ f.puts RUBOTY_MEGEN_TEMPLATE
145
+ end
146
+ end
147
+
148
+ # generate ruboty README.md template.
149
+ def self.generate
150
+ src = read_dsl
151
+ dsl = Ruboty::Dsl.new
152
+ dsl.instance_eval src
153
+ src = apply(dsl.ruboty_megen)
154
+ File.open(README, 'w:utf-8') { |file|file.puts src }
155
+ end
156
+
157
+ def self.read_dsl
158
+ File.open(RUBOTY_MEGEN_FILE) { |f|f.read }
159
+ end
160
+ private_class_method :read_dsl
161
+
162
+ # rubocop:disable UselessAssignment
163
+ def self.apply(config)
164
+ gem_class_name = config.gem_class_name
165
+ gem_name = config.gem_name
166
+ title = config.title
167
+ command_table = command_table(config.commands)
168
+ usages = usages(config.commands)
169
+ env_table = env_table(config.env)
170
+ dependency_table = dependency_table(config.dependencies)
171
+ user_name = config.user_name
172
+
173
+ erb = ERB.new(RUBOTY_README_TEMPLATE)
174
+ erb.result(binding)
175
+ end
176
+ private_class_method :apply
177
+ # rubocop:enable UselessAssignment
178
+
179
+ def self.command_table(commands)
180
+ command_table = commands.each_with_object([]) do |e, memo|
181
+ list = ['', e.read_name, e.read_pattern, e.read_description, '']
182
+ list = normalize_markdown_table(list)
183
+ memo << list.join('|')
184
+ end
185
+ command_table.join("\n")
186
+ end
187
+ private_class_method :command_table
188
+
189
+ def self.usages(commands)
190
+ usages = commands.each_with_object([]) do |e, memo|
191
+ name = e.read_name
192
+ description = e.read_description
193
+ row = ["### #{name}", "* #{description}", '', '~~~', '', '~~~']
194
+ memo << row.join("\n")
195
+ end
196
+ usages.join("\n\n")
197
+ end
198
+ private_class_method :usages
199
+
200
+ def self.env_table(env)
201
+ env_table = env.each_with_object([]) do |e, memo|
202
+ list = ['', e.read_name, e.read_description, '']
203
+ list = normalize_markdown_table(list)
204
+ memo << list.join('|')
205
+ end
206
+ env_table.join("\n")
207
+ end
208
+ private_class_method :env_table
209
+
210
+ def self.dependency_table(dependencies)
211
+ dependency_table = dependencies.each_with_object([]) do |e, memo|
212
+ list = ['', e.read_name, e.read_description, '']
213
+ list = normalize_markdown_table(list)
214
+ memo << list.join('|')
215
+ end
216
+ dependency_table.join("\n")
217
+ end
218
+ private_class_method :dependency_table
219
+
220
+ def self.normalize_markdown_table(texts)
221
+ texts.map { |e| e.gsub('|', '&#124;') }
222
+ end
223
+ private_class_method :normalize_markdown_table
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,7 @@
1
+ # RubotyMegen
2
+ module Ruboty
3
+ # Gen
4
+ module Gen
5
+ VERSION = '0.0.1'
6
+ end
7
+ end
data/lib/ruboty/gen.rb ADDED
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require 'ruboty/gen'
3
+ require 'ruboty/gen/readme'
4
+ require 'ruboty/gen/version'
5
+ require 'ruboty/dsl'
6
+ require 'ruboty/models'
7
+
8
+ module Ruboty
9
+ # Generator
10
+ module Gen
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module Ruboty
4
+ module Models
5
+ # Command
6
+ class Command
7
+ def initialize
8
+ @name, @pattern, @description = ''
9
+ end
10
+
11
+ def name(name)
12
+ @name = name
13
+ end
14
+
15
+ def pattern(pattern)
16
+ @pattern = pattern
17
+ end
18
+
19
+ def description(description)
20
+ @description = description
21
+ end
22
+
23
+ [:name, :pattern, :description].each do |m|
24
+ define_method :"read_#{m}" do
25
+ instance_variable_get("@#{m}")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Ruboty
4
+ module Models
5
+ # Dependency
6
+ class Dependency
7
+ def initialize
8
+ @name, @description = ''
9
+ end
10
+
11
+ def name(name)
12
+ @name = name
13
+ end
14
+
15
+ def description(description)
16
+ @description = description
17
+ end
18
+
19
+ [:name, :description].each do |m|
20
+ define_method :"read_#{m}" do
21
+ instance_variable_get("@#{m}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Ruboty
4
+ module Models
5
+ # Env
6
+ class Env
7
+ def initialize
8
+ @name, @description = ''
9
+ end
10
+
11
+ def name(name)
12
+ @name = name
13
+ end
14
+
15
+ def description(description)
16
+ @description = description
17
+ end
18
+
19
+ [:name, :description].each do |m|
20
+ define_method :"read_#{m}" do
21
+ instance_variable_get("@#{m}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require 'ruboty/models/command'
3
+ require 'ruboty/models/env'
4
+ require 'ruboty/models/dependency'
5
+
6
+ module Ruboty
7
+ # Models
8
+ module Models
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/gen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ruboty-megen'
8
+ spec.version = Ruboty::Gen::VERSION
9
+ spec.authors = ['tbpgr']
10
+ spec.email = ['tbpgr@tbpgr.jp']
11
+ spec.summary = 'ruboty-megen generate ruboty README.md template.'
12
+ spec.description = 'ruboty-megen generate ruboty README.md template.'
13
+ spec.homepage = 'https://github.com/tbpgr/ruboty-megen'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'thor', '~> 0.18.1'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'simplecov'
27
+ end
data/sample/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Ruboty::Ume
2
+
3
+ An Ruboty Handler + Actions to An Ruboty Handler + Actions to output N line messages..
4
+
5
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ruboty-ume'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ruboty-ume
22
+
23
+
24
+ ## Commands
25
+
26
+ |Command|Pattern|Description|
27
+ |:--|:--|:--|
28
+ |ume|/ume (?<count>.*?)z/|output empty message N lines (<count> times)|
29
+ |umec|/umec (?<text>.+?) (?<count>.*?)z/|output <text> message N lines (<count> times)|
30
+
31
+ ## Usage
32
+ ### ume
33
+ * output empty message N lines (<count> times)
34
+
35
+ ~~~
36
+
37
+ ~~~
38
+
39
+ ### umec
40
+ * output <text> message N lines (<count> times)
41
+
42
+ ~~~
43
+
44
+ ~~~
45
+
46
+ ## ENV
47
+
48
+ |Name|Description|
49
+ |:--|:--|
50
+ |ENV1|ENV1 desc|
51
+ |ENV2|ENV2 desc|
52
+
53
+ ## Dependency
54
+
55
+ |Name|Description|
56
+ |:--|:--|
57
+ |dependency2|dependency2 description|
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/tbpgr/ruboty-ume/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
data/sample/Rubotyme ADDED
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ user_name "tbpgr"
3
+
4
+ gem_class_name "Ume"
5
+ gem_name "ume"
6
+
7
+ title "An Ruboty Handler + Actions to output N line messages."
8
+
9
+ env do |e|
10
+ e.name "ENV1"
11
+ e.description "ENV1 desc"
12
+ end
13
+
14
+ env do |e|
15
+ e.name "ENV2"
16
+ e.description "ENV2 desc"
17
+ end
18
+
19
+ dependency do |d|
20
+ d.name "dependency2"
21
+ d.description "dependency2 description"
22
+ end
23
+
24
+ command do |c|
25
+ c.name "ume"
26
+ c.pattern "/ume (?<count>.*?)\z/"
27
+ c.description "output empty message N lines (<count> times)"
28
+ end
29
+
30
+ command do |c|
31
+ c.name "umec"
32
+ c.pattern "/umec (?<text>.+?) (?<count>.*?)\z/"
33
+ c.description "output <text> message N lines (<count> times)"
34
+ end
@@ -0,0 +1,165 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'ruboty/gen'
4
+ # require 'ruboty/models/env'
5
+ # require 'ruboty/models/dependency'
6
+ # require 'ruboty/models/command'
7
+
8
+ # rubocop:disable LineLength, UnusedMethodArgument
9
+ describe Ruboty::Gen::Readme do
10
+ context :generate do
11
+ let(:tmp) { 'tmp' }
12
+ let(:ruboty_megen_template) do
13
+ template = <<-EOS
14
+ # encoding: utf-8
15
+
16
+ user_name 'tbpgr'
17
+ gem_class_name 'SampleGem'
18
+ gem_name 'sample_gem'
19
+ title 'output sample messages'
20
+
21
+ env do |e|
22
+ e.name 'ENV1'
23
+ e.description 'ENV1 description'
24
+ end
25
+
26
+ env do |e|
27
+ e.name 'ENV2'
28
+ e.description 'ENV2 description'
29
+ end
30
+
31
+ dependency do |d|
32
+ d.name 'dependency1 name'
33
+ d.description 'dependency1 description'
34
+ end
35
+
36
+ dependency do |d|
37
+ d.name 'dependency2 name'
38
+ d.description 'dependency2 description'
39
+ end
40
+
41
+ command do |c|
42
+ c.name 'command1'
43
+ c.pattern '/command1 | hoge/'
44
+ c.description 'command1 description'
45
+ end
46
+
47
+ command do |c|
48
+ c.name 'command2'
49
+ c.pattern '/command2 | hoge/'
50
+ c.description 'command2 description'
51
+ end
52
+ EOS
53
+ template
54
+ end
55
+
56
+ cases = [
57
+ {
58
+ case_no: 1,
59
+ case_title: 'valid case',
60
+ expected: <<-EOS
61
+ # Ruboty::SampleGem
62
+
63
+ An Ruboty Handler + Actions to output sample messages.
64
+
65
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
66
+
67
+ ## Installation
68
+
69
+ Add this line to your application's Gemfile:
70
+
71
+ ```ruby
72
+ gem 'ruboty-sample_gem'
73
+ ```
74
+
75
+ And then execute:
76
+
77
+ $ bundle
78
+
79
+ Or install it yourself as:
80
+
81
+ $ gem install ruboty-sample_gem
82
+
83
+
84
+ ## Commands
85
+
86
+ |Command|Pattern|Description|
87
+ |:--|:--|:--|
88
+ |command1|/command1 &#124; hoge/|command1 description|
89
+ |command2|/command2 &#124; hoge/|command2 description|
90
+
91
+ ## Usage
92
+ ### command1
93
+ * command1 description
94
+
95
+ ~~~
96
+
97
+ ~~~
98
+
99
+ ### command2
100
+ * command2 description
101
+
102
+ ~~~
103
+
104
+ ~~~
105
+
106
+ ## ENV
107
+
108
+ |Name|Description|
109
+ |:--|:--|
110
+ |ENV1|ENV1 description|
111
+ |ENV2|ENV2 description|
112
+
113
+ ## Dependency
114
+
115
+ |Name|Description|
116
+ |:--|:--|
117
+ |dependency1 name|dependency1 description|
118
+ |dependency2 name|dependency2 description|
119
+
120
+ ## Contributing
121
+
122
+ 1. Fork it ( https://github.com/tbpgr/ruboty-sample_gem/fork )
123
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
124
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
125
+ 4. Push to the branch (`git push origin my-new-feature`)
126
+ 5. Create a new Pull Request
127
+ EOS
128
+ }
129
+ ]
130
+
131
+ cases.each do |c|
132
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
133
+ begin
134
+ case_before c
135
+
136
+ # -- given --
137
+ # nothing
138
+
139
+ # -- when --
140
+ Ruboty::Gen::Readme.generate
141
+ actual = File.open(Ruboty::Gen::Readme::README, 'r:utf-8') { |e|e.read }
142
+
143
+ # -- then --
144
+ expect(actual).to eq(c[:expected])
145
+ ensure
146
+ case_after c
147
+ end
148
+ end
149
+
150
+ def case_before(_c)
151
+ FileUtils.mkdir_p(tmp) unless Dir.exist? tmp
152
+ Dir.chdir(tmp)
153
+ File.open(Ruboty::Gen::Readme::RUBOTY_MEGEN_FILE, 'w:utf-8') do |file|
154
+ file.puts ruboty_megen_template
155
+ end
156
+ end
157
+
158
+ def case_after(_c)
159
+ Dir.chdir('../')
160
+ FileUtils.rm_rf(tmp) if Dir.exist? tmp
161
+ end
162
+ end
163
+ end
164
+ end
165
+ # rubocop:enable LineLength, UnusedMethodArgument
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
11
+ end
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+ end
data/tudu/doings ADDED
@@ -0,0 +1 @@
1
+ implement 'ruboty_megen_core_spec.rb'.
data/tudu/dones ADDED
File without changes
data/tudu/todos ADDED
@@ -0,0 +1,12 @@
1
+ implement 'ruboty_megen_core.rb' your main logic. pass rspec all specs.
2
+ implement bin 'bin/ruboty_megen'.
3
+ edit 'ruboty_megen.gemspec'.
4
+ edit 'README.md'.
5
+ edit 'LICENSE.txt'.
6
+ git add, commit.
7
+ rake install.
8
+ check gem(test using).
9
+ gem uninstall ruboty_megen.
10
+ rake release.
11
+ gem install ruboty_megen.
12
+ after release check.
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-megen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - tbpgr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ruboty-megen generate ruboty README.md template.
84
+ email:
85
+ - tbpgr@tbpgr.jp
86
+ executables:
87
+ - ruboty-megen
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - .rubocop.yml
94
+ - .travis.yml
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/ruboty-megen
100
+ - lib/models/command.rb
101
+ - lib/models/dependency.rb
102
+ - lib/models/env.rb
103
+ - lib/ruboty/dsl.rb
104
+ - lib/ruboty/dsl/dsl.rb
105
+ - lib/ruboty/dsl/dsl_model.rb
106
+ - lib/ruboty/gen.rb
107
+ - lib/ruboty/gen/readme.rb
108
+ - lib/ruboty/gen/version.rb
109
+ - lib/ruboty/models.rb
110
+ - lib/ruboty/models/command.rb
111
+ - lib/ruboty/models/dependency.rb
112
+ - lib/ruboty/models/env.rb
113
+ - ruboty-megen.gemspec
114
+ - sample/README.md
115
+ - sample/Rubotyme
116
+ - spec/ruboty/gen/readme_spec.rb
117
+ - spec/spec_helper.rb
118
+ - tudu/doings
119
+ - tudu/dones
120
+ - tudu/todos
121
+ homepage: https://github.com/tbpgr/ruboty-megen
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.3.0
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: ruboty-megen generate ruboty README.md template.
145
+ test_files:
146
+ - spec/ruboty/gen/readme_spec.rb
147
+ - spec/spec_helper.rb