scaffold 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ Puppet Scaffold
2
+ ===============
3
+
4
+ 0.0.3
5
+ -----
6
+
7
+ - Removed extraneous and non-functional config file code
8
+ - Added --template command line option
9
+ - Added --configdir command line option
10
+ - Added optparse
11
+ - Removed .gemspec and included this in Rakefile
12
+
13
+ 0.0.2
14
+ -----
15
+
16
+ - Fixed bug with template directory
17
+
18
+ 0.0.1
19
+ -----
20
+
21
+ - Initial release
@@ -20,26 +20,32 @@ Creates:
20
20
 
21
21
  == SYNOPSIS:
22
22
 
23
+ Use the --template option to specify the type of template you want to create.
24
+
23
25
  Create a module:
24
- $ scaffold module module_name
26
+ $ scaffold --template=module module
25
27
 
26
28
  Create a node:
27
- $ scaffold node node_name
29
+ $ scaffold --template=node node
28
30
 
29
31
  Create a class:
30
- $ scaffold class module_name class_name
32
+ $ scaffold --template=class module class
31
33
 
32
34
  Create a definition:
33
- $ scaffold define module_name define_name
35
+ $ scaffold --template=define module define
34
36
 
35
37
  Create a function:
36
- $ scaffold function module_name function_name function_type
38
+ $ scaffold --template=function module function type
37
39
 
38
40
  Create a type/provider:
39
- $ scaffold type module_name type_name
41
+ $ scaffold --template=type module type
40
42
 
41
43
  Create Puppet configuration:
42
- $ scaffold puppet
44
+ $ scaffold --template=puppet
45
+
46
+ Puppet configuration is created in the directory specified in the Puppet confdir variable but you can override this with the --configdir option.
47
+
48
+ $ scaffold --template=puppet --configdir=/opt/puppet
43
49
 
44
50
  == REQUIREMENTS:
45
51
 
@@ -52,7 +58,7 @@ Create Puppet configuration:
52
58
 
53
59
  == LICENSE:
54
60
 
55
- (The MIT License)
61
+ The MIT License
56
62
 
57
63
  Copyright (c) 2010 James Turnbull
58
64
 
data/Rakefile CHANGED
@@ -1,15 +1,38 @@
1
1
  require 'rubygems'
2
- require 'newgem/tasks'
2
+ require 'rake'
3
+ require 'rake/gempackagetask'
3
4
  require 'fileutils'
4
- require 'templater'
5
- require File.dirname(__FILE__)+'/lib/scaffold.rb'
5
+ require 'ftools'
6
6
 
7
- desc "Build gem"
8
- task :build do
9
- system "gem build .gemspec"
7
+ version = File.read('lib/scaffold.rb')[/VERSION *= *'(.*)'/,1] or fail "Couldn't find Scaffold version"
8
+
9
+ GEM_FILES = FileList[
10
+ '[A-Z]*',
11
+ 'bin/**/*',
12
+ 'lib/**/*',
13
+ ]
14
+
15
+ spec = Gem::Specification.new do |spec|
16
+ spec.name = 'scaffold'
17
+ spec.files = GEM_FILES.to_a
18
+ spec.executables = 'scaffold'
19
+ spec.version = version
20
+ spec.add_dependency('templater', '>= 0.5.0')
21
+ spec.summary = 'Scaffold is a templating tool for Puppet'
22
+ spec.description = 'Scaffold allows you to create basic Puppet configuration, modules, nodes, classes, functions and types.'
23
+ spec.author = 'James Turnbull'
24
+ spec.email = 'james@lovedthanlost.net'
25
+ spec.homepage = 'http://github.com/jamtur01/puppet-scaffold'
26
+ spec.rdoc_options = ["--main", "README.rdoc"]
27
+ spec.require_paths = ["lib"]
10
28
  end
11
29
 
30
+ Rake::GemPackageTask.new(spec) do |pkg|
31
+ pkg.need_zip = true
32
+ pkg.need_tar = true
33
+ end
34
+
12
35
  desc "Release gem to Gemcutter"
13
36
  task :release => :build do
14
- system "gem push scaffold"
37
+ system "gem push scaffold-#{version}.gem"
15
38
  end
data/TODO.rdoc CHANGED
@@ -1,6 +1,4 @@
1
1
  = scaffold TODO
2
2
 
3
- * Create generators for:
4
- - Check for presence of modules before creation
5
- - Tests
6
-
3
+ - Check for presence of modules before creation
4
+ - Tests
@@ -1,21 +1,75 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'puppet'
5
- require 'templater'
6
- require File.dirname(__FILE__)+'/../lib/scaffold.rb'
4
+ require 'optparse'
5
+ require 'scaffold'
7
6
 
8
- Puppet.parse_config
7
+ # List the available templates
8
+ TEMPLATES = %w[puppet module node class define function type]
9
9
 
10
- case ARGV[0]
11
- when 'puppet', 'node'
10
+ options = {}
11
+
12
+ optparse = OptionParser.new do |opts|
13
+ # Set a banner, displayed at the top
14
+ # of the help screen.
15
+ opts.banner = 'Usage: scaffold [options] --template="template" options ...'
16
+
17
+ opts.separator ''
18
+ opts.separator 'Configuration options:'
19
+
20
+ options[:configdir] = nil
21
+ opts.on( '-c', '--configdir=DIRECTORY', 'Specify the location of your Puppet configuration directory') do |confdir|
22
+ options[:configdir] = confdir
23
+ end
24
+
25
+ options[:template] = nil
26
+ opts.on( '--template=TEMPLATE', TEMPLATES, 'Template to create') do |template|
27
+ options[:template] = template
28
+ end
29
+
30
+ opts.separator ""
31
+ opts.separator "Common options:"
32
+
33
+ opts.on_tail('-v', '--version', 'Show version') do
34
+ puts Scaffold::VERSION
35
+ exit
36
+ end
37
+
38
+ opts.on_tail('-h', '--help', 'Display this screen' ) do
39
+ puts opts
40
+ exit
41
+ end
42
+ end
43
+
44
+ # Process the options and fail on invalid options or if template is not specified
45
+ begin
46
+ optparse.parse!
47
+ mandatory = [:template]
48
+ missing = mandatory.select{ |param| options[param].nil? }
49
+ if not missing.empty?
50
+ puts "Missing options: #{missing.join(', ')}"
51
+ puts optparse
52
+ exit
53
+ end
54
+ rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument
55
+ puts $!.to_s
56
+ puts optparse
57
+ exit
58
+ end
59
+
60
+ # Specify destination directory according to the template specified
61
+ if options[:template] == 'puppet'
62
+ if options[:configdir]
63
+ dir = options[:configdir]
64
+ else
12
65
  dir = Puppet[:confdir]
13
- puts "#{dir}"
14
- Scaffold::Generator.run_cli(dir, 'scaffold', Scaffold::VERSION, ARGV)
15
- when 'module', 'class', 'define'
16
- dir = Puppet[:modulepath].split(':')
17
- Scaffold::Generator.run_cli(dir[0], 'scaffold', Scaffold::VERSION, ARGV)
18
- when 'function', 'type'
19
- dir = Puppet[:modulepath].split(':')
20
- Scaffold::Generator.run_cli(dir[0], 'scaffold', Scaffold::VERSION, ARGV)
66
+ end
67
+ else
68
+ dir = Puppet[:modulepath].split(':')
21
69
  end
70
+
71
+ # Add generator name to ARGV
72
+ ARGV.unshift(options[:template])
73
+
74
+ # Run the generator
75
+ Scaffold::Generator.run_cli dir.to_s, 'scaffold', Scaffold::VERSION, ARGV
@@ -2,11 +2,13 @@ path = File.dirname(__FILE__) + '/scaffold/'
2
2
 
3
3
  require 'rubygems'
4
4
  require 'templater'
5
-
5
+ require 'puppet'
6
6
  require path + 'generator'
7
7
 
8
8
  module Scaffold
9
9
 
10
- VERSION = '0.0.2'
10
+ Puppet.parse_config
11
+
12
+ VERSION = '0.0.3'
11
13
 
12
14
  end
@@ -1,7 +1,7 @@
1
1
  module Scaffold
2
2
  module Generator
3
3
  extend Templater::Manifold
4
-
4
+
5
5
  desc <<-DESC
6
6
  Create template Puppet objects and configurations.
7
7
  DESC
@@ -9,13 +9,13 @@ module Scaffold
9
9
  ##
10
10
  class ModuleGenerator < Templater::Generator
11
11
  desc <<-DESC
12
- Create an empty Puppet module
12
+ Create an empty Puppet module. You must specify the name of the module.
13
13
  DESC
14
14
 
15
15
  first_argument :module_name, :required => true, :desc => "Your module name."
16
16
 
17
17
  def self.source_root
18
- File.join(File.dirname(__FILE__), 'templates/module')
18
+ File.join(File.dirname(__FILE__), 'templates/module')
19
19
  end
20
20
 
21
21
  # Create all subsdirectories
@@ -53,7 +53,7 @@ module Scaffold
53
53
 
54
54
  class NodeGenerator < Templater::Generator
55
55
  desc <<-DESC
56
- Generate a basic Puppet node
56
+ Generate a basic Puppet node. You must specify the name of the node.
57
57
  DESC
58
58
 
59
59
  first_argument :node_name, :required => true, :desc => "Your node name."
@@ -76,7 +76,7 @@ module Scaffold
76
76
 
77
77
  class ClassGenerator < Templater::Generator
78
78
  desc <<-DESC
79
- Create a Puppet class.
79
+ Create a Puppet class. You must specify the name of the module to create the class in and the name of the class.
80
80
  DESC
81
81
 
82
82
  first_argument :module_name, :required => true, :desc => "The module that contains the class"
@@ -94,7 +94,7 @@ module Scaffold
94
94
 
95
95
  class DefineGenerator < Templater::Generator
96
96
  desc <<-DESC
97
- Create a Puppet definition.
97
+ Create a Puppet definition. You must specify the name of the module to create the definition in and the name of the definition.
98
98
  DESC
99
99
 
100
100
  first_argument :module_name, :required => true, :desc => "The module that contains the definition"
@@ -112,7 +112,7 @@ module Scaffold
112
112
 
113
113
  class FunctionGenerator < Templater::Generator
114
114
  desc <<-DESC
115
- Create a Puppet function.
115
+ Create a Puppet function. Specify the name of the module, the name of the function and the type of the function, either statement or rvalue. Generator defaults to statement.
116
116
  DESC
117
117
 
118
118
  first_argument :module_name, :required => true, :desc => "The module that contains the function"
@@ -136,7 +136,7 @@ module Scaffold
136
136
 
137
137
  class TypeGenerator < Templater::Generator
138
138
  desc <<-DESC
139
- Create a Puppet type and provider.
139
+ Create a Puppet type and provider. You must specify the module to create the type and provider in and the name of the type to be created.
140
140
  DESC
141
141
 
142
142
  first_argument :module_name, :required => true, :desc => "The module that contains the type"
@@ -168,7 +168,7 @@ module Scaffold
168
168
 
169
169
  class PuppetGenerator < Templater::Generator
170
170
  desc <<-DESC
171
- Generate a basic Puppet configuration - specify the location of your Puppet configuration directory, for example /etc/puppet.
171
+ Generate a basic Puppet configuration.
172
172
  DESC
173
173
 
174
174
  def self.source_root
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - James Turnbull
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-07 00:00:00 +10:00
17
+ date: 2010-05-14 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ extra_rdoc_files: []
41
41
 
42
42
  files:
43
43
  - TODO.rdoc
44
+ - CHANGELOG.rdoc
44
45
  - Rakefile
45
46
  - README.rdoc
46
47
  - bin/scaffold