templater 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ === 1.0.0 2009-08-27
2
+
3
+ * Ruby 1.9 compatibility
@@ -0,0 +1,64 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/templater.rb
6
+ lib/templater/actions/action.rb
7
+ lib/templater/actions/directory.rb
8
+ lib/templater/actions/empty_directory.rb
9
+ lib/templater/actions/file.rb
10
+ lib/templater/actions/template.rb
11
+ lib/templater/capture_helpers.rb
12
+ lib/templater/cli/generator.rb
13
+ lib/templater/cli/manifold.rb
14
+ lib/templater/cli/parser.rb
15
+ lib/templater/core_ext/kernel.rb
16
+ lib/templater/core_ext/string.rb
17
+ lib/templater/description.rb
18
+ lib/templater/discovery.rb
19
+ lib/templater/generator.rb
20
+ lib/templater/manifold.rb
21
+ lib/templater/spec/helpers.rb
22
+ script/console
23
+ script/destroy
24
+ script/generate
25
+ spec/actions/directory_spec.rb
26
+ spec/actions/empty_directory_spec.rb
27
+ spec/actions/file_spec.rb
28
+ spec/actions/template_spec.rb
29
+ spec/core_ext/string_spec.rb
30
+ spec/generator/actions_spec.rb
31
+ spec/generator/arguments_spec.rb
32
+ spec/generator/desc_spec.rb
33
+ spec/generator/destination_root_spec.rb
34
+ spec/generator/empty_directories_spec.rb
35
+ spec/generator/files_spec.rb
36
+ spec/generator/generators_spec.rb
37
+ spec/generator/glob_spec.rb
38
+ spec/generator/invocations_spec.rb
39
+ spec/generator/invoke_spec.rb
40
+ spec/generator/options_spec.rb
41
+ spec/generator/render_spec.rb
42
+ spec/generator/source_root_spec.rb
43
+ spec/generator/templates_spec.rb
44
+ spec/manifold_spec.rb
45
+ spec/options_parser_spec.rb
46
+ spec/results/erb.rbs
47
+ spec/results/file.rbs
48
+ spec/results/random.rbs
49
+ spec/results/simple_erb.rbs
50
+ spec/spec_helper.rb
51
+ spec/spec_helpers_spec.rb
52
+ spec/templater_spec.rb
53
+ spec/templates/erb.rbt
54
+ spec/templates/glob/README
55
+ spec/templates/glob/arg.js
56
+ spec/templates/glob/hellothar.%feh%
57
+ spec/templates/glob/hellothar.html.%feh%
58
+ spec/templates/glob/subfolder/jessica_alba.jpg
59
+ spec/templates/glob/subfolder/monkey.rb
60
+ spec/templates/glob/test.rb
61
+ spec/templates/literals_erb.rbt
62
+ spec/templates/simple.rbt
63
+ spec/templates/simple_erb.rbt
64
+ templater.gemspec
@@ -1,6 +1,14 @@
1
1
  = Templater
2
2
 
3
- Templater is a system for generating files. Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts:
3
+ * http://github.com/jnicklas/templater
4
+
5
+ == Summary
6
+
7
+ Templater is a Ruby framework for building code generators.
8
+
9
+ == Description
10
+
11
+ Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts:
4
12
 
5
13
  - Actions (File copying routines, templates generation and directories creation routines).
6
14
  - Generators (set of rules).
@@ -68,7 +76,7 @@ This is how to create a very simple system for generating things:
68
76
 
69
77
  The generator classes override the source_root method to specify where templates will be located. All subclasses of Templater::Generator that have any actions must do this. The +template+ and +file+ methods add actions to the generator. In the first case, a template that is rendered with ERB and then put in its destination location, in the other case a file that is copied. +empty_directory+ action creates empty directory under destination root.
70
78
 
71
- Neither manifolds or generators actually do anything by themselves, they are just abstract representations. The last line invokes the command-line-interface, which fetches the desired generator, tells it to render its templates and checks with the user if there are any problems. The generators can easily be used without the command-line-interface, so it is easy to construct an alternative interface.
79
+ Neither manifolds or generators actually do anything by themselves, they are just abstract represenations. The last line invokes the command-line-interface, which fetches the desired generator, tells it to render its templates and checks with the user if there are any problems. The generators can easily be used without the command-line-interface, so it is easy to construct an alternative interface.
72
80
 
73
81
  == Invoking other generators
74
82
 
@@ -233,3 +241,26 @@ A generator for creating a model class, such as it used by Merb or Rails, could
233
241
  add :model, ModelGenerator
234
242
 
235
243
  end
244
+
245
+ == License
246
+
247
+ Copyright (c) 2008 Jonas Nicklas, Michael S. Klishin
248
+
249
+ Permission is hereby granted, free of charge, to any person obtaining
250
+ a copy of this software and associated documentation files (the
251
+ "Software"), to deal in the Software without restriction, including
252
+ without limitation the rights to use, copy, modify, merge, publish,
253
+ distribute, sublicense, and/or sell copies of the Software, and to
254
+ permit persons to whom the Software is furnished to do so, subject to
255
+ the following conditions:
256
+
257
+ The above copyright notice and this permission notice shall be
258
+ included in all copies or substantial portions of the Software.
259
+
260
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
261
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
262
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
263
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
264
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
265
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
266
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,143 +1,23 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'rubygems/specification'
4
- require 'rake/rdoctask'
5
- require 'date'
6
- require 'spec/rake/spectask'
7
- require File.join(File.dirname(__FILE__), 'lib', 'templater')
8
-
9
- PLUGIN = "templater"
10
- NAME = "templater"
11
- AUTHOR = "Jonas Nicklas, Michael Klishin"
12
- EMAIL = "jonas.nicklas@gmail.com, michael.s.klishin@gmail.com"
13
- HOMEPAGE = "http://templater.rubyforge.org/"
14
- SUMMARY = "File generation system"
15
-
16
-
17
- # Used by release task
18
- RUBY_FORGE_PROJECT = "templater"
19
- GEM_NAME = NAME
20
- PROJECT_URL = HOMEPAGE
21
- PROJECT_SUMMARY = SUMMARY
22
- PROJECT_DESCRIPTION = SUMMARY
23
-
24
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
25
- GEM_VERSION = Templater::VERSION + PKG_BUILD
26
- RELEASE_NAME = "REL #{GEM_VERSION}"
27
-
28
- require "extlib/tasks/release"
29
-
30
- #
31
- # ==== Gemspec and installation
32
- #
33
-
34
- spec = Gem::Specification.new do |s|
35
- s.name = NAME
36
- s.version = Templater::VERSION
37
- s.platform = Gem::Platform::RUBY
38
- s.has_rdoc = true
39
- s.extra_rdoc_files = ["README", "LICENSE", 'ROADMAP']
40
- s.summary = SUMMARY
41
- s.description = s.summary
42
- s.author = AUTHOR
43
- s.email = EMAIL
44
- s.homepage = HOMEPAGE
45
- s.require_path = 'lib'
46
- s.autorequire = PLUGIN
47
- s.files = %w(LICENSE README Rakefile ROADMAP) + Dir.glob("{lib,spec}/**/*")
48
-
49
- s.add_dependency "highline", ">= 1.4.0"
50
- s.add_dependency "diff-lcs", ">= 1.1.2"
51
- s.add_dependency "extlib", ">= 0.9.5"
52
- end
53
-
54
- Rake::GemPackageTask.new(spec) do |pkg|
55
- pkg.gem_spec = spec
56
- end
57
-
58
- desc "removes any generated content"
59
- task :clean do
60
- FileUtils.rm_rf "clobber/*"
61
- FileUtils.rm_rf "pkg/*"
62
- end
63
-
64
- desc "install the plugin locally"
65
- task :install => [:clean, :package] do
66
- sh %{sudo gem install pkg/#{NAME}-#{Templater::VERSION} --no-update-sources}
67
- end
68
-
69
- desc "create a gemspec file"
70
- task :make_spec do
71
- File.open("#{GEM}.gemspec", "w") do |file|
72
- file.puts spec.to_ruby
73
- end
74
- end
75
-
76
- namespace :jruby do
77
-
78
- desc "Run :package and install the resulting .gem with jruby"
79
- task :install => :package do
80
- sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Templater::VERSION}.gem --no-rdoc --no-ri}
81
- end
82
-
83
- end
84
-
85
- #
86
- # ==== RDoc
87
- #
88
-
89
- desc 'Generate documentation for Templater.'
90
- Rake::RDocTask.new(:doc) do |rdoc|
91
- rdoc.rdoc_dir = 'doc'
92
- rdoc.title = 'Templater'
93
- rdoc.options << '--line-numbers' << '--inline-source'
94
- rdoc.rdoc_files.include('README')
95
- rdoc.rdoc_files.include('LICENSE')
96
- rdoc.rdoc_files.include('lib/**/*.rb')
97
- end
98
-
99
- #
100
- # ==== RCov
101
- #
102
-
103
- desc "Run coverage suite"
104
- task :rcov do
105
- require 'fileutils'
106
- FileUtils.rm_rf("coverage") if File.directory?("coverage")
107
- FileUtils.mkdir("coverage")
108
- path = File.expand_path(Dir.pwd)
109
- files = Dir["spec/**/*_spec.rb"]
110
- files.each do |spec|
111
- puts "Getting coverage for #{File.expand_path(spec)}"
112
- command = %{rcov #{File.expand_path(spec)} --aggregate #{path}/coverage/data.data}
113
- command += " --no-html" unless spec == files.last
114
- `#{command} 2>&1`
115
- end
116
- end
117
-
118
- file_list = FileList['spec/**/*_spec.rb']
119
-
120
- desc "Run all examples"
121
- Spec::Rake::SpecTask.new('spec') do |t|
122
- t.spec_files = file_list
123
- end
124
-
125
- namespace :spec do
126
- desc "Run all examples with RCov"
127
- Spec::Rake::SpecTask.new('rcov') do |t|
128
- t.spec_files = file_list
129
- t.rcov = true
130
- t.rcov_dir = "doc/coverage"
131
- t.rcov_opts = ['--exclude', 'spec']
132
- end
133
-
134
- desc "Generate an html report"
135
- Spec::Rake::SpecTask.new('report') do |t|
136
- t.spec_files = file_list
137
- t.spec_opts = ["--format", "html:doc/reports/specs.html"]
138
- t.fail_on_error = false
139
- end
140
- end
141
-
142
- desc 'Default: run unit tests.'
143
- task :default => 'spec'
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/templater'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'templater' do
14
+ self.developer 'Jonas Nicklas', 'jonas.nicklas@gmail.com'
15
+ self.rubyforge_name = self.name # TODO this is default value
16
+ self.extra_deps << ['highline', ">= 1.4.0"]
17
+ self.extra_deps << ['diff-lcs', ">= 1.1.2"]
18
+ self.extra_deps << ['extlib', ">= 0.9.5"]
19
+ self.extra_dev_deps << ['rspec', '>= 1.2.8']
20
+ end
21
+
22
+ require 'newgem/tasks'
23
+ Dir['tasks/**/*.rake'].each { |t| load t }
@@ -14,7 +14,6 @@ require path + 'actions/template'
14
14
  require path + 'actions/file'
15
15
  require path + 'actions/directory'
16
16
  require path + 'actions/empty_directory'
17
- require path + 'actions/evaluation'
18
17
  require path + 'description'
19
18
  require path + 'generator'
20
19
  require path + 'manifold'
@@ -45,6 +44,6 @@ module Templater
45
44
  class MalformattedArgumentError < ArgumentError #:nodoc:
46
45
  end
47
46
 
48
- VERSION = '0.5.0'
47
+ VERSION = '1.0.0'
49
48
 
50
49
  end
@@ -5,11 +5,11 @@ module Templater
5
5
  class Generator
6
6
 
7
7
  def initialize(generator_name, generator_class, destination_root, name, version)
8
- @generator_name = generator_name
8
+ @generator_name = generator_name
9
9
  @destination_root = destination_root
10
- @generator_class = generator_class
11
- @name = name
12
- @version = version
10
+ @generator_class = generator_class
11
+ @name = name
12
+ @version = version
13
13
  end
14
14
 
15
15
  def version
@@ -20,11 +20,11 @@ module Templater
20
20
  # outputs a helpful message and quits
21
21
  def help
22
22
  puts "Usage: #{@name} #{@generator_name} [options] [args]"
23
- puts
23
+ puts ''
24
24
  puts @generator_class.desc
25
- puts
25
+ puts ''
26
26
  puts @options[:opts]
27
- puts
27
+ puts ''
28
28
  exit
29
29
  end
30
30
 
@@ -75,11 +75,9 @@ module Templater
75
75
  step_through_templates
76
76
 
77
77
  # Run hooks
78
- unless @options[:pretend]
79
- @generator.after_run
80
- @generator.after_generation unless @options[:delete]
81
- @generator.after_deletion if @options[:delete]
82
- end
78
+ @generator.after_run
79
+ @generator.after_generation unless @options[:delete]
80
+ @generator.after_deletion if @options[:delete]
83
81
  end
84
82
 
85
83
  def step_through_templates
@@ -125,7 +123,7 @@ module Templater
125
123
  puts "Rendering " + template.relative_destination
126
124
  puts ""
127
125
  # outputs each line of the file with the row number prepended
128
- template.render.to_a.each_with_index do |line, i|
126
+ template.render.to_lines.each_with_index do |line, i|
129
127
  puts((i+1).to_s.rjust(4) + ': ' + line)
130
128
  end
131
129
  puts ""
@@ -136,7 +134,7 @@ module Templater
136
134
  puts "Showing differences for " + template.relative_destination
137
135
  puts ""
138
136
 
139
- diffs = Diff::LCS.diff(::File.read(template.destination).to_s.to_a, template.render.to_a).first
137
+ diffs = Diff::LCS.diff(::File.read(template.destination).to_s.to_lines, template.render.to_lines).first
140
138
 
141
139
  diffs.each do |diff|
142
140
  output_diff_line(diff)
@@ -44,7 +44,7 @@ module Templater
44
44
  end.each do |name, generator|
45
45
  print " "
46
46
  print name.to_s.ljust(33)
47
- print generator.desc.to_a.first.chomp if generator.desc
47
+ print generator.desc.to_lines.first.chomp if generator.desc
48
48
  print "\n"
49
49
  end
50
50
  puts @options[:opts]
@@ -11,4 +11,4 @@ module Kernel
11
11
  ret
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -2,7 +2,16 @@ class String
2
2
 
3
3
  def realign_indentation
4
4
  basis = self.index(/\S/) # find the first non-whitespace character
5
- return self.to_a.map { |s| s[basis..-1] }.join
5
+ return self.to_lines.map { |s| s[basis..-1] }.join
6
6
  end
7
-
8
- end
7
+
8
+ if "".respond_to?(:lines)
9
+ def to_lines
10
+ lines.to_a
11
+ end
12
+ else
13
+ def to_lines
14
+ to_a
15
+ end
16
+ end
17
+ end
@@ -1,23 +1,25 @@
1
1
  module Templater
2
-
2
+
3
3
  class Description
4
4
  attr_accessor :name, :options, :block
5
-
5
+
6
6
  def initialize(name, options={}, &block)
7
7
  @name = name
8
8
  @options = options
9
9
  @block = block
10
- end
10
+ end
11
11
  end
12
-
12
+
13
13
  class ActionDescription < Description
14
+
14
15
  def compile(generator)
15
16
  @block.call(generator)
16
17
  end
18
+
17
19
  end
18
-
20
+
19
21
  class ArgumentDescription < Description
20
-
22
+
21
23
  # Checks if the given argument is valid according to this description
22
24
  #
23
25
  # === Parameters
@@ -33,7 +35,7 @@ module Templater
33
35
  elsif options[:as] == :array and not argument.is_a?(Array)
34
36
  raise Templater::MalformattedArgumentError, "Expected the argument to be an Array, but was '#{argument.inspect}'"
35
37
  end
36
-
38
+
37
39
  invalid = catch :invalid do
38
40
  block.call(argument) if block
39
41
  throw :invalid, :not_invalid
@@ -41,7 +43,7 @@ module Templater
41
43
  raise Templater::ArgumentError, invalid unless invalid == :not_invalid
42
44
  end
43
45
  end
44
-
46
+
45
47
  def extract(argument)
46
48
  case options[:as]
47
49
  when :hash
@@ -58,11 +60,11 @@ module Templater
58
60
  end
59
61
  return argument
60
62
  end
61
-
63
+
62
64
  end
63
-
65
+
64
66
  class InvocationDescription < Description
65
-
67
+
66
68
  def get(generator)
67
69
  klass = generator.class.manifold.generator(name)
68
70
  if klass and block
@@ -71,6 +73,6 @@ module Templater
71
73
  klass.new(generator.destination_root, generator.options, *generator.arguments)
72
74
  end
73
75
  end
74
-
76
+
75
77
  end
76
- end
78
+ end
@@ -308,25 +308,6 @@ module Templater
308
308
  end
309
309
  end
310
310
 
311
- # Evaluates given block in the scope of generator. Useful for modification
312
- # of existing files, for instance, Merb generators may update routing
313
- # file or something.
314
- #
315
- # === Parameters
316
- # name<Symbol>:: The name of this custom action
317
- # options<Hash>:: Options for this custom action
318
- # &block<Proc>:: A block to execute when the generator is instantiated
319
- #
320
- # === Options
321
- # :before<Symbol>:: Name of a method to execute before this template is invoked
322
- # :after<Symbol>:: Name of a method to execute after this template is invoked
323
- def custom_action(name, *args, &block)
324
- options = args.last.is_a?(Hash) ? args.pop : {}
325
- actions[name] = ActionDescription.new(name, options) do |generator|
326
- Actions::Evaluation.new(generator, name, options, &block)
327
- end
328
- end
329
-
330
311
  # An easy way to add many templates to a generator, each item in the list is added as a
331
312
  # template. The provided list can be either an array of Strings or a Here-Doc with templates
332
313
  # on individual lines.
@@ -344,7 +325,8 @@ module Templater
344
325
  # template_list ['a/third/template.rb', 'and/a/fourth.js']
345
326
  # end
346
327
  def template_list(list)
347
- list.to_a.each do |item|
328
+ list = list.to_lines if list.is_a?(String)
329
+ list.each do |item|
348
330
  item = item.to_s.chomp.strip
349
331
  self.template(item.gsub(/[\.\/]/, '_').to_sym, item)
350
332
  end
@@ -366,7 +348,8 @@ module Templater
366
348
  # file_list ['a/third/file.gif', 'and/a/fourth.rb']
367
349
  # end
368
350
  def file_list(list)
369
- list.to_a.each do |item|
351
+ list = list.to_lines if list.is_a?(String)
352
+ list.each do |item|
370
353
  item = item.to_s.chomp.strip
371
354
  self.file(item.gsub(/[\.\/]/, '_').to_sym, item)
372
355
  end
@@ -388,7 +371,8 @@ module Templater
388
371
  # directory_list ['a/third/directory', 'and/a/fourth']
389
372
  # end
390
373
  def directory_list(list)
391
- list.to_a.each do |item|
374
+ list = list.to_lines if list.is_a?(String)
375
+ list.each do |item|
392
376
  item = item.to_s.chomp.strip
393
377
  self.directory(item.gsub(/[\.\/]/, '_').to_sym, item)
394
378
  end
@@ -557,6 +541,8 @@ module Templater
557
541
 
558
542
  # Finds and returns all templates and files for this generators whose options match its options.
559
543
  #
544
+ # === Parameters
545
+ # type<Symbol>:: The type of actions to look up (optional)
560
546
  # === Returns
561
547
  # [Templater::Actions::*]:: The found templates and files.
562
548
  def actions(type=nil)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/templater.rb'}"
9
+ puts "Loading templater gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -12,6 +12,7 @@ end
12
12
  require 'templater.rb'
13
13
  require 'rubygems'
14
14
  require 'spec'
15
+ require 'spec/autorun'
15
16
  require 'fileutils'
16
17
 
17
18
  # Added a cross-platform temporary directory helper
@@ -0,0 +1,54 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{templater}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jonas Nicklas"]
9
+ s.date = %q{2009-08-28}
10
+ s.description = %q{Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts:
11
+
12
+ - Actions (File copying routines, templates generation and directories creation routines).
13
+ - Generators (set of rules).
14
+ - Manifolds (generator suites).
15
+ - The command line interface.
16
+
17
+ Hierarchy is pretty simple: manifold has one or many public and private generators. Public ones are supposed to be called
18
+ by end user. Generators have one or more action that specify what they do, where they take files, how they name resulting
19
+ files and so forth.}
20
+ s.email = ["jonas.nicklas@gmail.com"]
21
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
22
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "lib/templater.rb", "lib/templater/actions/action.rb", "lib/templater/actions/directory.rb", "lib/templater/actions/empty_directory.rb", "lib/templater/actions/file.rb", "lib/templater/actions/template.rb", "lib/templater/capture_helpers.rb", "lib/templater/cli/generator.rb", "lib/templater/cli/manifold.rb", "lib/templater/cli/parser.rb", "lib/templater/core_ext/kernel.rb", "lib/templater/core_ext/string.rb", "lib/templater/description.rb", "lib/templater/discovery.rb", "lib/templater/generator.rb", "lib/templater/manifold.rb", "lib/templater/spec/helpers.rb", "script/console", "script/destroy", "script/generate", "spec/actions/directory_spec.rb", "spec/actions/empty_directory_spec.rb", "spec/actions/file_spec.rb", "spec/actions/template_spec.rb", "spec/core_ext/string_spec.rb", "spec/generator/actions_spec.rb", "spec/generator/arguments_spec.rb", "spec/generator/desc_spec.rb", "spec/generator/destination_root_spec.rb", "spec/generator/empty_directories_spec.rb", "spec/generator/files_spec.rb", "spec/generator/generators_spec.rb", "spec/generator/glob_spec.rb", "spec/generator/invocations_spec.rb", "spec/generator/invoke_spec.rb", "spec/generator/options_spec.rb", "spec/generator/render_spec.rb", "spec/generator/source_root_spec.rb", "spec/generator/templates_spec.rb", "spec/manifold_spec.rb", "spec/options_parser_spec.rb", "spec/results/erb.rbs", "spec/results/file.rbs", "spec/results/random.rbs", "spec/results/simple_erb.rbs", "spec/spec_helper.rb", "spec/spec_helpers_spec.rb", "spec/templater_spec.rb", "spec/templates/erb.rbt", "spec/templates/glob/README", "spec/templates/glob/arg.js", "spec/templates/glob/hellothar.%feh%", "spec/templates/glob/hellothar.html.%feh%", "spec/templates/glob/subfolder/jessica_alba.jpg", "spec/templates/glob/subfolder/monkey.rb", "spec/templates/glob/test.rb", "spec/templates/literals_erb.rbt", "spec/templates/simple.rbt", "spec/templates/simple_erb.rbt", "templater.gemspec"]
23
+ s.homepage = %q{http://github.com/jnicklas/templater}
24
+ s.rdoc_options = ["--main", "README.rdoc"]
25
+ s.require_paths = ["lib"]
26
+ s.rubyforge_project = %q{templater}
27
+ s.rubygems_version = %q{1.3.5}
28
+ s.summary = %q{Templater has the ability to both copy files from A to B and also to render templates using ERB}
29
+
30
+ if s.respond_to? :specification_version then
31
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
32
+ s.specification_version = 3
33
+
34
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
35
+ s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
36
+ s.add_runtime_dependency(%q<diff-lcs>, [">= 1.1.2"])
37
+ s.add_runtime_dependency(%q<extlib>, [">= 0.9.5"])
38
+ s.add_development_dependency(%q<rspec>, [">= 1.2.8"])
39
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
40
+ else
41
+ s.add_dependency(%q<highline>, [">= 1.4.0"])
42
+ s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
43
+ s.add_dependency(%q<extlib>, [">= 0.9.5"])
44
+ s.add_dependency(%q<rspec>, [">= 1.2.8"])
45
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
46
+ end
47
+ else
48
+ s.add_dependency(%q<highline>, [">= 1.4.0"])
49
+ s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
50
+ s.add_dependency(%q<extlib>, [">= 0.9.5"])
51
+ s.add_dependency(%q<rspec>, [">= 1.2.8"])
52
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
53
+ end
54
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jonas Nicklas, Michael Klishin
8
- autorequire: templater
7
+ - Jonas Nicklas
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-25 00:00:00 +02:00
12
+ date: 2009-08-28 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,54 +42,76 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.9.5
44
44
  version:
45
- description: File generation system
46
- email: jonas.nicklas@gmail.com, michael.s.klishin@gmail.com
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.8
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.3.3
64
+ version:
65
+ description: |-
66
+ Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts:
67
+
68
+ - Actions (File copying routines, templates generation and directories creation routines).
69
+ - Generators (set of rules).
70
+ - Manifolds (generator suites).
71
+ - The command line interface.
72
+
73
+ Hierarchy is pretty simple: manifold has one or many public and private generators. Public ones are supposed to be called
74
+ by end user. Generators have one or more action that specify what they do, where they take files, how they name resulting
75
+ files and so forth.
76
+ email:
77
+ - jonas.nicklas@gmail.com
47
78
  executables: []
48
79
 
49
80
  extensions: []
50
81
 
51
82
  extra_rdoc_files:
52
- - README
53
- - LICENSE
54
- - ROADMAP
83
+ - History.txt
84
+ - Manifest.txt
55
85
  files:
56
- - LICENSE
57
- - README
86
+ - History.txt
87
+ - Manifest.txt
88
+ - README.rdoc
58
89
  - Rakefile
59
- - ROADMAP
60
- - lib/templater
61
- - lib/templater/actions
90
+ - lib/templater.rb
62
91
  - lib/templater/actions/action.rb
63
92
  - lib/templater/actions/directory.rb
64
93
  - lib/templater/actions/empty_directory.rb
65
- - lib/templater/actions/evaluation.rb
66
94
  - lib/templater/actions/file.rb
67
95
  - lib/templater/actions/template.rb
68
96
  - lib/templater/capture_helpers.rb
69
- - lib/templater/cli
70
97
  - lib/templater/cli/generator.rb
71
98
  - lib/templater/cli/manifold.rb
72
99
  - lib/templater/cli/parser.rb
73
- - lib/templater/core_ext
74
100
  - lib/templater/core_ext/kernel.rb
75
101
  - lib/templater/core_ext/string.rb
76
102
  - lib/templater/description.rb
77
103
  - lib/templater/discovery.rb
78
104
  - lib/templater/generator.rb
79
105
  - lib/templater/manifold.rb
80
- - lib/templater/spec
81
106
  - lib/templater/spec/helpers.rb
82
- - lib/templater.rb
83
- - spec/actions
84
- - spec/actions/custom_action_spec.rb
107
+ - script/console
108
+ - script/destroy
109
+ - script/generate
85
110
  - spec/actions/directory_spec.rb
86
111
  - spec/actions/empty_directory_spec.rb
87
- - spec/actions/evaluation_spec.rb
88
112
  - spec/actions/file_spec.rb
89
113
  - spec/actions/template_spec.rb
90
- - spec/core_ext
91
114
  - spec/core_ext/string_spec.rb
92
- - spec/generator
93
115
  - spec/generator/actions_spec.rb
94
116
  - spec/generator/arguments_spec.rb
95
117
  - spec/generator/desc_spec.rb
@@ -106,7 +128,6 @@ files:
106
128
  - spec/generator/templates_spec.rb
107
129
  - spec/manifold_spec.rb
108
130
  - spec/options_parser_spec.rb
109
- - spec/results
110
131
  - spec/results/erb.rbs
111
132
  - spec/results/file.rbs
112
133
  - spec/results/random.rbs
@@ -114,25 +135,26 @@ files:
114
135
  - spec/spec_helper.rb
115
136
  - spec/spec_helpers_spec.rb
116
137
  - spec/templater_spec.rb
117
- - spec/templates
118
138
  - spec/templates/erb.rbt
119
- - spec/templates/glob
139
+ - spec/templates/glob/README
120
140
  - spec/templates/glob/arg.js
121
141
  - spec/templates/glob/hellothar.%feh%
122
142
  - spec/templates/glob/hellothar.html.%feh%
123
- - spec/templates/glob/README
124
- - spec/templates/glob/subfolder
125
143
  - spec/templates/glob/subfolder/jessica_alba.jpg
126
144
  - spec/templates/glob/subfolder/monkey.rb
127
145
  - spec/templates/glob/test.rb
128
146
  - spec/templates/literals_erb.rbt
129
147
  - spec/templates/simple.rbt
130
148
  - spec/templates/simple_erb.rbt
149
+ - templater.gemspec
131
150
  has_rdoc: true
132
- homepage: http://templater.rubyforge.org/
133
- post_install_message:
134
- rdoc_options: []
151
+ homepage: http://github.com/jnicklas/templater
152
+ licenses: []
135
153
 
154
+ post_install_message:
155
+ rdoc_options:
156
+ - --main
157
+ - README.rdoc
136
158
  require_paths:
137
159
  - lib
138
160
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -149,10 +171,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
171
  version:
150
172
  requirements: []
151
173
 
152
- rubyforge_project:
153
- rubygems_version: 1.3.1
174
+ rubyforge_project: templater
175
+ rubygems_version: 1.3.5
154
176
  signing_key:
155
- specification_version: 2
156
- summary: File generation system
177
+ specification_version: 3
178
+ summary: Templater has the ability to both copy files from A to B and also to render templates using ERB
157
179
  test_files: []
158
180
 
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- Copyright (c) 2008 Jonas Nicklas
2
- Copyright (c) 2008 Michael S. Klishin
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/ROADMAP DELETED
@@ -1,35 +0,0 @@
1
- Roadmap:
2
-
3
- 0.5:
4
-
5
- * Custom actions (ex.: append/prepend to existing files).
6
-
7
- 0.6:
8
-
9
- * Internals overview.
10
- * Plugins development guide.
11
- * Overall improvements in documentation.
12
-
13
- 0.7:
14
-
15
- * Haml support.
16
-
17
- 0.8:
18
-
19
- * Interactive UI.
20
-
21
- 0.9:
22
-
23
- * Built-in generators generator.
24
- * Executable to run the generator above.
25
- * Clean up as much as possible before stabilization period.
26
-
27
- 1.0:
28
-
29
- * Redundant spec coverage.
30
- * Generators in natural languages with Treetop. We can write generators using
31
- plain text and use Cucumber-like steps to process actions.
32
-
33
- 1.x:
34
-
35
- * Add magic template names for files.
@@ -1,21 +0,0 @@
1
- module Templater
2
- module Actions
3
- class Evaluation < Action
4
- attr_reader :generaor, :name, :options, :operation
5
-
6
- def initialize(generator, name, options = {}, &operation)
7
- @generator, @name = generator, name
8
- @options = options
9
- @operation = operation
10
- end
11
-
12
- def render
13
- self.generator.instance_eval(&operation) || ''
14
- end
15
-
16
- def identical?
17
- false
18
- end
19
- end
20
- end
21
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Templater::Generator, ".custom_action" do
4
- before do
5
- @generator_class = Templater::Generator
6
- @generator_class.stub!(:source_root).and_return('/tmp/source')
7
- end
8
-
9
- it 'evaluates given block in context of generator' do
10
- $custom_action_evaluation_result = "not called yet"
11
- @generator_class.custom_action :update_routes_rb do
12
- $custom_action_evaluation_result = source_root
13
- end
14
-
15
- @generator_class.new("/tmp/destination").render!
16
- $custom_action_evaluation_result.should == "/tmp/source"
17
- end
18
- end
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Templater::Actions::Evaluation do
4
- before do
5
- @generator = mock('a generator')
6
- @generator.stub!(:source_root).and_return('/tmp/source')
7
- @generator.stub!(:destination_root).and_return('/tmp/destination')
8
- end
9
-
10
- describe '#render' do
11
- it "returns result of block evaluation" do
12
- evaluation = Templater::Actions::Evaluation.new(@generator, :monkey) do
13
- "noop"
14
- end
15
- evaluation.render.should == "noop"
16
- end
17
-
18
- it "returns empty string when block returned nil" do
19
- evaluation = Templater::Actions::Evaluation.new(@generator, :monkey) do
20
- nil
21
- end
22
- evaluation.render.should == ""
23
- end
24
- end
25
-
26
- describe "#identical?" do
27
- it "always returns false" do
28
- noop_evaluation = Templater::Actions::Evaluation.new(@generator, :monkey) do
29
- "noop"
30
- end
31
-
32
- another_evaluation = Templater::Actions::Evaluation.new(@generator, :monkey) do
33
- "noop"
34
- end
35
-
36
- noop_evaluation.should_not be_identical
37
- another_evaluation.should_not be_identical
38
- end
39
- end
40
- end