vigetlabs-provisional 2.0.2 → 2.0.3

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 2
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
@@ -11,33 +11,47 @@ module Provisional
11
11
  @options = options
12
12
  end
13
13
 
14
+ def rescuing_exceptions(&block)
15
+ begin
16
+ yield
17
+ rescue
18
+ raise RuntimeError, "Repository not created due to exception: #{$!}"
19
+ end
20
+ end
21
+
14
22
  def gitignore
15
23
  Provisional::IGNORE_FILES.join("\n")
16
24
  end
17
25
 
18
26
  def init
19
- FileUtils.mkdir_p @options[:name]
20
- Dir.chdir @options[:name]
21
- @options[:path] = Dir.getwd
22
- ::Git.init
27
+ rescuing_exceptions do
28
+ FileUtils.mkdir_p @options[:name]
29
+ Dir.chdir @options[:name]
30
+ @options[:path] = Dir.getwd
31
+ ::Git.init
32
+ end
23
33
  end
24
34
 
25
35
  def generate_rails
26
- generator_options = ['.', '-m', @options[:template_path]]
27
- Dir.chdir @options[:path]
28
- Rails::Generator::Base.use_application_sources!
29
- Rails::Generator::Scripts::Generate.new.run generator_options, :generator => 'app'
36
+ rescuing_exceptions do
37
+ generator_options = ['.', '-m', @options[:template_path]]
38
+ Dir.chdir @options[:path]
39
+ Rails::Generator::Base.use_application_sources!
40
+ Rails::Generator::Scripts::Generate.new.run generator_options, :generator => 'app'
41
+ end
30
42
  end
31
43
 
32
44
  def checkin
33
- repo = ::Git.open @options[:path]
34
- Dir.chdir @options[:path]
35
- File.open('.gitignore', 'w') do |f|
36
- f.puts gitignore
45
+ rescuing_exceptions do
46
+ repo = ::Git.open @options[:path]
47
+ Dir.chdir @options[:path]
48
+ File.open('.gitignore', 'w') do |f|
49
+ f.puts gitignore
50
+ end
51
+ repo.add '.'
52
+ repo.commit 'Initial commit by Provisional'
53
+ repo
37
54
  end
38
- repo.add '.'
39
- repo.commit 'Initial commit by Provisional'
40
- repo
41
55
  end
42
56
  end
43
57
  end
@@ -5,16 +5,20 @@ module Provisional
5
5
  module SCM
6
6
  class Github < Provisional::SCM::Git
7
7
  def checkin
8
- repo = super
9
- github_user = repo.config 'github.user'
10
- github_token = repo.config 'github.token'
11
- Net::HTTP.post_form URI.parse('http://github.com/api/v2/yaml/repos/create'), {
12
- 'login' => github_user,
13
- 'token' => github_token,
14
- 'name' => @options[:name]
15
- }
16
- repo.add_remote('origin', "git@github.com:#{github_user}/#{@options[:name]}.git")
17
- repo.push
8
+ begin
9
+ repo = super
10
+ github_user = repo.config 'github.user'
11
+ github_token = repo.config 'github.token'
12
+ Net::HTTP.post_form URI.parse('https://github.com/api/v2/yaml/repos/create'), {
13
+ 'login' => github_user,
14
+ 'token' => github_token,
15
+ 'name' => @options[:name]
16
+ }
17
+ repo.add_remote('origin', "git@github.com:#{github_user}/#{@options[:name]}.git")
18
+ repo.push
19
+ rescue
20
+ raise RuntimeError, "Repository created locally, but not pushed to GitHub due to exception: #{$!}"
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -20,8 +20,16 @@ plugin 'vl_cruise_control', :git => 'git://github.com/vigetlabs/vl_cruise_contro
20
20
  generate :viget_deployment
21
21
 
22
22
  # clean up
23
- run 'rm -rf public/index.html log/* test/fixtures config/database.yml'
24
- inside ('public/javascripts') do
23
+ run 'rm -rf public/images/rails.png log/* test/fixtures config/database.yml'
24
+ inside 'public' do
25
+ run 'rm -f index.html favicon.ico robots.txt'
26
+ end
27
+ inside 'public/javascripts' do
25
28
  run 'rm -f dragdrop.js controls.js effects.js prototype.js'
26
29
  end
30
+
31
+ # install jrails javascripts
27
32
  rake 'jrails:install:javascripts'
33
+
34
+ # setup shoulda rake tasks
35
+ file 'lib/tasks/shoulda.rake', %q[require 'shoulda/tasks']
@@ -24,6 +24,13 @@ class GitTest < Test::Unit::TestCase
24
24
  @scm.init
25
25
  end
26
26
 
27
+ def test_init_should_raise_RuntimeError_if_any_step_raises_any_exception
28
+ FileUtils.expects(:mkdir_p).with('name').raises(Errno::EEXIST)
29
+ assert_raise RuntimeError do
30
+ @scm.init
31
+ end
32
+ end
33
+
27
34
  def test_generate_rails
28
35
  Dir.expects(:chdir)
29
36
  Rails::Generator::Base.expects(:use_application_sources!)
@@ -33,6 +40,13 @@ class GitTest < Test::Unit::TestCase
33
40
  @scm.generate_rails
34
41
  end
35
42
 
43
+ def test_generate_rails_should_raise_RuntimeError_if_any_step_raises_any_exception
44
+ Dir.expects(:chdir).raises(Errno::ENOENT)
45
+ assert_raise RuntimeError do
46
+ @scm.generate_rails
47
+ end
48
+ end
49
+
36
50
  def test_checkin
37
51
  repo_stub = stub()
38
52
  repo_stub.expects(:add).with('.')
@@ -44,4 +58,11 @@ class GitTest < Test::Unit::TestCase
44
58
  File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
45
59
  @scm.checkin
46
60
  end
61
+
62
+ def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
63
+ Git.expects(:open).raises(ArgumentError)
64
+ assert_raise RuntimeError do
65
+ @scm.checkin
66
+ end
67
+ end
47
68
  end
@@ -47,6 +47,30 @@ class GithubTest < Test::Unit::TestCase
47
47
  gitignore_file.expects(:puts).with(@scm.gitignore)
48
48
  File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
49
49
 
50
+ URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
51
+ Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' })
52
+
50
53
  @scm.checkin
51
54
  end
55
+
56
+ def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
57
+ repo_stub = stub()
58
+ repo_stub.expects(:add).with('.')
59
+ repo_stub.expects(:commit).with('Initial commit by Provisional')
60
+ repo_stub.expects(:config).with('github.user').returns('user')
61
+ repo_stub.expects(:config).with('github.token').returns('token')
62
+
63
+ Git.expects(:open).returns(repo_stub)
64
+ Dir.expects(:chdir)
65
+ gitignore_file = stub()
66
+ gitignore_file.expects(:puts).with(@scm.gitignore)
67
+ File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
68
+
69
+ URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
70
+ Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' }).raises(Net::HTTPUnauthorized)
71
+
72
+ assert_raise RuntimeError do
73
+ @scm.checkin
74
+ end
75
+ end
52
76
  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.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cornick
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-21 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable: provisional
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -92,7 +92,7 @@ requirements: []
92
92
  rubyforge_project: viget
93
93
  rubygems_version: 1.2.0
94
94
  signing_key:
95
- specification_version: 2
95
+ specification_version: 3
96
96
  summary: Automation for new Rails Projects
97
97
  test_files: []
98
98