incept 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -0
- data/Rakefile +9 -0
- data/bin/incept +7 -0
- data/lib/incept.rb +11 -0
- data/lib/incept/cli.rb +40 -0
- data/lib/incept/configuration.rb +32 -0
- data/lib/incept/directory.rb +26 -0
- data/lib/incept/multiple_option_package.rb +53 -0
- data/lib/incept/package.rb +32 -0
- data/lib/incept/package_collection.rb +48 -0
- data/lib/incept/single_option_package.rb +29 -0
- data/lib/incept/template.rb +31 -0
- data/lib/incept/version.rb +3 -0
- data/spec/fixtures/templates/other_package_name/other_option/install.rb +1 -0
- data/spec/fixtures/templates/other_package_name/other_option/options.rb +1 -0
- data/spec/fixtures/templates/package_name/option_with_post_install/install.rb +1 -0
- data/spec/fixtures/templates/package_name/option_with_post_install/post_install.rb +1 -0
- data/spec/fixtures/templates/package_name/option_without_post_install/install.rb +1 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/incept/configuration_spec.rb +44 -0
- data/spec/unit/incept/directory_spec.rb +21 -0
- data/spec/unit/incept/multiple_option_package_spec.rb +100 -0
- data/spec/unit/incept/package_collection_spec.rb +91 -0
- data/spec/unit/incept/single_option_package_spec.rb +59 -0
- data/spec/unit/incept/template_spec.rb +70 -0
- data/templates/javascript/jquery/install.rb +1 -0
- data/templates/javascript/jquery/options.rb +1 -0
- data/templates/javascript/jquery/post_install.rb +1 -0
- metadata +151 -0
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/incept
ADDED
data/lib/incept.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'incept/version'
|
4
|
+
require 'incept/package'
|
5
|
+
require 'incept/single_option_package'
|
6
|
+
require 'incept/multiple_option_package'
|
7
|
+
require 'incept/package_collection'
|
8
|
+
require 'incept/template'
|
9
|
+
require 'incept/configuration'
|
10
|
+
require 'incept/directory'
|
11
|
+
require 'incept/cli'
|
data/lib/incept/cli.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
module Incept
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "new [app]", "Create a new Rails 3 application"
|
8
|
+
long_desc <<-D
|
9
|
+
Incept will ask you a few questions to determine what features you
|
10
|
+
would like to generate. Based on your answers it will setup a new Rails 3 application.
|
11
|
+
D
|
12
|
+
def new(project)
|
13
|
+
PackageCollection.each do |package|
|
14
|
+
package.selection = ask package.prompt
|
15
|
+
end
|
16
|
+
|
17
|
+
command = "rails new #{project} --template=#{template_file.path} #{additional_options}"
|
18
|
+
say "Running `#{command}`"
|
19
|
+
|
20
|
+
exec command
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "version", "Prints Incept's version information"
|
24
|
+
def version
|
25
|
+
say "Incept version #{Incept::VERSION}"
|
26
|
+
end
|
27
|
+
map %w(-v --version) => :version
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def template_file
|
32
|
+
@template_file ||= Tempfile.open('incept') {|f| f << PackageCollection.render }
|
33
|
+
end
|
34
|
+
|
35
|
+
def additional_options
|
36
|
+
PackageCollection.command_options
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Incept
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
def self.path
|
5
|
+
File.expand_path('../../../templates', __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.load
|
9
|
+
new(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(path)
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
|
16
|
+
def directories
|
17
|
+
@directories ||= begin
|
18
|
+
names = Directory.names_for(@path)
|
19
|
+
names.map {|name| Directory.new("#{@path}/#{name}") }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def map(&block)
|
24
|
+
to_hash.map(&block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_hash
|
28
|
+
@to_hash ||= directories.inject({}) {|h, d| h.merge(d.to_hash) }
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Incept
|
2
|
+
class Directory
|
3
|
+
|
4
|
+
def self.names_for(path)
|
5
|
+
Dir.new(path).entries.reject {|d| %w(. ..).include?(d) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
def package_name
|
13
|
+
@path.match(%r{/([^/]+)$})[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def options
|
17
|
+
self.class.names_for(@path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash
|
21
|
+
{package_name => options}
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Incept
|
2
|
+
class MultipleOptionPackage
|
3
|
+
include Package
|
4
|
+
|
5
|
+
def prompt
|
6
|
+
" Which #{@type} package would you like to use?\n" +
|
7
|
+
option_display + "\n" +
|
8
|
+
" Enter a choice (0-#{max_option}): "
|
9
|
+
end
|
10
|
+
|
11
|
+
def selection=(selection)
|
12
|
+
selection = selection.to_i
|
13
|
+
@selection = within_bounds?(selection) ? selection : 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def environment_variable_name
|
17
|
+
"PROLOGUE_#{@type.upcase}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def environment_variable_value
|
21
|
+
selected_package_name.downcase
|
22
|
+
end
|
23
|
+
|
24
|
+
def selected?
|
25
|
+
!selection.nil? && selection != 0
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def full_options
|
31
|
+
['None'] + @options
|
32
|
+
end
|
33
|
+
|
34
|
+
def option_display
|
35
|
+
String.new.tap do |output|
|
36
|
+
full_options.each_with_index {|o, i| output << " #{i}. #{o}\n" }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def max_option
|
41
|
+
@options.length
|
42
|
+
end
|
43
|
+
|
44
|
+
def within_bounds?(selection)
|
45
|
+
selection <= max_option && selection >= 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def selected_package_name
|
49
|
+
full_options[selection] if selected?
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Incept
|
2
|
+
module Package
|
3
|
+
|
4
|
+
def self.included(other)
|
5
|
+
other.class_eval do
|
6
|
+
attr_reader :selection
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(type, options)
|
11
|
+
@type = type
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def template_path
|
16
|
+
File.expand_path("../../../templates/#{@type}/#{selected_package_name.downcase}", __FILE__)
|
17
|
+
end
|
18
|
+
|
19
|
+
def template
|
20
|
+
@template ||= Template.new(template_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def render(type)
|
24
|
+
template.render(type)
|
25
|
+
end
|
26
|
+
|
27
|
+
def command_options
|
28
|
+
template.render(:options)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Incept
|
2
|
+
class PackageCollection
|
3
|
+
|
4
|
+
def self.configuration
|
5
|
+
@configuration ||= Configuration.load
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.packages
|
9
|
+
@packages ||= configuration.map {|type, options| new(type, options) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.each(&block)
|
13
|
+
packages.each(&block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.selected(&block)
|
17
|
+
packages.select {|p| p.selected? }.each(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.render
|
21
|
+
output = ''
|
22
|
+
selected do |package|
|
23
|
+
output << package.render(:install)
|
24
|
+
end
|
25
|
+
|
26
|
+
output << %{run "bundle install"\n}
|
27
|
+
|
28
|
+
selected do |package|
|
29
|
+
output << package.render(:post_install)
|
30
|
+
end
|
31
|
+
|
32
|
+
output
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.command_options
|
36
|
+
selected.map {|p| p.command_options }.join(' ')
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def self.new(type, options)
|
42
|
+
klass = (options.length == 1) ? SingleOptionPackage : MultipleOptionPackage
|
43
|
+
klass.new(type, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Incept
|
2
|
+
class SingleOptionPackage
|
3
|
+
|
4
|
+
include Package
|
5
|
+
|
6
|
+
def prompt
|
7
|
+
"Would you like to use #{option_name} for your #{@type} package? (y/n): "
|
8
|
+
end
|
9
|
+
|
10
|
+
def selection=(selection)
|
11
|
+
@selection = (selection == 'y')
|
12
|
+
end
|
13
|
+
|
14
|
+
def selected?
|
15
|
+
selection == true
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def option_name
|
21
|
+
@options.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def selected_package_name
|
25
|
+
option_name if selected?
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Incept
|
2
|
+
class Template
|
3
|
+
|
4
|
+
def initialize(path)
|
5
|
+
@path = path
|
6
|
+
end
|
7
|
+
|
8
|
+
def files
|
9
|
+
@files ||= Dir.glob("#{@path}/*.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(type)
|
13
|
+
path_to_file = map[type]
|
14
|
+
path_to_file.nil? ? '' : File.read(path_to_file) + line_ending(type)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def line_ending(type)
|
20
|
+
(type == :options) ? '' : "\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
def map
|
24
|
+
files.inject({}) do |map, filename|
|
25
|
+
matches = filename.match(%r{/([^/]+)\.rb$})
|
26
|
+
map.merge(matches[1].to_sym => filename)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
install
|
@@ -0,0 +1 @@
|
|
1
|
+
--option
|
@@ -0,0 +1 @@
|
|
1
|
+
install option_with_post_install
|
@@ -0,0 +1 @@
|
|
1
|
+
post_install for option_with_post_install
|
@@ -0,0 +1 @@
|
|
1
|
+
install option_without_post_install
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::Configuration do
|
4
|
+
|
5
|
+
context "the class" do
|
6
|
+
|
7
|
+
it "knows the path to the templates" do
|
8
|
+
Incept::Configuration.path.should == File.expand_path('../../../../templates', __FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can load the configured templates" do
|
12
|
+
Incept::Configuration.stub(:path).with().and_return('/')
|
13
|
+
Incept::Configuration.stub(:new).with('/').and_return('configuration')
|
14
|
+
|
15
|
+
Incept::Configuration.load.should == 'configuration'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context "an instance" do
|
21
|
+
|
22
|
+
it "has a collection of directories" do
|
23
|
+
path = File.expand_path('../../../fixtures/templates', __FILE__)
|
24
|
+
configuration = Incept::Configuration.new(path)
|
25
|
+
|
26
|
+
Incept::Directory.stub(:new).with("#{path}/other_package_name").and_return('dir_1')
|
27
|
+
Incept::Directory.stub(:new).with("#{path}/package_name").and_return('dir_2')
|
28
|
+
|
29
|
+
configuration.directories.should == ['dir_1', 'dir_2']
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can generate a hash representation of itself" do
|
33
|
+
directory_1 = stub(:to_hash => {'one' => []})
|
34
|
+
directory_2 = stub(:to_hash => {'two' => []})
|
35
|
+
|
36
|
+
configuration = Incept::Configuration.new('/')
|
37
|
+
configuration.stub(:directories).with().and_return([directory_1, directory_2])
|
38
|
+
|
39
|
+
configuration.to_hash.should == {'one' => [], 'two' => []}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::Directory do
|
4
|
+
before do
|
5
|
+
path = File.expand_path('../../../fixtures/templates/package_name', __FILE__)
|
6
|
+
@directory = Incept::Directory.new(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "knows the package name" do
|
10
|
+
@directory.package_name.should == 'package_name'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "knows the available options" do
|
14
|
+
@directory.options.should == ['option_with_post_install', 'option_without_post_install']
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can generate a hash representation of itself" do
|
18
|
+
@directory.to_hash.should == {'package_name' => ['option_with_post_install', 'option_without_post_install']}
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::MultipleOptionPackage do
|
4
|
+
|
5
|
+
context "an instance with a multi-select package" do
|
6
|
+
before { @package = Incept::MultipleOptionPackage.new(:scm, %w(Git SVN)) }
|
7
|
+
|
8
|
+
it "can generate a prompt" do
|
9
|
+
expected =
|
10
|
+
" Which scm package would you like to use?\n" +
|
11
|
+
" 0. None\n" +
|
12
|
+
" 1. Git\n" +
|
13
|
+
" 2. SVN\n" +
|
14
|
+
"\n" +
|
15
|
+
" Enter a choice (0-2): "
|
16
|
+
|
17
|
+
@package.prompt.should == expected
|
18
|
+
end
|
19
|
+
|
20
|
+
it "knows that there is no selection by default" do
|
21
|
+
@package.selection.should be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "knows the selection" do
|
25
|
+
@package.selection = 0
|
26
|
+
@package.selection.should == 0
|
27
|
+
end
|
28
|
+
|
29
|
+
it "knows the selection when given a string" do
|
30
|
+
@package.selection = "0"
|
31
|
+
@package.selection.should == 0
|
32
|
+
end
|
33
|
+
|
34
|
+
it "doesn't allow a selection greater than the max option" do
|
35
|
+
@package.selection = 3
|
36
|
+
@package.selection.should == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
it "doesn't allow a selection less than the minimum option" do
|
40
|
+
@package.selection = -1
|
41
|
+
@package.selection.should == 0
|
42
|
+
end
|
43
|
+
|
44
|
+
it "knows that the package has not been selected by default" do
|
45
|
+
@package.should_not be_selected
|
46
|
+
end
|
47
|
+
|
48
|
+
it "knows that the package has not been selected when the choice is zero" do
|
49
|
+
@package.selection = 0
|
50
|
+
@package.should_not be_selected
|
51
|
+
end
|
52
|
+
|
53
|
+
it "knows that the package has been selected" do
|
54
|
+
@package.selection = 1
|
55
|
+
@package.should be_selected
|
56
|
+
end
|
57
|
+
|
58
|
+
it "knows the base template path" do
|
59
|
+
@package.selection = 1
|
60
|
+
@package.template_path.should == File.expand_path('../../../../templates/scm/git', __FILE__)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "knows the environment variable name" do
|
64
|
+
@package.environment_variable_name.should == 'PROLOGUE_SCM'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "knows the environment variable value" do
|
68
|
+
@package.selection = 1
|
69
|
+
@package.environment_variable_value.should == 'git'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "has an associated template" do
|
73
|
+
@package.stub(:template_path).with().and_return('/path')
|
74
|
+
|
75
|
+
template = stub()
|
76
|
+
Incept::Template.stub(:new).with('/path').and_return(template)
|
77
|
+
|
78
|
+
@package.template.should == template
|
79
|
+
end
|
80
|
+
|
81
|
+
it "can render the underlying template" do
|
82
|
+
template = stub()
|
83
|
+
template.stub(:render).with(:install).and_return('install')
|
84
|
+
|
85
|
+
@package.stub(:template).and_return(template)
|
86
|
+
|
87
|
+
@package.render(:install).should == 'install'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "knows the command options" do
|
91
|
+
template = Incept::Template.new('')
|
92
|
+
template.stub(:render).with(:options).and_return('--skip-prototype')
|
93
|
+
@package.stub(:template).with().and_return(template)
|
94
|
+
|
95
|
+
@package.command_options.should == '--skip-prototype'
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::PackageCollection do
|
4
|
+
|
5
|
+
context "The class" do
|
6
|
+
|
7
|
+
it "can load a configuration" do
|
8
|
+
Incept::Configuration.stub(:load).with().and_return('configuration')
|
9
|
+
Incept::PackageCollection.configuration.should == 'configuration'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has a collection of packages" do
|
13
|
+
available_packages = {
|
14
|
+
'scm' => ['Git'],
|
15
|
+
'auth' => ['Devise', 'AuthLogic']
|
16
|
+
}
|
17
|
+
|
18
|
+
configuration = Incept::Configuration.new('/')
|
19
|
+
configuration.stub(:to_hash).with().and_return(available_packages)
|
20
|
+
|
21
|
+
Incept::PackageCollection.stub(:configuration).and_return(configuration)
|
22
|
+
|
23
|
+
Incept::SingleOptionPackage.stub(:new).with('scm', ['Git']).and_return('package_1')
|
24
|
+
Incept::MultipleOptionPackage.stub(:new).with('auth', ['Devise', 'AuthLogic']).and_return('package_2')
|
25
|
+
|
26
|
+
Incept::PackageCollection.packages.should == ['package_1', 'package_2']
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can iterate over packages with :each" do
|
30
|
+
Incept::PackageCollection.stub(:packages).with().and_return(['package'])
|
31
|
+
packages = []
|
32
|
+
Incept::PackageCollection.each {|p| packages << p }
|
33
|
+
|
34
|
+
packages.should == ['package']
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has a collection of selected packages" do
|
38
|
+
selected = Incept::SingleOptionPackage.new(:one, [])
|
39
|
+
selected.stub(:selected?).with().and_return(true)
|
40
|
+
|
41
|
+
unselected = Incept::SingleOptionPackage.new(:two, [])
|
42
|
+
unselected.stub(:selected?).with().and_return(false)
|
43
|
+
|
44
|
+
Incept::PackageCollection.stub(:packages).and_return([selected, unselected])
|
45
|
+
|
46
|
+
packages = []
|
47
|
+
Incept::PackageCollection.selected {|p| packages << p }
|
48
|
+
|
49
|
+
packages.should == [selected]
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with selected packages" do
|
53
|
+
before do
|
54
|
+
@package_1 = stub()
|
55
|
+
@package_1.stub(:selected?).with().and_return(true)
|
56
|
+
|
57
|
+
@package_2 = stub()
|
58
|
+
@package_2.stub(:selected?).with().and_return(true)
|
59
|
+
|
60
|
+
Incept::PackageCollection.stub(:packages).with().and_return([@package_1, @package_2])
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can render the templates for selected packages" do
|
64
|
+
@package_1.stub(:render).with(:install).and_return("package_1 install\n")
|
65
|
+
@package_1.stub(:render).with(:post_install).and_return("package_1 post-install\n")
|
66
|
+
|
67
|
+
@package_2.stub(:render).with(:install).and_return("package_2 install\n")
|
68
|
+
@package_2.stub(:render).with(:post_install).and_return('')
|
69
|
+
|
70
|
+
expected =
|
71
|
+
"package_1 install\n" +
|
72
|
+
"package_2 install\n" +
|
73
|
+
%{run "bundle install"\n} +
|
74
|
+
"package_1 post-install\n"
|
75
|
+
|
76
|
+
Incept::PackageCollection.render.should == expected
|
77
|
+
end
|
78
|
+
|
79
|
+
it "knows the command options" do
|
80
|
+
@package_1.stub(:command_options).with().and_return("--option-1")
|
81
|
+
@package_2.stub(:command_options).with().and_return("--option-2")
|
82
|
+
|
83
|
+
Incept::PackageCollection.command_options.should == "--option-1 --option-2"
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::SingleOptionPackage do
|
4
|
+
|
5
|
+
context "an instance with a single selection package" do
|
6
|
+
before { @package = Incept::SingleOptionPackage.new(:javascript, %w(jQuery)) }
|
7
|
+
|
8
|
+
it "can generate a prompt" do
|
9
|
+
@package.prompt.should == "Would you like to use jQuery for your javascript package? (y/n): "
|
10
|
+
end
|
11
|
+
|
12
|
+
it "knows it's not selected by default" do
|
13
|
+
@package.should_not be_selected
|
14
|
+
end
|
15
|
+
|
16
|
+
it "knows it's selected if the answer is 'y'" do
|
17
|
+
@package.selection = 'y'
|
18
|
+
@package.should be_selected
|
19
|
+
end
|
20
|
+
|
21
|
+
it "knows it's not selected if the answer is 'n'" do
|
22
|
+
@package.selection = 'n'
|
23
|
+
@package.should_not be_selected
|
24
|
+
end
|
25
|
+
|
26
|
+
it "knows the template path" do
|
27
|
+
@package.selection = 'y'
|
28
|
+
@package.template_path.should == File.expand_path('../../../../templates/javascript/jquery', __FILE__)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has an associated template" do
|
32
|
+
@package.stub(:template_path).with().and_return('/path')
|
33
|
+
|
34
|
+
template = stub()
|
35
|
+
Incept::Template.stub(:new).with('/path').and_return(template)
|
36
|
+
|
37
|
+
@package.template.should == template
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can render the underlying template" do
|
41
|
+
template = stub()
|
42
|
+
template.stub(:render).with(:install).and_return('install')
|
43
|
+
|
44
|
+
@package.stub(:template).and_return(template)
|
45
|
+
|
46
|
+
@package.render(:install).should == 'install'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "knows the command options" do
|
50
|
+
template = Incept::Template.new('')
|
51
|
+
template.stub(:render).with(:options).and_return('--skip-prototype')
|
52
|
+
@package.stub(:template).with().and_return(template)
|
53
|
+
|
54
|
+
@package.command_options.should == '--skip-prototype'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Incept::Template do
|
4
|
+
|
5
|
+
context "an instance with a package that has a post install file" do
|
6
|
+
before do
|
7
|
+
@path = File.expand_path('../../../fixtures/templates/package_name/option_with_post_install', __FILE__)
|
8
|
+
@template = Incept::Template.new(@path)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "knows there are multiple template files" do
|
12
|
+
@template.files.should == ["#{@path}/install.rb", "#{@path}/post_install.rb"]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "renders an empty string for the options file" do
|
16
|
+
@template.render(:options).should == ''
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can render the install file" do
|
20
|
+
@template.render(:install).should == "install option_with_post_install\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can render the post-install file" do
|
24
|
+
@template.render(:post_install).should == "post_install for option_with_post_install\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "an instance with a package that does not have a post install file" do
|
29
|
+
before do
|
30
|
+
@path = File.expand_path('../../../fixtures/templates/package_name/option_without_post_install', __FILE__)
|
31
|
+
@template = Incept::Template.new(@path)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "knows there's a single template file" do
|
35
|
+
@template.files.should == ["#{@path}/install.rb"]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "renders an empty string for the options file" do
|
39
|
+
@template.render(:options).should == ''
|
40
|
+
end
|
41
|
+
|
42
|
+
it "can render the install file" do
|
43
|
+
@template.render(:install).should == "install option_without_post_install\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "renders the empty string for the post-install file" do
|
47
|
+
@template.render(:post_install).should == ''
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "an instance with a package that has install options" do
|
52
|
+
before do
|
53
|
+
@path = File.expand_path('../../../fixtures/templates/other_package_name/other_option', __FILE__)
|
54
|
+
@template = Incept::Template.new(@path)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "knows there are multiple template files" do
|
58
|
+
@template.files.should == ["#{@path}/install.rb", "#{@path}/options.rb"]
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can render the options file" do
|
62
|
+
@template.render(:options).should == "--option"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "can render the install file" do
|
66
|
+
@template.render(:install).should == "install\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
gem "jquery-rails"
|
@@ -0,0 +1 @@
|
|
1
|
+
--skip-prototype
|
@@ -0,0 +1 @@
|
|
1
|
+
generate "jquery:install"
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: incept
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Patrick Reagan
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-20 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thor
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rails
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 3
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 3.0.0
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 0
|
59
|
+
- 0
|
60
|
+
version: 1.0.0
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 2
|
73
|
+
- 0
|
74
|
+
- 0
|
75
|
+
version: 2.0.0
|
76
|
+
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
description:
|
79
|
+
email:
|
80
|
+
- reaganpr@gmail.com
|
81
|
+
executables:
|
82
|
+
- incept
|
83
|
+
extensions: []
|
84
|
+
|
85
|
+
extra_rdoc_files: []
|
86
|
+
|
87
|
+
files:
|
88
|
+
- README.rdoc
|
89
|
+
- Rakefile
|
90
|
+
- bin/incept
|
91
|
+
- lib/incept/cli.rb
|
92
|
+
- lib/incept/configuration.rb
|
93
|
+
- lib/incept/directory.rb
|
94
|
+
- lib/incept/multiple_option_package.rb
|
95
|
+
- lib/incept/package.rb
|
96
|
+
- lib/incept/package_collection.rb
|
97
|
+
- lib/incept/single_option_package.rb
|
98
|
+
- lib/incept/template.rb
|
99
|
+
- lib/incept/version.rb
|
100
|
+
- lib/incept.rb
|
101
|
+
- spec/fixtures/templates/other_package_name/other_option/install.rb
|
102
|
+
- spec/fixtures/templates/other_package_name/other_option/options.rb
|
103
|
+
- spec/fixtures/templates/package_name/option_with_post_install/install.rb
|
104
|
+
- spec/fixtures/templates/package_name/option_with_post_install/post_install.rb
|
105
|
+
- spec/fixtures/templates/package_name/option_without_post_install/install.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/unit/incept/configuration_spec.rb
|
108
|
+
- spec/unit/incept/directory_spec.rb
|
109
|
+
- spec/unit/incept/multiple_option_package_spec.rb
|
110
|
+
- spec/unit/incept/package_collection_spec.rb
|
111
|
+
- spec/unit/incept/single_option_package_spec.rb
|
112
|
+
- spec/unit/incept/template_spec.rb
|
113
|
+
- templates/javascript/jquery/install.rb
|
114
|
+
- templates/javascript/jquery/options.rb
|
115
|
+
- templates/javascript/jquery/post_install.rb
|
116
|
+
has_rdoc: true
|
117
|
+
homepage: http://github.com/reagent/incept
|
118
|
+
licenses: []
|
119
|
+
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
segments:
|
139
|
+
- 1
|
140
|
+
- 3
|
141
|
+
- 6
|
142
|
+
version: 1.3.6
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.3.7
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: incept works best, put your app to the test
|
150
|
+
test_files: []
|
151
|
+
|