itrigga-generator 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +49 -3
  2. data/VERSION +1 -1
  3. data/itrigga-generator.gemspec +66 -0
  4. metadata +5 -4
@@ -1,6 +1,53 @@
1
1
  = itrigga-generator
2
2
 
3
- Description goes here.
3
+ A flexible template rendering gem. We use this to dynamically generate monit scripts, logrotate scripts, cron scripts etc.
4
+ At the moment only erb templates are supported.
5
+
6
+ == How to use with config file
7
+ There are 2 ways to make the generator work - with or without a config file.
8
+ A config file is simply a hash of options serialized into YAML. An example (test.yml) is:
9
+ +
10
+ ---
11
+ processes_to_start: [:worker]
12
+ processes:
13
+ worker:
14
+ name: worker_1
15
+ identifier: 1
16
+ +
17
+ In this example there is a worker process whose template should be rendered. If this was a monit script then in the TEMPLATE_DIR there must be a matching template
18
+ named worker.monit.config
19
+
20
+ This can be invoked by:
21
+ +rake itrigga:generator TEMPLATE_DIR=/tmp/test/templates OUTPUT_DIR=/tmp/test/output CONFIG_FILE=/tmp/test/test.yml+
22
+ This will look for the template in /tmp/test/templates and put the rendered template into /tmp/test/output
23
+
24
+ If a config file is given then is must define a processes hash. Each key needs to match the name of the template.
25
+ Only the templates listed in the processes_to_start list will be rendered.
26
+
27
+ For this example the worker.monit.config file looks like this:
28
+ +
29
+ check process <%= name %> with pidfile <%= File.join("/var/run","worker_#{identifer}.pid") %>
30
+ start program = "/etc/init.d/itrigga start worker <%= identifer %>"
31
+ stop program = "/etc/init.d/itrigga stop worker <%= identifer %>"
32
+ group workers
33
+ +
34
+
35
+ The keys defined in the config file for each process are made available to the template as top level variables (in this case identifer and name)
36
+ Also any variables given to the rake task are also made available - so there will be variables named template_dir, output_dir and config_file.
37
+
38
+ == How to use with no config file
39
+ You can also set the CONFIG_FILE=false in the rake task. This will then just make the variables in the rake task available to the template.
40
+
41
+ eg
42
+ rake itrigga:generator PATTERN=logrotate TEMPLATE_DIR=/tmp/test/templates OUTPUT_DIR=/tmp/test/output CONFIG_FILE=false
43
+
44
+ == What if I have different templates in the TEMPLATE_DIR?
45
+ Use the PATTERN=xxxx variable (which can be any regex minus the start and end /). This will then filter the templates in the TEMPLATE_DIR.
46
+
47
+ == What if I have a template I don't want rendered?
48
+ Change the template name to: worker.monit.config.inactive
49
+
50
+
4
51
 
5
52
  == Contributing to itrigga-generator
6
53
 
@@ -14,6 +61,5 @@ Description goes here.
14
61
 
15
62
  == Copyright
16
63
 
17
- Copyright (c) 2011 Anson. See LICENSE.txt for
64
+ Copyright (c) 2011 iTrigga Media. See LICENSE.txt for
18
65
  further details.
19
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{itrigga-generator}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Anson Kelly"]
12
+ s.date = %q{2011-10-05}
13
+ s.description = %q{Generates config files from templates using information from a config yaml file}
14
+ s.email = %q{ansonkelly@itrigga.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "itrigga-generator.gemspec",
28
+ "lib/itrigga-generator.rb",
29
+ "lib/itrigga-generator/constants.rb",
30
+ "lib/itrigga-generator/generator.rb",
31
+ "lib/tasks/generator.rake",
32
+ "test/helper.rb",
33
+ "test/test_itrigga-generator.rb"
34
+ ]
35
+ s.homepage = %q{http://gems.itrigga.com/itrigga-generator}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib", "lib", "lib"]
38
+ s.rubygems_version = %q{1.3.7}
39
+ s.summary = %q{Generates config files from templates}
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
49
+ s.add_development_dependency(%q<rcov>, [">= 0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<hashie>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ s.add_dependency(%q<rspec>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<hashie>, [">= 0"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
62
+ s.add_dependency(%q<rcov>, [">= 0"])
63
+ s.add_dependency(%q<rspec>, [">= 0"])
64
+ end
65
+ end
66
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itrigga-generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anson Kelly
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-04 00:00:00 +01:00
18
+ date: 2011-10-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -109,6 +109,7 @@ files:
109
109
  - README.rdoc
110
110
  - Rakefile
111
111
  - VERSION
112
+ - itrigga-generator.gemspec
112
113
  - lib/itrigga-generator.rb
113
114
  - lib/itrigga-generator/constants.rb
114
115
  - lib/itrigga-generator/generator.rb