vigetlabs-provisional 2.1.0 → 2.1.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/{README.rdoc → README.md} +24 -21
- data/VERSION.yml +1 -1
- data/lib/provisional/scm/svn.rb +49 -0
- data/lib/provisional/scm/unfuddle_svn.rb +43 -0
- data/test/unit/svn_test.rb +58 -0
- data/test/unit/unfuddle_svn_test.rb +55 -0
- metadata +9 -3
data/{README.rdoc → README.md}
RENAMED
@@ -1,22 +1,22 @@
|
|
1
|
-
|
1
|
+
# Provisional
|
2
2
|
|
3
|
-
|
3
|
+
## Description
|
4
4
|
|
5
5
|
Provisional creates a new Rails project, using a standard Rails 2.3 application template, and checks it into a new SCM repository.
|
6
6
|
|
7
7
|
In the future, Provisional may be expanded to create production and staging environments, set up continuous integration, and automate other tasks that are usually performed at the beginning of a project.
|
8
8
|
|
9
|
-
|
9
|
+
## Requirements
|
10
10
|
|
11
11
|
Provisional requires Rails 2.3.0 or greater.
|
12
12
|
|
13
13
|
Provisional is only tested on Mac OS X. It should also work on Linux. It is not tested or supported on Windows.
|
14
14
|
|
15
|
-
|
15
|
+
## Installation
|
16
16
|
|
17
17
|
sudo gem install provisional
|
18
18
|
|
19
|
-
|
19
|
+
## Usage
|
20
20
|
|
21
21
|
Options:
|
22
22
|
--name, -n <s>: Name of the project
|
@@ -29,26 +29,25 @@ Provisional is only tested on Mac OS X. It should also work on Linux. It is not
|
|
29
29
|
--config, -c <s>: Config file (optional)
|
30
30
|
--help, -h: Show this message
|
31
31
|
|
32
|
-
The SCM option can be one of the following ("project_name" refers to the value of the --name option):
|
32
|
+
The SCM option can be one of the following ("`project_name`" refers to the value of the --name option):
|
33
33
|
|
34
|
-
* git
|
35
|
-
* github
|
36
|
-
* unfuddle
|
37
|
-
|
38
|
-
(Subversion and Viget-specific SCM's were removed in Provisional 2.0.0. They may return at a later date.)
|
34
|
+
* `git`: creates a git repository in the `project_name` directory.
|
35
|
+
* `github`: creates a git repository in the `project_name` directory, creates `project_name` on GitHub using the specified credentials, adds it as the "origin" remote, and pushes. (See section below about required configuration.)
|
36
|
+
* `unfuddle`: creates a git repository in the `project_name` directory, creates a repository called `project_name` under an existing Unfuddle project using the specified credentials, and adds it as the "origin" remote. _You must push manually_ because Unfuddle typically has a lag of a few minutes between when a repository is created and when it can be accessed. (See section below about required configuration.)
|
37
|
+
* `unfuddle_svn`: creates a Subversion repository called `project_name` under an existing Unfuddle project using the specified credentials, and checks it out into the `project_name` directory.
|
39
38
|
|
40
39
|
The domain, username, password, and id options are used by certain SCMs to provide information needed to use an API. The documentation on these SCMs (below) will indicate how they are to be used.
|
41
40
|
|
42
41
|
The template option can be either a literal path to a template file, a URL for a template on a remote server, or the name of one of the templates found in lib/provisional/templates (without the .rb suffix.) The default viget template does the following:
|
43
42
|
|
44
43
|
* freezes rails from currently installed gems
|
45
|
-
* installs gems: mocha
|
46
|
-
* installs plugins: hoptoad_notifier
|
47
|
-
* installs a .gitignore file to ignore logs, temp files, sqlite3 databases, rcov reports, and database.yml
|
44
|
+
* installs gems: `mocha`, `factory_girl`, `shoulda`
|
45
|
+
* installs plugins: `hoptoad_notifier`, `jrails`, `model_generator_with_factories`, `viget_deployment`, `vl_cruise_control`
|
46
|
+
* installs a .gitignore file to ignore logs, temp files, sqlite3 databases, rcov reports, and `database.yml`
|
48
47
|
* generates Capistrano configuration with viget_deployment
|
49
|
-
* copies database.yml to database.yml-sample
|
50
|
-
* removes public/index.html
|
51
|
-
* creates an SCM repository and checks the application in
|
48
|
+
* copies `database.yml` to `database.yml-sample`
|
49
|
+
* removes `public/index.html`, `test/fixtures`, prototype, and script.aculo.us
|
50
|
+
* creates an SCM repository and checks the application in
|
52
51
|
|
53
52
|
All of these options can be specified either on the command line, or in a YAML file indicated by the --config option. The YAML file should be in simple key: value format:
|
54
53
|
|
@@ -57,15 +56,19 @@ All of these options can be specified either on the command line, or in a YAML f
|
|
57
56
|
|
58
57
|
Options specified via the command line take precedence over options specified in a YAML file, if both are specified.
|
59
58
|
|
60
|
-
|
59
|
+
## GitHub
|
61
60
|
|
62
61
|
To use GitHub, you will need to place your GitHub username and token in your Git configuration as described here: http://github.com/guides/local-github-config Since there is already this established convention for GitHub credentials, to prevent redundant configuration, Provisional does not use its own configuration options for GitHub access.
|
63
62
|
|
64
|
-
|
63
|
+
## Unfuddle
|
64
|
+
|
65
|
+
To use Unfuddle (for either Git or Subversion) you will need to specify the --domain, --id, --username and --password options. --domain is used to specify your unfuddle.com subdomain; --id is used to specify a project ID. Using a YAML file containing these options is recommended and should be helpful.
|
66
|
+
|
67
|
+
## TODO
|
65
68
|
|
66
|
-
|
69
|
+
Beanstalk (http://beanstalkapp.com/) will be supported once their API (currently in private beta) is available to all users.
|
67
70
|
|
68
|
-
|
71
|
+
## License
|
69
72
|
|
70
73
|
Copyright (c) 2009 Mark Cornick of Viget Labs <mark@viget.com>
|
71
74
|
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rails/version'
|
3
|
+
require 'rails_generator'
|
4
|
+
require 'rails_generator/scripts/generate'
|
5
|
+
|
6
|
+
module Provisional
|
7
|
+
module SCM
|
8
|
+
class Svn
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def rescuing_exceptions(&block)
|
14
|
+
begin
|
15
|
+
yield
|
16
|
+
rescue
|
17
|
+
raise RuntimeError, "Repository not created due to exception: #{$!}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def init
|
22
|
+
raise NotImplementedError, "The SVN scm cannot currently be used directly"
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate_rails
|
26
|
+
rescuing_exceptions do
|
27
|
+
system("svn co --username=#{@options['username']} --password=#{@options['password']} #{@options['url']} #{@options['name']}")
|
28
|
+
Dir.chdir @options['name']
|
29
|
+
%w(branches tags trunk).each {|d| Dir.mkdir(d)}
|
30
|
+
system("svn add branches tags trunk")
|
31
|
+
system("svn commit -m 'Structure by Provisional'")
|
32
|
+
Dir.chdir 'trunk'
|
33
|
+
|
34
|
+
generator_options = ['.', '-m', @options['template_path']]
|
35
|
+
Rails::Generator::Base.use_application_sources!
|
36
|
+
Rails::Generator::Scripts::Generate.new.run generator_options, :generator => 'app'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def checkin
|
41
|
+
# TODO: set svn:ignores
|
42
|
+
rescuing_exceptions do
|
43
|
+
system("svn add *")
|
44
|
+
system("svn commit -m 'Initial commit by Provisional'")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'provisional/scm/svn'
|
2
|
+
require 'net/http'
|
3
|
+
require 'builder'
|
4
|
+
|
5
|
+
module Provisional
|
6
|
+
module SCM
|
7
|
+
class UnfuddleSvn < Provisional::SCM::Svn
|
8
|
+
def initialize(options)
|
9
|
+
%w(username password domain id).each do |opt|
|
10
|
+
raise ArgumentError, "#{opt} must be specified" unless options[opt]
|
11
|
+
end
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def init
|
16
|
+
begin
|
17
|
+
xml = Builder::XmlMarkup.new
|
18
|
+
xml.repository do
|
19
|
+
xml.abbreviation @options['name']
|
20
|
+
xml.title @options['name']
|
21
|
+
xml.system 'svn'
|
22
|
+
xml.projects do
|
23
|
+
xml.project(:id => @options['id'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
http = Net::HTTP.new("#{@options['domain']}.unfuddle.com", 80)
|
28
|
+
request = Net::HTTP::Post.new('/api/v1/repositories.xml', 'Content-Type' => 'application/xml')
|
29
|
+
request.basic_auth(@options['username'], @options['password'])
|
30
|
+
request.body = xml.target!
|
31
|
+
response, data = http.request(request)
|
32
|
+
unless response.code == "201"
|
33
|
+
raise RuntimeError, "Repository not created on Unfuddle due to HTTP error: #{response.code}"
|
34
|
+
end
|
35
|
+
|
36
|
+
@options['url'] = "http://#{@options['domain']}.unfuddle.com/svn/#{@options['domain']}_#{@options['name']}/"
|
37
|
+
rescue
|
38
|
+
raise RuntimeError, "Repository not created on Unfuddle due to exception: #{$!}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/provisional/scm/svn'
|
3
|
+
|
4
|
+
class SvnTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@scm = Provisional::SCM::Svn.new(
|
8
|
+
{
|
9
|
+
'name' => 'name',
|
10
|
+
'template_path' => 'template_path',
|
11
|
+
'url' => 'url',
|
12
|
+
'username' => 'username',
|
13
|
+
'password' => 'password'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_init
|
19
|
+
assert_raise NotImplementedError do
|
20
|
+
@scm.init
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_generate_rails
|
25
|
+
@scm.expects(:system).with("svn co --username=username --password=password url name")
|
26
|
+
Dir.expects(:chdir).with('name')
|
27
|
+
%w(branches tags trunk).each {|d| Dir.expects(:mkdir).with(d)}
|
28
|
+
@scm.expects(:system).with("svn add branches tags trunk")
|
29
|
+
@scm.expects(:system).with("svn commit -m 'Structure by Provisional'")
|
30
|
+
Dir.expects(:chdir).with('trunk')
|
31
|
+
Rails::Generator::Base.expects(:use_application_sources!)
|
32
|
+
generator_stub = stub()
|
33
|
+
generator_stub.expects(:run).with(%w(. -m template_path), :generator => 'app')
|
34
|
+
Rails::Generator::Scripts::Generate.expects(:new).returns(generator_stub)
|
35
|
+
@scm.generate_rails
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_generate_rails_should_raise_RuntimeError_if_any_step_raises_any_exception
|
39
|
+
@scm.expects(:system).with("svn co --username=username --password=password url name")
|
40
|
+
Dir.expects(:chdir).with('name').raises(Errno::ENOENT)
|
41
|
+
assert_raise RuntimeError do
|
42
|
+
@scm.generate_rails
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_checkin
|
47
|
+
@scm.expects(:system).with("svn add *")
|
48
|
+
@scm.expects(:system).with("svn commit -m 'Initial commit by Provisional'")
|
49
|
+
@scm.checkin
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
|
53
|
+
@scm.expects(:system).with("svn add *").raises(RuntimeError)
|
54
|
+
assert_raise RuntimeError do
|
55
|
+
@scm.checkin
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/provisional/scm/unfuddle_svn'
|
3
|
+
|
4
|
+
class UnfuddleSvnTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@scm = Provisional::SCM::UnfuddleSvn.new(
|
7
|
+
{
|
8
|
+
'name' => 'name',
|
9
|
+
'template_path' => 'template_path',
|
10
|
+
'domain' => 'domain',
|
11
|
+
'id' => 1,
|
12
|
+
'username' => 'username',
|
13
|
+
'password' => 'password'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_init
|
19
|
+
request_stub = stub()
|
20
|
+
request_stub.expects(:basic_auth).with('username', 'password')
|
21
|
+
request_stub.expects(:body=)
|
22
|
+
response_stub = stub(:code => '201')
|
23
|
+
http_stub = stub()
|
24
|
+
http_stub.expects(:request).with(request_stub).returns(response_stub, nil)
|
25
|
+
|
26
|
+
Net::HTTP::Post.expects(:new).with('/api/v1/repositories.xml', 'Content-Type' => 'application/xml').returns(request_stub)
|
27
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).returns(http_stub)
|
28
|
+
|
29
|
+
@scm.init
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_init_should_raise_RuntimeError_if_unfuddle_api_call_fails
|
33
|
+
request_stub = stub()
|
34
|
+
request_stub.expects(:basic_auth).with('username', 'password')
|
35
|
+
request_stub.expects(:body=)
|
36
|
+
response_stub = stub(:code => '500')
|
37
|
+
http_stub = stub()
|
38
|
+
http_stub.expects(:request).with(request_stub).returns(response_stub, nil)
|
39
|
+
|
40
|
+
Net::HTTP::Post.expects(:new).with('/api/v1/repositories.xml', 'Content-Type' => 'application/xml').returns(request_stub)
|
41
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).returns(http_stub)
|
42
|
+
|
43
|
+
assert_raise RuntimeError do
|
44
|
+
@scm.init
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_init_should_raise_RuntimeError_if_any_step_raises_any_exception
|
49
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).raises(Net::HTTPNotFound)
|
50
|
+
|
51
|
+
assert_raise RuntimeError do
|
52
|
+
@scm.init
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigetlabs-provisional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cornick
|
@@ -59,9 +59,9 @@ executables:
|
|
59
59
|
extensions: []
|
60
60
|
|
61
61
|
extra_rdoc_files:
|
62
|
-
- README.
|
62
|
+
- README.md
|
63
63
|
files:
|
64
|
-
- README.
|
64
|
+
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- VERSION.yml
|
67
67
|
- bin/provisional
|
@@ -69,12 +69,16 @@ files:
|
|
69
69
|
- lib/provisional/project.rb
|
70
70
|
- lib/provisional/scm/git.rb
|
71
71
|
- lib/provisional/scm/github.rb
|
72
|
+
- lib/provisional/scm/svn.rb
|
72
73
|
- lib/provisional/scm/unfuddle.rb
|
74
|
+
- lib/provisional/scm/unfuddle_svn.rb
|
73
75
|
- lib/provisional/templates/viget.rb
|
74
76
|
- test/test_helper.rb
|
75
77
|
- test/unit/git_test.rb
|
76
78
|
- test/unit/github_test.rb
|
77
79
|
- test/unit/project_test.rb
|
80
|
+
- test/unit/svn_test.rb
|
81
|
+
- test/unit/unfuddle_svn_test.rb
|
78
82
|
- test/unit/unfuddle_test.rb
|
79
83
|
has_rdoc: true
|
80
84
|
homepage: http://github.com/vigetlabs/provisional
|
@@ -107,4 +111,6 @@ test_files:
|
|
107
111
|
- test/unit/git_test.rb
|
108
112
|
- test/unit/github_test.rb
|
109
113
|
- test/unit/project_test.rb
|
114
|
+
- test/unit/svn_test.rb
|
115
|
+
- test/unit/unfuddle_svn_test.rb
|
110
116
|
- test/unit/unfuddle_test.rb
|