ruboty-generator 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8bdf08ae3bfa25a63e89ea902d56159b6c94b1e
4
- data.tar.gz: f541ccca6ae1bac79e1bbe0a546b02705d1aa253
3
+ metadata.gz: a7cccfa58a4e11387f69d2c15c0bac73376f6f9c
4
+ data.tar.gz: 614c5adfc9d1d0e867ea7c91a5d6e8fa5529aa3f
5
5
  SHA512:
6
- metadata.gz: 44ca614f32a0b7ea85e21c957bad961ccfa8a95150b8a43ad15e9ba26848aa505852bb53c985c56c2ed0bc869b5e1d6f7eb46b22738ff8e03393107e5ea50f80
7
- data.tar.gz: 187eee4de58f63dc3c03bb99cb3a1f78615b906050576a8d477d124f84f9b9cf9703c6b36d1447f11691cf2f5a376a2d1ed17d58555410935c498a38eff02f35
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
- [![Gem Version](https://badge.fury.io/rb/ruboty-megen.svg)](http://badge.fury.io/rb/ruboty-generator)
5
+ [![Gem Version](https://badge.fury.io/rb/ruboty-generator.svg)](http://badge.fury.io/rb/ruboty-generator)
6
6
  [![Build Status](https://travis-ci.org/tbpgr/ruboty-generator.png?branch=master)](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
@@ -2,6 +2,6 @@
2
2
  module Ruboty
3
3
  # Generator
4
4
  class Generator
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor