bueller 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,17 +24,26 @@ class Bueller
24
24
  def repo; bueller.repo; end
25
25
 
26
26
  def run
27
- raise "Hey buddy, try committing them files first" unless clean_staging_area?
27
+ run = true
28
+ unless clean_staging_area?
29
+ output.puts "There are some modified files that haven't been committed. Proceed anyway?"
30
+ run = $stdin.gets =~ /(y|yes)/i ? true : false
31
+ end
28
32
 
29
- repo.checkout('master')
30
- repo.push
31
-
32
- unless release_tagged?
33
- output.puts "Tagging #{release_tag}"
34
- repo.add_tag(release_tag)
33
+ if run
34
+ repo.checkout('master')
35
+
36
+ if release_tagged?
37
+ repo.push
38
+ else
39
+ output.puts "Tagging #{release_tag}"
40
+ repo.add_tag release_tag
35
41
 
36
- output.puts "Pushing #{release_tag} to origin"
37
- repo.push('origin', release_tag)
42
+ output.puts "Pushing #{release_tag} to origin"
43
+ repo.push 'origin', release_tag
44
+ end
45
+ else
46
+ raise "Release cancelled"
38
47
  end
39
48
  end
40
49
 
@@ -19,17 +19,29 @@ class Bueller
19
19
 
20
20
  def version_helper; bueller.version_helper; end
21
21
  def gemspec_helper; bueller.gemspec_helper; end
22
+ def repo; bueller.repo; end
23
+ def commit; bueller.commit; end
22
24
 
23
25
  def run
24
26
  update_version
25
27
 
26
28
  gemspec_helper.update_version version_helper.to_s
29
+ gemspec_helper.set_date
27
30
  gemspec_helper.write
31
+
32
+ commit_version
28
33
  end
29
34
 
30
35
  def update_version
31
36
  raise "Subclasses should implement this"
32
37
  end
38
+
39
+ def commit_version
40
+ if repo and commit
41
+ repo.add gemspec_helper.path
42
+ repo.commit "Version bump to #{version_helper.to_s}"
43
+ end
44
+ end
33
45
  end
34
46
  end
35
47
  end
@@ -39,10 +39,11 @@ class Bueller
39
39
  end
40
40
 
41
41
  def path
42
+ return @path unless @path.nil?
42
43
  denormalized_path = Dir.glob(File.join(base_dir, '*.gemspec')).first
43
44
  raise NoGemspecFound, "No gemspec found in #{base_dir}" if denormalized_path.nil?
44
45
  absolute_path = File.expand_path(denormalized_path)
45
- absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
46
+ @path = absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
46
47
  end
47
48
 
48
49
  def spec_source
data/lib/bueller/tasks.rb CHANGED
@@ -78,21 +78,18 @@ class Bueller
78
78
  desc "Bump the gemspec by a major version."
79
79
  task :major => :version do
80
80
  bueller.bump_major_version
81
- bueller.write_gemspec
82
81
  $stdout.puts "Updated version: #{bueller.version}"
83
82
  end
84
83
 
85
84
  desc "Bump the gemspec by a minor version."
86
85
  task :minor => :version do
87
86
  bueller.bump_minor_version
88
- bueller.write_gemspec
89
87
  $stdout.puts "Updated version: #{bueller.version}"
90
88
  end
91
89
 
92
90
  desc "Bump the gemspec by a patch version."
93
91
  task :patch => :version do
94
92
  bueller.bump_patch_version
95
- bueller.write_gemspec
96
93
  $stdout.puts "Updated version: #{bueller.version}"
97
94
  end
98
95
  end
@@ -102,19 +99,10 @@ class Bueller
102
99
  task :release do
103
100
  end
104
101
 
105
- namespace :github do
106
- desc "Release Gem to GitHub"
107
- task :release do
108
- bueller.release_gem_to_github
109
- end
110
- end
111
-
112
- task :release => 'github:release'
113
-
114
102
  namespace :git do
115
- desc "Tag a release in Git"
103
+ desc "Tag a release and push to origin"
116
104
  task :release do
117
- bueller.release_to_git
105
+ bueller.git_tag_release
118
106
  end
119
107
  end
120
108
 
@@ -122,7 +110,7 @@ class Bueller
122
110
 
123
111
  namespace :rubygems do
124
112
  desc "Release gem to Rubygems"
125
- task :release => [:gemspec, :build] do
113
+ task :release => :build do
126
114
  bueller.release_gem_to_rubygems
127
115
  end
128
116
  end
@@ -73,6 +73,7 @@ require 'rake/rdoctask'
73
73
  Rake::RDocTask.new do |rdoc|
74
74
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
75
75
 
76
+ rdoc.main = 'README.rdoc'
76
77
  rdoc.rdoc_dir = 'rdoc'
77
78
  rdoc.title = "<%= project_name %> #{version}"
78
79
  rdoc.rdoc_files.include('README*')
data/lib/bueller.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'git'
2
3
 
3
4
  # Bueller helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
4
5
  #
@@ -110,10 +111,6 @@ class Bueller
110
111
  Bueller::Commands::Version::Write.run_for self, major, minor, patch, build
111
112
  end
112
113
 
113
- def release_gem_to_github
114
- Bueller::Commands::ReleaseToGithub.run_for self
115
- end
116
-
117
114
  def git_tag_release
118
115
  Bueller::Commands::GitTagRelease.run_for self
119
116
  end
@@ -17,12 +17,21 @@ describe Bueller::Commands::GitTagRelease do
17
17
  before :each do
18
18
  command.repo.stub! :checkout
19
19
  command.repo.stub! :push
20
+ command.repo.stub! :add_tag
21
+ command.stub!(:clean_staging_area?).and_return true
20
22
  command.stub!(:release_tagged?).and_return true
21
23
  end
22
24
 
23
- it 'should raise an error if the staging area is unclean' do
25
+ it 'should not run if the staging area is unclean and user does not confirm' do
24
26
  command.stub!(:clean_staging_area?).and_return false
25
- expect { command.run }.should raise_error(RuntimeError, /try committing/i)
27
+ $stdin.stub!(:gets).and_return 'no'
28
+ expect { command.run }.should raise_error
29
+ end
30
+ it 'should run if the staging area is unclean and user confirms' do
31
+ command.stub!(:clean_staging_area?).and_return false
32
+ $stdin.stub!(:gets).and_return 'yes'
33
+ command.repo.should_receive :checkout
34
+ command.run
26
35
  end
27
36
  it 'should check out master' do
28
37
  command.repo.should_receive(:checkout).with 'master'
@@ -32,17 +41,16 @@ describe Bueller::Commands::GitTagRelease do
32
41
  command.repo.should_receive :push
33
42
  command.run
34
43
  end
35
-
36
44
  it 'should not push tags if the release is already tagged' do
37
45
  command.repo.should_not_receive :add_tag
38
- command.repo.should_receive(:push).once
46
+ command.repo.should_receive :push
39
47
 
40
48
  command.run
41
49
  end
42
50
  it 'should push tags if the release is not tagged' do
43
51
  command.stub!(:release_tagged?).and_return false
44
52
  command.repo.should_receive :add_tag
45
- command.repo.should_receive(:push).twice
53
+ command.repo.should_receive :push
46
54
 
47
55
  command.run
48
56
  end
data/spec/bueller_spec.rb CHANGED
@@ -76,15 +76,7 @@ describe Bueller do
76
76
  end
77
77
  end
78
78
 
79
- describe '#bump_major_version' do
80
- it 'should build and run release to github command when running release_gem_to_github' do
81
- Bueller::Commands::ReleaseToGithub.should_receive(:run_for).with(bueller)
82
-
83
- bueller.release_gem_to_github
84
- end
85
- end
86
-
87
- describe '#bump_major_version' do
79
+ describe '#git_tag_release' do
88
80
  it 'should build and tag the release' do
89
81
  Bueller::Commands::GitTagRelease.should_receive(:run_for).with(bueller)
90
82
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Derek Kastner
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-15 00:00:00 -05:00
17
+ date: 2011-01-19 00:00:00 -05:00
18
18
  default_executable: bueller
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -198,7 +198,6 @@ files:
198
198
  - lib/bueller/tasks.rb
199
199
  - lib/bueller/rubyforge_tasks.rb
200
200
  - lib/bueller/generator.rb
201
- - lib/bueller/commands/release_to_github.rb
202
201
  - lib/bueller/commands/build_gem.rb
203
202
  - lib/bueller/commands/release_to_rubygems.rb
204
203
  - lib/bueller/commands/install_gem.rb
@@ -287,7 +286,6 @@ files:
287
286
  - spec/fixtures/bar/bar.gemspec
288
287
  - spec/bueller/gemspec_helper_spec.rb
289
288
  - spec/bueller/commands/git_tag_release_spec.rb
290
- - spec/bueller/commands/release_to_github_spec.rb
291
289
  - spec/bueller/commands/release_to_rubygems_spec.rb
292
290
  - spec/bueller/commands/build_gem_spec.rb
293
291
  - spec/bueller/commands/write_gemspec_spec.rb
@@ -316,7 +314,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
316
314
  requirements:
317
315
  - - ">="
318
316
  - !ruby/object:Gem::Version
319
- hash: -77423727
317
+ hash: -330140273
320
318
  segments:
321
319
  - 0
322
320
  version: "0"
@@ -364,7 +362,6 @@ test_files:
364
362
  - spec/fixtures/bar/bar.gemspec
365
363
  - spec/bueller/gemspec_helper_spec.rb
366
364
  - spec/bueller/commands/git_tag_release_spec.rb
367
- - spec/bueller/commands/release_to_github_spec.rb
368
365
  - spec/bueller/commands/release_to_rubygems_spec.rb
369
366
  - spec/bueller/commands/build_gem_spec.rb
370
367
  - spec/bueller/commands/write_gemspec_spec.rb
@@ -1,41 +0,0 @@
1
- class Bueller
2
- module Commands
3
- class ReleaseToGithub
4
- def self.run_for(bueller, attributes = {})
5
- command = new bueller, attributes
6
- command.run
7
- command
8
- end
9
-
10
- attr_accessor :output
11
- attr_reader :bueller
12
-
13
- def initialize(bueller, attributes = {})
14
- self.output = $stdout
15
- @bueller = bueller
16
-
17
- attributes.each_pair do |key, value|
18
- send("#{key}=", value)
19
- end
20
- end
21
-
22
- def base_dir; bueller.base_dir; end
23
- def version; bueller.version; end
24
- def repo; bueller.repo; end
25
-
26
- def run
27
- raise "Hey buddy, try committing them files first" unless clean_staging_area?
28
-
29
- repo.checkout('master')
30
-
31
- output.puts "Pushing master to origin"
32
- repo.push
33
- end
34
-
35
- def clean_staging_area?
36
- status = repo.status
37
- status.added.empty? && status.deleted.empty? && status.changed.empty?
38
- end
39
- end
40
- end
41
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bueller::Commands::ReleaseToGithub do
4
- let(:bueller) { Bueller.new }
5
- let(:command) { Bueller::Commands::ReleaseToGithub.new bueller, :output => StringIO.new }
6
-
7
- before :each do
8
- status = mock(Object)
9
- bueller.repo = mock(Git, :status => status)
10
-
11
- command.repo.status.stub!(:added).and_return []
12
- command.repo.status.stub!(:changed).and_return []
13
- command.repo.status.stub!(:deleted).and_return []
14
- end
15
-
16
- describe '#run' do
17
- before :each do
18
- command.repo.stub! :checkout
19
- command.repo.stub! :push
20
- command.stub!(:release_tagged?).and_return true
21
- end
22
-
23
- it 'should raise an error if the staging area is unclean' do
24
- command.stub!(:clean_staging_area?).and_return false
25
- expect { command.run }.should raise_error(RuntimeError, /try committing/i)
26
- end
27
- it 'should check out master' do
28
- command.repo.should_receive(:checkout).with 'master'
29
- command.run
30
- end
31
- it 'should push' do
32
- command.repo.should_receive :push
33
- command.run
34
- end
35
- end
36
-
37
- describe '#clean_staging_area?' do
38
- it 'should return true if there are no added, changed, or deleted files' do
39
- command.should be_clean_staging_area
40
- end
41
- it 'should return false if there are added files' do
42
- command.repo.status.stub!(:added).and_return ['Gemfile.lock']
43
- command.should_not be_clean_staging_area
44
- end
45
- it 'should return false if there are changed files' do
46
- command.repo.status.stub!(:changed).and_return ['Gemfile.lock']
47
- command.should_not be_clean_staging_area
48
- end
49
- it 'should return false if there are deleted files' do
50
- command.repo.status.stub!(:deleted).and_return ['Gemfile.lock']
51
- command.should_not be_clean_staging_area
52
- end
53
- end
54
- end