ruboty-articlegen 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6a10e1146705decf213c969ad5d2227ae020513
4
+ data.tar.gz: abf5a813a045583a34163068f513b077aed00fa6
5
+ SHA512:
6
+ metadata.gz: db0a3178f45d961b1a8a682186b0560c22a484dbcea7fba7b59402c50f85f1e8aea63c42520f5163b027e36fee1cb95961bdd924a6e17a67c4099136744f30f6
7
+ data.tar.gz: 85b1269017039b19dbfcfa05ddc0c76cd679bfebace2481721c237cefc70ff83a5c909abbdb7143b0fd360aab46fdb74aca72e92764bb305a73ecaf61a15cda8
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,114 @@
1
+ # Ruboty::Gen::Article
2
+
3
+ Generate Markdown Article for Ruboty Handler + Actions plugin.
4
+
5
+ [![Build Status](https://travis-ci.org/tbpgr/ruboty-articlegen.png?branch=master)](https://travis-ci.org/tbpgr/ruboty-articlegen)
6
+ [![Coverage Status](https://coveralls.io/repos/tbpgr/ruboty-articlegen/badge.png)](https://coveralls.io/r/tbpgr/ruboty-articlegen)
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-articlegen'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install ruboty-articlegen
25
+
26
+ ## Rubotyme
27
+ ### Setting File Parameters
28
+
29
+ |key|value|example|
30
+ |:--|:--|:--|
31
+ |github_user_name|github user name|tbpgr|
32
+ |rubygems_user_name|rubygems user name|tbpgr|
33
+ |gem_name|gem name|ume|
34
+ |title|タイトル文字列|チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました|
35
+ |purpose|用途|ruboty google_image で妙な画像を引き当ててしまった。<br>そんなときに限って、偉い人が近づいてくる。<br>急いでチャット画面から画像を追い出すんだ。<br><br>内緒のメッセージのやりとり。<br>そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。<br>急いでチャット画面から画像を追い出すんだ。<br>そんな時に空行を大量に追加してメッセージを画面外に追い出します。|
36
+ |env/name|環境変数|DEFAULT_UME_TEXT|
37
+ |env/description|環境変数の説明|default ume text|
38
+ |dependencies/name|依存先名称|Ume API|
39
+ |dependencies/description|依存先説明|Ume API の説明やURL|
40
+ |commands/command name|Ruboty::Handler.on の name に設定する内容 ※件数分|ume|
41
+ |commands/command pattern|Ruboty::Handler.on の pattern に設定する内容 ※件数分|/ume (?<count>.*?)\z/ |
42
+ |commands/command description|Ruboty::Handler.on の description に設定する内容 ※件数分|output empty message N lines (<count> times)|
43
+
44
+ ## Usage
45
+ ### init
46
+ generate Rubotyarticle template file.
47
+
48
+ ~~~
49
+ $ ruboty-articlegen init
50
+ ~~~
51
+
52
+ ### generate
53
+ generate Ruboty Handler + Action Article Markdown template
54
+
55
+ * edit Rubotyme file
56
+
57
+ ~~~ruby
58
+ # encoding: utf-8
59
+ github_user_name "tbpgr"
60
+ rubygems_user_name "tbpgr"
61
+
62
+ gem_name "ume"
63
+
64
+ title "チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました"
65
+
66
+ env do |e|
67
+ e.name "ENV1"
68
+ e.description "ENV1 desc"
69
+ end
70
+
71
+ env do |e|
72
+ e.name "ENV2"
73
+ e.description "ENV2 desc"
74
+ end
75
+
76
+ dependency do |d|
77
+ d.name "dependency1"
78
+ d.description "dependency1 description"
79
+ end
80
+
81
+ dependency do |d|
82
+ d.name "dependency2"
83
+ d.description "dependency2 description"
84
+ end
85
+
86
+ command do |c|
87
+ c.name "ume"
88
+ c.pattern "/ume (?<count>.*?)\z/"
89
+ c.description "output empty message N lines (<count> times)"
90
+ end
91
+
92
+ command do |c|
93
+ c.name "umec"
94
+ c.pattern "/umec (?<text>.+?) (?<count>.*?)\z/"
95
+ c.description "output <text> message N lines (<count> times)"
96
+ end
97
+ ~~~
98
+
99
+ * generate Airticle Markdown
100
+
101
+ ~~~
102
+ $ ruboty-articlegen generate
103
+ ~~~
104
+
105
+ * output
106
+ [sample output ruboty-ume ruboty-ume_article](https://github.com/tbpgr/ruboty-articlegen/blob/master/sample/ruboty-ume.md)
107
+
108
+ ## Contributing
109
+
110
+ 1. Fork it ( https://github.com/tbpgr/ruboty_articlegen/fork )
111
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
112
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
113
+ 4. Push to the branch (`git push origin my-new-feature`)
114
+ 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
@@ -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 Article Markdown template'
15
+ def generate
16
+ Ruboty::Gen::Article.generate
17
+ end
18
+
19
+ desc 'init', 'generate Rubotyme template'
20
+ def init
21
+ Ruboty::Gen::Article.init
22
+ end
23
+
24
+ desc 'version', 'version'
25
+ def version
26
+ p Ruboty::Gen::VERSION
27
+ end
28
+ end
29
+ end
30
+
31
+ Ruboty::CLI.start(ARGV)
@@ -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_articlegen
11
+
12
+ [:user_name, :gem_name, :title, :purpose].each do |f|
13
+ define_method f do |value|
14
+ @ruboty_articlegen.send("#{f}=", value)
15
+ end
16
+ end
17
+
18
+ def env
19
+ e = Ruboty::Models::Env.new
20
+ yield(e)
21
+ @ruboty_articlegen.env << e
22
+ end
23
+
24
+ def dependency
25
+ d = Ruboty::Models::Dependency.new
26
+ yield(d)
27
+ @ruboty_articlegen.dependencies << d
28
+ end
29
+
30
+ def command
31
+ c = Ruboty::Models::Command.new
32
+ yield(c)
33
+ @ruboty_articlegen.commands << c
34
+ end
35
+
36
+ def initialize
37
+ @ruboty_articlegen = Ruboty::DslModel.new
38
+ @ruboty_articlegen.user_name = 'your user_name username'
39
+ @ruboty_articlegen.gem_name = 'your_gem_name'
40
+ @ruboty_articlegen.title = 'title'
41
+ @ruboty_articlegen.purpose = 'purpose'
42
+ @ruboty_articlegen.env = []
43
+ @ruboty_articlegen.dependencies = []
44
+ @ruboty_articlegen.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
+ # title
11
+ attr_accessor :title
12
+
13
+ # gem_name
14
+ attr_accessor :gem_name
15
+
16
+ # purpose
17
+ attr_accessor :purpose
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,235 @@
1
+ # encoding: utf-8
2
+ require 'erb'
3
+
4
+ # rubocop:disable LineLength
5
+ module Ruboty
6
+ module Gen
7
+ # Article
8
+ class Article
9
+ RUBOTY_MEGEN_FILE = 'Rubotyariticle'
10
+ RUBOTY_MEGEN_TEMPLATE = <<-EOS
11
+ # encoding: utf-8
12
+
13
+ # user_name(github user name)
14
+ # user_name is required
15
+ # user_name allow only String
16
+ # user_name's default value => "user_name"
17
+ user_name "user_name"
18
+
19
+ # gem_name
20
+ # gem_name is required
21
+ # gem_name allow only String
22
+ # gem_name's default value => "your_gem_name"
23
+ # ex: sample_gem (not ruboty-sample_gem)
24
+ gem_name "your_gem_name"
25
+
26
+ # title
27
+ # title is required
28
+ # title allow only String
29
+ # title's default value => "title"
30
+ # ex: チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました
31
+ title "title"
32
+
33
+ # purpose
34
+ # purpose is required
35
+ # purpose allow only String
36
+ # purpose's default value => "purpose"
37
+ # ex: ruboty google_image で妙な画像を引き当ててしまった。
38
+ # ex: そんなときに限って、偉い人が近づいてくる。
39
+ # ex: 急いでチャット画面から画像を追い出すんだ。
40
+ # ex:
41
+ # ex: 内緒のメッセージのやりとり。
42
+ # ex: そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。
43
+ # ex: 急いでチャット画面から画像を追い出すんだ。
44
+ # ex:
45
+ # ex: そんな時に空行を大量に追加してメッセージを画面外に追い出します。
46
+ purpose <<-PURPOSE
47
+ plugin の用途を詳細に記述
48
+ PURPOSE
49
+
50
+ # you can set multiple ENV variables
51
+ env do |e|
52
+ # name
53
+ # name allow only String
54
+ # name's default value => ""
55
+ e.name "environment variable name"
56
+
57
+ # description
58
+ # description allow only String
59
+ # description's default value => ""
60
+ e.description ""
61
+ end
62
+
63
+ # you can set multiple dependencies
64
+ dependency do |d|
65
+ # name
66
+ # name allow only String
67
+ # name's default value => ""
68
+ d.name ""
69
+
70
+ # description
71
+ # description allow only String
72
+ # description's default value => ""
73
+ d.description ""
74
+ end
75
+
76
+ # you can set multiple commands
77
+ command do |c|
78
+ # name
79
+ # name allow only String
80
+ c.name ""
81
+
82
+ # pattern
83
+ # pattern allow only String
84
+ c.pattern ""
85
+
86
+ # description
87
+ # description allow only String
88
+ c.description ""
89
+
90
+ # example
91
+ # example allow only String
92
+ c.example ""
93
+ end
94
+ EOS
95
+
96
+ RUBOTY_ARTICLE_TEMPLATE = <<-EOS
97
+ # <%=title%> #ruboty
98
+
99
+ ## 概要
100
+ <%=title%>
101
+
102
+ ## 用途
103
+ <%=purpose%>
104
+ ## Installation
105
+
106
+ Add this line to your application's Gemfile:
107
+
108
+ ```ruby
109
+ gem 'ruboty-<%=gem_name%>'
110
+ ```
111
+
112
+ And then execute:
113
+
114
+ $ bundle
115
+
116
+ Or install it yourself as:
117
+
118
+ $ gem install ruboty-<%=gem_name%>
119
+
120
+ ## Commands
121
+
122
+ |Command|Pattern|Description|
123
+ |:--|:--|:--|
124
+ <%=command_table%>
125
+
126
+ ## Usage
127
+ <%=usages%>
128
+
129
+ ## ENV
130
+
131
+ |Name|Description|
132
+ |:--|:--|
133
+ <%=env_table%>
134
+
135
+ ## Dependency
136
+
137
+ |Name|Description|
138
+ |:--|:--|
139
+ <%=dependency_table%>
140
+
141
+ ## 参照
142
+ * [ruboty-<%=gem_name%> GitHub](https://github.com/<%=user_name%>/ruboty-<%=gem_name%>)
143
+ * [ruboty-<%=gem_name%> RubyGems](http://rubygems.org/gems/ruboty-<%=gem_name%>)
144
+ EOS
145
+
146
+ # generate Rubotyarticlegenfile to current directory.
147
+ def self.init
148
+ File.open(RUBOTY_MEGEN_FILE, 'w') do |f|
149
+ f.puts RUBOTY_MEGEN_TEMPLATE
150
+ end
151
+ end
152
+
153
+ # generate ruboty Article Markdown template.
154
+ def self.generate
155
+ src = read_dsl
156
+ dsl = Ruboty::Dsl.new
157
+ dsl.instance_eval src
158
+ src = apply(dsl.ruboty_articlegen)
159
+ File.open("ruboty-#{dsl.ruboty_articlegen.gem_name}.md", 'w:utf-8') do |file|
160
+ file.puts src
161
+ end
162
+ end
163
+
164
+ def self.read_dsl
165
+ File.open(RUBOTY_MEGEN_FILE) { |f|f.read }
166
+ end
167
+ private_class_method :read_dsl
168
+
169
+ # rubocop:disable UselessAssignment
170
+ def self.apply(config)
171
+ gem_name = config.gem_name
172
+ title = config.title
173
+ command_table = command_table(config.commands)
174
+ usages = usages(config.commands)
175
+ env_table = env_table(config.env)
176
+ dependency_table = dependency_table(config.dependencies)
177
+ user_name = config.user_name
178
+ purpose = config.purpose
179
+
180
+ erb = ERB.new(RUBOTY_ARTICLE_TEMPLATE)
181
+ erb.result(binding)
182
+ end
183
+ private_class_method :apply
184
+ # rubocop:enable UselessAssignment
185
+
186
+ def self.command_table(commands)
187
+ command_table = commands.each_with_object([]) do |e, memo|
188
+ list = ['', e.read_name, e.read_pattern, e.read_description, '']
189
+ list = normalize_markdown_table(list)
190
+ memo << list.join('|')
191
+ end
192
+ command_table.join("\n")
193
+ end
194
+ private_class_method :command_table
195
+
196
+ def self.usages(commands)
197
+ usages = commands.each_with_object([]) do |e, memo|
198
+ name = e.read_name
199
+ description = e.read_description
200
+ example = e.read_example.chomp
201
+ row = ["### #{name}", "* #{description}", '', '~~~', "#{example}", '~~~']
202
+ memo << row.join("\n")
203
+ end
204
+ usages.join("\n\n")
205
+ end
206
+ private_class_method :usages
207
+
208
+ def self.env_table(env)
209
+ env_table = env.each_with_object([]) do |e, memo|
210
+ list = ['', e.read_name, e.read_description, '']
211
+ list = normalize_markdown_table(list)
212
+ memo << list.join('|')
213
+ end
214
+ env_table.join("\n")
215
+ end
216
+ private_class_method :env_table
217
+
218
+ def self.dependency_table(dependencies)
219
+ dependency_table = dependencies.each_with_object([]) do |e, memo|
220
+ list = ['', e.read_name, e.read_description, '']
221
+ list = normalize_markdown_table(list)
222
+ memo << list.join('|')
223
+ end
224
+ dependency_table.join("\n")
225
+ end
226
+ private_class_method :dependency_table
227
+
228
+ def self.normalize_markdown_table(texts)
229
+ texts.map { |e| e.gsub('|', '&#124;') }
230
+ end
231
+ private_class_method :normalize_markdown_table
232
+ end
233
+ end
234
+ end
235
+ # rubocop:enable LineLength
@@ -0,0 +1,7 @@
1
+ # RubotyMegen
2
+ module Ruboty
3
+ # Gen
4
+ module Gen
5
+ VERSION = '1.0.0'
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/article'
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,34 @@
1
+ # encoding: utf-8
2
+
3
+ module Ruboty
4
+ module Models
5
+ # Command
6
+ class Command
7
+ def initialize
8
+ @name, @pattern, @description, @example = ''
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
+ def example(example)
24
+ @example = example
25
+ end
26
+
27
+ [:name, :pattern, :description, :example].each do |m|
28
+ define_method :"read_#{m}" do
29
+ instance_variable_get("@#{m}")
30
+ end
31
+ end
32
+ end
33
+ end
34
+ 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,29 @@
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
+ # rubocop:disable LineLength
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ruboty-articlegen'
9
+ spec.version = Ruboty::Gen::VERSION
10
+ spec.authors = ['tbpgr']
11
+ spec.email = ['tbpgr@tbpgr.jp']
12
+ spec.summary = 'ruboty-articlegen generate ruboty Article Markdown template.'
13
+ spec.description = 'ruboty-articlegen generate ruboty Article Markdown template.'
14
+ spec.homepage = 'https://github.com/tbpgr/ruboty-articlegen'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'thor', '~> 0.18.1'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.6'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'simplecov'
28
+ end
29
+ # rubocop:enable LineLength
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ user_name "tbpgr"
3
+
4
+ gem_name "ume"
5
+
6
+ title "チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました"
7
+ purpose <<-PURPOSE
8
+ ruboty google_image で妙な画像を引き当ててしまった。
9
+ そんなときに限って、偉い人が近づいてくる。
10
+ 急いでチャット画面から画像を追い出すんだ。
11
+
12
+ 内緒のメッセージのやりとり。
13
+ そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。
14
+ 急いでチャット画面から画像を追い出すんだ。
15
+
16
+ そんな時に空行を大量に追加してメッセージを画面外に追い出します。
17
+ PURPOSE
18
+
19
+ env do |e|
20
+ e.name "ENV1"
21
+ e.description "ENV1 desc"
22
+ end
23
+
24
+ env do |e|
25
+ e.name "ENV2"
26
+ e.description "ENV2 desc"
27
+ end
28
+
29
+ dependency do |d|
30
+ d.name "dependency1"
31
+ d.description "dependency1 description"
32
+ end
33
+
34
+ dependency do |d|
35
+ d.name "dependency2"
36
+ d.description "dependency2 description"
37
+ end
38
+
39
+ command do |c|
40
+ c.name "ume"
41
+ c.pattern "/ume (?<count>.*?)\z/"
42
+ c.description "output empty message N lines (<count> times)"
43
+ c.example <<-EXAMPLE
44
+ >ruboty command1
45
+ >result1
46
+ EXAMPLE
47
+ end
48
+
49
+ command do |c|
50
+ c.name "umec"
51
+ c.pattern "/umec (?<text>.+?) (?<count>.*?)\z/"
52
+ c.description "output <text> message N lines (<count> times)"
53
+ c.example <<-EXAMPLE
54
+ >ruboty command2
55
+ >result2
56
+ EXAMPLE
57
+ end
@@ -0,0 +1,73 @@
1
+ # チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました #ruboty
2
+
3
+ ## 概要
4
+ チャットを空メッセージ or 任意のメッセージで埋める ruboty-ume を作成しました
5
+
6
+ ## 用途
7
+ ruboty google_image で妙な画像を引き当ててしまった。
8
+ そんなときに限って、偉い人が近づいてくる。
9
+ 急いでチャット画面から画像を追い出すんだ。
10
+
11
+ 内緒のメッセージのやりとり。
12
+ そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。
13
+ 急いでチャット画面から画像を追い出すんだ。
14
+
15
+ そんな時に空行を大量に追加してメッセージを画面外に追い出します。
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'ruboty-ume'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install ruboty-ume
32
+
33
+ ## Commands
34
+
35
+ |Command|Pattern|Description|
36
+ |:--|:--|:--|
37
+ |ume|/ume (?<count>.*?)z/|output empty message N lines (<count> times)|
38
+ |umec|/umec (?<text>.+?) (?<count>.*?)z/|output <text> message N lines (<count> times)|
39
+
40
+ ## Usage
41
+ ### ume
42
+ * output empty message N lines (<count> times)
43
+
44
+ ~~~
45
+ >ruboty command1
46
+ >result1
47
+ ~~~
48
+
49
+ ### umec
50
+ * output <text> message N lines (<count> times)
51
+
52
+ ~~~
53
+ >ruboty command2
54
+ >result2
55
+ ~~~
56
+
57
+ ## ENV
58
+
59
+ |Name|Description|
60
+ |:--|:--|
61
+ |ENV1|ENV1 desc|
62
+ |ENV2|ENV2 desc|
63
+
64
+ ## Dependency
65
+
66
+ |Name|Description|
67
+ |:--|:--|
68
+ |dependency1|dependency1 description|
69
+ |dependency2|dependency2 description|
70
+
71
+ ## 参照
72
+ * [ruboty-ume GitHub](https://github.com/tbpgr/ruboty-ume)
73
+ * [ruboty-ume RubyGems](http://rubygems.org/gems/ruboty-ume)
@@ -0,0 +1,187 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'ruboty/gen'
4
+
5
+ # rubocop:disable LineLength, UnusedMethodArgument
6
+ describe Ruboty::Gen::Article do
7
+ context :generate do
8
+ let(:tmp) { 'tmp' }
9
+ let(:ruboty_articlegen_template) do
10
+ template = <<-EOS
11
+ # encoding: utf-8
12
+
13
+ user_name 'tbpgr'
14
+ gem_name 'sample_gem'
15
+ title 'チャットを空メッセージ or 任意のメッセージで埋める ruboty-sample_gem を作成しました'
16
+ purpose <<-PURPOSE
17
+ ruboty google_image で妙な画像を引き当ててしまった。
18
+ そんなときに限って、偉い人が近づいてくる。
19
+ 急いでチャット画面から画像を追い出すんだ。
20
+
21
+ 内緒のメッセージのやりとり。
22
+ そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。
23
+ 急いでチャット画面から画像を追い出すんだ。
24
+
25
+ そんな時に空行を大量に追加してメッセージを画面外に追い出します。
26
+ PURPOSE
27
+
28
+ env do |e|
29
+ e.name 'ENV1'
30
+ e.description 'ENV1 description'
31
+ end
32
+
33
+ env do |e|
34
+ e.name 'ENV2'
35
+ e.description 'ENV2 description'
36
+ end
37
+
38
+ dependency do |d|
39
+ d.name 'dependency1 name'
40
+ d.description 'dependency1 description'
41
+ end
42
+
43
+ dependency do |d|
44
+ d.name 'dependency2 name'
45
+ d.description 'dependency2 description'
46
+ end
47
+
48
+ command do |c|
49
+ c.name 'command1'
50
+ c.pattern '/command1 | hoge/'
51
+ c.description 'command1 description'
52
+ c.example <<-EXAMPLE
53
+ >ruboty command1
54
+ >result1
55
+ EXAMPLE
56
+ end
57
+
58
+ command do |c|
59
+ c.name 'command2'
60
+ c.pattern '/command2 | hoge/'
61
+ c.description 'command2 description'
62
+ c.example <<-EXAMPLE
63
+ >ruboty command2
64
+ >result2
65
+ EXAMPLE
66
+ end
67
+ EOS
68
+ template
69
+ end
70
+
71
+ cases = [
72
+ {
73
+ case_no: 1,
74
+ case_title: 'valid case',
75
+ expected: <<-EOS
76
+ # チャットを空メッセージ or 任意のメッセージで埋める ruboty-sample_gem を作成しました #ruboty
77
+
78
+ ## 概要
79
+ チャットを空メッセージ or 任意のメッセージで埋める ruboty-sample_gem を作成しました
80
+
81
+ ## 用途
82
+ ruboty google_image で妙な画像を引き当ててしまった。
83
+ そんなときに限って、偉い人が近づいてくる。
84
+ 急いでチャット画面から画像を追い出すんだ。
85
+
86
+ 内緒のメッセージのやりとり。
87
+ そんなときに限って、内緒のやりとりがばれるとまずい相手が近づいてくる。
88
+ 急いでチャット画面から画像を追い出すんだ。
89
+
90
+ そんな時に空行を大量に追加してメッセージを画面外に追い出します。
91
+
92
+ ## Installation
93
+
94
+ Add this line to your application's Gemfile:
95
+
96
+ ```ruby
97
+ gem 'ruboty-sample_gem'
98
+ ```
99
+
100
+ And then execute:
101
+
102
+ $ bundle
103
+
104
+ Or install it yourself as:
105
+
106
+ $ gem install ruboty-sample_gem
107
+
108
+ ## Commands
109
+
110
+ |Command|Pattern|Description|
111
+ |:--|:--|:--|
112
+ |command1|/command1 &#124; hoge/|command1 description|
113
+ |command2|/command2 &#124; hoge/|command2 description|
114
+
115
+ ## Usage
116
+ ### command1
117
+ * command1 description
118
+
119
+ ~~~
120
+ >ruboty command1
121
+ >result1
122
+ ~~~
123
+
124
+ ### command2
125
+ * command2 description
126
+
127
+ ~~~
128
+ >ruboty command2
129
+ >result2
130
+ ~~~
131
+
132
+ ## ENV
133
+
134
+ |Name|Description|
135
+ |:--|:--|
136
+ |ENV1|ENV1 description|
137
+ |ENV2|ENV2 description|
138
+
139
+ ## Dependency
140
+
141
+ |Name|Description|
142
+ |:--|:--|
143
+ |dependency1 name|dependency1 description|
144
+ |dependency2 name|dependency2 description|
145
+
146
+ ## 参照
147
+ * [ruboty-sample_gem GitHub](https://github.com/tbpgr/ruboty-sample_gem)
148
+ * [ruboty-sample_gem RubyGems](http://rubygems.org/gems/ruboty-sample_gem)
149
+ EOS
150
+ }
151
+ ]
152
+
153
+ cases.each do |c|
154
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
155
+ begin
156
+ case_before c
157
+
158
+ # -- given --
159
+ # nothing
160
+
161
+ # -- when --
162
+ Ruboty::Gen::Article.generate
163
+ actual = File.open('ruboty-sample_gem.md', 'r:utf-8') { |e|e.read }
164
+
165
+ # -- then --
166
+ expect(actual).to eq(c[:expected])
167
+ ensure
168
+ case_after c
169
+ end
170
+ end
171
+
172
+ def case_before(_c)
173
+ FileUtils.mkdir_p(tmp) unless Dir.exist? tmp
174
+ Dir.chdir(tmp)
175
+ File.open(Ruboty::Gen::Article::RUBOTY_MEGEN_FILE, 'w:utf-8') do |file|
176
+ file.puts ruboty_articlegen_template
177
+ end
178
+ end
179
+
180
+ def case_after(_c)
181
+ Dir.chdir('../')
182
+ FileUtils.rm_rf(tmp) if Dir.exist? tmp
183
+ end
184
+ end
185
+ end
186
+ end
187
+ # 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
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-articlegen
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tbpgr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 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-articlegen generate ruboty Article Markdown template.
84
+ email:
85
+ - tbpgr@tbpgr.jp
86
+ executables:
87
+ - ruboty-articlegen
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-articlegen
100
+ - lib/ruboty/dsl.rb
101
+ - lib/ruboty/dsl/dsl.rb
102
+ - lib/ruboty/dsl/dsl_model.rb
103
+ - lib/ruboty/gen.rb
104
+ - lib/ruboty/gen/article.rb
105
+ - lib/ruboty/gen/version.rb
106
+ - lib/ruboty/models.rb
107
+ - lib/ruboty/models/command.rb
108
+ - lib/ruboty/models/dependency.rb
109
+ - lib/ruboty/models/env.rb
110
+ - ruboty-articlegen.gemspec
111
+ - sample/Rubotyariticle
112
+ - sample/ruboty-ume.md
113
+ - spec/ruboty/gen/article_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/tbpgr/ruboty-articlegen
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.3.0
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: ruboty-articlegen generate ruboty Article Markdown template.
139
+ test_files:
140
+ - spec/ruboty/gen/article_spec.rb
141
+ - spec/spec_helper.rb