ronin-gen 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -1,3 +1,21 @@
1
+ === 0.1.1 / 2009-07-02
2
+
3
+ * Use Hoe >= 2.0.0.
4
+ * Require Ronin >= 0.2.4.
5
+ * Added Generator#touch.
6
+ * Added Ronin::UI::CommandLine::Commands::Gen for listing and
7
+ invoking generators.
8
+ * Added more defaults to Ronin::Generators::Platform::Overlay:
9
+ * Default maintainer.
10
+ * Default license.
11
+ * Default description.
12
+ * Added the --version option to the ronin-gen command.
13
+ * Removed the --list option from the ronin-gen command.
14
+ * Make sure Ronin::Generators::Platform::Overlay creates an
15
+ empty lib/init.rb file.
16
+ * Fixed a bug in the ronin-gen command, where generator names
17
+ were not being sanitized.
18
+
1
19
  === 0.1.0 / 2009-03-27
2
20
 
3
21
  * Initial release.
@@ -16,6 +16,7 @@ lib/ronin/generators/platform/overlay.rb
16
16
  lib/ronin/generators/platform/extension.rb
17
17
  lib/ronin/generators/platform/spec.rb
18
18
  lib/ronin/generators/platform/extension.rb
19
+ lib/ronin/ui/command_line/commands/gen.rb
19
20
  lib/ronin/ui/command_line/commands/gen_overlay.rb
20
21
  lib/ronin/ui/command_line/commands/gen_extension.rb
21
22
  tasks/spec.rb
@@ -23,10 +24,11 @@ spec/spec_helper.rb
23
24
  spec/generated_overlay_examples.rb
24
25
  spec/generated_extension_examples.rb
25
26
  spec/generators/helpers/generators.rb
26
- spec/generators/helpers/generators/file_generator.rb
27
- spec/generators/helpers/generators/dir_generator.rb
28
- spec/generators/helpers/generators/templated_generator.rb
29
27
  spec/generators/helpers/static/generators/templated.txt.erb
28
+ spec/generators/classes/file_generator.rb
29
+ spec/generators/classes/touch_generator.rb
30
+ spec/generators/classes/dir_generator.rb
31
+ spec/generators/classes/templated_generator.rb
30
32
  spec/generators/generator_spec.rb
31
33
  spec/generators/generators_spec.rb
32
34
  spec/generators/platform/overlay_spec.rb
data/Rakefile CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
+ require 'hoe/signing'
5
6
  require './tasks/spec.rb'
6
- require './lib/ronin/generators/version.rb'
7
7
 
8
- Hoe.new('ronin-gen', Ronin::Generators::VERSION) do |p|
9
- p.rubyforge_name = 'ronin'
10
- p.developer('Postmodern', 'postmodern.mod3@gmail.com')
11
- p.remote_rdoc_dir = 'docs/ronin-gen'
12
- p.extra_deps = [['ronin', '>=0.2.2']]
8
+ Hoe.spec('ronin-gen') do
9
+ self.rubyforge_name = 'ronin'
10
+ self.developer('Postmodern', 'postmodern.mod3@gmail.com')
11
+ self.remote_rdoc_dir = 'docs/ronin-gen'
12
+ self.extra_deps = [['ronin', '>=0.2.4']]
13
13
  end
14
14
 
15
15
  # vim: syntax=Ruby
@@ -7,10 +7,13 @@ unless $LOAD_PATH.include?(lib_dir)
7
7
  $LOAD_PATH << lib_dir
8
8
  end
9
9
 
10
+ require 'ronin/ui/command_line/commands/gen'
10
11
  require 'ronin/ui/command_line'
11
12
 
12
- if ARGV.length > 0
13
- ARGV[0] = "gen-#{ARGV.first}"
14
- end
13
+ if (ARGV.length > 0 && ARGV.first[0..0] != '-')
14
+ ARGV[0] = "gen_#{ARGV.first}"
15
15
 
16
- Ronin::UI::CommandLine.run(*ARGV)
16
+ Ronin::UI::CommandLine.run(*ARGV)
17
+ else
18
+ Ronin::UI::CommandLine::Commands::Gen.run(*ARGV)
19
+ end
@@ -21,15 +21,16 @@
21
21
  #
22
22
 
23
23
  require 'ronin/static/finders'
24
+ require 'ronin/templates/erb'
24
25
 
25
26
  require 'fileutils'
26
- require 'erb'
27
27
 
28
28
  module Ronin
29
29
  module Generators
30
30
  class Generator
31
31
 
32
32
  include Static::Finders
33
+ include Templates::Erb
33
34
 
34
35
  #
35
36
  # Runs the generator with the specified _path_.
@@ -73,6 +74,18 @@ module Ronin
73
74
  puts " #{sub_path}"
74
75
  end
75
76
 
77
+ #
78
+ # Touches the file at the specified _sub_path_.
79
+ #
80
+ # touch 'init.rb'
81
+ #
82
+ def touch(sub_path)
83
+ FileUtils.touch(expand_path(sub_path))
84
+
85
+ print_path(sub_path)
86
+ return sub_path
87
+ end
88
+
76
89
  #
77
90
  # Opens the file at the specified _sub_path_. If a _block_ is given,
78
91
  # it will be passed a newly created File object.
@@ -126,10 +139,7 @@ module Ronin
126
139
  # # => "..."
127
140
  #
128
141
  def render_template(static_file)
129
- static_file = find_static_file(static_file)
130
- erb = ERB.new(File.read(static_file))
131
-
132
- return erb.result(binding)
142
+ erb_file(find_static_file(static_file))
133
143
  end
134
144
 
135
145
  #
@@ -47,6 +47,15 @@ module Ronin
47
47
  # The Overlay objects directory
48
48
  OBJECTS_DIR = Ronin::Platform::Overlay::OBJECTS_DIR
49
49
 
50
+ # Default license to use
51
+ DEFAULT_LICENSE = 'CC-by'
52
+
53
+ # Default maintainer to use
54
+ DEFAULT_MAINTAINER = {:name => 'Name', :email => 'name@example.com'}
55
+
56
+ # Default description to use
57
+ DEFAULT_DESCRIPTION = 'This is an Overlay'
58
+
50
59
  # Title of the overlay
51
60
  attr_accessor :title
52
61
 
@@ -79,23 +88,26 @@ module Ronin
79
88
  # <tt>:source</tt>:: Source URL for the overlay.
80
89
  # <tt>:source_view</tt>:: Source View URL for the overlay.
81
90
  # <tt>:website</tt>:: Website for the overlay.
82
- # <tt>:license</tt>:: License for the overlay.
91
+ # <tt>:license</tt>:: License for the overlay. Defaults to
92
+ # DEFUALT_LICENSE, if not given.
83
93
  # <tt>:maintainers</tt>:: List of maintainers for the overlay.
84
94
  # <tt>:description</tt>:: The description of the overlay.
95
+ # Defaults to DEFAULT_DESCRIPTION,
96
+ # if not given.
85
97
  #
86
98
  def initialize(options={})
87
99
  @title = options[:title]
88
100
  @source = options[:source]
89
101
  @source_view = options[:source_view]
90
102
  @website = options[:website]
91
- @license = options[:license]
103
+ @license = (options[:license] || DEFAULT_LICENSE)
92
104
  @maintainers = []
93
105
 
94
106
  if options[:maintainers]
95
107
  @maintainers.merge!(options[:maintainers])
96
108
  end
97
109
 
98
- @description = options[:description]
110
+ @description = (options[:description] || DEFAULT_DESCRIPTION)
99
111
  @tasks = Set[]
100
112
 
101
113
  if options[:tasks]
@@ -119,8 +131,11 @@ module Ronin
119
131
  @title ||= File.basename(@path).gsub(/[_\s]+/,' ').capitalize
120
132
  @source_view ||= @source
121
133
  @website ||= @source_view
134
+ @maintainers << DEFAULT_MAINTAINER if @maintainers.empty?
122
135
 
123
136
  directory LIB_DIR
137
+ touch File.join(LIB_DIR,Ronin::Platform::Overlay::INIT_FILE)
138
+
124
139
  directory OBJECTS_DIR
125
140
  directory 'tasks'
126
141
 
@@ -180,43 +195,37 @@ module Ronin
180
195
  root << url_tag
181
196
  end
182
197
 
183
- if @license
184
- license_tag = XML::Node.new('license',doc)
185
- license_tag << XML::Text.new(@license,doc)
186
- root << license_tag
187
- end
188
-
189
- unless @maintainers.empty?
190
- maintainers_tag = XML::Node.new('maintainers',doc)
198
+ license_tag = XML::Node.new('license',doc)
199
+ license_tag << XML::Text.new(@license,doc)
200
+ root << license_tag
191
201
 
192
- @maintainers.each do |author|
193
- if (author[:name] || author[:email])
194
- maintainer_tag = XML::Node.new('maintainer',doc)
202
+ maintainers_tag = XML::Node.new('maintainers',doc)
195
203
 
196
- if author[:name]
197
- name_tag = XML::Node.new('name',doc)
198
- name_tag << XML::Text.new(author[:name],doc)
199
- maintainer_tag << name_tag
200
- end
204
+ @maintainers.each do |author|
205
+ if (author[:name] || author[:email])
206
+ maintainer_tag = XML::Node.new('maintainer',doc)
201
207
 
202
- if author[:email]
203
- email_tag = XML::Node.new('email',doc)
204
- email_tag << XML::Text.new(author[:email],doc)
205
- maintainer_tag << email_tag
206
- end
208
+ if author[:name]
209
+ name_tag = XML::Node.new('name',doc)
210
+ name_tag << XML::Text.new(author[:name],doc)
211
+ maintainer_tag << name_tag
212
+ end
207
213
 
208
- maintainers_tag << maintainer_tag
214
+ if author[:email]
215
+ email_tag = XML::Node.new('email',doc)
216
+ email_tag << XML::Text.new(author[:email],doc)
217
+ maintainer_tag << email_tag
209
218
  end
210
- end
211
219
 
212
- root << maintainers_tag
220
+ maintainers_tag << maintainer_tag
221
+ end
213
222
  end
214
223
 
215
- if @description
216
- description_tag = XML::Node.new('description',doc)
217
- description_tag << XML::Text.new(@description,doc)
218
- root << description_tag
219
- end
224
+ root << maintainers_tag
225
+
226
+ description_tag = XML::Node.new('description',doc)
227
+ description_tag << XML::Text.new(@description,doc)
228
+ root << description_tag
220
229
 
221
230
  doc << root
222
231
  doc.write_xml_to(metadata_file)
@@ -23,6 +23,6 @@
23
23
  module Ronin
24
24
  module Generators
25
25
  # Ronin Gen version
26
- VERSION = '0.1.0'
26
+ VERSION = '0.1.1'
27
27
  end
28
28
  end
@@ -0,0 +1,63 @@
1
+ #
2
+ #--
3
+ # Ronin Gen - A Ruby library for Ronin that provides various generators.
4
+ #
5
+ # Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ #++
21
+ #
22
+
23
+ require 'ronin/generators/version'
24
+ require 'ronin/ui/command_line/command'
25
+ require 'ronin/ui/command_line/command_line'
26
+
27
+ module Ronin
28
+ module UI
29
+ module CommandLine
30
+ module Commands
31
+ class Gen < Command
32
+
33
+ def define_options(opts)
34
+ opts.usage = '[options] NAME'
35
+
36
+ opts.options do
37
+ opts.on('-V','--version','Print version information and exit') do
38
+ success { puts "Ronin Gen #{Ronin::Generators::VERSION}" }
39
+ end
40
+ end
41
+
42
+ opts.arguments(
43
+ 'NAME' => 'Name of the Generator to run'
44
+ )
45
+
46
+ opts.summary('Runs the Generator with the specified NAME and options')
47
+ end
48
+
49
+ def arguments(*args)
50
+ puts CommandLine.commands.map { |name|
51
+ if name =~ /^gen_/
52
+ name.gsub(/^gen_/,' ')
53
+ else
54
+ nil
55
+ end
56
+ }.compact.sort
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,11 @@
1
+ require 'ronin/generators/generator'
2
+
3
+ class TouchGenerator < Generators::Generator
4
+
5
+ protected
6
+
7
+ def generate!
8
+ touch('test2.txt')
9
+ end
10
+
11
+ end
@@ -2,6 +2,11 @@ require 'ronin/generators/generator'
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'generators/helpers/generators'
5
+ require 'generators/classes/file_generator'
6
+ require 'generators/classes/touch_generator'
7
+ require 'generators/classes/dir_generator'
8
+ require 'generators/classes/templated_generator'
9
+
5
10
 
6
11
  require 'tmpdir'
7
12
  require 'fileutils'
@@ -20,6 +25,13 @@ describe Generators::Generator do
20
25
  File.read(File.join(@dir,'test.txt')).should == "hello\n"
21
26
  end
22
27
 
28
+ it "should touch files" do
29
+ generator = TouchGenerator.new
30
+ generator.run(@dir)
31
+
32
+ File.file?(File.join(@dir,'test2.txt')).should == true
33
+ end
34
+
23
35
  it "should generate directories" do
24
36
  generator = DirGenerator.new
25
37
  generator.run(@dir)
@@ -1,7 +1,3 @@
1
1
  require 'ronin/static/static'
2
2
 
3
- require 'generators/helpers/generators/file_generator'
4
- require 'generators/helpers/generators/dir_generator'
5
- require 'generators/helpers/generators/templated_generator'
6
-
7
3
  Static.directory File.join(File.dirname(__FILE__),'static')
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
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Scm1QpZKF1e
27
+ cezArMbxbSPaosxTCtG6LQTkE28lFQsmFZ5xzouugS4h5+LVJiVMmiP+l3EfkjFa
28
+ GOURU+rNEMPWo8MCWivGW7jes6BMzWHcW7DQ0scNVmIcCIgdyMmpscuAEOSeghy9
29
+ /fFs57Ey2OXBL55nDOyvN/ZQ2Vab05UH4t+GCxjAPeirzL/29FBtePT6VD44c38j
30
+ pDj+ws7QjtH/Qcrr1l9jfN0ehDs=
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2009-03-27 00:00:00 -07:00
33
+ date: 2009-07-08 00:00:00 -07:00
13
34
  default_executable:
14
35
  dependencies:
15
36
  - !ruby/object:Gem::Dependency
@@ -20,7 +41,7 @@ dependencies:
20
41
  requirements:
21
42
  - - ">="
22
43
  - !ruby/object:Gem::Version
23
- version: 0.2.2
44
+ version: 0.2.4
24
45
  version:
25
46
  - !ruby/object:Gem::Dependency
26
47
  name: hoe
@@ -30,9 +51,14 @@ dependencies:
30
51
  requirements:
31
52
  - - ">="
32
53
  - !ruby/object:Gem::Version
33
- version: 1.11.0
54
+ version: 2.3.2
34
55
  version:
35
- description: Ronin Gen is a Ruby library for Ronin that provides various generators. Ronin is a Ruby platform designed for information security and data exploration tasks. Ronin allows for the rapid development and distribution of code over many of the common Source-Code-Management (SCM) systems.
56
+ description: |-
57
+ Ronin Gen is a Ruby library for Ronin that provides various generators.
58
+
59
+ Ronin is a Ruby platform designed for information security and data
60
+ exploration tasks. Ronin allows for the rapid development and distribution
61
+ of code over many of the common Source-Code-Management (SCM) systems.
36
62
  email:
37
63
  - postmodern.mod3@gmail.com
38
64
  executables:
@@ -65,6 +91,7 @@ files:
65
91
  - lib/ronin/generators/platform/overlay.rb
66
92
  - lib/ronin/generators/platform/extension.rb
67
93
  - lib/ronin/generators/platform/spec.rb
94
+ - lib/ronin/ui/command_line/commands/gen.rb
68
95
  - lib/ronin/ui/command_line/commands/gen_overlay.rb
69
96
  - lib/ronin/ui/command_line/commands/gen_extension.rb
70
97
  - tasks/spec.rb
@@ -72,10 +99,11 @@ files:
72
99
  - spec/generated_overlay_examples.rb
73
100
  - spec/generated_extension_examples.rb
74
101
  - spec/generators/helpers/generators.rb
75
- - spec/generators/helpers/generators/file_generator.rb
76
- - spec/generators/helpers/generators/dir_generator.rb
77
- - spec/generators/helpers/generators/templated_generator.rb
78
102
  - spec/generators/helpers/static/generators/templated.txt.erb
103
+ - spec/generators/classes/file_generator.rb
104
+ - spec/generators/classes/touch_generator.rb
105
+ - spec/generators/classes/dir_generator.rb
106
+ - spec/generators/classes/templated_generator.rb
79
107
  - spec/generators/generator_spec.rb
80
108
  - spec/generators/generators_spec.rb
81
109
  - spec/generators/platform/overlay_spec.rb
@@ -86,6 +114,8 @@ files:
86
114
  - static/ronin/platform/generators/spec/spec_helper.rb
87
115
  has_rdoc: true
88
116
  homepage: http://ronin.rubyforge.org/gen/
117
+ licenses: []
118
+
89
119
  post_install_message:
90
120
  rdoc_options:
91
121
  - --main
@@ -107,9 +137,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
137
  requirements: []
108
138
 
109
139
  rubyforge_project: ronin
110
- rubygems_version: 1.3.1
140
+ rubygems_version: 1.3.4
111
141
  signing_key:
112
- specification_version: 2
142
+ specification_version: 3
113
143
  summary: Ronin Gen is a Ruby library for Ronin that provides various generators
114
144
  test_files: []
115
145
 
Binary file