prigner 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,15 @@
1
- = Prigner v0.1.1 (2010-10-21) - Changelog
1
+ = Prigner v0.2.1 (2010-11-05) - Changelog
2
+
3
+ == 2010-11-05
4
+
5
+ * Releasing of version 0.2.1.
6
+ * Updates in documentation.
7
+ * Adding of documentation for templates.
8
+ * Small fixes in prign executable.
9
+
10
+ == 2010-11-04
11
+
12
+ * Adding of template for Sinatra applications.
2
13
 
3
14
  == 2010-10-27
4
15
 
data/COPYING CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2009, 2010 Hallison Batista
1
+ Copyright (c) 2009, Hallison Batista
2
+ Copyright (c) 2010, Codigorama
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining a
4
5
  copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,11 +1,13 @@
1
1
  = Prigner
2
2
 
3
+ == DESCRIPTION
4
+
3
5
  Prigner is a Project Design Kit, that is, a tool which creates a conventional
4
6
  structure for several projects as RubyGems, Websites, MVC application and
5
7
  simple scripts. It is a DRY tool, because everything is based in templates. In
6
8
  short, a project template engine.
7
9
 
8
- == Features
10
+ === Features
9
11
 
10
12
  * Load and create all directories and files from template specification.
11
13
  * The template specification is parsed to command line options.
@@ -16,7 +18,12 @@ short, a project template engine.
16
18
  * Tests.
17
19
  * Code for versioning.
18
20
 
19
- == Installation
21
+ == SYNOPSIS
22
+
23
+ prign [OPTIONS]
24
+ prign [COMMAND] [TEMPLATE]
25
+
26
+ == INSTALLATION
20
27
 
21
28
  First, install Prigner stable through Gem:
22
29
 
@@ -26,7 +33,7 @@ If you want try the developer source:
26
33
 
27
34
  git clone http://github.com/codigorama/prigner.git
28
35
 
29
- == Usage
36
+ == USAGE
30
37
 
31
38
  Prigner create the most common Ruby projects through templates shared. To
32
39
  generate new Gem project, run command using the following syntax:
@@ -37,38 +44,61 @@ generate new Gem project, run command using the following syntax:
37
44
  |-- lib/
38
45
  | |-- foo/
39
46
  | `-- foo.rb
47
+ |-- test/
48
+ | |-- fixtures/
49
+ | |-- foo_test.rb
50
+ | `-- helper.rb
40
51
  |-- CHANGELOG
41
52
  |-- COPYING
53
+ |-- foo.gemspec
54
+ |-- Rakefile
42
55
  `-- README.rdoc
43
56
 
44
57
  This command will generate 'foo' Gem project structure. But all templates
45
58
  offers options.
46
59
 
47
- prign new ruby:gem --test --bin
60
+ prign new ruby:gem foo --bin
48
61
 
49
62
  foo/
50
63
  |-- bin/
51
64
  | `-- foo
52
65
  |-- lib/
53
66
  | |-- foo/
67
+ | | `-- cli.rb
54
68
  | `-- foo.rb
55
69
  |-- test/
70
+ | |-- fixtures/
56
71
  | |-- foo_test.rb
57
72
  | `-- helper.rb
58
73
  |-- CHANGELOG
59
74
  |-- COPYING
75
+ |-- foo.gemspec
76
+ |-- Rakefile
60
77
  `-- README.rdoc
61
78
 
62
79
  Run <tt>prign list</tt> to view all available templates.
63
80
 
64
81
  You can creates your own templates. Just save in your home directory
65
- <tt>~/.prigner/templates/<your-template></tt>.
82
+ <tt>~/.prigner/templates/<your-template></tt>. For more information about
83
+ templates, see "TEMPLATES.rdoc" file.
66
84
 
67
- == Copyright
85
+ == BUGS AND CONTRIBUTING
86
+
87
+ If you want contributes with the project, please, see the following instructions:
88
+
89
+ 1. Fork the project from http://github.com/codigorama/prigner.git.
90
+ 2. Set the following environment variable: <tt>export RUBYOPT=$PWD/lib:.</tt>,
91
+ where +PWD+ points to project directory.
92
+
93
+ If you find a bug, please, open a issue in http://github.com/codigorama/prigner/issues.
94
+
95
+ == AUTHOR
68
96
 
69
97
  Written by {Hallison Batista}[http://github.com/hallison].
70
98
 
71
- Prigner is Copyright (C) 2010, {Codigorama}[http://codigorama.com].
99
+ == COPYRIGHT
100
+
101
+ Prigner is Copyright (C) 2010, {Codigorama}[http://codigorama.com] under MIT License.
72
102
 
73
- See COPYRIGHT file for more information about license.
103
+ See COPYING file for more information about license.
74
104
 
data/Rakefile CHANGED
@@ -74,9 +74,9 @@ end
74
74
  # Documentation
75
75
  # =============================================================================
76
76
 
77
- CLOBBER << FileList["doc/api/*"]
77
+ CLOBBER << FileList["doc/api*"]
78
78
 
79
- file "doc/api/index.html" => FileList["lib/**/*.rb", "README.rdoc", "CHANGELOG"] do |filespec|
79
+ file "doc/api/index.html" => FileList["lib/**/*.rb", "README.rdoc", "TEMPLATES.rdoc", "CHANGELOG"] do |filespec|
80
80
  rdoc "--op", "doc/api",
81
81
  "--charset", "utf8",
82
82
  "--main", "'Prigner'",
data/TEMPLATES.rdoc ADDED
@@ -0,0 +1,192 @@
1
+ = Prigner Templates
2
+
3
+ Prigner defines a template as a set of files that contains all source needed to
4
+ build a project. All models are parsed using ERB as engine.
5
+
6
+ A example of template:
7
+
8
+ bash/
9
+ `-- default/
10
+ |-- models/
11
+ | `-- script.sh
12
+ `-- specfile
13
+
14
+ # bash/default/models/script.sh
15
+ #!/bin/bash
16
+ #$ <%=project.name%> v0.1.0
17
+ #$
18
+ #$ Usage:
19
+ #$ <%=project.name%> [options] [args]
20
+ #$
21
+ #$ Options:
22
+ #$ -e Enable anything.
23
+ #$ -s Set value to anything.
24
+ #$ -h Show this message.
25
+ #$
26
+
27
+ path="${BASH_SOURCE%/*}/"
28
+
29
+ # This function show the message written in the header.
30
+ function help {
31
+ local origin="$(1<${0})"
32
+ local comments="${origin}"
33
+
34
+ comments="${comments#\#!*\#\$}"
35
+ comments="${comments%\#\$*}"
36
+ comments="${comments//\#\$ }"
37
+ comments="${comments:1:${#comments}}"
38
+
39
+ test "${comments//\$}" != "${origin}" && echo "${comments//\#\$}"
40
+ }
41
+
42
+ [[ $# -eq 0 ]] && help && exit 0
43
+
44
+ declare enabled
45
+ declare setted
46
+
47
+ while getopts "es:h" opt; do
48
+ case $opt in
49
+ e) enabled=1 ;;
50
+ s) setted=$OPTARG ;;
51
+ h) help && exit 0 ;;
52
+ *) help && exit 0 ;;
53
+ esac
54
+ shift $(($OPTIND - 1))
55
+ done
56
+
57
+ [[ $enabled ]] && echo "<%=project.name%> enabled anything."
58
+ [[ $setted ]] && echo "<%=project.name%> set anything to $setted."
59
+
60
+ The +bash+ is the template *namespace*. When you use the following command:
61
+
62
+ prign new bash myscript
63
+
64
+ Prigner find the default template for the +bash+ namespace. That is, is equal
65
+ to use the command:
66
+
67
+ prign new bash:default myscript
68
+
69
+ This is useful for create template scopes and you can able create most
70
+ templates scoped by namespace. Example:
71
+
72
+ ruby/
73
+ |-- default/
74
+ | |-- models/
75
+ | | |-- CHANGELOG
76
+ | | |-- COPYING
77
+ | | |-- executable
78
+ | | |-- module.rb
79
+ | | |-- README.rdoc
80
+ | | |-- testhelper.rb
81
+ | | `-- test.rb
82
+ | `-- specfile
83
+ |-- gem/
84
+ | |-- models/
85
+ | | |-- CHANGELOG
86
+ | | |-- cli.rb
87
+ | | |-- COPYING
88
+ | | |-- executable
89
+ | | |-- gemspec
90
+ | | |-- module.rb
91
+ | | |-- Rakefile
92
+ | | |-- README.rdoc
93
+ | | |-- testhelper.rb
94
+ | | `-- test.rb
95
+ | `-- specfile
96
+ `-- sinatra/
97
+ |-- models/
98
+ | |-- mvc/
99
+ | | |-- config.rb
100
+ | | |-- controller.rb
101
+ | | |-- database.yml
102
+ | | |-- model.rb
103
+ | | `-- view.erb
104
+ | |-- application.rb
105
+ | |-- CHANGELOG
106
+ | |-- cli.rb
107
+ | |-- config.ru
108
+ | |-- executable
109
+ | |-- gemspec
110
+ | |-- LICENSE
111
+ | |-- module.rb
112
+ | |-- Rakefile
113
+ | |-- README.rdoc
114
+ | |-- testhelper.rb
115
+ | `-- test.rb
116
+ `-- specfile
117
+
118
+ In this example the +ruby+ namespace contains tree templates: +default+, +gem+
119
+ and +sinatra+.
120
+
121
+ == Template specification
122
+
123
+ The template has a specification file that defines the necessary information
124
+ about template.
125
+
126
+ === Specfile
127
+
128
+ The +specfile+ contains all needed information about template and parses
129
+ several filters as the keyword "project". This file must contain the following
130
+ keys:
131
+
132
+ [*author*]
133
+ The template author name.
134
+
135
+ [*email*]
136
+ Email for feedback.
137
+
138
+ [*version*]
139
+ Template version.
140
+
141
+ [*description*]
142
+ Template description.
143
+
144
+ [*directories*]
145
+ List of directories. This directories are created inside of the project
146
+ directory.
147
+
148
+ [*files*]
149
+ Template files. Use this keyword to map a pair of model and the result file.
150
+ Example:
151
+
152
+ files:
153
+ script.sh: (project).sh
154
+
155
+ [*options*]
156
+ The template options. Each option most be defined by a key that contained only
157
+ letters. Example:
158
+
159
+ options:
160
+ svn: Enable Subversion keys in source code.
161
+
162
+ Each option can includes files. For this, use the following syntax:
163
+
164
+ options: # Group of options
165
+ bin: # - keyword
166
+ description: # - description
167
+ Includes the executable file. #
168
+ files: # - files
169
+ executable: bin/(project)
170
+
171
+ In the +bash+ default template example, the specfile contains the following
172
+ information:
173
+
174
+ # bash/default/specfile
175
+ author:
176
+ Hallison Batista
177
+ email:
178
+ hallison@codigorama.com
179
+ version:
180
+ 0.1.0
181
+ description:
182
+ A simple Bash script
183
+
184
+ options:
185
+
186
+ directories:
187
+
188
+ files:
189
+ script.sh: (project).sh
190
+
191
+ # vim: filetype=yaml
192
+
data/bin/prign CHANGED
@@ -17,9 +17,8 @@ begin
17
17
  #{Prigner::Version}
18
18
 
19
19
  Usage:
20
- #{program} <namespace>[:template] [path] [options]
21
- #{program} <command> [command_options]
22
20
  #{program} [options]
21
+ #{program} <command> [options] <args>
23
22
 
24
23
  Commands:
25
24
  #{Prigner::CLI.commands.join(", ")}
data/lib/prigner.rb CHANGED
@@ -1,12 +1,19 @@
1
1
  #@ ---
2
2
  #@ :timestamp: 2009-07-16 14:05:16 -04:00
3
- #@ :date: 2010-10-27
4
- #@ :tag: 0.2.0
5
- # encoding: UTF-8
6
-
7
- # Copyright (c) 2009, 2010, Hallison Batista
3
+ #@ :date: 2010-11-05
4
+ #@ :tag: 0.2.1
8
5
 
9
- # The Prigner is a Projec Design Kit which help developers in DRY.
6
+ # ---
7
+ # encoding: UTF-8
8
+ #
9
+ # Copyright (c) 2010, Codigorama
10
+ # Copyright (c) 2009, Hallison Batista
11
+ # +++
12
+
13
+ # Prigner is a Project Design Kit, that is, a tool which creates a conventional
14
+ # structure for several projects as RubyGems, Websites, MVC application and
15
+ # simple scripts. It is a DRY tool, because everything is based in templates.
16
+ # In short, a project template engine.
10
17
  module Prigner
11
18
 
12
19
  # RubyGems
data/prigner.gemspec CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  #about
5
5
  spec.name = "prigner"
6
6
  spec.summary = "Project designer."
7
- spec.description = "Prigner is a Project Design Kit."
7
+ spec.description = "Prigner is a Project Design Kit (a.k.a. project builder). That is, it is a tool which builds your projects using templates."
8
8
  spec.authors = ["Hallison Batista"]
9
9
  spec.email = "hallison@codigorama.com"
10
10
  spec.homepage = "http://codigorama.com/products/prigner"
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
  #
15
15
 
16
16
  #version
17
- spec.version = "0.2.0"
18
- spec.date = "2010-10-27"
17
+ spec.version = "0.2.1"
18
+ spec.date = "2010-11-05"
19
19
  #
20
20
 
21
21
  #dependencies
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  "COPYING",
29
29
  "README.rdoc",
30
30
  "Rakefile",
31
+ "TEMPLATES.rdoc",
31
32
  "bin/prign",
32
33
  "lib/prigner.rb",
33
34
  "lib/prigner/builder.rb",
@@ -60,6 +61,23 @@ Gem::Specification.new do |spec|
60
61
  "share/templates/ruby/gem/models/module.rb",
61
62
  "share/templates/ruby/gem/models/testhelper.rb",
62
63
  "share/templates/ruby/gem/specfile",
64
+ "share/templates/ruby/sinatra/models/CHANGELOG",
65
+ "share/templates/ruby/sinatra/models/LICENSE",
66
+ "share/templates/ruby/sinatra/models/README.rdoc",
67
+ "share/templates/ruby/sinatra/models/Rakefile",
68
+ "share/templates/ruby/sinatra/models/application.rb",
69
+ "share/templates/ruby/sinatra/models/cli.rb",
70
+ "share/templates/ruby/sinatra/models/config.ru",
71
+ "share/templates/ruby/sinatra/models/executable",
72
+ "share/templates/ruby/sinatra/models/gemspec",
73
+ "share/templates/ruby/sinatra/models/module.rb",
74
+ "share/templates/ruby/sinatra/models/mvc/config.rb",
75
+ "share/templates/ruby/sinatra/models/mvc/controller.rb",
76
+ "share/templates/ruby/sinatra/models/mvc/database.yml",
77
+ "share/templates/ruby/sinatra/models/mvc/model.rb",
78
+ "share/templates/ruby/sinatra/models/mvc/view.erb",
79
+ "share/templates/ruby/sinatra/models/testhelper.rb",
80
+ "share/templates/ruby/sinatra/specfile",
63
81
  "test/builder_test.rb",
64
82
  "test/fixtures/model.rb.erb",
65
83
  "test/fixtures/templates/shared/templates/ruby/default/models/README.mkd",
@@ -0,0 +1,13 @@
1
+ <%=date%>
2
+ -----------
3
+
4
+ * Pre-Alpha. Project has been started.
5
+
6
+ * Include basic directory tree.
7
+
8
+ * Basic files have been added:
9
+
10
+ * Development tasks.
11
+
12
+ * Tests;
13
+
@@ -0,0 +1,21 @@
1
+ Copyright (c) <%=date.year%> <%=project.author%>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ 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 included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -0,0 +1,4 @@
1
+ = <%=project.upper_camel_case_namespace%>
2
+
3
+ This is my great Ruby project.
4
+
@@ -0,0 +1,146 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
2
+
3
+ require "rake/clean"
4
+ require "rake/testtask"
5
+ require "rake/gempackagetask"
6
+ require "rake/rdoctask"
7
+ require "lib/<%=project.name%>"
8
+
9
+ # Configurations
10
+ # =============================================================================
11
+
12
+ def git(cmd, *args)
13
+ `git #{cmd.to_s.gsub('_','-')} #{args.join(' ')}`
14
+ end
15
+
16
+ def manifest
17
+ @manifest ||= git(:ls_files).split("\n").sort.reject do |out|
18
+ out =~ /^\./ || out =~ /^doc/
19
+ end.map do |file|
20
+ " #{file.inspect}"
21
+ end.join(",\n")
22
+ end
23
+
24
+ def version
25
+ @version ||= <%=project.class_name%>.version
26
+ end
27
+
28
+ def tag
29
+ git(:tag).split("\n").last
30
+ end
31
+
32
+ def specfile
33
+ @specfile ||= Pathname.new("<%=project.name%>.gemspec")
34
+ end
35
+
36
+ def gemspec
37
+ @gemspec ||= eval(specfile.read)
38
+ end
39
+
40
+ # Test
41
+ # =============================================================================
42
+
43
+ Rake::TestTask.new do |test|
44
+ test.libs << "test"
45
+ test.test_files = FileList["test/*_test.rb"]
46
+ test.verbose = true
47
+ end
48
+
49
+ # Packaging
50
+ # =============================================================================
51
+
52
+ Rake::GemPackageTask.new gemspec do |spec|
53
+ spec.need_tar = true
54
+ end
55
+
56
+ # Documentation
57
+ # =============================================================================
58
+
59
+ Rake::RDocTask.new :doc do |rdoc|
60
+ rdoc.main = "<%=project.upper_camel_case_namespace%>"
61
+ rdoc.title = "<%=project.upper_camel_case_namespace%> v#{version.tag} API Documentation"
62
+ rdoc.rdoc_dir = "doc/api"
63
+ rdoc.rdoc_files = FileList["lib/**/*.rb", "README.rdoc", "CHANGELOG"]
64
+ rdoc.options << "--charset utf8" << "--inline-source" << "--promiscuous" << "--line-numbers"
65
+ end
66
+
67
+ # Versioning
68
+ # =============================================================================
69
+
70
+ desc "Dump version (current v#{version.tag})."
71
+ task :version, [:counter,:release] do |spec, args|
72
+ numbering = version.numbering
73
+ tagnames = %w[major minor patch]
74
+
75
+ if index = tagnames.index(args[:counter])
76
+ numbering[index] += 1
77
+ numbering.fill(0, (index + 1)..-1)
78
+ else
79
+ numbering[-1] += 1
80
+ end
81
+
82
+ numbering[-1] = "#{numbering[-1]}#{args[:release]}"
83
+ version.tag = numbering.join(".")
84
+ version.save!
85
+ puts version.to_hash.to_yaml
86
+ end
87
+
88
+ namespace :version do
89
+ desc "Update version date (current #{version.date})."
90
+ task :date, [:date] do |spec, args|
91
+ require "parsedate"
92
+ require "date"
93
+ yyyy, mm, dd = ParseDate.parsedate(args[:date]).compact if args[:date]
94
+ version.date = (yyyy && mm && dd) ? Date.new(yyyy, mm, dd) : Date.today
95
+ version.save!
96
+ puts version.to_hash.to_yaml
97
+ end
98
+ end
99
+ #
100
+ # Packaging
101
+ # =============================================================================
102
+
103
+ task :tagged do
104
+ abort "The gemspec not updated to version #{version.tag} (#{gemspec.version})" \
105
+ unless gemspec.version.to_s == version.tag
106
+ abort "The version #{version.tag} is not tagged." \
107
+ unless tag[1..-1] == version.tag
108
+ end
109
+
110
+ file specfile => FileList["{bin,lib,test}/**", "Rakefile"] do
111
+ spec = specfile.read
112
+
113
+ puts "Updating version ..."
114
+ spec.sub! /spec\.version\s*=\s*".*?"/, "spec.version = #{version.tag.inspect}"
115
+
116
+ puts "Updating date of version ..."
117
+ spec.sub! /spec\.date\s*=\s*".*?"/, "spec.date = #{version.date.to_s.inspect}"
118
+
119
+ puts "Updating file list ..."
120
+ spec.sub! /spec\.files\s*=\s*\[.*?\]/m, "spec.files = [\n#{manifest}\n ]"
121
+
122
+ specfile.open("w+") { |file| file << spec }
123
+
124
+ puts "Successfully update #{specfile} file"
125
+ end
126
+
127
+ desc "Release gem package to repositories."
128
+ task :release => [ :tagged, :package ] do
129
+ sh "gem push #{package('.gem')}"
130
+ end
131
+
132
+ desc "Install gem package #{gemspec.file_name}."
133
+ task :install => :package do
134
+ sh "gem install #{package('.gem')} --local"
135
+ end
136
+
137
+ desc "Uninstall gem package #{gemspec.file_name}."
138
+ task :uninstall do
139
+ sh "gem uninstall #{gemspec.name} --version #{gemspec.version}"
140
+ end
141
+
142
+ # Default
143
+ # =============================================================================
144
+
145
+ task :default => :test
146
+
@@ -0,0 +1,27 @@
1
+ <%namespace = project.upper_camel_case_namespace%>
2
+ require "sinatra"
3
+ require "sinatra/mapping"
4
+ <%if option.mvc.enabled%>
5
+ # This module load all source controllers placed in <tt>app/controllers</tt>.
6
+ module <%=namespace%>::Controllers
7
+ Dir["#{<%=namespace%>::ROOT}/app/controllers/*.rb"].each { |controller| require controller }
8
+ end
9
+ <%end%>
10
+ class <%=namespace%>::Application < Sinatra::Base
11
+
12
+ register Sinatra::Mapping
13
+ <%if option.mvc.enabled%>
14
+ <%=namespace%>::Controllers::constants.each do |controller|
15
+ use <%=namespace%>::Controllers::const_get(controller)
16
+ end
17
+
18
+ set :views, File.join(<%=namespace%>::ROOT, "app", "views")
19
+ <%end%>
20
+ map :root
21
+
22
+ get root_path do
23
+ <%= option.mvc.enabled ? "erb :index" : "\"\#{#{namespace}::Version} works!\"" %>
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,43 @@
1
+ # == Command-Line Interface
2
+ #
3
+ # This module look a command placed in CLI directory and run it.
4
+ module <%=project.upper_camel_case_namespace%>
5
+
6
+ module CLI
7
+
8
+ require "rbconfig"
9
+
10
+ # Ruby VM installed in OS.
11
+ def self.ruby
12
+ File.join(*::RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) +
13
+ ::RbConfig::CONFIG["EXEEXT"]
14
+ end
15
+
16
+ # The CLI path.
17
+ def self.path
18
+ "#{<%=project.upper_camel_case_namespace%>::ROOT}/lib/<%=project.name%>/cli"
19
+ end
20
+
21
+ # List of commands placed in <tt>lib/prigner/cli/</tt>.
22
+ def self.commands
23
+ Dir["#{path}/*.rb"].map do |source|
24
+ File.basename(source, ".rb")
25
+ end.sort
26
+ end
27
+
28
+ # Source command placed in CLI directory.
29
+ def self.source(command)
30
+ "#{path}/#{command}.rb"
31
+ end
32
+
33
+ # Look command in *CLI* directory and execute (by exec).
34
+ def self.run(*args)
35
+ command = args.shift if commands.include? args.first
36
+ raise RuntimeError, "unknown command '#{args.first}'" unless command
37
+ exec ruby, rubyopt, source(command), *args
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
@@ -0,0 +1,4 @@
1
+ require "<%=project.name%>"
2
+ require "<%=project.name%>/application"
3
+
4
+ run <%=project.upper_camel_case_namespace%>::Application
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "<%=project.name%>"
5
+
6
+ ARGV.options do |args|
7
+
8
+ args.on "-s", "--set VALUE", String, "Set anything" do |anything|
9
+ puts "Setting anything to #{anything} ..."
10
+ end
11
+
12
+ args.on "-a", "--anything", TrueClass, "Do anything!" do |enabled|
13
+ puts "Enable to doing anything ..." if enabled
14
+ end
15
+
16
+ unless ARGV.empty?
17
+ args.parse!
18
+ else
19
+ puts args
20
+ exit 0
21
+ end
22
+
23
+ end
@@ -0,0 +1,65 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.platform = Gem::Platform::RUBY
3
+
4
+ #about
5
+ spec.name = "<%=project.name%>"
6
+ spec.summary = "Say anything about <%=project.name%>"
7
+ spec.description = "Describes <%=project.name%>"
8
+ spec.author = "<%=project.author%>"
9
+ spec.email = ""
10
+ spec.homepage = "http://rubygems.org/gems/<%=project.name%>"
11
+ #spec.executables = [ "" ]
12
+ #spec.default_executable = ""
13
+ #
14
+
15
+ #version
16
+ spec.version = "0.0.1"
17
+ spec.date = "<%=date%>"
18
+ #
19
+
20
+ #dependencies
21
+ #spec.add_dependency ""
22
+ #
23
+
24
+ #manifest
25
+ spec.files = [
26
+ "LICENSE",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "lib/<%=project.name%>.rb",
30
+ "<%=project.name%>.gemspec",
31
+ "test/<%=project.name%>_test.rb",
32
+ ]
33
+ #
34
+
35
+ spec.test_files = spec.files.select{ |path| path =~ /^test\/*test*/ }
36
+
37
+ spec.require_paths = ["lib"]
38
+
39
+ #documentation
40
+ spec.has_rdoc = true
41
+ spec.extra_rdoc_files = [
42
+ "README.mkd",
43
+ "LICENSE"
44
+ ]
45
+ spec.rdoc_options = [
46
+ "--inline-source",
47
+ "--line-numbers",
48
+ "--charset", "utf8",
49
+ "--main", "<%=project.class_name%>",
50
+ "--title", "<%=project.class_name%> v#{spec.version} API Documentation"
51
+ ]
52
+
53
+ #rubygems
54
+ spec.rubyforge_project = spec.name
55
+ spec.post_install_message = <<-end_message.gsub(/^[ ]{4}/,'')
56
+ #{'-'*78}
57
+ <%=project.class_name%> v#{spec.version}
58
+
59
+ Thanks for use <%=project.class_name%>.
60
+
61
+ #{'-'*78}
62
+ end_message
63
+ #
64
+ end
65
+
@@ -0,0 +1,89 @@
1
+ #@ ---
2
+ #@ :tag: 0.1.0
3
+ #@ :date: <%=date%>
4
+ #@ :timestamp: <%=Time.now.strftime "%F %T %z"%>
5
+
6
+ # encoding: UTF-8
7
+
8
+ module <%=project.upper_camel_case_namespace%>
9
+
10
+ ROOT = File.join(File.dirname(__FILE__), "..")
11
+
12
+ # RubyGems
13
+ require "rubygems" unless $LOADED_FEATURES.include? "rubygems.rb"
14
+
15
+ # Standard library requirements
16
+ require "pathname"
17
+ require "yaml"
18
+
19
+ # Internal requirements
20
+ require "<%=project.name%>/config"
21
+
22
+ # Return the current version.
23
+ def self.version
24
+ @version ||= Version.current
25
+ end
26
+
27
+ # The objective of this class is to implement various ideas proposed by the
28
+ # Semantic Versioning Specification (see reference[http://semver.org/]).
29
+ class Version
30
+
31
+ FILE = Pathname.new(__FILE__).freeze
32
+
33
+ attr_accessor :date, :tag
34
+
35
+ attr_reader :timestamp
36
+
37
+ # Basic initialization of the attributes using a single hash.
38
+ def initialize(attributes = {})
39
+ attributes.each do |attribute, value|
40
+ send("#{attribute}=", value) if respond_to? "#{attribute}="
41
+ end
42
+ @timestamp = attributes[:timestamp]
43
+ end
44
+
45
+ # The numbering of the major, minor and patch values.
46
+ def numbering
47
+ self.tag.split(".").map do |key|
48
+ if key.match(/^(\d{1,})(\w+).*$/)
49
+ [ $1.to_i, $2 ]
50
+ else
51
+ key.to_i
52
+ end
53
+ end.flatten
54
+ end
55
+
56
+ def to_hash
57
+ [:tag, :date, :timestamp].inject({}) do |hash, key|
58
+ hash[key] = send(key)
59
+ hash
60
+ end
61
+ end
62
+
63
+ def save!
64
+ source = FILE.readlines
65
+ source[0..3] = self.to_hash.to_yaml.to_s.gsub(/^/, '#@ ')
66
+ FILE.open("w+") do |file|
67
+ file << source.join("")
68
+ end
69
+ self
70
+ end
71
+
72
+ class << self
73
+ def current
74
+ yaml = FILE.readlines[0..3].
75
+ join("").
76
+ gsub(/\#@ /,'')
77
+ new(YAML.load(yaml))
78
+ end
79
+
80
+ def to_s
81
+ name.match(/(.*?)::.*/)
82
+ "#{$1} v#{current.tag} (#{current.date})"
83
+ end
84
+ end # self
85
+
86
+ end # Version
87
+
88
+ end
89
+
@@ -0,0 +1,33 @@
1
+ <%namespace = project.upper_camel_case_namespace%>
2
+ module <%=namespace%>::Config
3
+
4
+ class Database < Struct.new(:adapter, :database, :user, :password, :host, :port)
5
+
6
+ # Database URI.
7
+ def uri
8
+ hostname = port ? "#{host}:#{port}" : host
9
+ "#{adapter}://#{user}:#{password}@#{hostname}/#{database}"
10
+ end
11
+
12
+ # Load configuration from <tt>config/database.yml</tt>.
13
+ def self.load_config
14
+ config = YAML.load_file(File.join(<%=namespace%>::ROOT, "config", "database.yml"))
15
+ new(
16
+ config["adapter"],
17
+ config["database"],
18
+ config["user"],
19
+ config["password"],
20
+ config["host"],
21
+ config["port"]
22
+ )
23
+ end
24
+
25
+ end
26
+
27
+ # Load Database configuration. See Database#load_config.
28
+ def self.database
29
+ Database.load_config
30
+ end
31
+
32
+ end
33
+
@@ -0,0 +1,15 @@
1
+ <%namespace = project.upper_camel_case_namespace%>
2
+ class <%=namespace%>::Controllers::About < Sinatra::Base
3
+
4
+ register Sinatra::Mapping
5
+
6
+ set :views, File.join(<%=namespace%>::ROOT, "app", "views")
7
+
8
+ map :root, File.basename(__FILE__, ".*").downcase
9
+
10
+ get root_path do
11
+ erb :index
12
+ end
13
+
14
+ end
15
+
@@ -0,0 +1,6 @@
1
+ adapter: sqlite
2
+ database: <%=project.name%>.db
3
+ user: <%=project.user.name%>
4
+ password: pass
5
+ host: db
6
+ port:
@@ -0,0 +1,3 @@
1
+ class MyModel
2
+ end
3
+
@@ -0,0 +1,2 @@
1
+ <%='<%=' + project.upper_camel_case_namespace%>::Version%>: path <%='<%=request.path'%>%> works!
2
+
@@ -0,0 +1,23 @@
1
+ # This code extracted from book "Ruby Best Practices" and the code be found
2
+ # in http://github.com/sandal/rbp/blob/master/testing/test_unit_extensions.rb
3
+
4
+ TEST_HOME = File.expand_path(File.dirname(__FILE__)) unless defined? TEST_HOME
5
+ FIXTURES = File.join(TEST_HOME, "fixtures") unless defined? FIXTURES
6
+
7
+ module Test::Unit
8
+ class TestCase
9
+ def self.should(description, &block)
10
+ test_name = "test_#{description.gsub(/\s+/,'_')}".downcase.to_sym
11
+ defined = instance_method(test_name) rescue false
12
+ raise "#{test_name} is already defined in #{self}" if defined
13
+ if block_given?
14
+ define_method(test_name, &block)
15
+ else
16
+ define_method(test_name) do
17
+ flunk "No implementation provided for #{description}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,46 @@
1
+ author:
2
+ Hallison Batista
3
+ email:
4
+ hallison@codigorama.com
5
+ version:
6
+ 0.1.0
7
+ description:
8
+ Ruby/Sinatra application template.
9
+
10
+ options:
11
+ bin:
12
+ description:
13
+ Includes executable file.
14
+ files:
15
+ executable: bin/(project)
16
+ cli.rb: lib/(project)/cli.rb
17
+ gem:
18
+ description:
19
+ Includes the RubyGems specification file.
20
+ files:
21
+ gemspec: (project).gemspec
22
+ mvc:
23
+ description:
24
+ Includes model, view and controller files.
25
+ files:
26
+ mvc/database.yml: config/database.yml
27
+ mvc/config.rb: lib/(project)/config.rb
28
+ mvc/model.rb: app/models/model.rb
29
+ mvc/view.erb: app/views/index.erb
30
+ mvc/controller.rb: app/controllers/about.rb
31
+
32
+ directories:
33
+ - lib/(project)
34
+ - test/fixtures
35
+
36
+ files:
37
+ LICENSE:
38
+ README.rdoc:
39
+ Rakefile:
40
+ config.ru:
41
+ module.rb: lib/(project).rb
42
+ application.rb: lib/(project)/application.rb
43
+ test.rb: test/(project)_test.rb
44
+ testhelper.rb: test/helper.rb
45
+
46
+ # vim: filetype=yaml
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prigner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hallison Batista
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-27 00:00:00 -04:00
18
+ date: 2010-11-05 00:00:00 -04:00
19
19
  default_executable: prign
20
20
  dependencies: []
21
21
 
22
- description: Prigner is a Project Design Kit.
22
+ description: Prigner is a Project Design Kit (a.k.a. project builder). That is, it is a tool which builds your projects using templates.
23
23
  email: hallison@codigorama.com
24
24
  executables:
25
25
  - prign
@@ -34,6 +34,7 @@ files:
34
34
  - COPYING
35
35
  - README.rdoc
36
36
  - Rakefile
37
+ - TEMPLATES.rdoc
37
38
  - bin/prign
38
39
  - lib/prigner.rb
39
40
  - lib/prigner/builder.rb
@@ -66,6 +67,23 @@ files:
66
67
  - share/templates/ruby/gem/models/module.rb
67
68
  - share/templates/ruby/gem/models/testhelper.rb
68
69
  - share/templates/ruby/gem/specfile
70
+ - share/templates/ruby/sinatra/models/CHANGELOG
71
+ - share/templates/ruby/sinatra/models/LICENSE
72
+ - share/templates/ruby/sinatra/models/README.rdoc
73
+ - share/templates/ruby/sinatra/models/Rakefile
74
+ - share/templates/ruby/sinatra/models/application.rb
75
+ - share/templates/ruby/sinatra/models/cli.rb
76
+ - share/templates/ruby/sinatra/models/config.ru
77
+ - share/templates/ruby/sinatra/models/executable
78
+ - share/templates/ruby/sinatra/models/gemspec
79
+ - share/templates/ruby/sinatra/models/module.rb
80
+ - share/templates/ruby/sinatra/models/mvc/config.rb
81
+ - share/templates/ruby/sinatra/models/mvc/controller.rb
82
+ - share/templates/ruby/sinatra/models/mvc/database.yml
83
+ - share/templates/ruby/sinatra/models/mvc/model.rb
84
+ - share/templates/ruby/sinatra/models/mvc/view.erb
85
+ - share/templates/ruby/sinatra/models/testhelper.rb
86
+ - share/templates/ruby/sinatra/specfile
69
87
  - test/builder_test.rb
70
88
  - test/fixtures/model.rb.erb
71
89
  - test/fixtures/templates/shared/templates/ruby/default/models/README.mkd
@@ -102,7 +120,7 @@ licenses: []
102
120
 
103
121
  post_install_message: |
104
122
  ------------------------------------------------------------------------------
105
- Prigner v0.2.0
123
+ Prigner v0.2.1
106
124
 
107
125
  Thanks for use Prigner. See all shared templates running:
108
126
 
@@ -117,7 +135,7 @@ rdoc_options:
117
135
  - --main
118
136
  - Prigner
119
137
  - --title
120
- - Prigner v0.2.0 API Documentation
138
+ - Prigner v0.2.1 API Documentation
121
139
  require_paths:
122
140
  - lib
123
141
  required_ruby_version: !ruby/object:Gem::Requirement