ruboty-generator 1.0.1 → 1.0.2
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 +4 -4
- data/README.md +1 -1
- data/lib/ruboty/generator/generate.rb +30 -0
- data/lib/ruboty/generator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7cccfa58a4e11387f69d2c15c0bac73376f6f9c
|
|
4
|
+
data.tar.gz: 614c5adfc9d1d0e867ea7c91a5d6e8fa5529aa3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c831609cbfca0cfbcb9a1f8483708f0bef7c9da550b9ff11b706e3ec1e4b238d8e0fb865221d202b0bb7084d78ce50919781e10836eb8f7173e92982e6dca9df
|
|
7
|
+
data.tar.gz: 2fe47260b044bc4d651e22d3a358036d611fb40a738c0d3a012dec15799b0c03eb95ca4f28a10099a9d4069eaa49b4e4c25b5b4c6a22b6211218877f3ddbde5d
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Generate Ruboty Handler + Actions plugin.
|
|
4
4
|
|
|
5
|
-
[](http://badge.fury.io/rb/ruboty-generator)
|
|
6
6
|
[](https://travis-ci.org/tbpgr/ruboty-generator)
|
|
7
7
|
|
|
8
8
|
[Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
|
|
@@ -7,6 +7,7 @@ module Ruboty
|
|
|
7
7
|
class Generator
|
|
8
8
|
README = 'README.md'
|
|
9
9
|
RUBOTY_GENERATOR_FILE = 'Rubotygenerator'
|
|
10
|
+
RUBOTY_MODULE_FILE = 'lib/ruboty'
|
|
10
11
|
RUBOTY_HANDLER_FILE = 'lib/ruboty/handlers'
|
|
11
12
|
RUBOTY_BASE_FILE = 'lib/ruboty'
|
|
12
13
|
RUBOTY_GENERATOR_FILE_TEMPLATE = <<-EOS
|
|
@@ -29,6 +30,17 @@ command do |c|
|
|
|
29
30
|
end
|
|
30
31
|
EOS
|
|
31
32
|
|
|
33
|
+
RUBOTY_MODULE_TEMPLATE = <<-EOS
|
|
34
|
+
require "ruboty/<%=gem_name%>/version"
|
|
35
|
+
require "ruboty/handlers/<%=gem_name%>"
|
|
36
|
+
|
|
37
|
+
module Ruboty
|
|
38
|
+
module <%=gem_class_name%>
|
|
39
|
+
# Your code goes here...
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
EOS
|
|
43
|
+
|
|
32
44
|
RUBOTY_HANDLER_TEMPLATE = <<-EOS
|
|
33
45
|
<%=action_requires%>
|
|
34
46
|
|
|
@@ -77,6 +89,8 @@ end
|
|
|
77
89
|
def self.generate(options = {})
|
|
78
90
|
config = load_config
|
|
79
91
|
execute_bundle_gem(config)
|
|
92
|
+
module_src = generate_module(config)
|
|
93
|
+
output_module(module_src, config.gem_name)
|
|
80
94
|
handler_src = generate_handler(config, options[:a])
|
|
81
95
|
output_handler(handler_src, config.gem_name)
|
|
82
96
|
return unless options[:a]
|
|
@@ -102,6 +116,22 @@ end
|
|
|
102
116
|
end
|
|
103
117
|
private_class_method :execute_bundle_gem
|
|
104
118
|
|
|
119
|
+
def self.generate_module(config)
|
|
120
|
+
gem_class_name = config.gem_class_name
|
|
121
|
+
gem_name = config.gem_name
|
|
122
|
+
erb = ERB.new(RUBOTY_MODULE_TEMPLATE)
|
|
123
|
+
erb.result(binding)
|
|
124
|
+
end
|
|
125
|
+
private_class_method :generate_module
|
|
126
|
+
|
|
127
|
+
def self.output_module(module_src, module_name)
|
|
128
|
+
module_path = "./ruboty-#{module_name}/#{Ruboty::Generator::RUBOTY_MODULE_FILE}"
|
|
129
|
+
FileUtils.mkdir_p(module_path)
|
|
130
|
+
puts module_src
|
|
131
|
+
File.open("#{module_path}/#{module_name}.rb", 'w:utf-8') { |e| e.puts module_src }
|
|
132
|
+
end
|
|
133
|
+
private_class_method :output_module
|
|
134
|
+
|
|
105
135
|
def self.generate_handler(config, have_actions)
|
|
106
136
|
gem_class_name = config.gem_class_name
|
|
107
137
|
gem_name = config.gem_name
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruboty-generator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tbpgr
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-12-
|
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|