ronin-gen 0.2.0 → 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +41 -0
- data/Gemfile +27 -0
- data/{README.txt → README.md} +30 -21
- data/Rakefile +24 -20
- data/bin/ronin-gen +27 -8
- data/data/ronin/gen/library/.document +5 -0
- data/data/ronin/gen/library/.gitignore +10 -0
- data/data/ronin/gen/library/.rspec +1 -0
- data/data/ronin/gen/library/.yardopts.erb +1 -0
- data/data/ronin/gen/library/COPYING.txt +339 -0
- data/data/ronin/gen/library/ChangeLog.md.erb +4 -0
- data/data/ronin/gen/library/Gemfile.erb +23 -0
- data/data/ronin/gen/library/README.md.erb +46 -0
- data/data/ronin/gen/library/Rakefile +30 -0
- data/data/ronin/gen/library/bin/ronin-command.erb +25 -0
- data/data/ronin/gen/library/bin/ronin-name.erb +27 -0
- data/data/ronin/gen/library/gemspec.yml.erb +20 -0
- data/data/ronin/gen/library/lib/ronin/_license.erb +19 -0
- data/data/ronin/gen/library/lib/ronin/gen/generators/generator.rb.erb +22 -0
- data/data/ronin/gen/library/lib/ronin/name.rb.erb +3 -0
- data/data/ronin/gen/library/lib/ronin/name/version.rb.erb +8 -0
- data/data/ronin/gen/library/lib/ronin/ui/command_line/commands/command.rb.erb +22 -0
- data/data/ronin/gen/library/library.gemspec.erb +10 -0
- data/data/ronin/gen/library/spec/name/name_spec.rb.erb +8 -0
- data/data/ronin/gen/library/spec/spec_helper.rb.erb +4 -0
- data/data/ronin/gen/repository/.rspec +1 -0
- data/data/ronin/gen/repository/Rakefile.erb +32 -0
- data/data/ronin/gen/repository/ronin.yml.erb +18 -0
- data/{static/ronin/generators/platform → data/ronin/gen/repository}/spec/spec_helper.rb +0 -0
- data/gemspec.yml +24 -0
- data/lib/ronin/gen.rb +26 -0
- data/lib/ronin/{ui/command_line/commands/gen_overlay.rb → gen/config.rb} +6 -8
- data/lib/ronin/{generators → gen}/dir_generator.rb +25 -21
- data/lib/ronin/{generators.rb → gen/exceptions.rb} +2 -5
- data/lib/ronin/{generators/platform/static.rb → gen/exceptions/unknown_generator.rb} +3 -6
- data/lib/ronin/gen/file_generator.rb +73 -0
- data/lib/ronin/gen/gen.rb +85 -0
- data/lib/ronin/gen/generatable.rb +36 -0
- data/lib/ronin/gen/generator.rb +312 -0
- data/lib/ronin/{ui/command_line/commands/gen_extension.rb → gen/generators.rb} +8 -9
- data/lib/ronin/gen/generators/library.rb +196 -0
- data/lib/ronin/gen/generators/repository.rb +130 -0
- data/lib/ronin/gen/ruby_generator.rb +34 -0
- data/lib/ronin/gen/source_code_generator.rb +46 -0
- data/lib/ronin/{generators → gen}/version.rb +3 -3
- data/lib/ronin/ui/{command_line → cli}/commands/gen.rb +18 -19
- data/ronin-gen.gemspec +10 -0
- data/spec/gen/classes/basic_generator.rb +16 -0
- data/spec/gen/classes/dir_generator.rb +9 -0
- data/spec/{generators → gen}/classes/file_generator.rb +2 -2
- data/spec/{generators → gen}/classes/templated_generator.rb +3 -3
- data/spec/gen/classes/touch_generator.rb +9 -0
- data/spec/gen/gen_spec.rb +22 -0
- data/spec/gen/generator_spec.rb +68 -0
- data/spec/gen/generators/library_spec.rb +132 -0
- data/spec/gen/generators/repository_spec.rb +92 -0
- data/spec/gen/helpers/data.rb +9 -0
- data/spec/{generators/helpers/static → gen/helpers/data}/generators/templated.txt.erb +0 -0
- data/spec/spec_helper.rb +3 -5
- metadata +190 -114
- data.tar.gz.sig +0 -0
- data/History.txt +0 -41
- data/Manifest.txt +0 -39
- data/bin/ronin-gen-extension +0 -12
- data/bin/ronin-gen-overlay +0 -12
- data/lib/ronin/generators/generator.rb +0 -165
- data/lib/ronin/generators/platform/extension.rb +0 -52
- data/lib/ronin/generators/platform/overlay.rb +0 -223
- data/spec/generated_extension_examples.rb +0 -27
- data/spec/generated_overlay_examples.rb +0 -72
- data/spec/generators/classes/dir_generator.rb +0 -9
- data/spec/generators/classes/touch_generator.rb +0 -9
- data/spec/generators/generator_spec.rb +0 -50
- data/spec/generators/generators_spec.rb +0 -9
- data/spec/generators/helpers/generators.rb +0 -3
- data/spec/generators/platform/extension_spec.rb +0 -22
- data/spec/generators/platform/overlay_spec.rb +0 -36
- data/spec/ui/command_line/commands/gen_extension_spec.rb +0 -22
- data/spec/ui/command_line/commands/gen_overlay_spec.rb +0 -38
- data/static/ronin/generators/platform/Rakefile.erb +0 -5
- data/static/ronin/generators/platform/extension.rb +0 -9
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -13
- metadata.gz.sig +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at example.com)
|
5
5
|
#
|
6
6
|
# This program is free software; you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -18,16 +18,15 @@
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
#
|
20
20
|
|
21
|
-
require '
|
21
|
+
require 'open_namespace'
|
22
22
|
|
23
23
|
module Ronin
|
24
|
-
module
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
24
|
+
module Gen
|
25
|
+
#
|
26
|
+
# {Generators} is the namespace where all generators are loaded from.
|
27
|
+
#
|
28
|
+
module Generators
|
29
|
+
include OpenNamespace
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
#
|
2
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/ui/cli/commands'
|
22
|
+
require 'ronin/gen/dir_generator'
|
23
|
+
require 'ronin/gen/config'
|
24
|
+
require 'ronin/gen/version'
|
25
|
+
require 'ronin/support/version'
|
26
|
+
require 'ronin/version'
|
27
|
+
|
28
|
+
module Ronin
|
29
|
+
module Gen
|
30
|
+
module Generators
|
31
|
+
#
|
32
|
+
# Generates a completely new Ronin library.
|
33
|
+
#
|
34
|
+
class Library < DirGenerator
|
35
|
+
|
36
|
+
# Default version of the library
|
37
|
+
DEFAULT_VERSION = '0.1.0'
|
38
|
+
|
39
|
+
# Default license of the library
|
40
|
+
DEFAULT_LICENSE = 'GPL-2'
|
41
|
+
|
42
|
+
# Default author of the library
|
43
|
+
DEFAULT_AUTHOR = 'Author'
|
44
|
+
|
45
|
+
# Default email of the library
|
46
|
+
DEFAULT_EMAIL = 'name@host.com'
|
47
|
+
|
48
|
+
# Default homepage for the library
|
49
|
+
DEFAULT_HOMEPAGE = 'http://ronin-ruby.github.com/'
|
50
|
+
|
51
|
+
# Directory to store command classes in
|
52
|
+
COMMANDS_DIR = File.join('lib',UI::CLI::Commands.namespace_root)
|
53
|
+
|
54
|
+
# Directory to store generator classes in
|
55
|
+
GENERATORS_DIR = File.join('lib',Generators.namespace_root)
|
56
|
+
|
57
|
+
desc 'Generates a new Ronin library'
|
58
|
+
class_option :name, :type => :string
|
59
|
+
class_option :version, :type => :string, :default => DEFAULT_VERSION
|
60
|
+
class_option :author, :type => :string, :default => DEFAULT_AUTHOR
|
61
|
+
class_option :email, :type => :string, :default => DEFAULT_EMAIL
|
62
|
+
class_option :homepage, :type => :string,
|
63
|
+
:default => DEFAULT_HOMEPAGE
|
64
|
+
class_option :commands, :type => :array, :default => []
|
65
|
+
class_option :generators, :type => :array, :default => []
|
66
|
+
class_option :no_git, :type => :boolean
|
67
|
+
|
68
|
+
def setup
|
69
|
+
@name = (options[:name] || File.basename(self.path))
|
70
|
+
@dir_name = @name.gsub(/^ronin[-_]/,'')
|
71
|
+
@module_name = @dir_name.capitalize
|
72
|
+
|
73
|
+
@title = @name.split(/[\s_-]+/).map { |word|
|
74
|
+
word.capitalize
|
75
|
+
}.join(' ')
|
76
|
+
|
77
|
+
@license = DEFAULT_LICENSE
|
78
|
+
|
79
|
+
@author = options[:author]
|
80
|
+
@email = options[:email]
|
81
|
+
@safe_email = @email.gsub(/\s*@\s*/,' at ')
|
82
|
+
@homepage = options[:homepage]
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Generates top-level files.
|
87
|
+
#
|
88
|
+
def generate
|
89
|
+
unless options[:no_git]
|
90
|
+
run("git init #{self.destination_root}")
|
91
|
+
end
|
92
|
+
|
93
|
+
erb File.join('ronin','gen','library','Gemfile.erb'), 'Gemfile'
|
94
|
+
cp File.join('ronin','gen','library','Rakefile'), 'Rakefile'
|
95
|
+
|
96
|
+
erb File.join('ronin','gen','library','library.gemspec.erb'),
|
97
|
+
"#{@name}.gemspec"
|
98
|
+
erb File.join('ronin','gen','library','gemspec.yml.erb'),
|
99
|
+
'gemspec.yml'
|
100
|
+
|
101
|
+
unless options[:no_git]
|
102
|
+
cp File.join('ronin','gen','library','.gitignore'), '.gitignore'
|
103
|
+
end
|
104
|
+
|
105
|
+
cp File.join('ronin','gen','library','.rspec'), '.rspec'
|
106
|
+
cp File.join('ronin','gen','library','.document'), '.document'
|
107
|
+
erb File.join('ronin','gen','library','.yardopts.erb'),
|
108
|
+
'.yardopts'
|
109
|
+
|
110
|
+
cp File.join('ronin','gen','library','COPYING.txt'), 'COPYING.txt'
|
111
|
+
|
112
|
+
erb File.join('ronin','gen','library','ChangeLog.md.erb'),
|
113
|
+
'ChangeLog.md'
|
114
|
+
|
115
|
+
erb File.join('ronin','gen','library','README.md.erb'),
|
116
|
+
'README.md'
|
117
|
+
|
118
|
+
mkdir 'data'
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# Generates the contents of the `bin` directory.
|
123
|
+
#
|
124
|
+
def bin
|
125
|
+
mkdir 'bin'
|
126
|
+
erb File.join('ronin','gen','library','bin','ronin-name.erb'),
|
127
|
+
File.join('bin',"ronin-#{@dir_name}")
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Generates the contents of the `lib` directory.
|
132
|
+
#
|
133
|
+
def lib
|
134
|
+
mkdir File.join('lib','ronin',@dir_name)
|
135
|
+
|
136
|
+
erb File.join('ronin','gen','library','lib','ronin','name.rb.erb'),
|
137
|
+
File.join('lib','ronin',"#{@dir_name}.rb")
|
138
|
+
|
139
|
+
erb File.join('ronin','gen','library','lib','ronin','name','version.rb.erb'),
|
140
|
+
File.join('lib','ronin',@dir_name,'version.rb')
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# Generates the test suite.
|
145
|
+
#
|
146
|
+
def test_suite
|
147
|
+
mkdir 'spec'
|
148
|
+
erb File.join('ronin','gen','library','spec','spec_helper.rb.erb'),
|
149
|
+
File.join('spec','spec_helper.rb')
|
150
|
+
|
151
|
+
mkdir File.join('spec',@dir_name)
|
152
|
+
erb File.join('ronin','gen','library','spec','name','name_spec.rb.erb'),
|
153
|
+
File.join('spec',@dir_name,"#{@dir_name}_spec.rb")
|
154
|
+
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# Generates any optional commands for the library.
|
158
|
+
#
|
159
|
+
def command_line
|
160
|
+
unless options[:commands].empty?
|
161
|
+
mkdir COMMANDS_DIR
|
162
|
+
|
163
|
+
options[:commands].each do |name|
|
164
|
+
@command_file = name.downcase.gsub(/[_-]+/,'_')
|
165
|
+
@command_class = @command_file.to_const_string
|
166
|
+
|
167
|
+
erb File.join('ronin','gen','library','bin','ronin-command.erb'),
|
168
|
+
File.join('bin','ronin-' + @command_file.gsub('_','-'))
|
169
|
+
|
170
|
+
erb File.join('ronin','gen','library',COMMANDS_DIR,'command.rb.erb'),
|
171
|
+
File.join(COMMANDS_DIR,"#{@command_file}.rb")
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
#
|
177
|
+
# Generates any optional generators for the library.
|
178
|
+
#
|
179
|
+
def gen
|
180
|
+
unless options[:generators].empty?
|
181
|
+
mkdir GENERATORS_DIR
|
182
|
+
|
183
|
+
options[:generators].each do |name|
|
184
|
+
@generator_file = name.downcase.gsub(/[_-]+/,'_')
|
185
|
+
@generator_class = @generator_file.to_const_string
|
186
|
+
|
187
|
+
erb File.join('ronin','gen','library',GENERATORS_DIR,'generator.rb.erb'),
|
188
|
+
File.join(GENERATORS_DIR,"#{@generator_file}.rb")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#
|
2
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/gen/config'
|
22
|
+
require 'ronin/gen/dir_generator'
|
23
|
+
require 'ronin/repository'
|
24
|
+
require 'ronin/version'
|
25
|
+
|
26
|
+
require 'set'
|
27
|
+
|
28
|
+
module Ronin
|
29
|
+
module Gen
|
30
|
+
module Generators
|
31
|
+
#
|
32
|
+
# Generates a completely new Ronin Repository.
|
33
|
+
#
|
34
|
+
class Repository < DirGenerator
|
35
|
+
|
36
|
+
# The repository metadata file
|
37
|
+
METADATA_FILE = Ronin::Repository::METADATA_FILE
|
38
|
+
|
39
|
+
# The repository lib directory
|
40
|
+
LIB_DIR = Ronin::Repository::LIB_DIR
|
41
|
+
|
42
|
+
# Default license to use
|
43
|
+
DEFAULT_LICENSE = 'CC-by'
|
44
|
+
|
45
|
+
# Default authors to use
|
46
|
+
DEFAULT_AUTHORS = {'Name' => 'name@example.com'}
|
47
|
+
|
48
|
+
# Default description to use
|
49
|
+
DEFAULT_DESCRIPTION = 'This is a Ronin Repository'
|
50
|
+
|
51
|
+
desc 'Generates a new Ronin Repository'
|
52
|
+
class_option :title, :type => :string
|
53
|
+
class_option :uri, :type => :string
|
54
|
+
class_option :source, :type => :string
|
55
|
+
class_option :website, :type => :string
|
56
|
+
class_option :license, :type => :string, :default => DEFAULT_LICENSE
|
57
|
+
class_option :description, :type => :string, :default => DEFAULT_DESCRIPTION
|
58
|
+
class_option :authors, :type => :hash, :default => DEFAULT_AUTHORS, :banner => 'NAME:EMAIL ...'
|
59
|
+
class_option :test_suite, :type => :string, :banner => 'test_unit|rspec'
|
60
|
+
class_option :docs, :type => :boolean
|
61
|
+
|
62
|
+
def setup
|
63
|
+
@title = options[:title]
|
64
|
+
@uri = options[:uri]
|
65
|
+
@source = options[:source]
|
66
|
+
@website = options[:website]
|
67
|
+
@license = options[:license]
|
68
|
+
@description = options[:description]
|
69
|
+
@authors = options[:authors]
|
70
|
+
@gems = options[:gems]
|
71
|
+
@test_suite = case options[:test_suite]
|
72
|
+
when 'test', 'test_unit'
|
73
|
+
:test_unit
|
74
|
+
when 'spec', 'rspec'
|
75
|
+
:rspec
|
76
|
+
end
|
77
|
+
|
78
|
+
@docs = options[:docs]
|
79
|
+
|
80
|
+
@title ||= File.basename(self.path).gsub(/[_\s]+/,' ').capitalize
|
81
|
+
@website ||= @source
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Generates a skeleton repository.
|
86
|
+
#
|
87
|
+
def generate
|
88
|
+
mkdir LIB_DIR
|
89
|
+
mkdir File.join(LIB_DIR,'ronin')
|
90
|
+
touch File.join(LIB_DIR,Ronin::Repository::INIT_FILE)
|
91
|
+
|
92
|
+
mkdir Ronin::Repository::DATA_DIR
|
93
|
+
mkdir Ronin::Repository::CACHE_DIR
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Generates the Rakefile of the repository.
|
98
|
+
#
|
99
|
+
def rakefile
|
100
|
+
erb File.join('ronin','gen','repository','Rakefile.erb'), 'Rakefile'
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# Generates a base test suite for the repository.
|
105
|
+
#
|
106
|
+
def test_suite
|
107
|
+
case @test_suite
|
108
|
+
when :test_unit
|
109
|
+
mkdir 'test'
|
110
|
+
when :rspec
|
111
|
+
cp File.join('ronin','gen','repository','.rspec'), '.rspec'
|
112
|
+
|
113
|
+
mkdir 'spec'
|
114
|
+
cp File.join('ronin','gen','repository','spec','spec_helper.rb'),
|
115
|
+
File.join('spec','spec_helper.rb')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
#
|
120
|
+
# Generates the XML metadata file for the repository.
|
121
|
+
#
|
122
|
+
def metadata
|
123
|
+
erb File.join('ronin','gen','repository','ronin.yml.erb'),
|
124
|
+
'ronin.yml'
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/gen/source_code_generator'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
module Gen
|
25
|
+
#
|
26
|
+
# A {SourceCodeGenerator} class for creating Ruby files.
|
27
|
+
#
|
28
|
+
class RubyGenerator < SourceCodeGenerator
|
29
|
+
|
30
|
+
file_extension! :rb
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/gen/file_generator'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
module Gen
|
25
|
+
#
|
26
|
+
# A {FileGenerator} class for creating Ruby files.
|
27
|
+
#
|
28
|
+
class SourceCodeGenerator < FileGenerator
|
29
|
+
|
30
|
+
class_option :editor, :default => ENV['EDITOR']
|
31
|
+
class_option :no_edit, :type => :boolean, :default => false
|
32
|
+
|
33
|
+
#
|
34
|
+
# Generates the source-code file and spawns a text-editor.
|
35
|
+
#
|
36
|
+
def self.generate(options={},arguments=[],&block)
|
37
|
+
generator = super(options,arguments,&block)
|
38
|
+
|
39
|
+
if (generator.options.no_edit? && generator.options.editor)
|
40
|
+
system(generator.options.editor,generator.path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at example.com)
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at example.com)
|
5
5
|
#
|
6
6
|
# This program is free software; you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -19,8 +19,8 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
module Ronin
|
22
|
-
module
|
22
|
+
module Gen
|
23
23
|
# Ronin Gen version
|
24
|
-
VERSION = '0.
|
24
|
+
VERSION = '1.0.0.pre1'
|
25
25
|
end
|
26
26
|
end
|