visionmedia-gen 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/History.rdoc +4 -0
- data/Manifest +13 -0
- data/README.rdoc +30 -0
- data/Rakefile +16 -0
- data/Todo.rdoc +12 -0
- data/gen.gemspec +34 -0
- data/lib/gen.rb +27 -0
- data/lib/gen/template.rb +51 -0
- data/lib/gen/version.rb +4 -0
- data/spec/gen_spec.rb +22 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/docs.rake +13 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- metadata +86 -0
data/History.rdoc
ADDED
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
= Gen
|
3
|
+
|
4
|
+
Template generation that doesn't suck.
|
5
|
+
|
6
|
+
== License:
|
7
|
+
|
8
|
+
(The MIT License)
|
9
|
+
|
10
|
+
Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
a copy of this software and associated documentation files (the
|
14
|
+
'Software'), to deal in the Software without restriction, including
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be
|
21
|
+
included in all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
26
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
27
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
28
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
29
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
ARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'echoe'
|
5
|
+
require './lib/gen.rb'
|
6
|
+
|
7
|
+
Echoe.new("gen", Gen::VERSION) do |p|
|
8
|
+
p.author = "TJ Holowaychuk"
|
9
|
+
p.email = "tj@vision-media.ca"
|
10
|
+
p.summary = "Template generation that doesn't suck"
|
11
|
+
p.url = "http://github.com/visionmedia/gen"
|
12
|
+
p.runtime_dependencies = []
|
13
|
+
p.runtime_dependencies << 'visionmedia-commander >=2.5.6'
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir['tasks/**/*.rake'].sort.each { |f| load f }
|
data/Todo.rdoc
ADDED
data/gen.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gen}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["TJ Holowaychuk"]
|
9
|
+
s.date = %q{2009-03-10}
|
10
|
+
s.description = %q{Template generation that doesn't suck}
|
11
|
+
s.email = %q{tj@vision-media.ca}
|
12
|
+
s.extra_rdoc_files = ["lib/gen/template.rb", "lib/gen/version.rb", "lib/gen.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
13
|
+
s.files = ["History.rdoc", "lib/gen/template.rb", "lib/gen/version.rb", "lib/gen.rb", "Rakefile", "README.rdoc", "spec/gen_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "Todo.rdoc", "Manifest", "gen.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/visionmedia/gen}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gen", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{gen}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Template generation that doesn't suck}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
33
|
+
end
|
34
|
+
end
|
data/lib/gen.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
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.
|
22
|
+
#++
|
23
|
+
|
24
|
+
$:.unshift File.dirname(__FILE__)
|
25
|
+
|
26
|
+
require 'gen/version'
|
27
|
+
require 'gen/template'
|
data/lib/gen/template.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
module Gen
|
3
|
+
class Template
|
4
|
+
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
attr_accessor :options, :attributes
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@options, @attributes = {}, {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def run! options = {}
|
14
|
+
@options = options
|
15
|
+
raise Error, 'root directory is required. Set using #root' unless root
|
16
|
+
raise Error, "invalid root directory '#{root}'" unless File.directory? root
|
17
|
+
hook :init
|
18
|
+
hook :run
|
19
|
+
end
|
20
|
+
|
21
|
+
def root dir = nil
|
22
|
+
@root = dir if dir
|
23
|
+
@root
|
24
|
+
end
|
25
|
+
|
26
|
+
%w( init run ).each do |name|
|
27
|
+
class_eval %(
|
28
|
+
def #{name} &block
|
29
|
+
@__hook_#{name} = block
|
30
|
+
end
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def hook name, *args, &block
|
35
|
+
proc = instance_variable_get :"@__hook_#{name}"
|
36
|
+
proc.call if proc
|
37
|
+
end
|
38
|
+
|
39
|
+
def attribute name, &block
|
40
|
+
@attributes[name] = yield
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def template name, &block
|
46
|
+
template = Template.new
|
47
|
+
template.instance_eval &block if block_given?
|
48
|
+
template
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/gen/version.rb
ADDED
data/spec/gen_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
describe Gen do
|
3
|
+
|
4
|
+
include Gen
|
5
|
+
|
6
|
+
describe "#template" do
|
7
|
+
it "should create a new template instance" do
|
8
|
+
template(:chrome).should be_kind_of(Gen::Template)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should accept a class evaluated block" do
|
12
|
+
chrome = template :chrome do
|
13
|
+
def test
|
14
|
+
'test'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
chrome.test.should == 'test'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
data/spec/spec_helper.rb
ADDED
data/tasks/docs.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Remove rdoc products'
|
5
|
+
task :remove => [:clobber_docs]
|
6
|
+
|
7
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
8
|
+
task :open do
|
9
|
+
browser = ENV["BROWSER"] || "safari"
|
10
|
+
sh "open -a #{browser} doc/index.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visionmedia-gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Holowaychuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-10 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: visionmedia-commander
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.5.6
|
24
|
+
version:
|
25
|
+
description: Template generation that doesn't suck
|
26
|
+
email: tj@vision-media.ca
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- lib/gen/template.rb
|
33
|
+
- lib/gen/version.rb
|
34
|
+
- lib/gen.rb
|
35
|
+
- README.rdoc
|
36
|
+
- tasks/docs.rake
|
37
|
+
- tasks/gemspec.rake
|
38
|
+
- tasks/spec.rake
|
39
|
+
files:
|
40
|
+
- History.rdoc
|
41
|
+
- lib/gen/template.rb
|
42
|
+
- lib/gen/version.rb
|
43
|
+
- lib/gen.rb
|
44
|
+
- Rakefile
|
45
|
+
- README.rdoc
|
46
|
+
- spec/gen_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
- tasks/docs.rake
|
49
|
+
- tasks/gemspec.rake
|
50
|
+
- tasks/spec.rake
|
51
|
+
- Todo.rdoc
|
52
|
+
- Manifest
|
53
|
+
- gen.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/visionmedia/gen
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --line-numbers
|
59
|
+
- --inline-source
|
60
|
+
- --title
|
61
|
+
- Gen
|
62
|
+
- --main
|
63
|
+
- README.rdoc
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "1.2"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project: gen
|
81
|
+
rubygems_version: 1.2.0
|
82
|
+
signing_key:
|
83
|
+
specification_version: 2
|
84
|
+
summary: Template generation that doesn't suck
|
85
|
+
test_files: []
|
86
|
+
|