ruboty-gen 1.0.1 → 1.1.0
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 +75 -5
- data/lib/ruboty/gen/cli.rb +3 -2
- data/lib/ruboty/gen/gem.rb +18 -4
- data/lib/ruboty/gen/version.rb +1 -1
- data/templates/newgem/lib/newgem.rb.tt +0 -1
- data/templates/ruboty/handlers/newgem.rb.tt +13 -3
- data/templates/ruboty/newgem/actions/newgem.rb.tt +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: 008edf104512ebfafab0d77002e02c3e0f96d195
|
4
|
+
data.tar.gz: b7179803f61b57615355ec38896d723b73d2ec8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a34deaf81cf1af040b25bad3098c2e7d2a18e2888ee56f33c0d0eaba640fd3b492c5a16322945231cdd4b96b5cfb276d89175d14003c3e658adf0ca4def957dc
|
7
|
+
data.tar.gz: f21c86e410cbcdc61f8d6f2bc512909aa25968b50dcccf2183049a3061ab2aeb612c9a2c544a84f1919586a43794cbc250e7aafb503138223cc0b73212e0448d
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
```
|
24
24
|
∩ ∩ ∠ i’m at ~/src/github.com/blockgiven
|
25
|
-
( ╹x╹) ruboty-gen gem yo
|
25
|
+
( ╹x╹) ruboty-gen gem yo action1 action2
|
26
26
|
create ruboty-yo/Gemfile
|
27
27
|
create ruboty-yo/Rakefile
|
28
28
|
create ruboty-yo/LICENSE.txt
|
@@ -33,7 +33,8 @@ Or install it yourself as:
|
|
33
33
|
create ruboty-yo/lib/ruboty/yo/version.rb
|
34
34
|
Initializing git repo in /Users/block_given/src/github.com/blockgiven/ruboty-yo
|
35
35
|
create ruboty-yo/lib/ruboty/handlers/yo.rb
|
36
|
-
create ruboty-yo/lib/ruboty/yo/actions/
|
36
|
+
create ruboty-yo/lib/ruboty/yo/actions/action1.rb
|
37
|
+
create ruboty-yo/lib/ruboty/yo/actions/action2.rb
|
37
38
|
∩ ∩ ∠ i’m at ~/src/github.com/blockgiven
|
38
39
|
( ╹x╹) cd ruboty-yo
|
39
40
|
∩ ∩ ∠ i’m at ~/src/github.com/blockgiven/ruboty-yo [master] ✗
|
@@ -49,14 +50,83 @@ Initializing git repo in /Users/block_given/src/github.com/blockgiven/ruboty-yo
|
|
49
50
|
│ │ └── yo.rb
|
50
51
|
│ ├── yo
|
51
52
|
│ │ ├── actions
|
52
|
-
│ │ │
|
53
|
+
│ │ │ ├── action1.rb
|
54
|
+
│ │ │ └── action2.rb
|
53
55
|
│ │ └── version.rb
|
54
56
|
│ └── yo.rb
|
55
57
|
└── ruboty-yo.gemspec
|
56
58
|
|
57
|
-
5 directories,
|
59
|
+
5 directories, 10 files
|
58
60
|
```
|
59
|
-
|
61
|
+
|
62
|
+
* ./lib/ruboty/yo.rb (generated code)
|
63
|
+
|
64
|
+
~~~ruby
|
65
|
+
require "ruboty/yo/version"
|
66
|
+
require "ruboty/handlers/yo"
|
67
|
+
|
68
|
+
module Ruboty
|
69
|
+
module Yo
|
70
|
+
# Your code goes here...
|
71
|
+
end
|
72
|
+
end
|
73
|
+
~~~
|
74
|
+
|
75
|
+
* ./lib/ruboty/handlers/yo.rb (generated code)
|
76
|
+
|
77
|
+
~~~ruby
|
78
|
+
require "ruboty/yo/actions/action1"
|
79
|
+
require "ruboty/yo/actions/action2"
|
80
|
+
|
81
|
+
module Ruboty
|
82
|
+
module Handlers
|
83
|
+
class Yo < Base
|
84
|
+
on /yo action1/, name: 'action1', description: 'TODO: write your description'
|
85
|
+
on /yo action2/, name: 'action2', description: 'TODO: write your description'
|
86
|
+
|
87
|
+
def action1(message)
|
88
|
+
Ruboty::Yo::Actions::Action1.new(message).call
|
89
|
+
end
|
90
|
+
|
91
|
+
def action2(message)
|
92
|
+
Ruboty::Yo::Actions::Action2.new(message).call
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
~~~
|
98
|
+
|
99
|
+
* ./lib/ruboty/yo/actions/action1.rb (generated code)
|
100
|
+
|
101
|
+
~~~ruby
|
102
|
+
module Ruboty
|
103
|
+
module Yo
|
104
|
+
module Actions
|
105
|
+
class Action1 < Ruboty::Actions::Base
|
106
|
+
def call
|
107
|
+
message.reply("TODO: write a message.")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
~~~
|
114
|
+
|
115
|
+
* ./lib/ruboty/yo/actions/action2.rb (generated code)
|
116
|
+
|
117
|
+
~~~ruby
|
118
|
+
module Ruboty
|
119
|
+
module Yo
|
120
|
+
module Actions
|
121
|
+
class Action2 < Ruboty::Actions::Base
|
122
|
+
def call
|
123
|
+
message.reply("TODO: write a message.")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
~~~
|
60
130
|
|
61
131
|
## Contributing
|
62
132
|
|
data/lib/ruboty/gen/cli.rb
CHANGED
@@ -20,9 +20,10 @@ module Ruboty
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a ruboty plugin"
|
23
|
-
def gem(name)
|
23
|
+
def gem(name, *actions)
|
24
|
+
actions = [name] if actions.size.zero?
|
24
25
|
Bundler::CLI::Gem.new(options, "ruboty-#{name}", self).run
|
25
|
-
Ruboty::Gen::Gem.new(options, name, self).run
|
26
|
+
Ruboty::Gen::Gem.new(options, name, actions, self).run
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
data/lib/ruboty/gen/gem.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Gen
|
3
3
|
class Gem
|
4
|
-
attr_reader :options, :ruboty_plugin_name, :thor
|
4
|
+
attr_reader :options, :ruboty_plugin_name, :actions, :thor
|
5
5
|
|
6
|
-
def initialize(options, ruboty_plugin_name, thor)
|
6
|
+
def initialize(options, ruboty_plugin_name, actions, thor)
|
7
7
|
@options = options
|
8
8
|
@ruboty_plugin_name = ruboty_plugin_name.chomp("/")
|
9
|
+
@actions = actions
|
9
10
|
@thor = thor
|
10
11
|
end
|
11
12
|
|
@@ -21,6 +22,8 @@ module Ruboty
|
|
21
22
|
constant_array = constant_name.split('::')
|
22
23
|
git_user_name = `git config user.name`.chomp
|
23
24
|
git_user_email = `git config user.email`.chomp
|
25
|
+
constant_actions = actions.map { |e|camelize(e) }
|
26
|
+
|
24
27
|
opts = {
|
25
28
|
:name => name,
|
26
29
|
:ruboty_plugin_name => ruboty_plugin_name,
|
@@ -33,11 +36,22 @@ module Ruboty
|
|
33
36
|
:author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
|
34
37
|
:email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
|
35
38
|
:test => options[:test],
|
36
|
-
:ext => options[:ext]
|
39
|
+
:ext => options[:ext],
|
40
|
+
:actions => actions,
|
41
|
+
:constant_actions => constant_actions
|
37
42
|
}
|
38
43
|
|
39
44
|
thor.template(File.join('ruboty/handlers/newgem.rb.tt'), File.join(target, "lib/ruboty/handlers/#{ruboty_plugin_name}.rb"), opts)
|
40
|
-
|
45
|
+
actions.each do |action|
|
46
|
+
opts[:constant_action] = camelize(action)
|
47
|
+
thor.template(File.join('ruboty/newgem/actions/newgem.rb.tt'), File.join(target, "lib/ruboty/#{ruboty_plugin_name}/actions/#{action}.rb"), opts)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def camelize(text)
|
54
|
+
text.split('_').map { |e|e.capitalize }.join
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
data/lib/ruboty/gen/version.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "<%=config[:namespaced_path]%>/version"
|
2
2
|
require "ruboty/handlers/<%= config[:name].gsub(/^ruboty-/, '') %>"
|
3
|
-
require "ruboty/<%= config[:name].gsub(/^ruboty-/, '') %>/actions/<%= config[:name].gsub(/^ruboty-/, '') %>"
|
4
3
|
<%- if config[:ext] -%>
|
5
4
|
require "<%=config[:namespaced_path]%>/<%=config[:underscored_name]%>"
|
6
5
|
<%- end -%>
|
@@ -1,11 +1,21 @@
|
|
1
|
+
<%- if config[:actions] -%>
|
2
|
+
<%- config[:actions].each do |action| -%>
|
3
|
+
require "ruboty/<%= config[:name].gsub(/^ruboty-/, '') %>/actions/<%= action %>"
|
4
|
+
<%- end -%>
|
5
|
+
<%- end -%>
|
6
|
+
|
1
7
|
module Ruboty
|
2
8
|
module Handlers
|
3
9
|
class <%= config[:ruboty_plugin_constant_name] %> < Base
|
4
|
-
|
10
|
+
<%- config[:actions].each do |action| -%>
|
11
|
+
on /<%= config[:ruboty_plugin_name].gsub('_', ' ') %> <%= action %>/, name: '<%= action %>', description: 'TODO: write your description'
|
12
|
+
<%- end -%>
|
13
|
+
<%- config[:actions].each_with_index do |action, i| -%>
|
5
14
|
|
6
|
-
def
|
7
|
-
Ruboty::<%= config[:ruboty_plugin_constant_name] %>::Actions::<%= config[:
|
15
|
+
def <%= action %>(message)
|
16
|
+
Ruboty::<%= config[:ruboty_plugin_constant_name] %>::Actions::<%= config[:constant_actions][i]%>.new(message).call
|
8
17
|
end
|
18
|
+
<%- end -%>
|
9
19
|
end
|
10
20
|
end
|
11
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module <%= config[:ruboty_plugin_constant_name] %>
|
3
3
|
module Actions
|
4
|
-
class <%= config[:
|
4
|
+
class <%= config[:constant_action] %> < Ruboty::Actions::Base
|
5
5
|
def call
|
6
6
|
message.reply("TODO: write a message.")
|
7
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- block_given?
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|