prigner 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,67 @@
|
|
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
|
+
"CHANGELOG",
|
27
|
+
"COPYING",
|
28
|
+
"README.mkd",
|
29
|
+
"Rakefile",
|
30
|
+
"lib/<%=project.name%>.rb",
|
31
|
+
"<%=project.name%>.gemspec",
|
32
|
+
"test/<%=project.name%>_test.rb",
|
33
|
+
]
|
34
|
+
#
|
35
|
+
|
36
|
+
spec.test_files = spec.files.select{ |path| path =~ /^test\/*test*/ }
|
37
|
+
|
38
|
+
spec.require_paths = ["lib"]
|
39
|
+
|
40
|
+
#documentation
|
41
|
+
spec.has_rdoc = true
|
42
|
+
spec.extra_rdoc_files = [
|
43
|
+
"README.mkd",
|
44
|
+
"COPYING",
|
45
|
+
"CHANGELOG"
|
46
|
+
]
|
47
|
+
spec.rdoc_options = [
|
48
|
+
"--inline-source",
|
49
|
+
"--line-numbers",
|
50
|
+
"--charset", "utf8",
|
51
|
+
"--main", "<%=project.class_name%>",
|
52
|
+
"--title", "<%=project.class_name%> v#{spec.version} API Documentation"
|
53
|
+
]
|
54
|
+
|
55
|
+
#rubygems
|
56
|
+
spec.rubyforge_project = spec.name
|
57
|
+
spec.post_install_message = <<-end_message.gsub(/^[ ]{4}/,'')
|
58
|
+
#{'-'*78}
|
59
|
+
<%=project.class_name%> v#{spec.version}
|
60
|
+
|
61
|
+
Thanks for use <%=project.class_name%>.
|
62
|
+
|
63
|
+
#{'-'*78}
|
64
|
+
end_message
|
65
|
+
#
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#@ ---
|
2
|
+
#@ :tag: 0.0.1
|
3
|
+
#@ :date: <%=date%>
|
4
|
+
#@ :milestone: Pre-Alpha
|
5
|
+
#@ :timestamp: <%=Time.now.strftime "%F %T %z"%>
|
6
|
+
|
7
|
+
# encoding: UTF-8
|
8
|
+
|
9
|
+
module <%=project.upper_camel_case_namespace%>
|
10
|
+
|
11
|
+
# RubyGems
|
12
|
+
require "rubygems" unless $LOADED_FEATURES.include? "rubygems.rb"
|
13
|
+
|
14
|
+
# Standard library requirements
|
15
|
+
require "pathname"
|
16
|
+
require "yaml"
|
17
|
+
|
18
|
+
# Return the current version.
|
19
|
+
def self.version
|
20
|
+
@version ||= Version.current
|
21
|
+
end
|
22
|
+
|
23
|
+
class Version #:nodoc:
|
24
|
+
|
25
|
+
FILE = Pathname.new(__FILE__).freeze
|
26
|
+
|
27
|
+
attr_accessor :tag, :date, :milestone
|
28
|
+
attr_reader :timestamp
|
29
|
+
|
30
|
+
def initialize(attributes = {})
|
31
|
+
attributes.each do |attribute, value|
|
32
|
+
send("#{attribute}=", value) if respond_to? "#{attribute}="
|
33
|
+
end
|
34
|
+
@timestamp = attributes[:timestamp]
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_hash
|
38
|
+
[:tag, :date, :milestone, :timestamp].inject({}) do |hash, key|
|
39
|
+
hash[key] = send(key)
|
40
|
+
hash
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def save!
|
45
|
+
@date = Date.today
|
46
|
+
source = FILE.readlines
|
47
|
+
source[0..4] = self.to_hash.to_yaml.to_s.gsub(/^/, '#@ ')
|
48
|
+
FILE.open("w+") do |file|
|
49
|
+
file << source.join("")
|
50
|
+
end
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
class << self
|
55
|
+
def current
|
56
|
+
yaml = FILE.readlines[0..4].
|
57
|
+
join("").
|
58
|
+
gsub(/\#@ /,'')
|
59
|
+
new(YAML.load(yaml))
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_s
|
63
|
+
name.match(/(.*?)::.*/)
|
64
|
+
"#{$1} v#{current.tag}, #{current.date} (#{current.milestone})"
|
65
|
+
end
|
66
|
+
end # self
|
67
|
+
|
68
|
+
end # Version
|
69
|
+
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
author : Hallison Batista
|
2
|
+
email : hallison@codigorama.com
|
3
|
+
version : 0.1.0
|
4
|
+
description : Default template for RubyGem projects
|
5
|
+
|
6
|
+
options:
|
7
|
+
|
8
|
+
directories:
|
9
|
+
- lib/(project)
|
10
|
+
- test/fixtures
|
11
|
+
|
12
|
+
files:
|
13
|
+
CHANGELOG:
|
14
|
+
COPYING:
|
15
|
+
README.mkd:
|
16
|
+
Rakefile:
|
17
|
+
gemspec: (project).gemspec
|
18
|
+
module.rb: lib/(project).rb
|
19
|
+
empty_test.rb: test/(project)_test.rb
|
20
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "test/helpers"
|
3
|
+
require "lib/prigner"
|
4
|
+
|
5
|
+
class BuilderTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@template = Prigner::Template.load(:ruby)
|
9
|
+
@project = Prigner::Project.new("#{FIXTURES}/project/duck")
|
10
|
+
@builder = Prigner::Builder.new(@project, @template)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
FileUtils.remove_dir @project.path if File.exist? @project.path
|
15
|
+
end
|
16
|
+
|
17
|
+
should "create project path" do
|
18
|
+
@builder.make_project_path.each do |path, status|
|
19
|
+
assert status, "Project path #{path} not created"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
should "create project directories" do
|
24
|
+
directories = @builder.make_project_directories
|
25
|
+
directories.each do |directory, status|
|
26
|
+
assert status, "Directory #{directory} not created"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
should "create project files" do
|
31
|
+
files = @builder.make_project_files
|
32
|
+
files.each do |file, status|
|
33
|
+
assert status, "File #{file} not created"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= '# $Id$' if option.svn.enabled %>
|
2
|
+
BASE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/.."
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(BASE_PATH) unless $LOAD_PATH.include? BASE_PATH
|
5
|
+
|
6
|
+
require "test/unit"
|
7
|
+
require "test/helpers"
|
8
|
+
require "lib/<%=project.name%>"
|
9
|
+
|
10
|
+
class <%=project.class_name%>Test < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
# start here
|
14
|
+
end
|
15
|
+
|
16
|
+
should "check the truth" do
|
17
|
+
assert true
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
author : John Doe
|
2
|
+
email : john.doe@se7en.com
|
3
|
+
version : 0.1.0
|
4
|
+
description : Default template for Ruby projects
|
5
|
+
|
6
|
+
options:
|
7
|
+
svn: Include Subversion keywords in code.
|
8
|
+
git: Enable Git flags in templates.
|
9
|
+
|
10
|
+
directories:
|
11
|
+
- test/fixtures
|
12
|
+
- lib/(project)
|
13
|
+
|
14
|
+
files:
|
15
|
+
README.mkd :
|
16
|
+
module.rb : lib/(project).rb
|
17
|
+
empty_test.rb : test/(project)_test.rb
|
18
|
+
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
author : John Doe
|
2
|
+
email : john.doe@se7en.com
|
3
|
+
version : 0.1.0
|
4
|
+
description : Default template for Ruby projects
|
5
|
+
|
6
|
+
options:
|
7
|
+
svn: Include Subversion keywords in code.
|
8
|
+
git: Enable Git flags in templates.
|
9
|
+
|
10
|
+
directories:
|
11
|
+
- test/fixtures
|
12
|
+
- lib/(project)
|
13
|
+
|
14
|
+
files:
|
15
|
+
README.mkd.erb :
|
16
|
+
module.rb.erb : lib/(project).rb
|
17
|
+
empty_test.rb.erb : test/(project)_test.rb
|
18
|
+
|
File without changes
|
File without changes
|
File without changes
|
data/test/helpers.rb
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
FIXTURES = File.expand_path(File.join(File.dirname(__FILE__), "fixtures")) unless defined? FIXTURES
|
5
|
+
|
6
|
+
module Test::Unit
|
7
|
+
class TestCase
|
8
|
+
def self.should(description, &block)
|
9
|
+
test_name = "test_#{description.gsub(/\s+/,'_')}".downcase.to_sym
|
10
|
+
defined = instance_method(test_name) rescue false
|
11
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
12
|
+
if block_given?
|
13
|
+
define_method(test_name, &block)
|
14
|
+
else
|
15
|
+
define_method(test_name) do
|
16
|
+
flunk "No implementation provided for #{description}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/test/model_test.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "test/helpers"
|
3
|
+
require "lib/prigner"
|
4
|
+
|
5
|
+
class ModelTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@binds = {
|
9
|
+
:name => "project",
|
10
|
+
:version => "0.1.0",
|
11
|
+
:author => "John Doe",
|
12
|
+
:functions => [
|
13
|
+
:create,
|
14
|
+
:recover,
|
15
|
+
:update,
|
16
|
+
:delete
|
17
|
+
]
|
18
|
+
}
|
19
|
+
@file = "#{FIXTURES}/model-result.rb"
|
20
|
+
@model = Prigner::Model.new("#{FIXTURES}/model.rb.erb", @binds)
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
File.delete(@file) if File.exist?(@file)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "check bind values" do
|
28
|
+
@binds.map do |key, value|
|
29
|
+
assert_equal value, @model.binder.send(key)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
should "build contents" do
|
34
|
+
@model.build!
|
35
|
+
|
36
|
+
assert_equal <<-end_result.gsub(/^[ ]{6}/, ''), @model.contents
|
37
|
+
#!/usr/bin/ruby
|
38
|
+
# name : project
|
39
|
+
# version: 0.1.0
|
40
|
+
# author : John Doe
|
41
|
+
|
42
|
+
module Project
|
43
|
+
|
44
|
+
def create
|
45
|
+
# type code for create
|
46
|
+
end
|
47
|
+
|
48
|
+
def recover
|
49
|
+
# type code for recover
|
50
|
+
end
|
51
|
+
|
52
|
+
def update
|
53
|
+
# type code for update
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete
|
57
|
+
# type code for delete
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end_result
|
62
|
+
end
|
63
|
+
|
64
|
+
should "write file using contents parsed" do
|
65
|
+
@model.write @file
|
66
|
+
assert File.exist?(@file)
|
67
|
+
assert_equal @model.contents, File.read(@file)
|
68
|
+
end
|
69
|
+
|
70
|
+
should "write result file" do
|
71
|
+
file = "#{FIXTURES}/models/should-exist-new-project.rb"
|
72
|
+
@model.write file
|
73
|
+
|
74
|
+
assert_equal file, @model.file_written
|
75
|
+
assert_equal @model.contents, File.read(file)
|
76
|
+
assert File.exist?(file)
|
77
|
+
|
78
|
+
File.delete(file)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "test/helpers"
|
3
|
+
require "lib/prigner"
|
4
|
+
|
5
|
+
class ProjectTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@project = Prigner::Project.new("#{FIXTURES}/project/ruby-tagger")
|
9
|
+
end
|
10
|
+
|
11
|
+
should "check basic attributes of project" do
|
12
|
+
assert_equal "#{FIXTURES}/project/ruby-tagger", @project.path
|
13
|
+
assert_equal "ruby-tagger", @project.name
|
14
|
+
end
|
15
|
+
|
16
|
+
should "split name" do
|
17
|
+
assert_equal %w{ruby tagger}, @project.name_splited
|
18
|
+
end
|
19
|
+
|
20
|
+
should "naming to upper camel case" do
|
21
|
+
assert_equal "RubyTagger", @project.upper_camel_case_name
|
22
|
+
assert_equal "rubyTagger", @project.lower_camel_case_name
|
23
|
+
end
|
24
|
+
|
25
|
+
should "naming to namespace with upper camel case" do
|
26
|
+
assert_equal "Ruby::Tagger", @project.upper_camel_case_namespace("::")
|
27
|
+
assert_equal "Ruby.Tagger", @project.upper_camel_case_namespace(".")
|
28
|
+
end
|
29
|
+
|
30
|
+
should "naming to namespace with lower camel case" do
|
31
|
+
assert_equal "ruby::Tagger", @project.lower_camel_case_namespace("::")
|
32
|
+
assert_equal "ruby.Tagger", @project.lower_camel_case_namespace(".")
|
33
|
+
end
|
34
|
+
|
35
|
+
should "naming to namespace with upper case" do
|
36
|
+
assert_equal "RUBY::TAGGER", @project.upper_case_namespace("::")
|
37
|
+
assert_equal "RUBY.TAGGER", @project.upper_case_namespace(".")
|
38
|
+
end
|
39
|
+
|
40
|
+
should "naming to namespace with lower case" do
|
41
|
+
assert_equal "ruby::tagger", @project.lower_case_namespace("::")
|
42
|
+
assert_equal "ruby.tagger", @project.lower_case_namespace(".")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
data/test/spec_test.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "test/helpers"
|
3
|
+
require "lib/prigner"
|
4
|
+
|
5
|
+
class SpecTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@info = {
|
9
|
+
"author" => "John Doe",
|
10
|
+
"email" => "john.doe@se7en.com",
|
11
|
+
"version" => "0.1.0",
|
12
|
+
"description" => "Default template for Ruby projects"
|
13
|
+
}
|
14
|
+
@options = {
|
15
|
+
"svn" => "Include Subversion keywords in code.",
|
16
|
+
"git" => "Enable Git flags in templates."
|
17
|
+
}
|
18
|
+
@directories = [
|
19
|
+
"test/fixtures",
|
20
|
+
"lib/(project)"
|
21
|
+
]
|
22
|
+
@files = {
|
23
|
+
"README.mkd" => nil,
|
24
|
+
"module.rb" => "lib/(project).rb",
|
25
|
+
"empty_test.rb" => "test/(project)_test.rb"
|
26
|
+
}
|
27
|
+
specfile = "#{FIXTURES}/templates/shared/ruby/default/specfile"
|
28
|
+
@spec = Prigner::Spec.load(specfile)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "check basic informatio about template" do
|
32
|
+
@info.each do |attribute, value|
|
33
|
+
assert_equal value, @spec.send(attribute)
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_equal @directories.sort, @spec.directories.sort
|
37
|
+
|
38
|
+
%w{options files}.each do |checker|
|
39
|
+
instance_variable_get("@#{checker}").each do |attribute, value|
|
40
|
+
assert_equal value, @spec.send(checker)[attribute]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should "set default values when initialize with emtpy attributes" do
|
46
|
+
spec = Prigner::Spec.new(nil)
|
47
|
+
assert_kind_of Array, spec.directories
|
48
|
+
assert_kind_of Hash, spec.files
|
49
|
+
assert_kind_of Hash, spec.options
|
50
|
+
end
|
51
|
+
|
52
|
+
should "raise runtime error if specfile is nil" do
|
53
|
+
assert_raises RuntimeError do
|
54
|
+
Prigner::Spec.load(nil)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
should "raise runtime error if specfile not exist" do
|
59
|
+
assert_raises RuntimeError do
|
60
|
+
Prigner::Spec.load("not/found")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "test/helpers"
|
3
|
+
require "lib/prigner"
|
4
|
+
|
5
|
+
class Prigner::Template
|
6
|
+
def self.shared_path
|
7
|
+
[ "#{FIXTURES}/templates/user",
|
8
|
+
"#{FIXTURES}/templates/shared" ]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class TemplateTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@options = {
|
16
|
+
:svn => "Include Subversion keywords in code.",
|
17
|
+
:git => "Enable Git flags in templates."
|
18
|
+
}
|
19
|
+
@path = "#{FIXTURES}/templates/shared/ruby/default"
|
20
|
+
@project_path = "#{FIXTURES}/project/foo"
|
21
|
+
@template = Prigner::Template.new(@path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
FileUtils.remove_dir @project_path if File.exist? @project_path
|
26
|
+
end
|
27
|
+
|
28
|
+
should "load basic attributes from directory name" do
|
29
|
+
assert_equal "ruby", @template.namespace
|
30
|
+
assert_equal "default", @template.name
|
31
|
+
end
|
32
|
+
|
33
|
+
should "load options" do
|
34
|
+
@options.keys.each do |option|
|
35
|
+
assert_equal @options[option], @template.options[option].description
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
should "disable all options by default" do
|
40
|
+
@options.keys.each do |option|
|
41
|
+
assert !@template.options[option].enabled
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should "load a template using namespace" do
|
46
|
+
template = Prigner::Template.load(:ruby)
|
47
|
+
assert_equal @path, template.path.to_s
|
48
|
+
assert_equal "ruby", template.namespace
|
49
|
+
assert_equal "default", template.name
|
50
|
+
end
|
51
|
+
|
52
|
+
should "load a template looking home user directory" do
|
53
|
+
ENV['HOME'] = "#{FIXTURES}/templates/user"
|
54
|
+
template = Prigner::Template.load(:ruby, :program)
|
55
|
+
assert_equal "ruby", template.namespace
|
56
|
+
assert_equal "program", template.name
|
57
|
+
end
|
58
|
+
|
59
|
+
should "check number of models and directories" do
|
60
|
+
assert_equal 2, @template.directories.size
|
61
|
+
assert_equal 3, @template.models.size, "Models size not matched"
|
62
|
+
end
|
63
|
+
|
64
|
+
should "list all template paths from shared path" do
|
65
|
+
assert_equal 6, Prigner::Template.all_template_paths.size
|
66
|
+
end
|
67
|
+
|
68
|
+
should "list all templates grouped by namespace" do
|
69
|
+
assert_equal 3, Prigner::Template.all.keys.size
|
70
|
+
assert_equal 1, Prigner::Template.all["bash"].size
|
71
|
+
assert_equal 2, Prigner::Template.all["ruby"].size
|
72
|
+
assert_equal 3, Prigner::Template.all["vim"].size
|
73
|
+
end
|
74
|
+
|
75
|
+
should "raise runtime error when specfile not found" do
|
76
|
+
assert_raises RuntimeError do
|
77
|
+
Prigner::Template.new("not/exist")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
should "raise runtime error when nil values to namespace and/or template" do
|
82
|
+
assert_raises RuntimeError do
|
83
|
+
Prigner::Template.load(nil, nil)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|