rubygems-tasks 0.1.0.pre1

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ ChangeLog.*
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ doc/
2
+ pkg/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "Gem::Tasks Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2011-08-30
2
+
3
+ * Initial release:
4
+
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2012 Hal Brodigan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # rubygems-tasks
2
+
3
+ * [Source](https://github.com/postmodern/rubygems-tasks)
4
+ * [Issues](https://github.com/postmodern/rubygems-tasks/issues)
5
+ * [Email](mailto:postmodern.mod3 at gmail.com)
6
+
7
+ ## Description
8
+
9
+ rubygems-tasks provides simple Rake tasks for building, installing and releasing
10
+ Ruby gems.
11
+
12
+ require 'rubygems/tasks'
13
+ Gem::Tasks.new
14
+
15
+ ## Philosophy
16
+
17
+ The Rake tasks which you use to manage a Ruby project _should not_ be coupled
18
+ to the project generator which you used to create the project.
19
+ Project generators have _nothing_ to do with the Rake tasks used to build,
20
+ install and release a Ruby project.
21
+
22
+ Each project generator (Hoe, Jeweler, Bundler, etc) having their
23
+ own set of Rake tasks introduces differing functionality between projects,
24
+ and creates factions between developers. Ruby Developers should not be
25
+ factionalized by their project generator or Rake tasks. Ruby Developers should
26
+ have a common set of Rake tasks that they can use in any project.
27
+ This is what rubygems-tasks seeks to accomplish.
28
+
29
+ ## Features
30
+
31
+ * Provides tasks to build, install and push gems to [rubygems.org][1].
32
+ * Loads all project metadata from the `.gemspec` file.
33
+ * Supports loading multiple `.gemspec` files.
34
+ * Supports pushing gems to alternate [RubyGems][2] servers.
35
+ * Supports optionally building `.tar.gz` and `.zip` archives.
36
+ * `build:tar`
37
+ * `build:zip`
38
+ * Supports [Git][3], [Mercurial][4] and [SubVersion][5] Source-Code-Managers
39
+ (SCMs).
40
+ * Provides optional `sign` tasks for package integrity:
41
+ * `sign:checksum`
42
+ * `sign:pgp`
43
+ * Provides a `console` task, for jumping right into your code.
44
+ * Defines task aliases for users coming from [Jeweler][6] or [Hoe][7].
45
+ * ANSI coloured messages!
46
+
47
+ ## Anti-Features
48
+
49
+ * **Does not** parse project metadata from the README or the ChangeLog.
50
+ * **Does not** generate or modify code.
51
+ * **Does not** automatically commit changes.
52
+ * **Does not** inject dependencies into gems.
53
+ * **Zero** dependencies.
54
+
55
+ ## Install
56
+
57
+ $ gem install rubygems-tasks
58
+
59
+ ## Examples
60
+
61
+ Specifying an alternate Ruby Console to run:
62
+
63
+ Gem::Tasks.new do |tasks|
64
+ tasks.console.command = 'pry'
65
+ end
66
+
67
+ Enable pushing gems to an in-house [RubyGems][2] server:
68
+
69
+ Gem::Tasks.new do |tasks|
70
+ tasks.push.host = 'gems.company.come'
71
+ end
72
+
73
+ Disable the `push` task:
74
+
75
+ Gem::Tasks.new(:push => false)
76
+
77
+ Enable building `.tar.gz` and `.zip` archives:
78
+
79
+ Gem::Tasks.new(:build => {:tar => true, :zip => true})
80
+
81
+ Enable Checksums and PGP signatures for built packages:
82
+
83
+ Gem::Tasks.new(:sign => {:checksum => true, :pgp => true})
84
+
85
+ Selectively defining tasks:
86
+
87
+ Gem::SCM::Status.new
88
+ Gem::SCM::Tag.new(:format => 'REL-%s')
89
+ Gem::Build::Tar.new
90
+ Gem::Sign::Checksum.new
91
+ Gem::Console.new
92
+
93
+ ## Synopsis
94
+
95
+ rake build # Builds all packages
96
+ rake console # Spawns an Interactive Ruby Console
97
+ rake install # Installs all built gem packages
98
+ rake release # Performs a release
99
+
100
+ ## Copyright
101
+
102
+ Copyright (c) 2011-2012 Hal Brodigan
103
+
104
+ See {file:LICENSE.txt} for details.
105
+
106
+ [1]: https://rubygems.org/
107
+ [2]: https://github.com/rubygems/rubygems.org#readme
108
+ [3]: http://git-scm.com/
109
+ [4]: http://mercurial.selenic.com/
110
+ [5]: http://subversion.tigris.org/
111
+ [6]: https://github.com/technicalpickles/jeweler#readme
112
+ [7]: https://github.com/seattlerb/hoe#readme
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ lib_dir = File.expand_path('lib',File.dirname(__FILE__))
5
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
6
+
7
+ require 'rubygems/tasks'
8
+ Gem::Tasks.new(
9
+ :build => {:gem => true, :tar => true},
10
+ :sign => {:checksum => true, :pgp => true}
11
+ )
12
+
13
+ begin
14
+ gem 'rspec', '~> 2.4'
15
+ require 'rspec/core/rake_task'
16
+
17
+ RSpec::Core::RakeTask.new
18
+ rescue LoadError
19
+ task :spec do
20
+ abort "Please run `gem install rspec` to install RSpec."
21
+ end
22
+ end
23
+ task :test => :spec
24
+ task :default => :spec
25
+
26
+ begin
27
+ gem 'yard', '~> 0.7'
28
+ require 'yard'
29
+
30
+ YARD::Rake::YardocTask.new
31
+ rescue LoadError => e
32
+ task :yard do
33
+ abort 'Please run `gem install yard` to install YARD.'
34
+ end
35
+ end
data/gemspec.yml ADDED
@@ -0,0 +1,14 @@
1
+ name: rubygems-tasks
2
+ version: 0.1.0.pre1
3
+ summary: Rake tasks for managing and releasing Ruby projects.
4
+ description:
5
+ Simple Rake tasks for managing and releasing Ruby projects.
6
+
7
+ authors: Postmodern
8
+ email: postmodern.mod3@gmail.com
9
+ homepage: https://github.com/postmodern/rubygems-tasks
10
+ has_yard: true
11
+
12
+ development_dependencies:
13
+ rspec: ~> 2.4
14
+ yard: ~> 0.7
@@ -0,0 +1,9 @@
1
+ require 'rubygems/tasks/console'
2
+ require 'rubygems/tasks/build'
3
+ require 'rubygems/tasks/install'
4
+ require 'rubygems/tasks/scm'
5
+ require 'rubygems/tasks/scm'
6
+ require 'rubygems/tasks/push'
7
+ require 'rubygems/tasks/release'
8
+ require 'rubygems/tasks/sign'
9
+ require 'rubygems/tasks/tasks'
@@ -0,0 +1,3 @@
1
+ require 'rubygems/tasks/build/tar'
2
+ require 'rubygems/tasks/build/gem'
3
+ require 'rubygems/tasks/build/zip'
@@ -0,0 +1,58 @@
1
+ require 'rubygems/tasks/build/task'
2
+
3
+ require 'rubygems/builder'
4
+ require 'fileutils'
5
+
6
+ module Gem
7
+ class Tasks
8
+ module Build
9
+ #
10
+ # The `build:gem` task.
11
+ #
12
+ class Gem < Task
13
+
14
+ #
15
+ # Initializes the `build:gem` task.
16
+ #
17
+ # @param [Hash] options
18
+ # Additional options.
19
+ #
20
+ def initialize(options={})
21
+ super()
22
+
23
+ yield self if block_given?
24
+ define
25
+ end
26
+
27
+ #
28
+ # Defines the `build:gem` task.
29
+ #
30
+ def define
31
+ build_task :gem
32
+
33
+ # backwards compatibility for Gem::PackageTask
34
+ task :gem => 'build:gem'
35
+
36
+ # backwards compatibility for Hoe
37
+ task :package => 'build:gem'
38
+ end
39
+
40
+ #
41
+ # Builds the `.gem` package.
42
+ #
43
+ # @param [String] path
44
+ # The path for the `.gem` package.
45
+ #
46
+ # @param [Gem::Specification] gemspec
47
+ # The gemspec to build the `.gem` package from.
48
+ #
49
+ def build(path,gemspec)
50
+ builder = ::Gem::Builder.new(gemspec)
51
+
52
+ FileUtils.mv builder.build, Project::PKG_DIR
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,49 @@
1
+ require 'rubygems/tasks/build/task'
2
+
3
+ require 'set'
4
+
5
+ module Gem
6
+ class Tasks
7
+ module Build
8
+ #
9
+ # The `build:tar` task.
10
+ #
11
+ class Tar < Task
12
+
13
+ #
14
+ # Initializes the `build:tar` task.
15
+ #
16
+ # @param [Hash] options
17
+ # Additional options.
18
+ #
19
+ def initialize(options={})
20
+ super()
21
+
22
+ yield self if block_given?
23
+ define
24
+ end
25
+
26
+ #
27
+ # Defines the `build:tar` task.
28
+ #
29
+ def define
30
+ build_task :tar, 'tar.gz'
31
+ end
32
+
33
+ #
34
+ # Builds a `.tar.gz` archive.
35
+ #
36
+ # @param [String] path
37
+ # The path for the `.tar.gz` archive.
38
+ #
39
+ # @param [Gem::Specification] gemspec
40
+ # The gemspec to generate the archive from.
41
+ #
42
+ def build(path,gemspec)
43
+ run 'tar', 'czf', path, *gemspec.files
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,54 @@
1
+ require 'rubygems/tasks/task'
2
+
3
+ require 'rubygems/builder'
4
+
5
+ module Gem
6
+ class Tasks
7
+ module Build
8
+ class Task < Tasks::Task
9
+
10
+ protected
11
+
12
+ def build_task(name,extname=name)
13
+ directory Project::PKG_DIR
14
+
15
+ @project.builds.each do |build,packages|
16
+ namespace :build do
17
+ namespace name do
18
+ gemspec = @project.gemspecs[build]
19
+ path = packages[extname]
20
+
21
+ # define file tasks, so the packages are not needless re-built
22
+ file(path => [Project::PKG_DIR, *gemspec.files]) do
23
+ status "Building #{File.basename(path)} ..."
24
+
25
+ build(path,gemspec)
26
+ end
27
+
28
+ task build => path
29
+ end
30
+ end
31
+
32
+ task "build:#{build}" => "build:#{name}:#{build}"
33
+ end
34
+
35
+ gemspec_tasks "build:#{name}"
36
+
37
+ desc "Builds all packages" unless task?(:build)
38
+ task :build => "build:#{name}"
39
+ end
40
+
41
+ #
42
+ # @param [String] path
43
+ #
44
+ # @param [Gem::Specification] gemspec
45
+ #
46
+ # @abstract
47
+ #
48
+ def build(path,gemspec)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,47 @@
1
+ require 'rubygems/tasks/build/task'
2
+
3
+ module Gem
4
+ class Tasks
5
+ module Build
6
+ #
7
+ # The `build:zip` task.
8
+ #
9
+ class Zip < Task
10
+
11
+ #
12
+ # Initializes the `build:zip` task.
13
+ #
14
+ # @param [Hash] options
15
+ # Additional options.
16
+ #
17
+ def initialize(options={})
18
+ super()
19
+
20
+ yield self if block_given?
21
+ define
22
+ end
23
+
24
+ #
25
+ # Defines the `build:zip` task.
26
+ #
27
+ def define
28
+ build_task :zip
29
+ end
30
+
31
+ #
32
+ # Builds the `.zip` archive.
33
+ #
34
+ # @param [String] path
35
+ # The path for the `.zip` archive.
36
+ #
37
+ # @param [Gem::Specification] gemspec
38
+ # The gemspec to build the archive from.
39
+ #
40
+ def build(path,gemspec)
41
+ run 'zip', '-q', path, *gemspec.files
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,73 @@
1
+ require 'rubygems/tasks/task'
2
+
3
+ module Gem
4
+ class Tasks
5
+ #
6
+ # The `console` task.
7
+ #
8
+ class Console < Task
9
+
10
+ # The default Interactive Ruby Console
11
+ DEFAULT_CONSOLE = 'irb'
12
+
13
+ # The default command to run
14
+ DEFAULT_COMMAND = (ENV['RUBYCONSOLE'] || DEFAULT_CONSOLE)
15
+
16
+ # The Ruby Console command
17
+ attr_accessor :command
18
+
19
+ # Additional options for the Ruby Console
20
+ attr_accessor :options
21
+
22
+ #
23
+ # Initializes the `console` task.
24
+ #
25
+ # @param [Hash] options
26
+ # Additional options.
27
+ #
28
+ # @option options [String, Array] :command (DEFAULT_COMMAND)
29
+ # The Ruby Console command to run.
30
+ #
31
+ # @option options [Array] :options
32
+ # Additional options for the Ruby Console.
33
+ #
34
+ def initialize(options={})
35
+ super()
36
+
37
+ @command = options.fetch(:command,DEFAULT_COMMAND)
38
+ @options = Array(options[:options])
39
+
40
+ yield self if block_given?
41
+ define
42
+ end
43
+
44
+ #
45
+ # Defines the `console` task.
46
+ #
47
+ def define
48
+ @project.gemspecs.each do |name,gemspec|
49
+ namespace :console do
50
+ task name do |t,args|
51
+ arguments = [@command, *@options]
52
+ arguments += gemspec.require_paths.map { |dir| "-I#{dir}" }
53
+
54
+ if @project.bundler?
55
+ if @command == DEFAULT_CONSOLE
56
+ run 'bundle', 'console'
57
+ else
58
+ run 'bundle', 'exec', *arguments
59
+ end
60
+ else
61
+ run *arguments
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ desc "Spawns an Interactive Ruby Console"
68
+ task :console => "console:#{@project.gemspecs.keys.first}"
69
+ end
70
+
71
+ end
72
+ end
73
+ end