choosy 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,20 +1,16 @@
1
- begin
2
- require 'choosy/versiontask'
3
- rescue LoadError => e
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
5
- require 'choosy/versiontask'
6
- end
7
-
8
1
  require 'rubygems'
9
2
  require 'rake'
10
3
  require 'rspec/core/rake_task'
11
- require 'bundler'
12
- Bundler::GemHelper.install_tasks
13
4
 
14
- PACKAGE_NAME = "choosy"
5
+ begin
6
+ require 'choosy/rake'
7
+ rescue LoadError => e
8
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
9
+ require 'choosy/rake'
10
+ end
15
11
 
16
12
  desc "Default task"
17
- task :default => [ :spec ]
13
+ task :default => [:spec]
18
14
 
19
15
  desc "Run the RSpec tests"
20
16
  RSpec::Core::RakeTask.new :spec
@@ -50,20 +46,7 @@ desc "Create RDocs: TODO"
50
46
  task :rdoc
51
47
 
52
48
  desc "Cleans the generated files."
53
- task :clean do
54
- rm Dir.glob('*.gemspec')
55
- rm Dir.glob('*.gem')
56
- rm_rf 'pkg'
57
- end
49
+ task :clean => ['gem:clean']
58
50
 
59
- desc "Deploys the gem to rubygems.org"
60
- task :gem => [:doc, :version] do
61
- sh "gem build #{PACKAGE_NAME}.gemspec"
62
- sh "gem push #{PACKAGE_NAME}-#{$version}.gem"
63
- sh "git tag -m 'Tagging release #{$version}' v#{$version}"
64
- sh "git push origin :refs/tags/#{$version}"
65
- end
66
-
67
- desc "Does the full release cycle."
68
- task :deploy => [:gem, :clean] do
69
- end
51
+ desc "Runs the full deploy"
52
+ task :push => [:release, :clean]
@@ -2,5 +2,5 @@
2
2
  version:
3
3
  major: 0
4
4
  minor: 3
5
- tiny: 1
5
+ tiny: 3
6
6
  date: 25/03/2011
@@ -0,0 +1,131 @@
1
+
2
+ # This is a library task that others can use to expose functionality in their rake files
3
+ # It defines the '$version' global variable to let users pull this information out
4
+ # into their own scripts.
5
+
6
+ module SH
7
+ def self.attempt(command, options={}, &block)
8
+ contents = nil
9
+ IO.popen("#{command} 2>&1", 'r') do |io|
10
+ contents = io.read
11
+ end
12
+ if $? != 0
13
+ yield [$?, contents] if block_given?
14
+
15
+ if options[:error]
16
+ raise options[:error]
17
+ else
18
+ puts contents
19
+ raise "Unable to execute command: #{command}" unless options[:fail] == false
20
+ end
21
+ end
22
+
23
+ if options[:success] && contents !~ options[:success]
24
+ raise "Command failed: #{command}"
25
+ elsif options[:failure] && contents =~ options[:failure]
26
+ raise "Command didn't succeed: #{command}"
27
+ end
28
+
29
+ puts contents unless options[:quiet]
30
+ end
31
+
32
+ def self.files(ending_with, &block)
33
+ files = Dir.glob("*#{ending_with}")
34
+
35
+ raise "No #{ending_with} files found." if files.empty?
36
+
37
+ files.each do |file|
38
+ yield file
39
+ end
40
+ end
41
+ end
42
+
43
+ #########################################################################
44
+ # Version
45
+ require 'choosy/version'
46
+
47
+ desc "Shows the current version number."
48
+ task :version => ['version:load'] do
49
+ puts "Current version: #{$version.to_s}"
50
+ end
51
+
52
+ namespace :version do
53
+ task :load do
54
+ puts Dir.pwd
55
+ if ENV['VERSION_FILE']
56
+ $version = Choosy::Version.new(ENV['VERSION_FILE'])
57
+ else
58
+ $version = Choosy::Version.load(:dir => Dir.pwd, :relpath => 'lib')
59
+ end
60
+ end
61
+
62
+ [:tiny, :minor, :major].each do |type|
63
+ desc "Bumps the #{type} revision number."
64
+ task type => :load do
65
+ old = $version.to_s
66
+ $version.version!(type)
67
+ puts "Bumped version: #{old} -> #{$version}"
68
+ end
69
+ end
70
+ end
71
+
72
+ #########################################################################
73
+ # Release
74
+ desc "Tags the current release in git, builds the gemspec, and pushes the gem"
75
+ task :release => ['gem:push', 'git:tag', 'git:push']
76
+
77
+ #########################################################################
78
+ # Git
79
+ namespace :git do
80
+ task :diff => ['version:load'] do
81
+ SH.attempt "git diff --exit-code", :error => "git diff: Your work doesn't seem to be checked in!", :quiet => true
82
+ end
83
+
84
+ task :tag => [:diff, 'version:load'] do
85
+ sh "Tagging version #{$version}"
86
+ SH.attempt "git tag -a -m 'Tagging release #{$version}' v#{$version}" do |code, contents|
87
+ SH.attempt "git tag -d v#{$version}", :error => "git tag: unable to delete tag"
88
+ raise "Unable to commit tag."
89
+ end
90
+ end
91
+
92
+ task :push => [:diff, 'version:load'] do
93
+ SH.attempt "git push"
94
+ SH.attempt "git push --tags"
95
+ end
96
+ end
97
+
98
+ #########################################################################
99
+ # Gems
100
+ desc "Build the current gemspecs."
101
+ task :gem => ['gem:build']
102
+
103
+ namespace :gem do
104
+ desc "Builds the current gemspec."
105
+ task :build do
106
+ SH.files('gemspec') do |gemspec|
107
+ puts " Building gemspec: #{gemspec}"
108
+ SH.attempt "gem build #{gemspec}"
109
+ end
110
+ end
111
+
112
+ desc "Pushes the current gem."
113
+ task :push => :build do
114
+ SH.files ("#{$version}.gem") do |gem|
115
+ puts " Pushing gems: #{gem}"
116
+ SH.attempt "gem push #{gem}"
117
+ end
118
+ end
119
+
120
+ desc "Installs the current gem."
121
+ task :install => :build do
122
+ SH.files ("#{$version}.gem") do |gem|
123
+ puts " Installing gem: #{gem}"
124
+ SH.attempt "gem install --no-ri --no-rdoc #{gem}"
125
+ end
126
+ end
127
+
128
+ task :clean do
129
+ rm Dir.glob('*.gem')
130
+ end
131
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gabe McArthur
@@ -78,6 +78,7 @@ files:
78
78
  - lib/VERSION.yml
79
79
  - lib/choosy/errors.rb
80
80
  - lib/choosy/printing.rb
81
+ - lib/choosy/rake.rb
81
82
  - lib/choosy/converter.rb
82
83
  - lib/choosy/parse_result.rb
83
84
  - lib/choosy/verifier.rb
@@ -92,7 +93,6 @@ files:
92
93
  - lib/choosy/dsl/command_builder.rb
93
94
  - lib/choosy/dsl/option_builder.rb
94
95
  - lib/choosy/dsl/base_command_builder.rb
95
- - lib/choosy/versiontask.rb
96
96
  - lib/choosy/parser.rb
97
97
  - lib/choosy/base_command.rb
98
98
  - lib/choosy/printing/manpage_printer.rb
@@ -1,30 +0,0 @@
1
-
2
- # This is a library task that others can use to expose functionality in their rake files
3
- # It defines the '$version' global variable to let users pull this information out
4
- # into their own scripts.
5
-
6
- require 'choosy/version'
7
-
8
- desc "Shows the current version number."
9
- task :version => ['version:load'] do
10
- puts "Current version: #{$version.to_s}"
11
- end
12
-
13
- namespace :version do
14
- task :load do
15
- puts Dir.pwd
16
- if ENV['VERSION_FILE']
17
- $version = Choosy::Version.new(ENV['VERSION_FILE'])
18
- else
19
- $version = Choosy::Version.load(:dir => Dir.pwd, :relpath => 'lib')
20
- end
21
- end
22
-
23
- [:tiny, :minor, :major].each do |type|
24
- desc "Bumps the #{type} revision number."
25
- task type => :load do
26
- $version.version!(type)
27
- puts "New version: #{$version.to_s}"
28
- end
29
- end
30
- end