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.
Files changed (87) hide show
  1. data/.document +4 -0
  2. data/.rspec +1 -0
  3. data/.yardopts +1 -0
  4. data/ChangeLog.md +41 -0
  5. data/Gemfile +27 -0
  6. data/{README.txt → README.md} +30 -21
  7. data/Rakefile +24 -20
  8. data/bin/ronin-gen +27 -8
  9. data/data/ronin/gen/library/.document +5 -0
  10. data/data/ronin/gen/library/.gitignore +10 -0
  11. data/data/ronin/gen/library/.rspec +1 -0
  12. data/data/ronin/gen/library/.yardopts.erb +1 -0
  13. data/data/ronin/gen/library/COPYING.txt +339 -0
  14. data/data/ronin/gen/library/ChangeLog.md.erb +4 -0
  15. data/data/ronin/gen/library/Gemfile.erb +23 -0
  16. data/data/ronin/gen/library/README.md.erb +46 -0
  17. data/data/ronin/gen/library/Rakefile +30 -0
  18. data/data/ronin/gen/library/bin/ronin-command.erb +25 -0
  19. data/data/ronin/gen/library/bin/ronin-name.erb +27 -0
  20. data/data/ronin/gen/library/gemspec.yml.erb +20 -0
  21. data/data/ronin/gen/library/lib/ronin/_license.erb +19 -0
  22. data/data/ronin/gen/library/lib/ronin/gen/generators/generator.rb.erb +22 -0
  23. data/data/ronin/gen/library/lib/ronin/name.rb.erb +3 -0
  24. data/data/ronin/gen/library/lib/ronin/name/version.rb.erb +8 -0
  25. data/data/ronin/gen/library/lib/ronin/ui/command_line/commands/command.rb.erb +22 -0
  26. data/data/ronin/gen/library/library.gemspec.erb +10 -0
  27. data/data/ronin/gen/library/spec/name/name_spec.rb.erb +8 -0
  28. data/data/ronin/gen/library/spec/spec_helper.rb.erb +4 -0
  29. data/data/ronin/gen/repository/.rspec +1 -0
  30. data/data/ronin/gen/repository/Rakefile.erb +32 -0
  31. data/data/ronin/gen/repository/ronin.yml.erb +18 -0
  32. data/{static/ronin/generators/platform → data/ronin/gen/repository}/spec/spec_helper.rb +0 -0
  33. data/gemspec.yml +24 -0
  34. data/lib/ronin/gen.rb +26 -0
  35. data/lib/ronin/{ui/command_line/commands/gen_overlay.rb → gen/config.rb} +6 -8
  36. data/lib/ronin/{generators → gen}/dir_generator.rb +25 -21
  37. data/lib/ronin/{generators.rb → gen/exceptions.rb} +2 -5
  38. data/lib/ronin/{generators/platform/static.rb → gen/exceptions/unknown_generator.rb} +3 -6
  39. data/lib/ronin/gen/file_generator.rb +73 -0
  40. data/lib/ronin/gen/gen.rb +85 -0
  41. data/lib/ronin/gen/generatable.rb +36 -0
  42. data/lib/ronin/gen/generator.rb +312 -0
  43. data/lib/ronin/{ui/command_line/commands/gen_extension.rb → gen/generators.rb} +8 -9
  44. data/lib/ronin/gen/generators/library.rb +196 -0
  45. data/lib/ronin/gen/generators/repository.rb +130 -0
  46. data/lib/ronin/gen/ruby_generator.rb +34 -0
  47. data/lib/ronin/gen/source_code_generator.rb +46 -0
  48. data/lib/ronin/{generators → gen}/version.rb +3 -3
  49. data/lib/ronin/ui/{command_line → cli}/commands/gen.rb +18 -19
  50. data/ronin-gen.gemspec +10 -0
  51. data/spec/gen/classes/basic_generator.rb +16 -0
  52. data/spec/gen/classes/dir_generator.rb +9 -0
  53. data/spec/{generators → gen}/classes/file_generator.rb +2 -2
  54. data/spec/{generators → gen}/classes/templated_generator.rb +3 -3
  55. data/spec/gen/classes/touch_generator.rb +9 -0
  56. data/spec/gen/gen_spec.rb +22 -0
  57. data/spec/gen/generator_spec.rb +68 -0
  58. data/spec/gen/generators/library_spec.rb +132 -0
  59. data/spec/gen/generators/repository_spec.rb +92 -0
  60. data/spec/gen/helpers/data.rb +9 -0
  61. data/spec/{generators/helpers/static → gen/helpers/data}/generators/templated.txt.erb +0 -0
  62. data/spec/spec_helper.rb +3 -5
  63. metadata +190 -114
  64. data.tar.gz.sig +0 -0
  65. data/History.txt +0 -41
  66. data/Manifest.txt +0 -39
  67. data/bin/ronin-gen-extension +0 -12
  68. data/bin/ronin-gen-overlay +0 -12
  69. data/lib/ronin/generators/generator.rb +0 -165
  70. data/lib/ronin/generators/platform/extension.rb +0 -52
  71. data/lib/ronin/generators/platform/overlay.rb +0 -223
  72. data/spec/generated_extension_examples.rb +0 -27
  73. data/spec/generated_overlay_examples.rb +0 -72
  74. data/spec/generators/classes/dir_generator.rb +0 -9
  75. data/spec/generators/classes/touch_generator.rb +0 -9
  76. data/spec/generators/generator_spec.rb +0 -50
  77. data/spec/generators/generators_spec.rb +0 -9
  78. data/spec/generators/helpers/generators.rb +0 -3
  79. data/spec/generators/platform/extension_spec.rb +0 -22
  80. data/spec/generators/platform/overlay_spec.rb +0 -36
  81. data/spec/ui/command_line/commands/gen_extension_spec.rb +0 -22
  82. data/spec/ui/command_line/commands/gen_overlay_spec.rb +0 -38
  83. data/static/ronin/generators/platform/Rakefile.erb +0 -5
  84. data/static/ronin/generators/platform/extension.rb +0 -9
  85. data/tasks/spec.rb +0 -10
  86. data/tasks/yard.rb +0 -13
  87. metadata.gz.sig +0 -0
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / <%= Time.new.strftime("%Y-%m-%d") %>
2
+
3
+ * Initial release:
4
+
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ RONIN = 'http://github.com/ronin-ruby'
4
+
5
+ gemspec
6
+
7
+ gem 'ronin-support', '~> <%= Ronin::Support::VERSION %>', :git => "#{RONIN}/ronin-support.git"
8
+ gem 'ronin', '~> <%= Ronin::VERSION %>', :git => "#{RONIN}/ronin.git"
9
+
10
+ group(:development) do
11
+ gem 'rake', '~> 0.8.7'
12
+
13
+ case RUBY_PLATFORM
14
+ when 'java'
15
+ gem 'maruku', '~> 0.6.0'
16
+ else
17
+ gem 'rdiscount', '~> 1.6.3'
18
+ end
19
+
20
+ gem 'ore-core', '~> 0.1.0'
21
+ gem 'ore-tasks', '~> 0.3.0'
22
+ gem 'rspec', '~> 2.0.0'
23
+ end
@@ -0,0 +1,46 @@
1
+ # <%= @title %>
2
+
3
+ * [Source](http://github.com/ronin-ruby/<%= @name %>)
4
+ * [Issues](http://github.com/ronin-ruby/<%= @name %>/issues)
5
+ * [Documentation](http://rubydoc.info/github/ronin-ruby/<%= @name %>)
6
+ * <%= @author %> (<%= @safe_email %>)
7
+
8
+ ## Description
9
+
10
+ <%= @title %> is a Ronin library.
11
+
12
+ ## Features
13
+
14
+ ## Synopsis
15
+
16
+ $ ronin <%= @dir_name %>
17
+
18
+ ## Examples
19
+
20
+ ## Requirements
21
+
22
+ * [ronin](http://github.com/ronin-ruby/ronin) ~> <%= Ronin::VERSION %>
23
+
24
+ ## Install
25
+
26
+ $ sudo gem install <%= @name %>
27
+
28
+ ## License
29
+
30
+ <%= @title %> - A Ronin library.
31
+
32
+ Copyright (c) <%= Time.new.strftime("%Y") %> <%= @author %> (<%= @safe_email %>)
33
+
34
+ This program is free software; you can redistribute it and/or modify
35
+ it under the terms of the GNU General Public License as published by
36
+ the Free Software Foundation; either version 2 of the License, or
37
+ (at your option) any later version.
38
+
39
+ This program is distributed in the hope that it will be useful,
40
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
41
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42
+ GNU General Public License for more details.
43
+
44
+ You should have received a copy of the GNU General Public License
45
+ along with this program; if not, write to the Free Software
46
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler'
5
+ rescue LoadError => e
6
+ STDERR.puts e.message
7
+ STDERR.puts "Run `gem install bundler` to install Bundler."
8
+ exit e.status_code
9
+ end
10
+
11
+ begin
12
+ Bundler.setup(:development)
13
+ rescue Bundler::BundlerError => e
14
+ STDERR.puts e.message
15
+ STDERR.puts "Run `bundle install` to install missing gems"
16
+ exit e.status_code
17
+ end
18
+
19
+ require 'rake'
20
+
21
+ require 'ore/tasks'
22
+ Ore::Tasks.new
23
+
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new
26
+ task :default => :spec
27
+
28
+ require 'yard'
29
+ YARD::Rake::YardocTask.newrequire 'rubygems'
30
+ require 'bundler'
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ root_dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
6
+ if File.directory?(File.join(root_dir,'.git'))
7
+ Dir.chdir(root_dir) do |path|
8
+ require 'bundler'
9
+
10
+ begin
11
+ Bundler.setup(:default)
12
+ rescue Bundler::BundlerError => e
13
+ STDERR.puts e.message
14
+ STDERR.puts "Run `bundle install` to install missing gems"
15
+ exit e.status_code
16
+ end
17
+ end
18
+ end
19
+
20
+ lib_dir = File.join(root_dir,'lib')
21
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
22
+
23
+ require 'ronin/ui/cli/commands/<%= @command_file %>'
24
+
25
+ Ronin::UI::CLI::Commands::<%= @command_class %>.start
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ root_dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
6
+ if File.directory?(File.join(root_dir,'.git'))
7
+ Dir.chdir(root_dir) do |path|
8
+ require 'bundler'
9
+
10
+ begin
11
+ Bundler.setup(:default)
12
+ rescue Bundler::BundlerError => e
13
+ STDERR.puts e.message
14
+ STDERR.puts "Run `bundle install` to install missing gems"
15
+ exit e.status_code
16
+ end
17
+ end
18
+ end
19
+
20
+ lib_dir = File.join(root_dir,'lib')
21
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
22
+
23
+ require 'ronin/ui/console'
24
+ require 'ronin/ui/cli/commands/console'
25
+
26
+ Ronin::UI::Console.auto_load << 'ronin/<%= @dir_name %>'
27
+ Ronin::UI::CLI::Commands::Console.start
@@ -0,0 +1,20 @@
1
+ name: <%= @name %>
2
+ summary: <%= @summary %>
3
+ description:
4
+ <%= @description %>
5
+
6
+ license: GPL-2
7
+ authors: <%= @author %>
8
+ email: <%= @email %>
9
+ homepage: <%= @homepage %>
10
+ has_yard: true
11
+
12
+ dependencies:
13
+ # ronin: ~> <%= Ronin::VERSION %>
14
+ <%- unless options[:generators].empty? -%>
15
+ # ronin-gen: ~> <%= Ronin::Gen::VERSION %>
16
+ <%- end -%>
17
+
18
+ development_dependencies:
19
+ bundler: ~> 1.0.0
20
+ yard: ~> 0.6.0
@@ -0,0 +1,19 @@
1
+ #
2
+ # <%= @title %> - A Ronin library.
3
+ #
4
+ # Copyright (c) <%= Time.new.strftime("%Y") %> <%= @author %> (<%= @safe_email %>)
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
+ #
@@ -0,0 +1,22 @@
1
+ <%= erb File.join('..','..','_license.erb') %>
2
+
3
+ require 'ronin/gen/generators/file_generator'
4
+
5
+ module Ronin
6
+ module Gen
7
+ module Generators
8
+ class <%= @generator_class %> < FileGenerator
9
+
10
+ class_option :opt, :type => :string
11
+ arguments :arg, :type => :string
12
+
13
+ def setup
14
+ end
15
+
16
+ def generate
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ <%= erb '_license.erb' %>
2
+
3
+ require 'ronin/<%= @dir_name %>/version'
@@ -0,0 +1,8 @@
1
+ <%= erb File.join('..','_license.erb') %>
2
+
3
+ module Ronin
4
+ module <%= @module_name %>
5
+ # <%= @name %> version
6
+ VERSION = '<%= DEFAULT_VERSION %>'
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ <%= erb File.join('..','..','..','_license.erb') %>
2
+
3
+ require 'ronin/ui/command_line/command'
4
+
5
+ module Ronin
6
+ module UI
7
+ module CommandLine
8
+ module Commands
9
+ class <%= @command_class %> < Command
10
+
11
+ desc 'A command'
12
+ class_option :name, :type => :string
13
+ argument :path, :type => :string
14
+
15
+ def default
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ begin
4
+ Ore::Specification.new do |gemspec|
5
+ # custom logic here
6
+ end
7
+ rescue NameError
8
+ STDERR.puts "The '<%= @name -%>.gemspec' file requires Ore."
9
+ STDERR.puts "Run `gem install ore-core` to install Ore."
10
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'ronin/<%= @dir_name %>/version'
3
+
4
+ describe <%= @module_name %> do
5
+ it "should have a VERSION constant" do
6
+ subject.const_get('VERSION').should_not be_nil
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'ronin/<%= @dir_name %>/version'
3
+
4
+ include Ronin
@@ -0,0 +1 @@
1
+ --colour --format documentation
@@ -0,0 +1,32 @@
1
+ # -*- ruby -*-
2
+
3
+ <%- case @test_suite
4
+ when :rspec -%>
5
+ begin
6
+ gem 'rspec', '~> 2.0.0'
7
+ require 'rspec/core/rake_task'
8
+
9
+ RSpec::Core::RakeTask.new
10
+ rescue LoadError => e
11
+ task :spec do
12
+ abort "Please run `gem install rspec` to install RSpec."
13
+ end
14
+ end
15
+ task :default => :spec
16
+ <%- when :test_unit -%>
17
+ <%- end -%>
18
+
19
+ <%- if @docs -%>
20
+ begin
21
+ gem 'yard', '~> 0.6.0'
22
+ require 'yard'
23
+
24
+ YARD::Rake::YardocTask.new
25
+ rescue LoadError => e
26
+ task :yard do
27
+ abort "Please run `gem install yard` to install YARD."
28
+ end
29
+ end
30
+ <%- end -%>
31
+
32
+ # vim: syntax=Ruby
@@ -0,0 +1,18 @@
1
+ title: <%= @title %>
2
+ license: <%= @license %>
3
+ <%- if @uri -%>
4
+ uri: <%= @uri %>
5
+ <%- end -%>
6
+ <%- if @source -%>
7
+ source: <%= @source %>
8
+ <%- end -%>
9
+ <%- if @website -%>
10
+ website: <%= @website %>
11
+ <%- end -%>
12
+ authors:
13
+ <%- @authors.each do |name,email| -%>
14
+ <%= name -%>: <%= email %>
15
+ <%- end -%>
16
+
17
+ description:
18
+ <%= @description -%>
@@ -0,0 +1,24 @@
1
+ name: ronin-gen
2
+ summary: A Ruby library for Ronin that provides various generators.
3
+ description:
4
+ Ronin Gen is a Ruby library for Ronin that provides various generators.
5
+
6
+ license: GPL-2
7
+ authors: Postmodern
8
+ email: postmodern.mod3@gmail.com
9
+ homepage: http://github.com/ronin-ruby/ronin-gen
10
+ has_yard: true
11
+
12
+ requirements: git >= 1.6.0.0, for the library generator
13
+
14
+ dependencies:
15
+ open_namespace: ~> 0.3.0
16
+ data_paths: ~> 0.2.1
17
+ thor: ~> 0.14.3
18
+ # Ronin dependencies:
19
+ ronin-support: ~> 0.1.0.pre
20
+ ronin: ~> 1.0.0.pre
21
+
22
+ development_dependencies:
23
+ bundler: ~> 1.0.0
24
+ yard: ~> 0.6.1
@@ -0,0 +1,26 @@
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/generator'
22
+ require 'ronin/gen/file_generator'
23
+ require 'ronin/gen/dir_generator'
24
+ require 'ronin/gen/generatable'
25
+ require 'ronin/gen/gen'
26
+ require 'ronin/gen/version'
@@ -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 gmail.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
@@ -18,16 +18,14 @@
18
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
19
  #
20
20
 
21
- require 'ronin/generators/platform/overlay'
21
+ require 'data_paths'
22
22
 
23
23
  module Ronin
24
- module UI
25
- module CommandLine
26
- module Commands
27
- class GenOverlay < Generators::Platform::Overlay
24
+ module Gen
25
+ module Config
26
+ include DataPaths
28
27
 
29
- end
30
- end
28
+ register_data_dir File.join(File.dirname(__FILE__),'..','..','..','data')
31
29
  end
32
30
  end
33
31
  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 gmail.com)
4
+ # Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.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,12 +18,15 @@
18
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
19
  #
20
20
 
21
- require 'ronin/generators/generator'
21
+ require 'ronin/gen/generator'
22
22
 
23
23
  require 'fileutils'
24
24
 
25
25
  module Ronin
26
- module Generators
26
+ module Gen
27
+ #
28
+ # A {Generator} class for creating directories.
29
+ #
27
30
  class DirGenerator < Generator
28
31
 
29
32
  argument :path, :type => :string, :require => true
@@ -44,27 +47,28 @@ module Ronin
44
47
  # gen.generate('path/to/dir')
45
48
  #
46
49
  def self.generate(path,options={},arguments=[])
47
- path = File.expand_path(path)
48
-
49
- generator = self.new([path] + arguments, options)
50
- generator.invoke()
50
+ super(options,[File.expand_path(path)] + arguments)
51
51
  end
52
52
 
53
- no_tasks do
54
- #
55
- # Invokes the tasks of the generator.
56
- #
57
- # @param [Array] names
58
- # The task names to invoke.
59
- #
60
- def invoke(*names,&block)
61
- if self.path
62
- self.destination_root = self.path
63
- end
53
+ protected
64
54
 
65
- inside() do |path|
66
- super(*names,&block)
67
- end
55
+ #
56
+ # Initializes the generator.
57
+ #
58
+ # @param [Array] arguments
59
+ # Additional arguments for the generator.
60
+ #
61
+ # @param [Hash] options
62
+ # Options to pass to the generator.
63
+ #
64
+ # @param [Hash] config
65
+ # Additional configuration for the generator.
66
+ #
67
+ # @since 1.0.0
68
+ #
69
+ def initialize(arguments=[],options={},config={})
70
+ super(arguments,options,config) do |gen|
71
+ gen.destination_root = self.path
68
72
  end
69
73
  end
70
74