kissgen 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +15 -0
- data/Rakefile +87 -0
- data/bin/kissgen +10 -0
- data/lib/kissgen.rb +9 -0
- data/lib/kissgen/generator.rb +75 -0
- data/lib/kissgen/template.rb +47 -0
- data/lib/kissgen/version.rb +3 -0
- data/spec/public/generator_spec.rb +40 -0
- data/spec/public/generators/merb_app/README +3 -0
- data/spec/public/generators/merb_app/Rakefile +0 -0
- data/spec/public/generators/merb_app/app/controllers/application.rb +2 -0
- data/spec/public/generators/merb_app/app/controllers/exceptions.rb +13 -0
- data/spec/public/generators/merb_app/app/controllers/posts.rb +0 -0
- data/spec/public/generators/merb_app/app/helpers/global_helpers.rb +5 -0
- data/spec/public/generators/merb_app/app/models/article.rb +0 -0
- data/spec/public/generators/merb_app/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/spec/public/generators/merb_app/app/views/exceptions/not_acceptable.html.erb +38 -0
- data/spec/public/generators/merb_app/app/views/exceptions/not_found.html.erb +40 -0
- data/spec/public/generators/merb_app/app/views/layout/application.html.erb +11 -0
- data/spec/public/generators/merb_app/app/views/posts/index.html.erb +0 -0
- data/spec/public/generators/merb_app/setup.rb +3 -0
- data/spec/public/template_spec.rb +41 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +7 -0
- metadata +97 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Lance Carlson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
RC Generator
|
2
|
+
============
|
3
|
+
|
4
|
+
A simple code generator.
|
5
|
+
|
6
|
+
= API Usage
|
7
|
+
|
8
|
+
require 'rcgen'
|
9
|
+
KISSGen::Generator.new "/path/to/generator", "/path/where/files/are/generated"
|
10
|
+
KISSGen::Generator.generate(:pretend => true)
|
11
|
+
KISSGen::Generator.generate
|
12
|
+
|
13
|
+
= Console Usage (TODO)
|
14
|
+
|
15
|
+
rake generator:build <generator_name>
|
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
require "rake/gempackagetask"
|
4
|
+
require "rake/rdoctask"
|
5
|
+
require "spec/rake/spectask"
|
6
|
+
|
7
|
+
require "lib/kissgen/version"
|
8
|
+
|
9
|
+
NAME = "kissgen"
|
10
|
+
|
11
|
+
spec = Gem::Specification.new do |s|
|
12
|
+
s.name = NAME
|
13
|
+
s.version = KISSGen::VERSION
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
s.author = "Lance Carlson"
|
16
|
+
s.email = "lancecarlson@gmail.com"
|
17
|
+
s.homepage = "http://rcgen.rubyforge.org"
|
18
|
+
s.summary = "A Simple Code Generator"
|
19
|
+
s.bindir = "bin"
|
20
|
+
s.description = s.summary
|
21
|
+
s.executables = %w( kissgen )
|
22
|
+
s.require_path = "lib"
|
23
|
+
s.files = %w( LICENSE README Rakefile ) + Dir["{bin,spec,lib}/**/*"]
|
24
|
+
s.has_rdoc = true
|
25
|
+
s.extra_rdoc_files = %w( README LICENSE )
|
26
|
+
s.required_ruby_version = ">= 1.8.4"
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |package|
|
30
|
+
package.gem_spec = spec
|
31
|
+
end
|
32
|
+
|
33
|
+
##############################################################################
|
34
|
+
# installation & removal
|
35
|
+
##############################################################################
|
36
|
+
desc "Run :package and install the resulting .gem"
|
37
|
+
task :install do
|
38
|
+
sh %{rake package}
|
39
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Run :clean and uninstall the .gem"
|
43
|
+
task :uninstall => [:clean] do
|
44
|
+
sh %{sudo gem uninstall #{NAME}}
|
45
|
+
end
|
46
|
+
|
47
|
+
##############################################################################
|
48
|
+
# specs
|
49
|
+
##############################################################################
|
50
|
+
desc "Run specs"
|
51
|
+
Spec::Rake::SpecTask.new("specs") do |t|
|
52
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
53
|
+
t.spec_opts = File.read("spec/spec.opts").split("\n")
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Run specs with coverage"
|
57
|
+
Spec::Rake::SpecTask.new("rcov") do |t|
|
58
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
59
|
+
t.spec_opts = File.read("spec/spec.opts").split("\n")
|
60
|
+
t.rcov = true
|
61
|
+
t.rcov_opts = ['--exclude', 'gems', '--exclude', 'spec']
|
62
|
+
end
|
63
|
+
|
64
|
+
##############################################################################
|
65
|
+
# documentation
|
66
|
+
##############################################################################
|
67
|
+
Rake::RDocTask.new do |rdoc|
|
68
|
+
rdoc.rdoc_dir = 'doc'
|
69
|
+
rdoc.title = 'KISSGen'
|
70
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
71
|
+
rdoc.options << '--charset' << 'utf-8'
|
72
|
+
rdoc.rdoc_files.include("README", "LICENSE")
|
73
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'send rdoc to rubyforge'
|
77
|
+
task :rf_doc do
|
78
|
+
sh %{sudo chmod -R 755 doc}
|
79
|
+
sh %{/usr/bin/scp -r -p doc/* lancelot@rubyforge.org:/var/www/gforge-projects/anvil}
|
80
|
+
end
|
81
|
+
|
82
|
+
##############################################################################
|
83
|
+
# misc
|
84
|
+
##############################################################################
|
85
|
+
task :release => :package do
|
86
|
+
sh %{rubyforge add_release #{NAME} #{NAME} "#{KISSGen::VERSION}" pkg/#{NAME}-#{KISSGen::VERSION}.gem}
|
87
|
+
end
|
data/bin/kissgen
ADDED
data/lib/kissgen.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
module KISSGen
|
2
|
+
# The generator class is where you configure path and import files
|
3
|
+
#
|
4
|
+
# require 'rcgen'
|
5
|
+
# KISSGen::Generator.new "/path/to/generator", "/path/where/files/are/generated"
|
6
|
+
# KISSGen::Generator.generate(:pretend => true)
|
7
|
+
# KISSGen::Generator.generate
|
8
|
+
class Generator
|
9
|
+
class SetupFailure < StandardError; end
|
10
|
+
|
11
|
+
attr_reader :path, :copy_path, :files
|
12
|
+
attr_accessor :explain_pretend, :explain_created, :explain_footer
|
13
|
+
attr_accessor :setup_file_path
|
14
|
+
|
15
|
+
def initialize(path, copy_path)
|
16
|
+
@path = path
|
17
|
+
@copy_path = copy_path
|
18
|
+
@files = []
|
19
|
+
@explain_pretend = "== PRETEND MODE: Would have created the following files: =="
|
20
|
+
@explain_generate = "== Generated the following files: =="
|
21
|
+
@explain_footer = "====== Generator Finished ======"
|
22
|
+
|
23
|
+
import_setup
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_file_path
|
27
|
+
@path + "/setup.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Import setup file which is located in /path/to/generator/setup.rb
|
31
|
+
def import_setup
|
32
|
+
raise SetupFailure, "Setup file does not exist in #{File.expand_path(setup_file_path)}" unless File.exists?(setup_file_path)
|
33
|
+
instance_eval(File.new(setup_file_path).read)
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate(options = {})
|
37
|
+
puts(options[:pretend] ? @explain_pretend : @explain_generate)
|
38
|
+
|
39
|
+
@files.each do |file|
|
40
|
+
puts(options[:pretend] ? "#{file.copy_path}" : file.create)
|
41
|
+
end
|
42
|
+
|
43
|
+
puts @explain_footer
|
44
|
+
end
|
45
|
+
|
46
|
+
# Adds a file to the list of files to generate
|
47
|
+
#
|
48
|
+
# This will generate the template README file relative to the copy path
|
49
|
+
#
|
50
|
+
# file "README"
|
51
|
+
#
|
52
|
+
# or
|
53
|
+
#
|
54
|
+
# file "README", "README_PLEASE"
|
55
|
+
def file(relative_file_path, relative_copy_path = relative_file_path, options = {})
|
56
|
+
template = Template.new(self, relative_file_path, relative_copy_path)
|
57
|
+
@files << template
|
58
|
+
template
|
59
|
+
end
|
60
|
+
|
61
|
+
# Recursively adds a directory to the list of files to generate
|
62
|
+
#
|
63
|
+
# directory "app"
|
64
|
+
def directory(directory_path, relative_copy_path = directory_path, options = {})
|
65
|
+
Dir["#{File.join(@path, directory_path)}/**/*"].each do |file_path|
|
66
|
+
unless FileTest.directory?(file_path)
|
67
|
+
# Take the template file path and give relative paths
|
68
|
+
relative_path = Pathname.new(file_path).relative_path_from(Pathname.new(File.join(@path, directory_path)))
|
69
|
+
new_path = File.join(relative_copy_path, relative_path)
|
70
|
+
@files << Template.new(self, File.join(directory_path, relative_path), new_path)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module KISSGen
|
2
|
+
class Template
|
3
|
+
class SourceFileNotFoundError < StandardError; end
|
4
|
+
attr_reader :generator, :path, :copy_path
|
5
|
+
|
6
|
+
def initialize(generator, path, copy_path)
|
7
|
+
@generator = generator
|
8
|
+
@path = path
|
9
|
+
@copy_path = copy_path
|
10
|
+
|
11
|
+
source_path_check
|
12
|
+
end
|
13
|
+
|
14
|
+
def source_path_check
|
15
|
+
raise SourceFileNotFoundError, "Template source file could not be found at #{full_source_path}" unless File.exists?(full_source_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def full_source_path
|
19
|
+
File.join @generator.path, @path
|
20
|
+
end
|
21
|
+
|
22
|
+
def full_copy_path
|
23
|
+
File.join @generator.copy_path, @copy_path
|
24
|
+
end
|
25
|
+
|
26
|
+
# This will create the file with parsed data in the destination directory
|
27
|
+
def create
|
28
|
+
puts copy_path
|
29
|
+
FileUtils.mkdir_p(File.dirname(full_copy_path))
|
30
|
+
@file = File.new full_copy_path, "w"
|
31
|
+
@file.print output # Taylor OWNZ
|
32
|
+
@file.close
|
33
|
+
end
|
34
|
+
|
35
|
+
# Parsed ERB output
|
36
|
+
def output
|
37
|
+
ERB.new(IO.read(full_source_path)).result
|
38
|
+
end
|
39
|
+
|
40
|
+
# Will remove the file if it exists
|
41
|
+
def delete
|
42
|
+
raise "Need to create the file first. File: #{@file.inspect}" unless @file
|
43
|
+
File.delete(full_copy_path)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require(File.join(File.dirname(__FILE__), "/../spec_helper"))
|
2
|
+
|
3
|
+
describe KISSGen::Generator do
|
4
|
+
describe "new" do
|
5
|
+
before(:each) do
|
6
|
+
@path = File.dirname(__FILE__) + "/generators/merb_app"
|
7
|
+
@copy_path = File.expand_path(File.dirname(__FILE__) + "/generators/empty")
|
8
|
+
@bad_path = File.dirname(__FILE__) + "/doesnotexist"
|
9
|
+
@empty = File.dirname(__FILE__) + "/generators/empty"
|
10
|
+
@generator = KISSGen::Generator.new(@path, @copy_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should fail if the setup file cannot be found" do
|
14
|
+
lambda {
|
15
|
+
KISSGen::Generator.new(@empty, @copy_path)
|
16
|
+
}.should raise_error("Setup file does not exist in #{File.expand_path(@empty) + "/setup.rb"}")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should import template files for a new generator" do
|
20
|
+
@generator.files.length.should == 12
|
21
|
+
@generator.files[0].copy_path.should == "README"
|
22
|
+
@generator.files[1].copy_path.should == "Rakefile"
|
23
|
+
@generator.files[2].copy_path.should == "app/controllers/application.rb"
|
24
|
+
@generator.files[3].copy_path.should == "app/controllers/exceptions.rb"
|
25
|
+
@generator.files[4].copy_path.should == "app/controllers/posts.rb"
|
26
|
+
@generator.files[5].copy_path.should == "app/helpers/global_helpers.rb"
|
27
|
+
@generator.files[6].copy_path.should == "app/models/article.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should allow you to pretend to generate the files and output the results" do
|
31
|
+
@generator.generate(:pretend => true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should generate new template files when no options are not set" do
|
35
|
+
#@generator.generate
|
36
|
+
#puts @copy_path
|
37
|
+
#File.exists?(@copy_path + "/README").should be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,216 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
4
|
+
<title><%%= @exception_name %></title>
|
5
|
+
<style type="text/css" media="screen">
|
6
|
+
body {
|
7
|
+
font-family:arial;
|
8
|
+
font-size:11px;
|
9
|
+
}
|
10
|
+
h1 {
|
11
|
+
font-size:48px;
|
12
|
+
letter-spacing:-4px;
|
13
|
+
margin:0;
|
14
|
+
line-height:36px;
|
15
|
+
color:#333;
|
16
|
+
}
|
17
|
+
h1 sup {
|
18
|
+
font-size: 0.5em;
|
19
|
+
}
|
20
|
+
h1 sup.error_500, h1 sup.error_400 {
|
21
|
+
color:#990E05;
|
22
|
+
}
|
23
|
+
h1 sup.error_100, h1 sup.error_200 {
|
24
|
+
color:#00BF10;
|
25
|
+
}
|
26
|
+
h1 sup.error_300 {
|
27
|
+
/* pretty sure you cant 'see' status 300
|
28
|
+
errors but if you could I think they
|
29
|
+
would be blue */
|
30
|
+
color:#1B2099;
|
31
|
+
}
|
32
|
+
h2 {
|
33
|
+
font-size:36px;
|
34
|
+
letter-spacing:-3px;
|
35
|
+
margin:0;
|
36
|
+
line-height:28px;
|
37
|
+
color:#444;
|
38
|
+
}
|
39
|
+
a, a:visited {
|
40
|
+
color:#00BF10;
|
41
|
+
}
|
42
|
+
.internalError {
|
43
|
+
width:800px;
|
44
|
+
margin:50px auto;
|
45
|
+
}
|
46
|
+
.header {
|
47
|
+
border-bottom:10px solid #333;
|
48
|
+
margin-bottom:1px;
|
49
|
+
background-image: url("data:image/gif;base64,R0lGODlhAwADAIAAAP///8zMzCH5BAAAAAAALAAAAAADAAMAAAIEBHIJBQA7");
|
50
|
+
padding:20px;
|
51
|
+
}
|
52
|
+
table.trace {
|
53
|
+
width:100%;
|
54
|
+
font-family:courier, monospace;
|
55
|
+
letter-spacing:-1px;
|
56
|
+
border-collapse: collapse;
|
57
|
+
border-spacing:0;
|
58
|
+
}
|
59
|
+
table.trace tr td{
|
60
|
+
padding:0;
|
61
|
+
height:26px;
|
62
|
+
font-size:13px;
|
63
|
+
vertical-align:middle;
|
64
|
+
}
|
65
|
+
table.trace tr.file{
|
66
|
+
border-top:2px solid #fff;
|
67
|
+
background-color:#F3F3F3;
|
68
|
+
}
|
69
|
+
table.trace tr.source {
|
70
|
+
background-color:#F8F8F8;
|
71
|
+
display:none;
|
72
|
+
}
|
73
|
+
table.trace .open tr.source {
|
74
|
+
display:table-row;
|
75
|
+
}
|
76
|
+
table.trace tr.file td.expand {
|
77
|
+
width:23px;
|
78
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAIAAABvSEP3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdVJREFUeNqMVL+TwUAYxaRIOlEhlZHGDAUzzOQ61+AqXMV1lJSU7q/QRqm8KFUcJTNn5qJkaPyoKKVz7y4mF8na5Kt29tt9+/Z97/u81+vVQ4r9frdarS6Xi7ETDIZisRjxMGPfmk4niNPpZE+xLAugbPaZ53nzvtfMBe/3+/3dbuehBrAKhZdUKkVAWa9Xsiybv0CPZDJZLr/qa5/BwgwRjYqOKIvFYjQa/aNommZh0Ww2K5UqzwfoQOPxaLPZ3FAmk0+7lplMpt1u53J5OpBOR0eZEE9wHJfP5zud93g88QhluwWbjW+5VOmKBgKBer3eaDTDYeGBQF8+x7rqIYoiPgixWJazpA6HA+MSxRArkUgMh0M409g8Ho8+9wYxxCqVSq1W26EDHGM2m4HOHQrEc38f/Yn7cLmlIRhBENzcx8cVRZnPZ/YUep2BWkjTIfA+PKVpZAXR5QxsjiqCKvGEqqp443w+0dvy17swqD0HB3S73V5PpkNg1qBqt8kwGCjmPkinM0QJbIoEa7U6UG6ToVgs4V9G2g0ESoP5Aoi7KYX5oCgf8IKbkvn9/mr1LRQKESamzgJy0g0tSZIuB3nuGqRU9Vv9C4sKkUhEkp4soxvxI8AAhWrrtXa3X8EAAAAASUVORK5CYII=);
|
79
|
+
background-position:top left;
|
80
|
+
background-repeat:no-repeat;
|
81
|
+
}
|
82
|
+
table.trace .open tr.file td.expand {
|
83
|
+
width:19px;
|
84
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAXZJREFUeNrslK1ywkAUhcMOBomEOiSdqLxEBJX0NaijOsjyHGGmCGyQQYaiiiw4gktkcOmZbpsuuzQ/M5XnqJ2d3S/n3nM3rTzPLUP7/Tt0+pLcGQwG3W53OLyHzPMtjYL7q9UqSRLrD4E1Gj1orCvKYuFHUWTVkOM44/HjDcp8/lL4r6NerzeZPMm1KFw0QkDn83m5fP2lHA4fNQvRtNvtjsfDd0WzmSfb2e/fdTqdOvdh/HLJZLOn0+d2HJ+KRGzbdl23EpFlmed5cp2maRzHQq1lvQ5KMi6EUZBGfup6E1pTfd+vrGW7jbQ2C9hTt9BpqNyIWaAwAy6xg2eBz5iRC/NomiZhGN5sqmnkauo0BUGgVQoBjQ80oCACgNQdZHfTYBkF2mxCtWWAqunWpahxIDUt3QYUxIFQpJHyIWpXjinabKbbwItMHT+NyjchrP8QKaSQQgoppJBCCimkkEIKKaSQQgoppJBCCimkkEIKKaSo+hRgAEFD17X08O2NAAAAAElFTkSuQmCC);
|
85
|
+
background-position:top left;
|
86
|
+
background-repeat:no-repeat;
|
87
|
+
}
|
88
|
+
table.trace tr.source td.collapse {
|
89
|
+
width:19px;
|
90
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVxJREFUeNrs0zFygkAUBmBlUkgJHdABlQwVkVJKKUxBYWbkALTxMJwhltyDFkss03IF8pudIcwaDaDl/6pd2P327b7d+eHwMXs4lNkzggoVKlSoUKFChQoVKlSoUKFChQoVKlSoUKFChQqVEYqm6ft9+qiSJEkYho7jTlcw2fd9NOI4nq4gEdFwXXe1Cqco63VkWVbXRTqLhTpOwQRpF7quR1E0TgGhqvLKUFCyoQqG/rks3O6kZKW/eRFpevOCoGTXVTcMQ5EyxyDEkML1c5RzuZOICIyXqn7JBVez6282MWrx731HOv2qB8Hri2lamNk0DfpVVdV1Peodappmmua8bdvzuc7zfNprzrLMth1FnGh/X8MjCAIQv/cFz/+65PcDh7rbvYv2ZUfdj+PxsyzLgVl0hKwgTqeqKApx2LeOc7t98zyv/1FWOgvx9RPii23bmL9cetJ8Ed8CDAC6aFW8bCzFhwAAAABJRU5ErkJggg==);
|
91
|
+
background-position:bottom left;
|
92
|
+
background-repeat:no-repeat;
|
93
|
+
background-color:#6F706F;
|
94
|
+
}
|
95
|
+
table.trace tr td.path {
|
96
|
+
padding-left:10px;
|
97
|
+
}
|
98
|
+
table.trace tr td.code {
|
99
|
+
padding-left:35px;
|
100
|
+
white-space: pre;
|
101
|
+
line-height:9px;
|
102
|
+
padding-bottom:10px;
|
103
|
+
}
|
104
|
+
table.trace tr td.code em {
|
105
|
+
font-weight:bold;
|
106
|
+
color:#00BF10;
|
107
|
+
}
|
108
|
+
table.trace tr td.code a {
|
109
|
+
width: 20px;
|
110
|
+
float: left;
|
111
|
+
}
|
112
|
+
table.trace tr td.code .more {
|
113
|
+
color:#666;
|
114
|
+
}
|
115
|
+
table.trace tr td.line {
|
116
|
+
width:30px;
|
117
|
+
text-align:right;
|
118
|
+
padding-right:4px;
|
119
|
+
}
|
120
|
+
.footer {
|
121
|
+
margin-top:5px;
|
122
|
+
font-size:11px;
|
123
|
+
color:#444;
|
124
|
+
text-align:right;
|
125
|
+
}
|
126
|
+
</style>
|
127
|
+
</head>
|
128
|
+
<body>
|
129
|
+
<div class="internalError">
|
130
|
+
|
131
|
+
<div class="header">
|
132
|
+
<h1><%%= @exception_name %> <sup class="error_<%%= @exception.class::STATUS %>"><%%= @exception.class::STATUS %></sup></h1>
|
133
|
+
<%% if show_details = ::Merb::Config[:exception_details] -%>
|
134
|
+
<h2><%%= @exception.message %></h2>
|
135
|
+
<%% else -%>
|
136
|
+
<h2>Sorry about that...</h2>
|
137
|
+
<%% end -%>
|
138
|
+
<h3>Parameters</h3>
|
139
|
+
<ul>
|
140
|
+
<%% params[:original_params].each do |param, value| %>
|
141
|
+
<li><strong><%%= param %>:</strong> <%%= value.inspect %></li>
|
142
|
+
<%% end %>
|
143
|
+
<%%= "<li>None</li>" if params[:original_params].empty? %>
|
144
|
+
</ul>
|
145
|
+
|
146
|
+
<h3>Session</h3>
|
147
|
+
<ul>
|
148
|
+
<%% params[:original_session].each do |param, value| %>
|
149
|
+
<li><strong><%%= param %>:</strong> <%%= value.inspect %></li>
|
150
|
+
<%% end %>
|
151
|
+
<%%= "<li>None</li>" if params[:original_session].empty? %>
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
<h3>Cookies</h3>
|
155
|
+
<ul>
|
156
|
+
<%% params[:original_cookies].each do |param, value| %>
|
157
|
+
<li><strong><%%= param %>:</strong> <%%= value.inspect %></li>
|
158
|
+
<%% end %>
|
159
|
+
<%%= "<li>None</li>" if params[:original_cookies].empty? %>
|
160
|
+
</ul>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<%% if show_details %>
|
164
|
+
<table class="trace">
|
165
|
+
<%% @exception.backtrace.each_with_index do |line, index| %>
|
166
|
+
<tbody class="close">
|
167
|
+
<tr class="file">
|
168
|
+
<td class="expand">
|
169
|
+
</td>
|
170
|
+
<td class="path">
|
171
|
+
<%%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
|
172
|
+
<%% unless line.match(/\.erb:/) %>
|
173
|
+
in "<strong><%%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
|
174
|
+
<%% else %>
|
175
|
+
(<strong>ERB Template</strong>)
|
176
|
+
<%% end %>
|
177
|
+
</td>
|
178
|
+
<td class="line">
|
179
|
+
<a href="txmt://open?url=file://<%%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&line=<%%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%%=lineno%></a>
|
180
|
+
</td>
|
181
|
+
</tr>
|
182
|
+
<tr class="source">
|
183
|
+
<td class="collapse">
|
184
|
+
</td>
|
185
|
+
<td class="code" colspan="2"><%% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
|
186
|
+
<a href="txmt://open?url=file://<%%=file%>&line=<%%=llineno%>"><%%= llineno %></a><%%='<em>' if llineno==lineno.to_i %><%%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%%='</em>' if llineno==lineno.to_i %>
|
187
|
+
<%% end %>
|
188
|
+
|
189
|
+
</td>
|
190
|
+
</tr>
|
191
|
+
</tbody>
|
192
|
+
<%% end %>
|
193
|
+
</table>
|
194
|
+
<script type="text/javascript" charset="utf-8">
|
195
|
+
// swop the open & closed classes
|
196
|
+
els = document.getElementsByTagName('td');
|
197
|
+
for(i=0; i<els.length; i++){
|
198
|
+
if(els[i].className=='expand' || els[i].className=='collapse'){
|
199
|
+
els[i].onclick = function(e){
|
200
|
+
tbody = this.parentNode.parentNode;
|
201
|
+
if(tbody.className=='open'){
|
202
|
+
tbody.className='closed';
|
203
|
+
}else{
|
204
|
+
tbody.className='open';
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
</script>
|
210
|
+
<%% end %>
|
211
|
+
<div class="footer">
|
212
|
+
lots of love, from <a href="#">merb</a>
|
213
|
+
</div>
|
214
|
+
</div>
|
215
|
+
</body>
|
216
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div id="container">
|
2
|
+
<div id="header-container">
|
3
|
+
<img src="/images/merb.jpg">
|
4
|
+
<!-- <h1>Mongrel + Erb</h1> -->
|
5
|
+
<h2>pocket rocket web framework</h2>
|
6
|
+
<hr />
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div id="left-container">
|
10
|
+
<h3>Exception:</h3>
|
11
|
+
<p><%%= params[:exception] %></p>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div id="main-container">
|
15
|
+
<h3>Why am I seeing this page?</h3>
|
16
|
+
<p>Merb couldn't find an appropriate content_type to return,
|
17
|
+
based on what you said was available via provides() and
|
18
|
+
what the client requested. For more information, visit
|
19
|
+
http://merbivore.com/fixing_406_issues
|
20
|
+
</p>
|
21
|
+
|
22
|
+
<h3>Where can I find help?</h3>
|
23
|
+
<p>If you have any questions or if you can't figure something out, please take a
|
24
|
+
look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
|
25
|
+
feel free to come chat at irc.freenode.net, channel #merb.</p>
|
26
|
+
|
27
|
+
<h3>How do I edit this page?</h3>
|
28
|
+
<p>You can change what people see when this happens byy editing <tt>app/views/exceptions/not_found.html.erb</tt>.</p>
|
29
|
+
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div id="footer-container">
|
33
|
+
<hr />
|
34
|
+
<div class="left"></div>
|
35
|
+
<div class="right">© 2007 the merb dev team</div>
|
36
|
+
<p> </p>
|
37
|
+
</div>
|
38
|
+
</div>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<div id="container">
|
2
|
+
<div id="header-container">
|
3
|
+
<img src="/images/merb.jpg">
|
4
|
+
<!-- <h1>Mongrel + Erb</h1> -->
|
5
|
+
<h2>pocket rocket web framework</h2>
|
6
|
+
<hr />
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div id="left-container">
|
10
|
+
<h3>Exception:</h3>
|
11
|
+
<p><%%= params[:exception] %></p>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div id="main-container">
|
15
|
+
<h3>Welcome to Merb!</h3>
|
16
|
+
<p>Merb is a light-weight MVC framework written in Ruby. We hope you enjoy it.</p>
|
17
|
+
|
18
|
+
<h3>Where can I find help?</h3>
|
19
|
+
<p>If you have any questions or if you can't figure something out, please take a
|
20
|
+
look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
|
21
|
+
feel free to come chat at irc.freenode.net, channel #merb.</p>
|
22
|
+
|
23
|
+
<h3>How do I edit this page?</h3>
|
24
|
+
<p>You're seeing this page because you need to edit the following files:
|
25
|
+
<ul>
|
26
|
+
<li>config/merb.yml <strong><em>(optional)</em></strong></li>
|
27
|
+
<li>config/router.rb <strong><em>(recommended)</em></strong></li>
|
28
|
+
<li>app/views/exceptions/not_found.html.erb <strong><em>(recommended)</em></strong></li>
|
29
|
+
<li>app/views/layout/application.html.erb <strong><em>(change this layout)</em></strong></li>
|
30
|
+
</ul>
|
31
|
+
</p>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div id="footer-container">
|
35
|
+
<hr />
|
36
|
+
<div class="left"></div>
|
37
|
+
<div class="right">© 2007 the merb dev team</div>
|
38
|
+
<p> </p>
|
39
|
+
</div>
|
40
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
|
3
|
+
<head>
|
4
|
+
<title>Fresh Merb App</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<%%= catch_content :for_layout %>
|
10
|
+
</body>
|
11
|
+
</html>
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require(File.join(File.dirname(__FILE__), "/../spec_helper"))
|
2
|
+
|
3
|
+
describe KISSGen::Generator do
|
4
|
+
describe "new" do
|
5
|
+
before(:each) do
|
6
|
+
@copy_from = File.dirname(__FILE__) + "/generators/merb_app/app"
|
7
|
+
@copy_to = File.dirname(__FILE__) + "/generators/empty/app"
|
8
|
+
@path = "views/layout/application.html.erb"
|
9
|
+
@generator = mock(KISSGen::Generator)
|
10
|
+
@generator.stub!(:path).and_return(@copy_from)
|
11
|
+
@generator.stub!(:copy_path).and_return(@copy_to)
|
12
|
+
@template = KISSGen::Template.new(@generator, @path, @path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def application_erb_output
|
16
|
+
%Q(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
17
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
|
18
|
+
<head>
|
19
|
+
<title>Fresh Merb App</title>
|
20
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
21
|
+
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8">
|
22
|
+
</head>
|
23
|
+
<body>
|
24
|
+
<%= catch_content :for_layout %>
|
25
|
+
</body>
|
26
|
+
</html>)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have an erb parsed output" do
|
30
|
+
@template.output.should == application_erb_output
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create the file in the copy directory and feed it the erb output" do
|
34
|
+
@template.create
|
35
|
+
IO.read(@template.full_copy_path).should == application_erb_output
|
36
|
+
@template.delete
|
37
|
+
FileUtils.remove_dir(@copy_to)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kissgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lance Carlson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-08 23:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A Simple Code Generator
|
17
|
+
email: lancecarlson@gmail.com
|
18
|
+
executables:
|
19
|
+
- kissgen
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- LICENSE
|
25
|
+
files:
|
26
|
+
- LICENSE
|
27
|
+
- README
|
28
|
+
- Rakefile
|
29
|
+
- bin/kissgen
|
30
|
+
- spec/public
|
31
|
+
- spec/public/app
|
32
|
+
- spec/public/app/views
|
33
|
+
- spec/public/app/views/layout
|
34
|
+
- spec/public/generator_spec.rb
|
35
|
+
- spec/public/generators
|
36
|
+
- spec/public/generators/empty
|
37
|
+
- spec/public/generators/merb_app
|
38
|
+
- spec/public/generators/merb_app/app
|
39
|
+
- spec/public/generators/merb_app/app/controllers
|
40
|
+
- spec/public/generators/merb_app/app/controllers/application.rb
|
41
|
+
- spec/public/generators/merb_app/app/controllers/exceptions.rb
|
42
|
+
- spec/public/generators/merb_app/app/controllers/posts.rb
|
43
|
+
- spec/public/generators/merb_app/app/helpers
|
44
|
+
- spec/public/generators/merb_app/app/helpers/global_helpers.rb
|
45
|
+
- spec/public/generators/merb_app/app/models
|
46
|
+
- spec/public/generators/merb_app/app/models/article.rb
|
47
|
+
- spec/public/generators/merb_app/app/views
|
48
|
+
- spec/public/generators/merb_app/app/views/exceptions
|
49
|
+
- spec/public/generators/merb_app/app/views/exceptions/internal_server_error.html.erb
|
50
|
+
- spec/public/generators/merb_app/app/views/exceptions/not_acceptable.html.erb
|
51
|
+
- spec/public/generators/merb_app/app/views/exceptions/not_found.html.erb
|
52
|
+
- spec/public/generators/merb_app/app/views/layout
|
53
|
+
- spec/public/generators/merb_app/app/views/layout/application.html.erb
|
54
|
+
- spec/public/generators/merb_app/app/views/posts
|
55
|
+
- spec/public/generators/merb_app/app/views/posts/index.html.erb
|
56
|
+
- spec/public/generators/merb_app/Rakefile
|
57
|
+
- spec/public/generators/merb_app/README
|
58
|
+
- spec/public/generators/merb_app/setup.rb
|
59
|
+
- spec/public/template_spec.rb
|
60
|
+
- spec/publicapp
|
61
|
+
- spec/publicapp/views
|
62
|
+
- spec/publicapp/views/layout
|
63
|
+
- spec/spec.opts
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- lib/kissgen
|
66
|
+
- lib/kissgen/generator.rb
|
67
|
+
- lib/kissgen/template.rb
|
68
|
+
- lib/kissgen/version.rb
|
69
|
+
- lib/kissgen.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://rcgen.rubyforge.org
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.8.4
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.0.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: A Simple Code Generator
|
96
|
+
test_files: []
|
97
|
+
|