prigner 0.1.0
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/CHANGELOG +248 -0
- data/COPYING +21 -0
- data/README.mkd +90 -0
- data/Rakefile +211 -0
- data/bin/prign +65 -0
- data/lib/prigner/builder.rb +51 -0
- data/lib/prigner/cli/copy.rb +0 -0
- data/lib/prigner/cli/list.rb +54 -0
- data/lib/prigner/cli/new.rb +96 -0
- data/lib/prigner/cli.rb +102 -0
- data/lib/prigner/extensions.rb +67 -0
- data/lib/prigner/model.rb +97 -0
- data/lib/prigner/project.rb +71 -0
- data/lib/prigner/template.rb +148 -0
- data/lib/prigner.rb +186 -0
- data/prigner.gemspec +120 -0
- data/share/templates/ruby/default/models/CHANGELOG +13 -0
- data/share/templates/ruby/default/models/COPYING +21 -0
- data/share/templates/ruby/default/models/README.rdoc +4 -0
- data/share/templates/ruby/default/models/module.rb +5 -0
- data/share/templates/ruby/default/specfile +16 -0
- data/share/templates/ruby/gem/models/CHANGELOG +13 -0
- data/share/templates/ruby/gem/models/COPYING +21 -0
- data/share/templates/ruby/gem/models/README.mkd +5 -0
- data/share/templates/ruby/gem/models/Rakefile +213 -0
- data/share/templates/ruby/gem/models/empty_test.rb +16 -0
- data/share/templates/ruby/gem/models/gemspec +67 -0
- data/share/templates/ruby/gem/models/module.rb +71 -0
- data/share/templates/ruby/gem/specfile +20 -0
- data/test/builder_test.rb +38 -0
- data/test/fixtures/model.rb.erb +12 -0
- data/test/fixtures/templates/shared/ruby/default/README.mkd +2 -0
- data/test/fixtures/templates/shared/ruby/default/models/README.mkd +2 -0
- data/test/fixtures/templates/shared/ruby/default/models/Rakefile +7 -0
- data/test/fixtures/templates/shared/ruby/default/models/empty_test.rb +21 -0
- data/test/fixtures/templates/shared/ruby/default/models/module.rb +6 -0
- data/test/fixtures/templates/shared/ruby/default/specfile +18 -0
- data/test/fixtures/templates/user/bash/default/specfile +0 -0
- data/test/fixtures/templates/user/ruby/program/models/README.erb +2 -0
- data/test/fixtures/templates/user/ruby/program/models/cli.rb.erb +5 -0
- data/test/fixtures/templates/user/ruby/program/models/module.rb.erb +6 -0
- data/test/fixtures/templates/user/ruby/program/models/program.rb.erb +3 -0
- data/test/fixtures/templates/user/ruby/program/specfile +18 -0
- data/test/fixtures/templates/user/vim/default/specfile +0 -0
- data/test/fixtures/templates/user/vim/plugin/specfile +0 -0
- data/test/fixtures/templates/user/vim/syntax/specfile +0 -0
- data/test/helpers.rb +22 -0
- data/test/model_test.rb +82 -0
- data/test/project_test.rb +46 -0
- data/test/spec_test.rb +64 -0
- data/test/template_test.rb +88 -0
- metadata +142 -0
data/lib/prigner.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
#@ ---
|
2
|
+
#@ :timestamp: 2009-07-16 14:05:16 -04:00
|
3
|
+
#@ :date: 2010-10-18
|
4
|
+
#@ :tag: 0.1.0
|
5
|
+
#@ :milestone: Alpha
|
6
|
+
# encoding: UTF-8
|
7
|
+
|
8
|
+
# Copyright (c) 2009, 2010, Hallison Batista
|
9
|
+
|
10
|
+
# The Prigner is a Projec Design Kit which help developers in DRY.
|
11
|
+
module Prigner
|
12
|
+
|
13
|
+
# RubyGems
|
14
|
+
require "rubygems" unless $LOADED_FEATURES.include? "rubygems.rb"
|
15
|
+
|
16
|
+
# Standard library requirements
|
17
|
+
require "pathname"
|
18
|
+
require "optparse"
|
19
|
+
require "yaml"
|
20
|
+
|
21
|
+
# Internal requirements
|
22
|
+
require "prigner/extensions"
|
23
|
+
|
24
|
+
# Root directory for project.
|
25
|
+
ROOT = Pathname.new(__FILE__).dirname.join('..').expand_path.freeze
|
26
|
+
|
27
|
+
# Modules
|
28
|
+
autoload :Project, "prigner/project"
|
29
|
+
autoload :Model, "prigner/model"
|
30
|
+
autoload :Template, "prigner/template"
|
31
|
+
autoload :Builder, "prigner/builder"
|
32
|
+
autoload :CLI, "prigner/cli"
|
33
|
+
|
34
|
+
# Return the current version.
|
35
|
+
def self.version
|
36
|
+
@version ||= Version.current
|
37
|
+
end
|
38
|
+
|
39
|
+
class Version #:nodoc:
|
40
|
+
|
41
|
+
FILE = Pathname.new(__FILE__).freeze
|
42
|
+
|
43
|
+
attr_accessor :tag, :date, :milestone
|
44
|
+
attr_reader :timestamp
|
45
|
+
|
46
|
+
def initialize(attributes = {})
|
47
|
+
attributes.each do |attribute, value|
|
48
|
+
send("#{attribute}=", value) if respond_to? "#{attribute}="
|
49
|
+
end
|
50
|
+
@timestamp = attributes[:timestamp]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_hash
|
54
|
+
[:tag, :date, :milestone, :timestamp].inject({}) do |hash, key|
|
55
|
+
hash[key] = send(key)
|
56
|
+
hash
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def save!
|
61
|
+
@date = Date.today
|
62
|
+
source = FILE.readlines
|
63
|
+
source[0..4] = self.to_hash.to_yaml.to_s.gsub(/^/, '#@ ')
|
64
|
+
FILE.open("w+") do |file|
|
65
|
+
file << source.join("")
|
66
|
+
end
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
class << self
|
71
|
+
def current
|
72
|
+
yaml = FILE.readlines[0..4].
|
73
|
+
join("").
|
74
|
+
gsub(/\#@ /,'')
|
75
|
+
new(YAML.load(yaml))
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_s
|
79
|
+
name.match(/(.*?)::.*/)
|
80
|
+
"#{$1} v#{current.tag}, #{current.date} (#{current.milestone})"
|
81
|
+
end
|
82
|
+
end # self
|
83
|
+
|
84
|
+
end # Version
|
85
|
+
|
86
|
+
# == Specification class
|
87
|
+
#
|
88
|
+
# This class implements the basic attributes for Template specification.
|
89
|
+
class Spec
|
90
|
+
|
91
|
+
# Author name of template.
|
92
|
+
attr_reader :author
|
93
|
+
|
94
|
+
# Email for more information about template.
|
95
|
+
attr_reader :email
|
96
|
+
|
97
|
+
# Template version.
|
98
|
+
attr_reader :version
|
99
|
+
|
100
|
+
# Template description.
|
101
|
+
attr_reader :description
|
102
|
+
|
103
|
+
# Options that enables several features in model files.
|
104
|
+
attr_reader :options
|
105
|
+
|
106
|
+
# List of directories that will be created in project tree.
|
107
|
+
attr_reader :directories
|
108
|
+
|
109
|
+
# List of files that link a model to result file.
|
110
|
+
attr_reader :files
|
111
|
+
|
112
|
+
# Default values.
|
113
|
+
DEFAULTS = {
|
114
|
+
"options" => {},
|
115
|
+
"directories" => [],
|
116
|
+
"files" => {}
|
117
|
+
}
|
118
|
+
|
119
|
+
# Initialize the spec using options in Hash.
|
120
|
+
#
|
121
|
+
# Example:
|
122
|
+
#
|
123
|
+
# Prigner::Spec.new :author => "Anakin Skywalker",
|
124
|
+
# :email => "anakin@tatooine.net",
|
125
|
+
# :version => "1.0.0",
|
126
|
+
# :options => {
|
127
|
+
# "lightsaber" => "Enable red light saber",
|
128
|
+
# "force" => "Use the force"
|
129
|
+
# },
|
130
|
+
# :directories => %w{galactic/republic galactic/empire},
|
131
|
+
# :files => {
|
132
|
+
# "son.erb" => "jedi/luke_skywalker.knight"
|
133
|
+
# "chosen.erb" => "rebels/leia_organa.princess"
|
134
|
+
# }
|
135
|
+
def initialize(attributes = {})
|
136
|
+
DEFAULTS.update(attributes || {}).each do |attribute, value|
|
137
|
+
instance_variable_set "@#{attribute}", value if self.respond_to? attribute
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Load a Specfile and initialize a new Spec that be used in Template.
|
142
|
+
def self.load(specfile)
|
143
|
+
new(YAML.load_file(specfile))
|
144
|
+
rescue Exception => error
|
145
|
+
raise RuntimeError, "Unable to load Specfile."
|
146
|
+
end
|
147
|
+
|
148
|
+
end # Spec
|
149
|
+
|
150
|
+
# == Binder to common filters
|
151
|
+
#
|
152
|
+
# When a new Project is created, then several filters are available to use
|
153
|
+
# in Skel files.
|
154
|
+
class Binder
|
155
|
+
|
156
|
+
# Project.
|
157
|
+
attr_reader :project
|
158
|
+
|
159
|
+
# Template options.
|
160
|
+
attr_reader :options
|
161
|
+
|
162
|
+
alias option options
|
163
|
+
|
164
|
+
# The binder work binding to Project filters and Template options for use
|
165
|
+
# in Skel files.
|
166
|
+
def initialize(project, options)
|
167
|
+
@project, @options = project, options
|
168
|
+
end
|
169
|
+
|
170
|
+
def date
|
171
|
+
Date.today.clone
|
172
|
+
end
|
173
|
+
|
174
|
+
# Check if an options is enabled in Template.
|
175
|
+
def enabled?(option, &block)
|
176
|
+
yield block if @options[option].enabled
|
177
|
+
end
|
178
|
+
|
179
|
+
def binding #:nodoc:
|
180
|
+
super
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
end # Prigner
|
186
|
+
|
data/prigner.gemspec
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.platform = Gem::Platform::RUBY
|
3
|
+
|
4
|
+
#about
|
5
|
+
spec.name = "prigner"
|
6
|
+
spec.summary = "Project designer."
|
7
|
+
spec.description = "Prigner is a Project Design Kit."
|
8
|
+
spec.authors = ["Hallison Batista"]
|
9
|
+
spec.email = "hallison@codigorama.com"
|
10
|
+
spec.homepage = "http://codigorama.com/products/prigner"
|
11
|
+
spec.executables = [ "prign" ]
|
12
|
+
spec.default_executable = "prign"
|
13
|
+
#
|
14
|
+
|
15
|
+
#version
|
16
|
+
spec.version = "0.1.0"
|
17
|
+
spec.date = "2010-10-18"
|
18
|
+
#
|
19
|
+
|
20
|
+
#dependencies
|
21
|
+
#spec.add_dependency ""
|
22
|
+
#
|
23
|
+
|
24
|
+
#manifest
|
25
|
+
spec.files = [
|
26
|
+
"CHANGELOG",
|
27
|
+
"COPYING",
|
28
|
+
"README.mkd",
|
29
|
+
"Rakefile",
|
30
|
+
"bin/prign",
|
31
|
+
"lib/prigner.rb",
|
32
|
+
"lib/prigner/builder.rb",
|
33
|
+
"lib/prigner/cli.rb",
|
34
|
+
"lib/prigner/cli/copy.rb",
|
35
|
+
"lib/prigner/cli/list.rb",
|
36
|
+
"lib/prigner/cli/new.rb",
|
37
|
+
"lib/prigner/extensions.rb",
|
38
|
+
"lib/prigner/model.rb",
|
39
|
+
"lib/prigner/project.rb",
|
40
|
+
"lib/prigner/template.rb",
|
41
|
+
"prigner.gemspec",
|
42
|
+
"share/templates/ruby/default/models/CHANGELOG",
|
43
|
+
"share/templates/ruby/default/models/COPYING",
|
44
|
+
"share/templates/ruby/default/models/README.rdoc",
|
45
|
+
"share/templates/ruby/default/models/module.rb",
|
46
|
+
"share/templates/ruby/default/specfile",
|
47
|
+
"share/templates/ruby/gem/models/CHANGELOG",
|
48
|
+
"share/templates/ruby/gem/models/COPYING",
|
49
|
+
"share/templates/ruby/gem/models/README.mkd",
|
50
|
+
"share/templates/ruby/gem/models/Rakefile",
|
51
|
+
"share/templates/ruby/gem/models/empty_test.rb",
|
52
|
+
"share/templates/ruby/gem/models/gemspec",
|
53
|
+
"share/templates/ruby/gem/models/module.rb",
|
54
|
+
"share/templates/ruby/gem/specfile",
|
55
|
+
"test/builder_test.rb",
|
56
|
+
"test/fixtures/model.rb.erb",
|
57
|
+
"test/fixtures/templates/shared/ruby/default/README.mkd",
|
58
|
+
"test/fixtures/templates/shared/ruby/default/models/README.mkd",
|
59
|
+
"test/fixtures/templates/shared/ruby/default/models/Rakefile",
|
60
|
+
"test/fixtures/templates/shared/ruby/default/models/empty_test.rb",
|
61
|
+
"test/fixtures/templates/shared/ruby/default/models/module.rb",
|
62
|
+
"test/fixtures/templates/shared/ruby/default/specfile",
|
63
|
+
"test/fixtures/templates/user/bash/default/specfile",
|
64
|
+
"test/fixtures/templates/user/ruby/program/models/README.erb",
|
65
|
+
"test/fixtures/templates/user/ruby/program/models/cli.rb.erb",
|
66
|
+
"test/fixtures/templates/user/ruby/program/models/module.rb.erb",
|
67
|
+
"test/fixtures/templates/user/ruby/program/models/program.rb.erb",
|
68
|
+
"test/fixtures/templates/user/ruby/program/specfile",
|
69
|
+
"test/fixtures/templates/user/vim/default/specfile",
|
70
|
+
"test/fixtures/templates/user/vim/plugin/specfile",
|
71
|
+
"test/fixtures/templates/user/vim/syntax/specfile",
|
72
|
+
"test/helpers.rb",
|
73
|
+
"test/model_test.rb",
|
74
|
+
"test/project_test.rb",
|
75
|
+
"test/spec_test.rb",
|
76
|
+
"test/template_test.rb"
|
77
|
+
]
|
78
|
+
#
|
79
|
+
|
80
|
+
spec.test_files = spec.files.select{ |path| path =~ /^test\/*test*/ }
|
81
|
+
|
82
|
+
spec.require_paths = ["lib"]
|
83
|
+
|
84
|
+
#documentation
|
85
|
+
spec.has_rdoc = true
|
86
|
+
spec.extra_rdoc_files = [
|
87
|
+
"README.mkd",
|
88
|
+
"COPYING",
|
89
|
+
"CHANGELOG"
|
90
|
+
]
|
91
|
+
spec.rdoc_options = [
|
92
|
+
"--inline-source",
|
93
|
+
"--line-numbers",
|
94
|
+
"--charset", "utf8",
|
95
|
+
"--main", "Prigner",
|
96
|
+
"--title", "Prigner v#{spec.version} API Documentation"
|
97
|
+
]
|
98
|
+
|
99
|
+
#rubygems
|
100
|
+
spec.rubyforge_project = spec.name
|
101
|
+
spec.post_install_message = <<-end_message.gsub(/^[ ]{4}/,'')
|
102
|
+
#{'-'*78}
|
103
|
+
Prigner v#{spec.version}
|
104
|
+
|
105
|
+
Thanks for use Prigner.
|
106
|
+
|
107
|
+
Try run:
|
108
|
+
|
109
|
+
$ prign list
|
110
|
+
|
111
|
+
See all shared templates. If you want customize a template, just run:
|
112
|
+
|
113
|
+
$ prign copy <namespace>[:template]
|
114
|
+
|
115
|
+
Please, feedback in http://github.com/codigorama/prigner/issues.
|
116
|
+
#{'-'*78}
|
117
|
+
end_message
|
118
|
+
#
|
119
|
+
end
|
120
|
+
|
@@ -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,16 @@
|
|
1
|
+
author : Hallison Batista
|
2
|
+
email : hallison@codigorama.com
|
3
|
+
version : 0.1.0
|
4
|
+
description : Default template for Ruby projects
|
5
|
+
|
6
|
+
options:
|
7
|
+
|
8
|
+
directories:
|
9
|
+
- lib/(project)
|
10
|
+
|
11
|
+
files:
|
12
|
+
CHANGELOG:
|
13
|
+
COPYING:
|
14
|
+
README.rdoc:
|
15
|
+
module.rb : lib/(project).rb
|
16
|
+
|
@@ -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,213 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require "rake/clean"
|
4
|
+
require "lib/<%=project.name%>"
|
5
|
+
|
6
|
+
# Helpers
|
7
|
+
# =============================================================================
|
8
|
+
|
9
|
+
def rdoc(*args)
|
10
|
+
@rdoc ||= if Gem.available? "hanna"
|
11
|
+
["hanna", "--fmt", "html", "--accessor", "option_accessor=RW", *args]
|
12
|
+
else
|
13
|
+
["rdoc", *args]
|
14
|
+
end
|
15
|
+
sh @rdoc.join(" ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test(pattern)
|
19
|
+
testfiles = Dir[pattern]
|
20
|
+
if Gem.available? "turn"
|
21
|
+
sh [ "turn", *testfiles ].join(" ")
|
22
|
+
else
|
23
|
+
testfiles.each do |testfile|
|
24
|
+
sh "ruby #{testfile}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def manifest
|
30
|
+
@manifest ||= `git ls-files`.split("\n").sort.reject do |out|
|
31
|
+
out =~ /^\./ || out =~ /^doc/
|
32
|
+
end.map do |file|
|
33
|
+
" #{file.inspect}"
|
34
|
+
end.join(",\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
def log
|
38
|
+
@log ||= `git log --date=short --format='%d;%cd;%s;%b;'`
|
39
|
+
end
|
40
|
+
|
41
|
+
def version
|
42
|
+
@version ||= <%=project.class_name%>.version
|
43
|
+
end
|
44
|
+
|
45
|
+
def gemspec
|
46
|
+
@gemspec ||= Struct.new(:spec, :file).new
|
47
|
+
@gemspec.file ||= Pathname.new("<%=project.name%>.gemspec")
|
48
|
+
@gemspec.spec ||= eval @gemspec.file.read
|
49
|
+
@gemspec
|
50
|
+
end
|
51
|
+
|
52
|
+
# Documentation
|
53
|
+
# =============================================================================
|
54
|
+
|
55
|
+
namespace :doc do
|
56
|
+
|
57
|
+
CLOBBER << FileList["doc/*"]
|
58
|
+
|
59
|
+
file "doc/api/index.html" => FileList["lib/**/*.rb", "README.mkd", "CHANGELOG"] do |filespec|
|
60
|
+
rm_rf "doc"
|
61
|
+
rdoc "--op", "doc/api",
|
62
|
+
"--charset", "utf8",
|
63
|
+
"--main", "'<%=project.class_name%>'",
|
64
|
+
"--title", "'<%=project.class_name%> v#{version.tag} API Documentation'",
|
65
|
+
"--inline-source",
|
66
|
+
"--promiscuous",
|
67
|
+
"--line-numbers",
|
68
|
+
filespec.prerequisites.join(" ")
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Build API documentation (doc/api)"
|
72
|
+
task :api => "doc/api/index.html"
|
73
|
+
|
74
|
+
desc "Creates/updates CHANGELOG file."
|
75
|
+
task :changelog do |spec|
|
76
|
+
historic = {}
|
77
|
+
text = ""
|
78
|
+
|
79
|
+
log.scan(/(.*?);(.*?);(.*?);(.*?);/m) do |tag, date, subject, content|
|
80
|
+
|
81
|
+
historic[date] = {
|
82
|
+
:release => "#{date} #{tag.match(/(v\d\..*)/im) ? tag : nil}",
|
83
|
+
:changes => []
|
84
|
+
} unless historic.has_key? date
|
85
|
+
|
86
|
+
historic[date][:changes] << "\n* #{subject}\n"
|
87
|
+
historic[date][:changes] << content.gsub(/(.*?)\n/m){"\n #{$1}\n"} unless content.empty?
|
88
|
+
end
|
89
|
+
|
90
|
+
historic.keys.sort.reverse.each do |date|
|
91
|
+
entry = historic[date]
|
92
|
+
puts "Adding historic from date #{date} ..."
|
93
|
+
text << <<-end_text.gsub(/^[ ]{8}/,'')
|
94
|
+
#{entry[:release]}
|
95
|
+
#{"-" * entry[:release].size}
|
96
|
+
#{entry[:changes]}
|
97
|
+
end_text
|
98
|
+
end
|
99
|
+
|
100
|
+
File.open("CHANGELOG", "w+") { |changelog| changelog << text }
|
101
|
+
puts "Historic has #{historic.keys.size} entry dates"
|
102
|
+
puts "Successfully updated CHANGELOG file"
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
# Versioning
|
108
|
+
# =============================================================================
|
109
|
+
|
110
|
+
namespace :version do
|
111
|
+
|
112
|
+
major, minor, patch, build = version.tag.split(".").map{ |key| key.to_i } << 0
|
113
|
+
|
114
|
+
desc "Dump major version"
|
115
|
+
task :major do
|
116
|
+
version.tag = "#{major+=1}.0.0"
|
117
|
+
version.save!
|
118
|
+
puts version.to_hash.to_yaml
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Dump minor version"
|
122
|
+
task :minor do
|
123
|
+
version.tag = "#{major}.#{minor+=1}.0"
|
124
|
+
version.save!
|
125
|
+
puts version.to_hash.to_yaml
|
126
|
+
end
|
127
|
+
|
128
|
+
desc "Dump patch version"
|
129
|
+
task :patch do
|
130
|
+
version.tag = "#{major}.#{minor}.#{patch+=1}"
|
131
|
+
version.save!
|
132
|
+
puts version.to_hash.to_yaml
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "Dump build version"
|
136
|
+
task :build do
|
137
|
+
version.tag = "#{major}.#{minor}.#{patch}.#{build+=1}"
|
138
|
+
version.save!
|
139
|
+
puts version.to_hash.to_yaml
|
140
|
+
end
|
141
|
+
|
142
|
+
desc "Update version date (current #{version.date})"
|
143
|
+
task :date, [:date] do |spec, args|
|
144
|
+
require "parsedate"
|
145
|
+
require "date"
|
146
|
+
yyyy, mm, dd = ParseDate.parsedate(args[:date]).compact if args[:date]
|
147
|
+
version.date = (yyyy && mm && dd) ? Date.new(yyyy, mm, dd) : Date.today
|
148
|
+
version.save!
|
149
|
+
puts version.to_hash.to_yaml
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
task :version => "version:build"
|
154
|
+
|
155
|
+
# RubyGems
|
156
|
+
# =============================================================================
|
157
|
+
|
158
|
+
namespace :gem do
|
159
|
+
|
160
|
+
file gemspec.file => FileList["{lib,test}/**", "Rakefile"] do
|
161
|
+
spec = gemspec.file.read
|
162
|
+
|
163
|
+
puts "Updating version ..."
|
164
|
+
spec.sub! /spec\.version\s*=\s*".*?"/, "spec.version = #{version.tag.inspect}"
|
165
|
+
|
166
|
+
puts "Updating date of version ..."
|
167
|
+
spec.sub! /spec\.date\s*=\s*".*?"/, "spec.date = #{version.date.to_s.inspect}"
|
168
|
+
|
169
|
+
puts "Updating file list ..."
|
170
|
+
spec.sub! /spec\.files\s*=\s*\[.*?\]/m, "spec.files = [\n#{manifest}\n ]"
|
171
|
+
|
172
|
+
gemspec.file.open("w+") { |file| file << spec }
|
173
|
+
|
174
|
+
puts "Successfully update #{gemspec.file} file"
|
175
|
+
end
|
176
|
+
|
177
|
+
desc "Build gem package #{gemspec.spec.file_name}"
|
178
|
+
task :build => gemspec.file do
|
179
|
+
sh "gem build #{gemspec.file}"
|
180
|
+
end
|
181
|
+
|
182
|
+
desc "Deploy gem package to RubyGems.org"
|
183
|
+
task :deploy => :build do
|
184
|
+
sh "gem push #{gemspec.spec.file_name}"
|
185
|
+
end
|
186
|
+
|
187
|
+
desc "Install gem package #{gemspec.spec.file_name}"
|
188
|
+
task :install => :build do
|
189
|
+
sh "gem install #{gemspec.spec.file_name} --local"
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "Uninstall gem package #{gemspec.spec.file_name}"
|
193
|
+
task :uninstall do
|
194
|
+
sh "gem uninstall #{gemspec.spec.name} --version #{gemspec.spec.version}"
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
task :gem => "gem:build"
|
200
|
+
|
201
|
+
# Test
|
202
|
+
# =============================================================================
|
203
|
+
|
204
|
+
desc "Run tests"
|
205
|
+
task :test, [:pattern] do |spec, args|
|
206
|
+
test(args[:pattern] ? "test/#{args[:pattern]}_test.rb" : "test/*_test.rb")
|
207
|
+
end
|
208
|
+
|
209
|
+
# Default
|
210
|
+
# =============================================================================
|
211
|
+
|
212
|
+
task :default => "test"
|
213
|
+
|